private static void DrawWaveList(WavesEditor wavesEditor) { if (wavesEditor._currentSequance != null) { _waveListScrollPosition = EditorGUILayout.BeginScrollView(_waveListScrollPosition); { if (wavesEditor._currentSequance != SelectedSequance) { _selectedWaveList = new ReorderableList(wavesEditor._currentSequance.Waves, typeof(SequanceDefenition), true, false, true, true); _selectedWaveList.drawElementCallback = (Rect cellRect, int index, bool isActive, bool isFocused) => { for (int i=0; i < wavesEditor._currentSequance.Waves[index].SpawnedItems.Count; i++) { GUI.DrawTexture(new Rect(cellRect.x + (i * 16), cellRect.y, 16, 16), TeaxtureForSpwanItem(wavesEditor._currentSequance.Waves[index].SpawnedItems[i].SpwanedColor, wavesEditor)); } if (wavesEditor._currentSequance.Waves[index].Delay > 0) { EditorGUI.LabelField(new Rect(cellRect.x + wavesEditor._currentSequance.Waves[index].SpawnedItems.Count * 16, cellRect.y, 100,16) ,"Delay " + wavesEditor._currentSequance.Waves[index].Delay); } }; _selectedWaveList.onSelectCallback = (list) => { wavesEditor._currentWave = wavesEditor._currentSequance.Waves[list.index]; _selectedTab = eWaveEditorTabTab.Wave; }; _selectedWaveList.onAddCallback = (list) => { if (wavesEditor._currentSequance != null) { WaveDataObject newWave = new WaveDataObject(); wavesEditor._currentSequance.Waves.Add(newWave); wavesEditor._currentWave = newWave; _selectedWave = newWave; list.index = list.count - 1; } }; SelectedSequance = wavesEditor._currentSequance; } _selectedWaveList.DoLayoutList(); } EditorGUILayout.EndScrollView(); } }
public static void DrawProperties(this WavesEditor wavesEditor, Rect rect) { EditorGUI.DrawRect(new Rect(0, 0, rect.width, rect.height), Color.yellow); GUILayout.BeginArea(new Rect(0, 0, rect.width * 0.1f, rect.height)); { GUILayout.BeginArea(new Rect(5, 0, rect.width * 0.1f, rect.height)); EditorGUILayout.BeginVertical(); { if (GUILayout.Toggle(_selectedTab == eWaveEditorTabTab.Sequance, "Sequance", "Button", GUILayout.Height(rect.height * 0.3f))) { _selectedTab = eWaveEditorTabTab.Sequance; } if (GUILayout.Toggle(_selectedTab == eWaveEditorTabTab.Wave, "Wave", "Button", GUILayout.Height(rect.height * 0.3f))) { _selectedTab = eWaveEditorTabTab.Wave; } if (GUILayout.Toggle(_selectedTab == eWaveEditorTabTab.Item, "Item", "Button", GUILayout.Height(rect.height * 0.3f))) { _selectedTab = eWaveEditorTabTab.Item; } } EditorGUILayout.EndVertical(); GUILayout.EndArea(); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(rect.width * 0.1f, 0, rect.width - rect.width * 0.1f, rect.height)); { EditorGUILayout.BeginVertical("Box"); { switch (_selectedTab) { case eWaveEditorTabTab.Sequance: { if (wavesEditor._currentSequance == null) { break; } DrawSequancePanel(wavesEditor); break; } case eWaveEditorTabTab.Wave: { if (wavesEditor._currentWave == null) { _selectedTab = eWaveEditorTabTab.Sequance; break; } DrawWavePanel(wavesEditor); break; } case eWaveEditorTabTab.Item: { if (wavesEditor._currentSpwanItem == null) { _selectedTab = eWaveEditorTabTab.Wave; break; } DrawItemPanel(wavesEditor); break; } } } EditorGUILayout.EndVertical(); } GUILayout.EndArea(); }
private static void DrawSpwanedItemsList(WavesEditor wavesEditor) { if (wavesEditor._currentWave != null) { _spawnedItemsListScrollPosition = EditorGUILayout.BeginScrollView(_spawnedItemsListScrollPosition); { if (wavesEditor._currentWave != _selectedWave && wavesEditor._currentWave.SpawnedItems != null) { _spawnedItemsList = new ReorderableList(wavesEditor._currentWave.SpawnedItems, typeof(SpawnedItemDataObject), true, false, true, true); _spawnedItemsList.drawElementCallback = (Rect cellRect, int index, bool isActive, bool isFocused) => { if (wavesEditor._currentWave != null && wavesEditor._currentWave.SpawnedItems != null && wavesEditor._currentWave.SpawnedItems.Count > index) { if (wavesEditor._currentWave.SpawnedItems[index] != null) { GUI.DrawTexture(new Rect(cellRect.x, cellRect.y, 16, 16), TeaxtureForSpwanItem(wavesEditor._currentWave.SpawnedItems[index].SpwanedColor, wavesEditor)); } } }; _spawnedItemsList.onSelectCallback = (list) => { wavesEditor._currentSpwanItem = wavesEditor._currentWave.SpawnedItems[list.index]; _selectedTab = eWaveEditorTabTab.Item; }; _spawnedItemsList.onAddCallback = (list) => { SpawnedItemDataObject newItem = new SpawnedItemDataObject(); newItem.ForceVector = new Vector2(0, 144); wavesEditor._currentWave.SpawnedItems.Add(newItem); }; _selectedWave = wavesEditor._currentWave; } if (_spawnedItemsList != null) { _spawnedItemsList.DoLayoutList(); } } EditorGUILayout.EndScrollView(); } }