Пример #1
0
 //public Transform LoadAndParent(string path, Transform parent)
 //{
 //    var g2 = (GameObject)Resources.Load(path);
 //    var g = Load(path);
 //    Transform t1 = g.transform;
 //    Transform t2 = g2.transform;
 //    t1.parent = parent;
 //    t1.localPosition = t2.position;
 //    t1.localRotation = t2.rotation;
 //    return t1;
 //}
 public GameObject Load(GameObject path, Vector3 pos, Quaternion rot)
 {
     if (!setting.disablePool)
     {
         var         name     = Path.GetFileName(path.name) + "(Clone)";
         var         keyvalue = list.FirstOrDefault(a => a.Value == name);
         ModelHolder mh       = keyvalue.Key;
         if (mh != null && mh.model == null)
         {
             Debug.LogError("Pool Model Removed");
             list.Remove(mh);
             mh = null;
         }
         if (mh != null)
         {
             mh.model.position = pos;
             mh.model.rotation = rot;
             mh.UnHide();
             list.Remove(mh);
             return(mh.model.gameObject);
         }
     }
     return((GameObject)Instantiate(path, pos, rot));
 }