Example #1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        GetItemObjectsFoldout = EditorGUILayout.Foldout(GetItemObjectsFoldout, "資料庫下載");

        GUILayout.BeginVertical("Box");

        EditorGUILayout.PropertyField(serializedObject.FindProperty("appID"), new GUIContent("資料表的ID"));

        GUILayout.EndVertical();

        for (int i = 0; i < serializedObject.FindProperty("downloadDatabaseRows").arraySize; i++)
        {
            if (serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize < 3)
            {
                serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize = 3;
            }
            else if (serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize == 5)
            {
                serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize = 7;
            }
            else if (serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize == 6)
            {
                serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize = 4;
            }
            else if (serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize >= 7)
            {
                serializedObject.FindProperty("downloadDatabaseRows").GetArrayElementAtIndex(i).FindPropertyRelative("fieldsNames").arraySize = 7;
            }
        }

        if (GetItemObjectsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("downloadDatabaseRows"), typeof(DownloadDatabaseRow));
        }
        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        IsOpenOriginInspector = GUILayout.Toggle(IsOpenOriginInspector, new GUIContent("開啟原始面板"));
        if (IsOpenOriginInspector)
        {
            base.OnInspectorGUI();


            GUILayout.Space(20f);
        }

        // base.OnInspectorGUI();
        serializedObject.Update();

        GUILayout.BeginVertical("Box");

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.TipSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("TipSound"),
            "是否啟用",
            "播放提示音效"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSound"),
            "是否啟用",
            "正確音效"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundWaitOverOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSoundWaitOver"),
            "是否啟用",
            "正確音效等待音效結束才進下一關"
            );


        GUILayout.EndHorizontal();

        GUILayout.Space(20f);

        GUILayout.BeginVertical("Box");

        Instance.OtherAnimObjs.ShowInBeginOnOff = EditorGUILayout.Toggle("是否一開始就顯示圖片", Instance.OtherAnimObjs.ShowInBeginOnOff);

        Instance.OtherAnimObjs.OtherAnimObjOnOff = EditorGUILayout.BeginToggleGroup("額外動畫物件", Instance.OtherAnimObjs.OtherAnimObjOnOff);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPrefab"), new GUIContent("額外動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPosition"), new GUIContent("額外動畫的位置"));
        if (GUILayout.Button("選擇額外動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.OtherAnimObjs.OtherAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("額外動畫位置", obj, (pos) => {
                float x = Mathf.RoundToInt((pos.x * 10f)) / 10f;
                float y = Mathf.RoundToInt((pos.y * 10f)) / 10f;
                Instance.OtherAnimObjs.OtherAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }
        EditorGUILayout.EndToggleGroup();

        GUILayout.EndVertical();

        GUILayout.Space(20f);


        moveItemsFoldout             = EditorGUILayout.Foldout(moveItemsFoldout, "拖曳物件的圖片 / 位置");
        Instance.IsCloseBackToOriPos = GUILayout.Toggle(Instance.IsCloseBackToOriPos, new GUIContent("關閉自動回彈功能"));

        if (moveItemsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MoveItems"), typeof(MoveItem_matchA), MoveItem_ArrayEditorMiddle, MoveItem_ArrayEditorTrail);
        }

        matchPosFoldout = EditorGUILayout.Foldout(matchPosFoldout, "感應區圖片、正確物件資訊");
        if (matchPosFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MatchPosItems"), typeof(MatchPosItem_matchA), MatchItemPost_ArrayEditorMiddle, MatchItemPost_ArrayEditorTrail);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(Instance);
            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Instance.gameObject.scene);
        }

        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        IsOpenOriginInspector = GUILayout.Toggle(IsOpenOriginInspector, new GUIContent("開啟原始面板"));
        if (IsOpenOriginInspector)
        {
            base.OnInspectorGUI();

            GUILayout.Space(20f);
        }

        GUILayout.BeginVertical("Box");
        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.TipSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("TipSound"),
            "是否啟用",
            "播放提示音效"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSound"),
            "是否啟用",
            "正確音效"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.CouldHaveSameChildCount,
            serializedObject.FindProperty("CouldHaveSameChildCount"),
            "是否啟用",
            "當物件組合存在相同個數時,答對?"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.DidnotHaveSameMatchItem,
            serializedObject.FindProperty("DidnotHaveSameMatchItem"),
            "啟用",
            "不要有相對的配對物件"
            );

        GUILayout.EndVertical();

        GUILayout.Space(20f);

        GUILayout.BeginVertical("Box");

        Instance.OtherAnimObjs.ShowInBeginOnOff = EditorGUILayout.Toggle("是否一開始就顯示圖片", Instance.OtherAnimObjs.ShowInBeginOnOff);

        Instance.OtherAnimObjs.OtherAnimObjOnOff = EditorGUILayout.BeginToggleGroup("額外動畫物件", Instance.OtherAnimObjs.OtherAnimObjOnOff);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPrefab"), new GUIContent("額外動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPosition"), new GUIContent("額外動畫的位置"));
        if (GUILayout.Button("選擇額外動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.OtherAnimObjs.OtherAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("額外動畫位置", obj, (pos) => {
                float x = Mathf.RoundToInt((pos.x * 100f)) / 100f;
                float y = Mathf.RoundToInt((pos.y * 100f)) / 100f;
                Instance.OtherAnimObjs.OtherAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }
        EditorGUILayout.EndToggleGroup();
        EditorGUILayout.EndVertical();

        GUILayout.Space(20f);



        //Instance.removeItemObj.removeItemOnOff = EditorGUILayout.Toggle("是否創建垃圾桶", Instance.removeItemObj.removeItemOnOff);
        GUILayout.BeginVertical("Box");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("removeItemObj").FindPropertyRelative("removeItemObj"), new GUIContent("垃圾桶的圖片"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("removeItemObj").FindPropertyRelative("removeItemObjPosition"), new GUIContent("垃圾桶的位置"));
        GUILayout.EndVertical();
        GUILayout.Space(20f);

        //EditorGUILayout.EndToggleGroup();


        matchPosFoldout = EditorGUILayout.Foldout(matchPosFoldout, "感應區圖片、正確物件資訊");
        if (matchPosFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MatchPosItems"), typeof(MatchPosItem_PermutationsSum), MatchItemPost_ArrayEditorMiddle, MatchItemPost_ArrayEditorTrail);
        }

        moveItemsFoldout = EditorGUILayout.Foldout(moveItemsFoldout, "拖曳物件的圖片、物件資訊");
        if (moveItemsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MoveItems"), typeof(MoveItem_PermutationsSum), MoveItem_ArrayEditorMiddle, MoveItem_ArrayEditorTrail);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(Instance);
            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Instance.gameObject.scene);
        }

        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        IsOpenOriginInspector = GUILayout.Toggle(IsOpenOriginInspector, new GUIContent("開啟原始面板"));
        if (IsOpenOriginInspector)
        {
            base.OnInspectorGUI();


            GUILayout.Space(20f);
        }

        serializedObject.Update();

        GUILayout.BeginVertical("Box");

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.TipSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("TipSound"),
            "是否啟用開頭音效",
            "開頭音效或開頭配音"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSound"),
            "是否啟用答對音效",
            "答對音效"
            );


        GUILayout.EndHorizontal();

        GUILayout.Space(20f);

        GUILayout.BeginVertical("Box");

        #region 開頭動畫物件

        Instance.HeaderAnimObj.HeaderAnimObjOnOff = EditorGUILayout.BeginToggleGroup("開頭動畫物件", Instance.HeaderAnimObj.HeaderAnimObjOnOff);

        Instance.HeaderAnimObj.DisableAtTipEnd = GUILayout.Toggle(Instance.HeaderAnimObj.DisableAtTipEnd, new GUIContent("在開頭音效之後是否關閉動畫"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("HeaderAnimObj").FindPropertyRelative("HeaderAnimObjPrefab"), new GUIContent("開頭動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("HeaderAnimObj").FindPropertyRelative("HeaderAnimObjPosition"), new GUIContent("開頭動畫的位置"));
        if (GUILayout.Button("選擇開頭動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.HeaderAnimObj.HeaderAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("開頭動畫位置", obj, (pos) => {
                float x = Mathf.RoundToInt((pos.x * 10f)) / 10f;
                float y = Mathf.RoundToInt((pos.y * 10f)) / 10f;
                Instance.HeaderAnimObj.HeaderAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }

        EditorGUILayout.EndToggleGroup();
        #endregion


        GUILayout.Space(20);


        #region 額外動畫物件
        Instance.EndingAnimObjs.EndingAnimObjOnOff = EditorGUILayout.BeginToggleGroup("額外動畫物件", Instance.EndingAnimObjs.EndingAnimObjOnOff);
        Instance.EndingAnimObjs.ShowInBeginOnOff   = GUILayout.Toggle(Instance.EndingAnimObjs.ShowInBeginOnOff, "是否一開始就顯示圖片");

        EditorGUILayout.PropertyField(serializedObject.FindProperty("EndingAnimObjs").FindPropertyRelative("EndingAnimObjPrefab"), new GUIContent("結束動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("EndingAnimObjs").FindPropertyRelative("EndingAnimObjPosition"), new GUIContent("結束動畫的位置"));
        if (GUILayout.Button("選擇結束動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.EndingAnimObjs.EndingAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("結束動畫位置", obj, (pos) =>
            {
                float x = Mathf.RoundToInt((pos.x * 10f)) / 10f;
                float y = Mathf.RoundToInt((pos.y * 10f)) / 10f;
                Instance.EndingAnimObjs.EndingAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }
        EditorGUILayout.EndToggleGroup();
        #endregion

        GUILayout.EndVertical();

        GUILayout.Space(20f);

        moveItemsFoldout = EditorGUILayout.Foldout(moveItemsFoldout, "選擇題物件資訊");
        if (moveItemsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("clickData"), typeof(ClickData), MoveItem_ArrayEditorMiddle, MoveItem_ArrayEditorTrail);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(Instance);
            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Instance.gameObject.scene);
        }

        serializedObject.ApplyModifiedProperties();
    }