public static bool DestroyUI(int instanceId) { if (Id2UINodes.ContainsKey(instanceId)) { LuaUINode target = Id2UINodes[instanceId]; if (Id2UINodes[instanceId].HasParent) { Id2UINodes[Id2UINodes[instanceId].ParentNodeId].ChildNodeId.Remove(instanceId); } DeattachChild(instanceId); GameObject.Destroy(target.Node); } return(true); }
public static LuaTable Create(string luaName, string prefabPath, int parentId) { var prefab = Resources.Load <GameObject>(prefabPath); var go = GameObject.Instantiate(prefab); int instanceId = go.GetInstanceID(); string luaClass = string.IsNullOrEmpty(luaName) ? prefab.name : luaName; LuaUINode node = new LuaUINode(Instance, go, luaClass, parentId); //UINodes[path].Add(node); Id2UINodes[go.GetInstanceID()] = node; if (node.HasParent && Id2UINodes.ContainsKey(node.ParentNodeId)) { Id2UINodes[node.ParentNodeId].AddChildNode(go.GetInstanceID()); } node.InitLua(); #if UNITY_EDITOR Debug.Log("$$ createUI Id:" + instanceId); #endif return(node.LuaInstance as LuaTable); }