本文整理汇总了C#中UnityEngine.GameObject.As方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.As方法的具体用法?C# GameObject.As怎么用?C# GameObject.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.As方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extend
/// <summary>
/// Extends this quick start with additional components.
/// </summary>
/// <param name="gameWorld">The game world.</param>
protected override void Extend(GameObject gameWorld)
{
var go = this.gameObject;
AddIfMissing<VectorFieldManagerComponent>(gameWorld, true);
if (gameWorld.As<IUnitGroupingStrategyFactory>() == null)
{
gameWorld.AddComponent<SteeringUnitGroupingStrategyFactory>();
}
AddIfMissing<SteerForVectorFieldComponent>(go, 5);
AddIfMissing<SteerForFormationComponent>(go, 10);
AddIfMissing<SteerForBlockedCellRepulsionComponent>(go, 20);
AddIfMissing<SteerForContainmentComponent>(go, 20);
AddIfMissing<SteeringController>(go, false);
}
示例2: Initialize
/// <summary>
/// Initializes the Unit Facade.
/// </summary>
/// <param name="unitObject">The unit game object.</param>
public virtual void Initialize(GameObject unitObject)
{
_props = unitObject.As<IUnitProperties>(false, true);
_movable = unitObject.As<IMovable>(false, false);
_moving = unitObject.As<IMovingObject>(false, true);
_speeder = unitObject.As<IDefineSpeed>(false, true);
_pathFinderOptions = unitObject.As<IPathFinderOptions>(false, false) ?? new PathFinderOptions();
_pathNavOptions = unitObject.As<IPathNavigationOptions>(false, false) ?? new PathNavigationOptions();
this.isMovable = _movable != null;
if (!this.isMovable)
{
_movable = new MovableDummy(unitObject.name);
}
this.gameObject = unitObject;
this.transform = unitObject.transform;
this.collider = unitObject.GetComponent<Collider>();
this.isAlive = true;
this.hasArrivedAtDestination = true;
}