public void OnSelectionChange() { try { GameObject selectedObject = Selection.activeObject as GameObject; if (selectedObject != null) { selectedController = selectedObject.GetComponent <DMKController>(); if (selectedController != null) { if (selectedController.danmakus == null) { selectedController.danmakus = new List <DMKDanmaku>(); } } } else { selectedController = null; } selectedGraphObject = null; if (selectedController != null && selectedController.danmakus.Count > 0) { selectedDanmaku = selectedController.danmakus[0]; } this.Repaint(); } catch { selectedController = null; selectedGraphObject = null; } }
public void CopyFrom(DMKDanmaku danmaku) { this.playMode = danmaku.playMode; this.playInterval = danmaku.playInterval; this.parentController = danmaku.parentController; this.shooters.Clear(); foreach (DMKBulletShooterController shooterController in danmaku.shooters) { DMKBulletShooterController newController = (DMKBulletShooterController)ScriptableObject.CreateInstance <DMKBulletShooterController>(); newController.CopyFrom(shooterController); this.shooters.Add(newController); } this.modifiers.Clear(); foreach (DMKShooterModifier modifier in danmaku.modifiers) { DMKShooterModifier newModifier = (DMKShooterModifier)ScriptableObject.CreateInstance(modifier.GetType()); newModifier.CopyFrom(modifier); this.modifiers.Add(newModifier); } this.triggers.Clear(); foreach (DMKTrigger trigger in danmaku.triggers) { DMKTrigger newTrigger = (DMKTrigger)ScriptableObject.CreateInstance(trigger.GetType()); newTrigger.CopyFrom(trigger); this.triggers.Add(newTrigger); } }
void OnDanmakuMenuPasteClicked(object userData) { if (copiedDanmaku != null) { DMKDanmaku dst = userData as DMKDanmaku; dst.CopyFrom(copiedDanmaku); } }
void OnDanmakuMenuRemoveClicked(object userData) { if (selectedDanmaku == userData) { selectedDanmaku = null; } selectedController.danmakus.Remove(userData as DMKDanmaku); this.Repaint(); }
public void OnFocus() { if (selectedController != null && selectedController.danmakus.IndexOf(selectedDanmaku) == -1) { selectedDanmaku = null; this.Repaint(); } else if (selectedController == null) { this.OnSelectionChange(); } }
DMKDanmaku CreateNewDanmaku() { DMKDanmaku danmaku = (DMKDanmaku)ScriptableObject.CreateInstance <DMKDanmaku>(); danmaku.name = "New Danmaku"; danmaku.shooters = new List <DMKBulletShooterController>(); selectedController.danmakus.Add(danmaku); selectedDanmaku = danmaku; selectedDanmaku.parentController = selectedController; return(danmaku); }
void ShowDanmakuOptionMenu(DMKDanmaku danmaku) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Create New Danmaku"), false, OnDanmakuMenuCreateNewClicked, danmaku); menu.AddSeparator(""); menu.AddItem(new GUIContent("Copy Selected"), false, OnDanmakuMenuCopyClicked, danmaku); menu.AddItem(new GUIContent("Paste"), false, OnDanmakuMenuPasteClicked, danmaku); if (copiedDanmaku != null) { menu.AddItem(new GUIContent("Paste As New"), false, OnDanmakuMenuPasteAsNewClicked, danmaku); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Remove Selected"), false, OnDanmakuMenuRemoveClicked, danmaku); menu.ShowAsContext(); }
void DanmakuGUI(DMKDanmaku danmaku) { danmaku.name = EditorGUILayout.TextField("Name", danmaku.name); selectedController.maxBulletCount = EditorGUILayout.IntField("Max Num Bullets", selectedController.maxBulletCount); EditorGUI.BeginChangeCheck(); danmaku.playMode = (DMKDanmakuPlayMode)EditorGUILayout.EnumPopup("Play Mode", danmaku.playMode); if (EditorGUI.EndChangeCheck()) { if (selectedController.currentAttackIndex != -1) { selectedController.StartDanmaku(selectedController.currentAttackIndex); } } if (danmaku.playMode != DMKDanmakuPlayMode.All) { danmaku.playInterval = (int)Mathf.Clamp(EditorGUILayout.IntField("Interval", danmaku.playInterval), 0, 999999); } }
public void StartDanmaku(DMKDanmaku danmaku) { this.StartDanmaku(this.danmakus.IndexOf(danmaku)); }
void OnDanmakuListWindow() { GUI.Label(new Rect(2, 0, 60, 16), "Danmakus"); if (GUI.Button(new Rect(DanmakuListWindowWidth - 20, 0, 24, 16), new GUIContent(Resources.LoadAssetAtPath <Texture2D>("Assets/Scripts/DanmakuX/Editor/Resources/Icons/settings.png")), "label")) { this.ShowDanmakuOptionMenu(selectedDanmaku); // this.CreateNewDanmaku(); } danmakuListScrollPosition = EditorGUILayout.BeginScrollView(danmakuListScrollPosition); for (int i = 0; i < selectedController.danmakus.Count; ++i) { DMKDanmaku danmaku = selectedController.danmakus[i]; GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); GUI.SetNextControlName("danmaku_" + i.ToString()); if (selectedDanmaku == danmaku) { GUIStyle s = new GUIStyle(EditorStyles.foldout); s.normal.textColor = s.onNormal.textColor = s.onFocused.textColor; danmaku.editorExpanded = EditorGUILayout.Foldout(danmaku.editorExpanded, danmaku.name, s); } else { danmaku.editorExpanded = EditorGUILayout.Foldout(danmaku.editorExpanded, danmaku.name); } GUILayout.EndHorizontal(); } if (danmaku.editorExpanded) { this.DanmakuGUI(danmaku); } GUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); if (Event.current.type == EventType.Repaint) { for (int i = 0; i < selectedController.danmakus.Count; ++i) { DMKDanmaku danmaku = selectedController.danmakus[i]; if (GUI.GetNameOfFocusedControl() == "danmaku_" + i.ToString()) { // Debug.Log(GUI.GetNameOfFocusedControl()); if (selectedDanmaku != danmaku) { selectedDanmaku = danmaku; selectedGraphObject = null; // this.Repaint(); } } } } }
void OnDanmakuMenuCopyClicked(object userData) { copiedDanmaku = userData as DMKDanmaku; }