当前位置: 首页>>代码示例>>C#>>正文


C# Transform.Cast方法代码示例

本文整理汇总了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();
 }
开发者ID:DanielLause,项目名称:MiniGame-Project4,代码行数:9,代码来源:EnemyAi.cs

示例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;
    }
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:12,代码来源:GroupPatternConverter.cs

示例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);
             }
         }
     }
 }
开发者ID:wuxin0602,项目名称:Nothing,代码行数:31,代码来源:HeroUtils.cs

示例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;
        }
    }
开发者ID:igm-capstone,项目名称:capstone-game-unity,代码行数:16,代码来源:AssetPipelineTools.cs


注:本文中的Transform.Cast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。