public BulletCtrl CreateBulletEffect(CharacterData owner, CharacterData target, List <BuffCtrl> buffs, string Path, bool lastBullet) { passObj _obj = null; //if(owner.characterCtrl.activeAction.Skill.serverData.sample.sid==21113|| // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 22113|| // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 23113|| // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 24113|| // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 25113) {//关羽技能正反两面 // if (target.camp == 2) _obj = MonoBase.Create3Dobj(Path,"Guanyu_AOE_0"); // else _obj = MonoBase.Create3Dobj(Path ,"Guanyu_AOE_1"); //} else if (owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 22117 || // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 23117 || // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 24117 || // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 25117 || // owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 26117|| // owner.characterCtrl.activeAction.Skill.serverData.sample.sid==21117) //{ // if (target.camp == 2) _obj = MonoBase.Create3Dobj(Path, "Xiaolongnv_AOE1"); // else _obj = MonoBase.Create3Dobj(Path, "Xiaolongnv_AOE2"); //} int[] tempSid = CommandConfigManager.Instance.doubleEffectSkillSids; int sidd = owner.characterCtrl.activeAction.Skill.serverData.sample.sid; for (int i = 0; i < tempSid.Length; i++) { if (sidd == tempSid[i]) { string fileNmae = PathKit.getFileName(Path); _obj = MonoBase.Create3Dobj(Path, fileNmae + (target.camp == 2 ? "1" : "2")); break; } } if (_obj == null) { _obj = MonoBase.Create3Dobj(Path); } //子弹类型数据在prefab上定义 //passObj _obj = MonoBase.Create3Dobj (Path); BulletCtrl _ctrl = _obj.obj.GetComponent <BulletCtrl> (); _ctrl.transform.parent = BattleManager.Instance.battleFieldRoom.transform; _ctrl.initBullet(target, owner, buffs, lastBullet); AddEffect(_ctrl); return(_ctrl); }
public void resourcesLoadTexture(Object obj) { if (obj == null) { return; } if (typeof(UITexture) == obj.GetType()) { if ((obj as UITexture).mainTexture != (Texture2D)Resources.Load(path)) { (obj as UITexture).mainTexture = (Texture2D)Resources.Load(path); } (obj as UITexture).gameObject.SetActive(true); callbackAfterLoad(obj, obj); } else if (typeof(GameObject) == obj.GetType()) { GameObject gameObj = obj as GameObject; if (gameObj.renderer != null && gameObj.renderer.material != null) { gameObj.renderer.material.mainTexture = (Texture2D)Resources.Load(path); } callbackAfterLoad(obj, obj); } else if (typeof(Transform) == obj.GetType()) { Object obj2 = Resources.Load(path); //如果路径无,再次尝试 if (obj2 == null) { string _name = PathKit.getFileName(path); obj2 = Resources.Load(path + "/" + _name) as GameObject; } GameObject tmp = GameObject.Instantiate(obj2) as GameObject; tmp.transform.parent = obj as Transform; tmp.transform.localScale = Vector3.one; tmp.transform.localPosition = Vector3.zero; callbackAfterLoad(obj, tmp); } }
//指定读取path包内的name文件 public static passObj Create3Dobj(string path, string fileName) { passObj lastObj = new passObj(); UnityEngine.Object _tmp = null; //开发时直接读取Resource资源 if (ResourcesManager.Instance.allowLoadFromRes) { if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor) { UnityEngine.Object obj = Resources.Load(path); if (obj == null) { string _name = PathKit.getFileName(path); if (string.IsNullOrEmpty(fileName)) { obj = Resources.Load(path + "/" + _name); } else { print(path + "/" + fileName); obj = Resources.Load(path + "/" + fileName); } } if (obj != null) { lastObj.obj = MonoBehaviour.Instantiate(obj) as GameObject; return(lastObj); } } } //从资源库里获取 ResourcesData res = ResourcesManager.Instance.getResource(path); if (res == null) { if (ResourcesManager.Instance.allowLoadFromRes) { _tmp = Resources.Load(path); //如果路径无,再次尝试 if (_tmp == null) { string _name = PathKit.getFileName(path); _tmp = Resources.Load(path + "/" + _name); } } } else { lastObj.data = res; if (string.IsNullOrEmpty(fileName)) { _tmp = res.ResourcesBundle.mainAsset; } else { _tmp = res.ResourcesBundle.Load(fileName); } // lastObj.data.MemoryData=_tmp; } if (_tmp == null) { return(lastObj); } lastObj.obj = MonoBehaviour.Instantiate(_tmp) as GameObject; return(lastObj); }
public void pushTexture(Object obj) { if (obj == null) { return; } if (data != null || webImage != null) { //有网络资源用网络资源 Texture2D tmpTex = null; if (webImage != null) { tmpTex = webImage; } else if (data != null && data.ResourcesBundle != null) { // if (TextureManager.instance.debugMode) // Debug.Log (data.ResourcesPath); if (data.ResourcesBundle.mainAsset is Texture2D) { tmpTex = (Texture2D)data.ResourcesBundle.mainAsset; } } if (typeof(UITexture) == obj.GetType()) { if ((obj as UITexture).mainTexture == null || (obj as UITexture).mainTexture.GetHashCode() != tmpTex.GetHashCode()) { (obj as UITexture).mainTexture = tmpTex; } (obj as UITexture).gameObject.SetActive(true); callbackAfterLoad(obj, obj); } else if (typeof(GameObject) == obj.GetType()) { GameObject gameObj = obj as GameObject; if (gameObj.renderer != null && gameObj.renderer.material != null) { gameObj.renderer.material.mainTexture = tmpTex; } callbackAfterLoad(obj, obj); } else if (typeof(Transform) == obj.GetType()) { GameObject tmp = GameObject.Instantiate(data.ResourcesBundle.mainAsset) as GameObject; tmp.transform.parent = obj as Transform; tmp.transform.localScale = Vector3.one; tmp.transform.localPosition = Vector3.zero; callbackAfterLoad(obj, tmp); } } else if (ResourcesManager.Instance.allowLoadFromRes) { Texture2D tmpTex = null; if (webImage != null) { tmpTex = webImage; } else { tmpTex = Resources.Load(path) as Texture2D; } //直接资源读取咯 if (typeof(UITexture) == obj.GetType()) { if ((obj as UITexture).mainTexture != tmpTex) { (obj as UITexture).mainTexture = tmpTex; } (obj as UITexture).gameObject.SetActive(true); callbackAfterLoad(obj, obj); } else if (typeof(GameObject) == obj.GetType()) { GameObject gameObj = obj as GameObject; if (gameObj.renderer != null && gameObj.renderer.material != null) { gameObj.renderer.material.mainTexture = tmpTex; } callbackAfterLoad(obj, obj); } else if (typeof(Transform) == obj.GetType()) { Object obj2 = Resources.Load(path); //如果路径无,再次尝试 if (obj2 == null) { string _name = PathKit.getFileName(path); obj2 = Resources.Load(path + "/" + _name) as GameObject; } GameObject tmp = GameObject.Instantiate(obj2) as GameObject; tmp.transform.parent = obj as Transform; tmp.transform.localScale = Vector3.one; tmp.transform.localPosition = Vector3.zero; callbackAfterLoad(obj, tmp); } } }