示例#1
0
        protected static Transform GetParent(string bigType, string smallType)
        {
            var       uri = GetUri(bigType, smallType);
            Transform theParent;

            if (!Parents.TryGetValue(uri, out theParent))
            {
                var bigTypeObjName = string.Format("__{0}__", bigType);
                var bigTypeObj     = GameObject.Find(bigTypeObjName) ?? new GameObject(bigTypeObjName);
                GameObject.DontDestroyOnLoad(bigTypeObj);
                bigTypeObj.transform.SetAsFirstSibling();

                theParent = new GameObject(smallType).transform;
                KTool.SetChild(theParent, bigTypeObj.transform);
                Parents[uri] = theParent;
            }
            return(theParent);
        }
示例#2
0
 /// <summary>
 /// 设置某个物件,在指定调试组下
 /// </summary>
 /// <param name="bigType"></param>
 /// <param name="smallType"></param>
 /// <param name="obj"></param>
 public static void SetParent(string bigType, string smallType, GameObject obj)
 {
     var uri = GetUri(bigType, smallType);
     Transform theParent = GetParent(bigType, smallType);
     int typeCount;
     if (!Counts.TryGetValue(uri, out typeCount))
     {
         Counts[uri] = 0;
     }
     typeCount = ++Counts[uri];
     try
     {
         KTool.SetChild(obj, theParent.gameObject);
     }
     catch (Exception e)
     {
         Log.Error(string.Format("[SetParent]{0}->{1}->{2}", bigType, smallType, e.Message));
     }
     theParent.gameObject.name = GetNameWithCount(smallType, typeCount);
 }