零碎的知识点
嘿哈
这里都是网上冲浪,群友撕逼,水群看到的知识点,暂时没有成体系。就先随手记下来。
- 关于Unity物体的实例化,考虑可否通过预制体实例;
internal static bool IsPrefab(this Transform This)
{
var TempObject = new GameObject();
try
{
TempObject.transform.parent = This.parent;
var OriginalIndex = This.GetSiblingIndex();
This.SetSiblingIndex(int.MaxValue);
if (This.GetSiblingIndex() == 0) return true;
This.SetSiblingIndex(OriginalIndex);
return false;
}
finally
{
Object.DestroyImmediate(TempObject);
}
}