예제 #1
0
 private void OnEnable()
 {
     m_target = target as TilemapGroup;
     m_target.Refresh();
     m_tilemapReordList       = CreateTilemapReorderableList();
     m_tilemapReordList.index = serializedObject.FindProperty("m_selectedIndex").intValue;
 }
예제 #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();
            }
        }
 private void OnEnable()
 {
     m_target = target as TilemapGroup;
     m_target.Refresh();
     m_selectedIndexProp           = serializedObject.FindProperty("m_selectedIndex");
     m_displayTilemapRList         = serializedObject.FindProperty("m_displayTilemapRList");
     m_tilemapReordList            = CreateTilemapReorderableList();
     m_tilemapReordList.index      = m_selectedIndexProp.intValue;
     m_sceneViewTilemapRList       = CreateTilemapReorderableList();
     m_sceneViewTilemapRList.index = m_selectedIndexProp.intValue;
     if (!m_target.DisplayTilemapRList)
     {
         m_sceneViewTilemapRList.elementHeight = 0f;
         m_sceneViewTilemapRList.draggable     = m_sceneViewTilemapRList.elementHeight > 0f;
         m_sceneViewTilemapRList.displayAdd    = m_sceneViewTilemapRList.draggable;
         m_sceneViewTilemapRList.displayRemove = m_sceneViewTilemapRList.draggable;
     }
 }