void DrawAudio(int id)
        {
            if (!(id < mData.AnimationSkillList.Count))
            {
                return;
            }

            for (int i = 0; i < mData.AnimationSkillList[id].AudioStructList.Count; i++)
            {
                AudioStruct _eff = mData.AnimationSkillList[id].AudioStructList[i];

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                string _titleName = _eff.Audio ? _eff.Audio.name : "Audio" + (i + 1).ToString();
                EditorGUILayout.BeginHorizontal();
                //此子特效的界面折叠
                _eff.isFoldout = EditorGUILayout.Foldout(_eff.isFoldout, _titleName);
                GUILayout.FlexibleSpace();
                //此子特效是否可用
                _eff.isEnabled = EditorGUILayout.Toggle("", _eff.isEnabled);

                if (GUILayout.Button("DELETE"))
                {
                    mData.AnimationSkillList[id].AudioStructList.Remove(_eff);
                    return;
                }

                EditorGUILayout.EndHorizontal();

                mData.AnimationSkillList[id].AudioStructList[i] = _eff;

                if (_eff.isFoldout)
                {
                    EditorGUI.BeginDisabledGroup(!_eff.isEnabled);
                    _eff.Audio = (AudioClip)EditorGUILayout.ObjectField("Audio", _eff.Audio, typeof(AudioClip), true);

                    _eff.DelayTime = EditorGUILayout.FloatField("Delay Time", _eff.DelayTime);
                    if (_eff.DelayTime > mData.AnimationSkillList[id].fTime)
                    {
                        _eff.DelayTime = mData.AnimationSkillList[id].fTime;
                    }

                    _eff.LifeTime = EditorGUILayout.FloatField("Life Time", _eff.LifeTime);

                    mData.AnimationSkillList[id].AudioStructList[i] = _eff;
                }
                EditorGUI.EndDisabledGroup();


                EditorGUILayout.EndVertical();
                EditorGUI.indentLevel--;
            }
        }
Beispiel #2
0
        IEnumerator WaitPlayAudio(AudioStruct es)
        {
            if (es.isEnabled)
            {
                yield return(new WaitForSeconds(es.DelayTime));
            }
            else
            {
                yield break;
            }

            if (es.Audio != null)
            {
                AudioClip _startEff = GameObject.Instantiate <AudioClip>(es.Audio, this.transform.position, Quaternion.identity);
                AudioSource.PlayClipAtPoint(_startEff, transform.position);
                Destroy(_startEff, es.LifeTime);
            }

            yield return(new WaitForEndOfFrame());
        }
        void DrawAnimation()
        {
            if (mData.AnimationSkillList == null)
            {
                return;
            }

            for (int i = 0; i < mData.AnimationSkillList.Count; i++)
            {
                EditorGUILayout.Space();

                AnimationSkillStruct _ass = mData.AnimationSkillList[i];
                if (_ass.Type == NFAnimaStateType.NONE)
                {
                    continue;
                }

                if (_ass.IsFoldout)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    _ass.fCurTime = EditorGUILayout.Slider(_ass.Type.ToString(), _ass.fCurTime, 0f, _ass.fTime);
                    if (_ass.fCurTime > 0)
                    {
                        for (int j = 0; j < mData.AnimationSkillList.Count; j++)
                        {
                            if (i != j)
                            {
                                mData.AnimationSkillList[j].fCurTime = 0f;
                            }
                        }

                        m_CurrentTime  = _ass.fCurTime / _ass.fTime;
                        mManulPlayType = _ass.Type;
                    }

                    _ass.fSpeed = EditorGUILayout.FloatField("Play Speed:", _ass.fSpeed);

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Play"))
                    {
                        //mASC.SetAnimator(mASC.GetComponent<Animator>());
                        _ass.fCurTime  = 0f;
                        m_CurrentTime  = 0f;
                        mManulPlayType = NFAnimaStateType.NONE;
                        mPlayType      = _ass.Type;
                        mASC.PlayAnimaState(mPlayType, -1);
                    }

                    if (GUILayout.Button("Stop"))
                    {
                        _ass.fCurTime  = 0f;
                        m_CurrentTime  = 0f;
                        mManulPlayType = NFAnimaStateType.NONE;
                        mPlayType      = NFAnimaStateType.Idle;
                        mASC.PlayAnimaState(NFAnimaStateType.Idle, -1);

                        for (int j = 0; j < mData.AnimationSkillList.Count; j++)
                        {
                            mData.AnimationSkillList[j].fCurTime = 0f;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    _ass.AnimationClip = (AnimationClip)EditorGUILayout.ObjectField("AnimaitonClip:", _ass.AnimationClip, typeof(AnimationClip), true);

                    EditorGUILayout.BeginHorizontal();
                    if (_ass.AnimationClip == null)
                    {
                        _ass.fTime = 1f;
                    }
                    else
                    {
                        _ass.fTime = _ass.AnimationClip.length / _ass.fSpeed;
                    }
                    EditorGUILayout.LabelField("NextAnima After:", _ass.fTime.ToString());
                    _ass.NextType = (NFAnimaStateType)EditorGUILayout.EnumPopup(_ass.NextType);

                    EditorGUILayout.EndHorizontal();



                    mData.AnimationSkillList[i] = _ass;

                    //添加特效与删除片断
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("ADD EFFECT"))
                    {
                        EffectStruct _es = new EffectStruct();
                        _es.LifeTime  = 3;
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].EffectStructList.Add(_es);
                    }
                    if (GUILayout.Button("ADD Audio"))
                    {
                        AudioStruct _es = new AudioStruct();
                        _es.LifeTime  = 3;
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].AudioStructList.Add(_es);
                    }
                    if (GUILayout.Button("ADD Bullet"))
                    {
                        BulletStruct _es = new BulletStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].BulletStructList.Add(_es);
                    }



                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("ADD Damage"))
                    {
                        DamageStruct _es = new DamageStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].DamageStructList.Add(_es);
                    }

                    if (GUILayout.Button("ADD Movement"))
                    {
                        MovementStruct _es = new MovementStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].MovementStructList.Add(_es);
                    }

                    if (GUILayout.Button("ADD Camera"))
                    {
                        CameraStruct _es = new CameraStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].CameraStructList.Add(_es);
                    }

                    EditorGUILayout.EndHorizontal();

                    if (mData.AnimationSkillList.Count > 0)
                    {
                        DrawEffect(i);
                        DrawAudio(i);
                        DrawMovement(i);
                        DrawDamage(i);
                        DrawBullet(i);
                        DrawCamera(i);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        }