Ejemplo n.º 1
0
 public void CreateHeroPrefab(string name, string parentName, string nameInScene, string layerName, bool removeBoxCollider, LuaFunction func)
 {
     base.ResManager.LoadPrefab(name, delegate(UnityEngine.Object[] objs)
     {
         if (objs.Length == 0)
         {
             return;
         }
         GameObject gameObject           = objs[0] as GameObject;
         gameObject                      = UnityEngine.Object.Instantiate <GameObject>(gameObject);
         gameObject.transform.localScale = Vector3.one;
         gameObject.transform.position   = Vector3.one * 10000f;
         if (!string.IsNullOrEmpty(parentName))
         {
             gameObject.transform.SetParent(GameObject.Find(parentName).transform);
         }
         if (!string.IsNullOrEmpty(layerName))
         {
             Util.SetLayer(gameObject, layerName);
         }
         if (string.IsNullOrEmpty(nameInScene))
         {
             gameObject.name = gameObject.name.Replace("(Clone)", string.Empty);
         }
         else
         {
             gameObject.name = nameInScene;
         }
         gameObject.AddComponent <LuaBehaviour>().assetbundleName = Util.GetAssetBundleName(name);
         if (removeBoxCollider)
         {
             UnityEngine.Object.Destroy(gameObject.GetComponent <BoxCollider>());
             Animator componentInChildren = gameObject.GetComponentInChildren <Animator>();
             componentInChildren.SetTrigger("xingzou");
         }
         if (func != null)
         {
             func.Call(new object[]
             {
                 gameObject
             });
             func.Dispose();
             func = null;
         }
         string assetBundleName = Util.GetAssetBundleName(name);
         this.ResManager.UnloadAssetBundleWithoutDependencies(assetBundleName);
     });
 }
Ejemplo n.º 2
0
 public void CreateUIPrefab(string name, string parentName, string nameInScene, string layerName, LuaFunction func)
 {
     base.ResManager.LoadPrefab(name, delegate(UnityEngine.Object[] objs)
     {
         if (objs.Length == 0)
         {
             return;
         }
         GameObject gameObject = objs[0] as GameObject;
         gameObject            = UnityEngine.Object.Instantiate <GameObject>(gameObject);
         if (!string.IsNullOrEmpty(parentName))
         {
             string text = "MainCanvas/GuiCamera";
             if (parentName.Equals(text))
             {
                 gameObject.transform.SetParent(this.Parent);
             }
             else if (parentName.StartsWith(text))
             {
                 gameObject.transform.SetParent(this.Parent.FindChild(parentName.Substring(text.Length + 1)));
             }
         }
         if (!string.IsNullOrEmpty(layerName))
         {
             Util.SetLayer(gameObject, layerName);
         }
         string text2 = gameObject.name;
         if (string.IsNullOrEmpty(nameInScene))
         {
             text2 = text2.Replace("(Clone)", string.Empty);
         }
         else
         {
             text2 = nameInScene;
         }
         gameObject.name = this.checkNameInPeers(gameObject.transform.parent, text2);
         gameObject.transform.localScale    = Vector3.one;
         gameObject.transform.localPosition = Vector3.zero;
         if (gameObject.transform as RectTransform)
         {
             ((RectTransform)gameObject.transform).offsetMin = Vector2.zero;
             ((RectTransform)gameObject.transform).offsetMax = Vector2.zero;
         }
         if (name.StartsWith("Effects/"))
         {
             gameObject.AddComponent <LuaBehaviour>().assetbundleName = Util.GetAssetBundleName("Effects/allEffects");
         }
         else
         {
             gameObject.AddComponent <LuaBehaviour>().assetbundleName = Util.GetAssetBundleName(name);
         }
         UITweener component = gameObject.GetComponent <TweenScale>();
         if (component != null && component.enabled)
         {
             this.isPlayAnimation = true;
             component.SetOnFinished(delegate
             {
                 this.isPlayAnimation = false;
             });
         }
         if (func != null)
         {
             func.Call(new object[]
             {
                 gameObject
             });
             func.Dispose();
             func = null;
         }
         string assetBundleName = Util.GetAssetBundleName(name);
         if (name.StartsWith("Effects/"))
         {
             assetBundleName = Util.GetAssetBundleName("Effects/allEffects");
         }
         this.ResManager.UnloadAssetBundleWithoutDependencies(assetBundleName);
     });
 }