コード例 #1
0
 void Update()
 {
     if (curNum < maxNum)
     {
         // 3:获取资源路径path
         path = AssetDatabase.GUIDToAssetPath(allmat[curNum]);
         //Debug.Log(" ====== " + curNum + " : " + path + " ===== ");
         // 4:加载Prefab资源
         GameObject obj = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
         // 5:实例化Prefab
         GameObject instObj = PrefabUtility.InstantiatePrefab(obj) as GameObject;
         // 6:重命名Prefab,去掉 (clone)后缀
         instObj.name = instObj.name.Split('(')[0];
         // 7:获取实例化的prefab的Transform
         Transform trans = instObj.GetComponent <Transform>();
         // 8:遍历Transform查找所有子节点,并找到ParticleSystem然后添加脚本
         GameUtils.AttachParticleCS(trans);
         // 9:重新覆盖Prefab,应用修改!
         PrefabUtility.ReplacePrefab(instObj, obj);
         // 10:删除实例化出来的Prefab对象
         Object.DestroyImmediate(instObj);
         curNum++;
         this.Repaint();
     }
     if (curNum == maxNum)
     {
         this.Close();
     }
 }
コード例 #2
0
ファイル: EffectManager.cs プロジェクト: ww386362087/MoyuHero
    /// <summary>
    /// 实例化一个静态effect
    /// </summary>
    /// <param name="effectName">要实例化的特效名称</param>
    /// <param name="parent">实例化特效依附的父类挂点</param>
    /// <param name="lifetime">是否重置指定的生存时间,默认为特效对象上的Light组件获得</param>
    /// <param name="isAttach">是否需要依附,默认不依附任何挂点</param>
    public void InstanceEffect_Static(string effectName, ObjectCreature pCaster, Transform parent, float lifetime = 0f, bool isAttach = false)
    {
        EffectStatic _effect = GetFreeEffectStatic(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            obj.transform.position = parent.position;
            obj.transform.rotation = parent.transform.rotation;
            _effect.SetCasterObj(pCaster);
            if (isAttach)
            {
                obj.transform.parent = parent;
            }
            _effect.ResetTime();
            _effect.SetActivation(true);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                LogManager.LogError("!!!!Error:InstanceEffect_Static() effectRes is null!The effectName:" + effectName + "GameObject is:" + pCaster.GetGameObject() + "effect location:" + parent.name);
                return;
            }

            EffectStatic _newEffect = new EffectStatic();

            GameObject _obj = Instantiate(_AssetRes, parent.position, parent.transform.rotation) as GameObject;
            if (pCaster is ObjectMonster)
            {
                float _scale = ((ObjectMonster)pCaster).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            if (isAttach)
            {
                _obj.transform.parent = parent;
            }
            _newEffect.SetGameObject(_obj);
            _newEffect.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            //if (lifetime > 0f)
            //{
            //    _newEffect.SetLiftTime(lifetime);
            //}

            m_EffectStaticList.Add(_newEffect);
        }
    }
コード例 #3
0
ファイル: EffectManager.cs プロジェクト: ww386362087/MoyuHero
    /// <summary>
    /// 实例化弹道特效
    /// </summary>
    /// <param name="effectName">特效名称</param>
    /// <param name="MasterObj">发起者对象</param>
    /// <param name="TargetObj">目标对象</param>
    /// <param name="_SpellInfo">子弹的技能信息</param>
    public void InstanceEffect_Bullet(string effectName, ObjectCreature MasterObj, ObjectCreature TargetObj, SpellInfo _SpellInfo, EffectHit_Callback HitHandle = null)
    {
        //子弹释放中音效
        AudioControler.Inst.PlaySound(_SpellInfo.GetSpellRow().getBulletsFiredSound());
        //技能弹道的音效
        AudioControler.Inst.PlaySound(_SpellInfo.GetSpellRow().getBallIsticSound());

        EffectSpell _effect = GetFreeEffectSpell(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            _effect.ResetTime();
            _effect.InitBornPoint(MasterObj);
            _effect.InitTargetPoint(TargetObj);
            _effect.SetHitEffectHandle(HitHandle);
            _effect.SetGameObject(obj);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                return;
            }

            EffectSpell _newEffect = new EffectSpell(_SpellInfo);
            _newEffect.InitBornPoint(MasterObj);
            _newEffect.InitTargetPoint(TargetObj);

            GameObject _obj = Instantiate(_AssetRes, _newEffect.GetInitialLocation(), Quaternion.identity) as GameObject;
            if (MasterObj is ObjectMonster)
            {
                float _scale = ((ObjectMonster)MasterObj).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            _newEffect.SetGameObject(_obj);
            _newEffect.SetEffectName(effectName);
            _newEffect.SetHitEffectHandle(HitHandle);

            m_EffectSpellList.Add(_newEffect);
        }
        //技能震动
        if (FightEditorContrler.GetInstantiate() != null)
        {
            FightEditorContrler.GetInstantiate().SkillShake(_SpellInfo.GetSpellRow().getVibrationScreen(), EM_SPELL_SHAKE_TYPE.EM_SPELL_SHAKE_TYPE_RELEASE);
        }
    }
コード例 #4
0
ファイル: EffectManager.cs プロジェクト: ww386362087/MoyuHero
    /// <summary>
    /// 实例化链接特效
    /// </summary>
    /// <param name="effectName">要实例化的特效名称</param>
    public void InstanceEffect_Link(string effectName, ObjectCreature pCaster, Vector3 pos, List <ObjectCreature> info, float lifetime = 0f)
    {
        EffectLink _effect = GetFreeEffectLink(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            obj.transform.position = pos;
            _effect.SetCasterObj(pCaster);
            _effect.SetObjList(info);
            _effect.ResetTime();
            _effect.SetActivation(true);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                return;
            }
            EffectLink _newEffect = new EffectLink();

            GameObject _obj = Instantiate(_AssetRes, pos, Quaternion.identity) as GameObject;
            if (pCaster is ObjectMonster)
            {
                float _scale = ((ObjectMonster)pCaster).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            _newEffect.SetGameObject(_obj);
            _newEffect.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            _newEffect.SetObjList(info);
            if (lifetime > 0f)
            {
                _newEffect.SetLiftTime(lifetime);
            }
            m_EffectLinkList.Add(_newEffect);
        }
    }
コード例 #5
0
ファイル: EffectManager.cs プロジェクト: ww386362087/MoyuHero
    /// <summary>
    /// 在指定坐标实例化一个存在指定生存时间的静态特效
    /// </summary>
    /// <param name="effectName"></param>
    /// <param name="parent">坐标</param>
    /// <param name="lifetime">生存时间</param>
    /// <param name="_SpellInfo"></param>
    public void InstanceEffect_Static(string effectName, ObjectCreature pCaster, Vector3 parent, float lifetime, SpellInfo _SpellInfo)
    {
        EffectStatic _effect = GetFreeEffectStatic(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            obj.transform.position = parent;
            _effect.SetCasterObj(pCaster);
            _effect.ResetTime();
            _effect.SetActivation(true);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                return;
            }

            EffectStatic _newEffect = new EffectStatic();

            GameObject _obj = Instantiate(_AssetRes, parent, Quaternion.identity) as GameObject;
            if (pCaster is ObjectMonster)
            {
                float _scale = ((ObjectMonster)pCaster).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            _newEffect.SetGameObject(_obj);
            _newEffect.SetLiftTime(lifetime);
            _newEffect.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            m_EffectStaticList.Add(_newEffect);
        }
        //技能震动
        FightEditorContrler.GetInstantiate().SkillShake(_SpellInfo.GetSpellRow().getVibrationScreen(), EM_SPELL_SHAKE_TYPE.EM_SPELL_SHAKE_TYPE_RELEASE);
    }