本文整理汇总了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;
}
示例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.");
}