本文整理汇总了C#中Transform.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.Cast方法的具体用法?C# Transform.Cast怎么用?C# Transform.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.Cast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
private void Awake()
{
gameTime = GameObject.Find("GlobalScripts").GetComponent<GameTime>();
waypointContainer = GameObject.Find("WaypointContainer").transform;
sun = GameObject.Find("Directional Light");
player = GameObject.Find("Player").transform;
myAgent = GetComponent<NavMeshAgent>();
wayPoints = waypointContainer.Cast<Transform>().ToArray();
}
示例2: CreateGroupPattern
Coord[] CreateGroupPattern(Transform pattern)
{
Coord[] patternCoords = new Coord[pattern.childCount];
int i = 0;
foreach (var child in pattern.Cast<Transform>().OrderBy(t => t.name))
{
patternCoords[i] = new Coord(Mathf.RoundToInt(child.position.x), Mathf.RoundToInt(child.position.y));
i++;
}
return patternCoords;
}
示例3: AddOrDelItems
public static void AddOrDelItems(Transform parent, Transform childPrefab, bool isAdd, int count, string poolName, UIEventListener.VoidDelegate normalPress, UIEventListener.VoidDelegate longPress)
{
if (isAdd)
{
for (int i = 0; i < count; i++)
{
var item = PoolManager.Pools[poolName].Spawn(childPrefab);
Utils.MoveToParent(parent, item);
NGUITools.SetActive(item.gameObject, true);
var longPressDetecter = item.GetComponent<NGUILongPress>();
longPressDetecter.OnNormalPress += normalPress;
longPressDetecter.OnLongPress += longPress;
}
}
else
{
if (PoolManager.Pools.ContainsKey(poolName))
{
var list = parent.Cast<Transform>().ToList();
for (int index = 0; index < count; index++)
{
var item = list[index];
var longPressDetecter = item.GetComponent<NGUILongPress>();
longPressDetecter.OnNormalPress -= normalPress;
longPressDetecter.OnLongPress -= longPress;
item.parent = PoolManager.Pools[poolName].transform;
PoolManager.Pools[poolName].Despawn(item);
}
}
}
}
示例4: FlattenChildren
private static IEnumerable<Transform> FlattenChildren(Transform transform)
{
if (transform.childCount == 0)
{
yield return transform;
}
var children = transform.Cast<Transform>();
var flatten = (Func<Transform, IEnumerable<Transform>>) FlattenChildren;
// select many receive
foreach (var child in children.SelectMany(flatten))
{
yield return child;
}
}