Example #1
0
    public static void Open(ArenaData arenaData)
    {
        if (_window != null)
        {
            _window.Focus();
            return;
        }

        _window = GetWindow <CellsEditorWindow>();
        _window.titleContent = new GUIContent("Cells Editor", EditorGUIUtility.FindTexture("d_ViewToolOrbit On"));
        _window._arenaData   = arenaData;
        _window.minSize      = _window.maxSize = arenaData.Size * CellSize + new Vector2(LeftSideWidth, 0);
    }
Example #2
0
    private void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        _arenaConfig =
            EditorGUILayout.ObjectField("Arena config", _arenaConfig, typeof(ArenaConfig), false) as ArenaConfig;
        if (EditorGUI.EndChangeCheck())
        {
            if (_arenaConfig != null)
            {
                _arenaIndexes       = new int[_arenaConfig.Arenas.Length];
                _arenaIndexDisplays = new string[_arenaConfig.Arenas.Length];
                for (int i = 0; i < _arenaIndexes.Length; i++)
                {
                    _arenaIndexes[i]       = i;
                    _arenaIndexDisplays[i] = i.ToString();
                }
            }
        }

        if (_arenaConfig == null || _arenaConfig.Arenas.Length == 0)
        {
            return;
        }

        _currentArenaIndex = EditorGUILayout.IntPopup("Arena", _currentArenaIndex, _arenaIndexDisplays, _arenaIndexes);
        _currentArenaData  = _arenaConfig.Arenas[_currentArenaIndex];

        if (GUILayout.Button("Open editor"))
        {
            CellsEditorWindow.Open(_currentArenaData);
        }

        if (GUILayout.Button("Save"))
        {
            EditorUtility.SetDirty(_arenaConfig);
            AssetDatabase.Refresh();
        }
    }