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


C# GameObject.AddTag方法代码示例

本文整理汇总了C#中UnityEngine.GameObject.AddTag方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.AddTag方法的具体用法?C# GameObject.AddTag怎么用?C# GameObject.AddTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.GameObject的用法示例。


在下文中一共展示了GameObject.AddTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRoot

 public static GameObject CreateRoot(string name, params System.Type[] components)
 {
     var go = new GameObject(name);
     go.AddTag(SPConstants.TAG_ROOT);
     foreach (var tp in components)
     {
         go.AddComponent(tp);
     }
     return go;
 }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:10,代码来源:GameObjUtil.cs

示例2: PoolObject

        /// <summary>Put object back in the pool. You can force children to be reenabled, if desired.</summary>
        public void PoolObject(GameObject obj, bool reenableChildren)
        {
            for (int i = 0; i < prefabsToPool.Count; i++)
            {
                if (prefabsToPool[i].Prefab == null) continue;
                if (prefabsToPool[i].Prefab.name != obj.name) continue;

                // Object was found. Deactivate it, stop/clear particle effects, and put it in the pool.
                obj.transform.parent = container.transform;
                ParticleSystem[] particleSystems = obj.GetComponentsInChildren<ParticleSystem>();
                for (int j = 0; j < particleSystems.Length; j++)
                {
                    particleSystems[j].Stop();
                    particleSystems[j].Clear();
                    particleSystems[j].enableEmission = true;
                }
                if (reenableChildren)
                {
                    Transform[] trans = obj.GetComponentsInChildren<Transform>(true);
                    for (int j = 0; j < trans.Length; j++)
                        trans[j].gameObject.SetActive(true);
                }

                obj.AddTag(Tag.Pooled);
                obj.SetActive(false);

                // Try to find an empty spot for the object to be placed in.
                for (int j=0; j<Pool[i].Length; j++)
                {
                    if (Pool[i][j] == null)
                    {
                        Pool[i][j] = obj;
                        return;
                    }
                }
                Destroy(obj);
                if (!suppressWarnings)
                    Debug.LogWarning("[" + obj.name + "] was destroyed instead of pooled. Reason: The pool size for this prefab was too small (" + Pool[i].Length + "). Consider increasing the pool size.");
                
                return;
            }

            Destroy(obj);
            if (!suppressWarnings)
                Debug.LogWarning("[" + obj.name + "] was destroyed instead of pooled. Reason: Prefab not found in pool.");
        }
开发者ID:tegleg,项目名称:mfp,代码行数:47,代码来源:ObjectPool.cs


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