コード例 #1
0
        public override void OnInspectorGUI()
        {
            var targetObj = target as TilemapGroup;

            // NOTE: this happens during undo/redo
            if (targetObj.transform.childCount != targetObj.Tilemaps.Count)
            {
                targetObj.Refresh();
            }
            serializedObject.Update();

            // clamp index to valid value
            serializedObject.FindProperty("m_selectedIndex").intValue = m_tilemapReordList.index = Mathf.Clamp(m_tilemapReordList.index, -1, targetObj.Tilemaps.Count - 1);

            // Draw Tilemap List
            m_tilemapReordList.DoLayoutList();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_unselectedColorMultiplier"));
            EditorGUILayout.Space();

            // Draw Tilemap Inspector
            TilemapEditor tilemapEditor = GetTilemapEditor();

            if (tilemapEditor)
            {
                tilemapEditor.OnInspectorGUI();
            }

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                Repaint();
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            // NOTE: this happens during undo/redo
            if (m_target.transform.childCount != m_target.Tilemaps.Count)
            {
                m_target.Refresh();
            }
            serializedObject.Update();

            if (m_tilemapReordList.HasKeyboardControl())
            {
                DoKeyboardChecks();
            }

            // clamp index to valid value
            m_selectedIndexProp.intValue = Mathf.Clamp(m_selectedIndexProp.intValue, -1, m_target.Tilemaps.Count - 1);

            // Draw Tilemap List
            m_tilemapReordList.index = m_selectedIndexProp.intValue;
            m_tilemapReordList.DoLayoutList();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_unselectedColorMultiplier"), new GUIContent("Highlight Alpha"));
            EditorGUIUtility.labelWidth = 200f;
            EditorGUILayout.PropertyField(m_defaultTilemapWindowVisibleProperty, new GUIContent("Display Default Tilemap Window"));
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.Space();

            // Draw Tilemap Inspector
            TilemapEditor tilemapEditor = GetTilemapEditor();

            if (tilemapEditor)
            {
                tilemapEditor.OnInspectorGUI();
            }

            m_displayTilemapRList.boolValue = m_sceneViewTilemapRList.elementHeight > 0f;
            serializedObject.ApplyModifiedProperties();

            //fix: argument exception when removing the last tilemap in the list
            if (Event.current.type == EventType.Layout)
            {
                for (int i = 0; i < m_tilemapRemovingList.Count; ++i)
                {
                    Undo.DestroyObjectImmediate(m_tilemapRemovingList[i]);
                }
                m_tilemapRemovingList.Clear();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                Repaint();
            }
        }