Example #1
0
    public static SpawnerEditWindow Initialize(UnitSpawner us, int index, Vector3Int position)
    {
        SpawnerEditWindow window = (SpawnerEditWindow)SpawnerEditWindow.GetWindow(typeof(SpawnerEditWindow));

        window.m_unitSpawner = us;
        window.m_position    = position;
        window.m_index       = index;
        window.Show();
        return(window);
    }
Example #2
0
        public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int pos)
        {
            if (brushTarget.layer == 31)
            {
                return;
            }
            //Tilemap layerTilemap = brushTarget.GetComponent<Tilemap>();
            UnitSpawner spawner = brushTarget.GetComponent <UnitSpawner>();

            if (spawner == null)
            {
                Debug.LogError("TileMap对象必须包含一个 生怪器 组件");
                return;
            }
            if (m_window)
            {
                m_window.Close();
            }

            if (null != m_clipBoardBuff)
            {
                for (int i = 0; i < spawner.spawns.Count; i++)
                {
                    if (pos == spawner.spawns[i].position)
                    {
                        spawner.spawns[i] = m_clipBoardBuff.CloneSetPos(pos);
                        m_window          = SpawnerEditWindow.Initialize(spawner, i, pos);
                        return;
                    }
                }
                spawner.spawns.Add(m_clipBoardBuff.CloneSetPos(pos));
                m_window = SpawnerEditWindow.Initialize(spawner, spawner.spawns.Count - 1, pos);
                var prefabStage = PrefabStageUtility.GetPrefabStage(spawner.gameObject);
                if (prefabStage != null)
                {
                    EditorSceneManager.MarkSceneDirty(prefabStage.scene);
                }
                return;
            }
            else
            {
                Debug.LogWarning("剪贴板没有值");
            }
        }
Example #3
0
        public override void Select(GridLayout grid, GameObject brushTarget, BoundsInt position)
        {
            if (brushTarget.layer == 31)
            {
                return;
            }
            //Tilemap layerTilemap = brushTarget.GetComponent<Tilemap>();
            UnitSpawner spawner = brushTarget.GetComponent <UnitSpawner>();

            if (spawner == null)
            {
                Debug.LogError("TileMap对象必须包含一个 生怪器 组件");
                return;
            }
            if (m_window)
            {
                m_window.Close();
            }
            Vector3Int  pos = position.position;
            PrefabStage prefabStage;

            for (int i = 0; i < spawner.spawns.Count; i++)
            {
                if (pos == spawner.spawns[i].position)
                {
                    m_window    = SpawnerEditWindow.Initialize(spawner, i, pos);
                    prefabStage = PrefabStageUtility.GetPrefabStage(spawner.gameObject);
                    if (prefabStage != null)
                    {
                        EditorSceneManager.MarkSceneDirty(prefabStage.scene);
                    }
                    return;
                }
            }
            m_window    = SpawnerEditWindow.Initialize(spawner, spawner.spawns.Count, pos);
            prefabStage = PrefabStageUtility.GetPrefabStage(spawner.gameObject);
            if (prefabStage != null)
            {
                EditorSceneManager.MarkSceneDirty(prefabStage.scene);
            }
        }