Ejemplo n.º 1
0
    private void OnGUI()
    {
        if (effectData == null)
        {
            return;
        }
        EditorGUILayout.BeginVertical();
        {
            //상단 .add, .remove, .copy
            UnityObject source = effectSource;
            EditorHelper.EditorToolTopLayer(effectData, ref selection, ref source,
                                            this.uiWidthMiddle);
            effectSource = (GameObject)source;


            EditorGUILayout.BeginHorizontal();
            {   //중간, 데이터 목록
                EditorHelper.EditorToolListLayer(ref SP1, effectData, ref selection,
                                                 ref source, this.uiWidthLarge);
                effectSource = (GameObject)source;

                //설정부분
                EditorGUILayout.BeginVertical();
                {
                    SP2 = EditorGUILayout.BeginScrollView(this.SP2);
                    {
                        if (effectData.GetDataCount() > 0)
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                EditorGUILayout.Separator();
                                EditorGUILayout.LabelField("ID", selection.ToString(), GUILayout.Width(uiWidthLarge));
                                effectData.names[selection] = EditorGUILayout.TextField("이름.", effectData.names[selection],
                                                                                        GUILayout.Width(uiWidthLarge * 1.5f));
                                effectData.effectClips[selection].effectType = (EffectType)EditorGUILayout.EnumPopup("이펙트 타입.",
                                                                                                                     effectData.effectClips[selection].effectType, GUILayout.Width(uiWidthLarge));
                                EditorGUILayout.Separator();
                                if (effectSource == null && effectData.effectClips[selection].effectName != string.Empty)
                                {
                                    effectData.effectClips[selection].PreLoad();
                                    effectSource = Resources.Load(effectData.effectClips[selection].effectPath +
                                                                  effectData.effectClips[selection].effectName) as GameObject;
                                }
                                effectSource = (GameObject)EditorGUILayout.ObjectField("이펙트", this.effectSource, typeof(GameObject), false,
                                                                                       GUILayout.Width(uiWidthLarge * 1.5f));
                                if (effectSource != null)
                                {
                                    effectData.effectClips[selection].effectPath = EditorHelper.GetPath(this.effectSource);
                                    effectData.effectClips[selection].effectName = effectSource.name;
                                }
                                else
                                {
                                    effectData.effectClips[selection].effectPath = string.Empty;
                                    effectData.effectClips[selection].effectName = string.Empty;
                                    effectSource = null;
                                }
                                EditorGUILayout.Separator();
                            }
                            EditorGUILayout.EndVertical();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.Separator();
        //에디터 구분 하단.
        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Reload Settings"))
            {
                effectData = CreateInstance <EffectData>();
                effectData.LoadData();
                selection         = 0;
                this.effectSource = null;
            }
            if (GUILayout.Button("Save"))
            {
                EffectTool.effectData.SaveData();
                CreateEnumStructure();
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
        }
        EditorGUILayout.EndHorizontal();
    }
    private void OnGUI()
    {
        if (effectData == null)
        {
            //Debug.LogError("EffectTool/OnGUI Error! effectData is null");
            return;
        }

        EditorGUILayout.BeginVertical();       // EffectTool 레이아웃 전체를 수직적으로 구성
        {
            UnityObject source = effectSource; //GameObject -> UnityObject 박싱

            /*
             * 가장 상단에 EditorToolTopLayer
             * source는 게임 오브젝트, 오디오 클립, 애니메이션 클립 등이 될 수 있으므로
             * UnityObject 형식으로 받아서 작업한 뒤,
             * 각 메소드마다 자신이 사용할 형식으로 다시 언박싱한다.(여기서는 GameObject)
             */
            EditorHelper.EditorToolTopLayer(effectData, ref selection, ref source, this.uiWidthMiddle);
            effectSource = source as GameObject; // UnityObject-> GameObject 언박싱


            EditorGUILayout.BeginHorizontal();
            {
                // 중간 데이터 리스트 레이아웃
                EditorHelper.EditorToolListLayer(ref SP1, effectData, ref selection, ref source, this.uiWidthLarge);
                effectSource = source as GameObject;

                //설정 부분
                EditorGUILayout.BeginVertical();
                {
                    SP2 = EditorGUILayout.BeginScrollView(this.SP2);
                    {
                        if (effectData.GetDataCount() > 0)
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                EditorGUILayout.Separator();
                                EditorGUILayout.LabelField("ID", selection.ToString(), GUILayout.Width(uiWidthLarge));
                                effectData.names[selection] = EditorGUILayout.TextField("이름.", effectData.names[selection], GUILayout.Width(uiWidthLarge * 1.5f));
                                effectData.effectClips[selection].effectType = (EffectType)EditorGUILayout.EnumPopup("이펙트 타입.",
                                                                                                                     effectData.effectClips[selection].effectType,
                                                                                                                     GUILayout.Width(uiWidthLarge));

                                //이펙트 리로스 실제로 보여주기
                                EditorGUILayout.Separator();
                                if (effectSource == null && effectData.effectClips[selection].effectName != string.Empty)
                                {
                                    effectData.effectClips[selection].PreLoad();
                                    //full path 사용해볼것
                                    effectSource = Resources.Load(
                                        effectData.effectClips[selection].effectPath +
                                        effectData.effectClips[selection].effectName) as GameObject;
                                }
                                effectSource = (GameObject)EditorGUILayout.ObjectField("이펙트.", this.effectSource, typeof(GameObject), false, GUILayout.Width(uiWidthLarge * 1.5f));

                                if (effectSource != null) //불러오기 성공 -> 경로와 이름 세팅
                                {
                                    effectData.effectClips[selection].effectPath = EditorHelper.GetPath(this.effectSource);
                                    effectData.effectClips[selection].effectName = effectSource.name;
                                }
                                else //불러오기 실패
                                {
                                    effectData.effectClips[selection].effectPath = string.Empty;
                                    effectData.effectClips[selection].effectName = string.Empty;
                                    effectSource = null;
                                }
                                EditorGUILayout.Separator();
                            }
                            EditorGUILayout.EndVertical();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.Separator();

        //하단
        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Reload Settings"))
            {
                effectData = CreateInstance <EffectData>();
                effectData.LoadData();
                selection         = 0;
                this.effectSource = null;
            }
            if (GUILayout.Button("Save"))
            {
                EffectTool.effectData.SaveData();
                CreateEnumStructure();
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
        }
        EditorGUILayout.EndHorizontal();
    }