public static YamlUnityObject Create(string type) { YamlUnityObject obj = null; switch (type) { case "GameObject": obj = new YamlGameObject(); break; case "Transform": obj = new YamlTransform(); break; case "ParticleSystem": obj = new YamlParticleSystem(); break; //--其他的不管了 } if (obj != null) { obj.TypeName = type; } return(obj); }
void FindChildren(YamlTransform parent, List <YamlTransform> allTransforms) { //如果子还有子,则继续Find //算法效率有点低.... foreach (var transform in allTransforms) { if (parent.IsContainsChild(transform.LocalId)) { transform.Parent = parent; if (transform.HasAnyChild()) { FindChildren(transform, allTransforms); } } } }