/// <summary> /// draws a check box to toggle persist state ON / OFF for a /// component. will be disabled if the 'Default' state has /// been overridden /// </summary> public static void PersistToggle(vp_ComponentPersister persister) { bool oldPersistState = persister.Component.Persist; GUI.color = Color.white; if (persister.Component.DefaultState.TextAsset != null) { persister.Component.Persist = false; GUI.color = m_ColorTransparentWhite; } persister.Component.Persist = vp_EditorGUIUtility.SmallToggle("Persist Play Mode Changes", persister.Component.Persist); if (persister.Component.DefaultState.TextAsset != null && persister.Component.Persist == true) { string s = "Can't Persist Play Mode Changes when the 'Default' state has been overridden with a text file preset."; if (!Application.isPlaying) s += "\n\nClick 'Unlock' to reenable inspector changes to this component."; vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Locked", s); persister.Component.Persist = false; } if (oldPersistState != persister.Component.Persist) persister.Persist(); GUI.color = Color.white; }
/// <summary> /// disables the persister and removes its reference /// </summary> public virtual void OnDestroy() { m_Persister.IsActive = false; m_Persister = null; // NOTE: may prevent 'IsPlayingOrAllowExecuteInEditMode' error }
/// <summary> /// draws a check box to toggle persist state ON / OFF for a /// component. will be disabled if the 'Default' state has /// been overridden /// </summary> public static void PersistToggle(vp_ComponentPersister persister) { bool oldPersistState = persister.Component.Persist; GUI.color = Color.white; if (persister.Component.DefaultState.TextAsset != null) { persister.Component.Persist = false; GUI.color = m_ColorTransparentWhite; } persister.Component.Persist = vp_EditorGUIUtility.SmallToggle("Persist Play Mode Changes", persister.Component.Persist); if (persister.Component.DefaultState.TextAsset != null && persister.Component.Persist == true) { string s = "Can't Persist Play Mode Changes when the 'Default' state has been overridden with a text file preset."; if (!Application.isPlaying) { s += "\n\nClick 'Unlock' to reenable inspector changes to this component."; } vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Locked", s); persister.Component.Persist = false; } if (oldPersistState != persister.Component.Persist) { persister.Persist(); } GUI.color = Color.white; }
public virtual void OnEnable() { m_Component = (ac_PlayerActivitySound)target; if (m_Persister == null) { m_Persister = new vp_ComponentPersister(); } m_Persister.Component = m_Component; m_Persister.IsActive = true; }
/// <summary> /// hooks up the FPSCamera object to the inspector target /// </summary> public void OnEnable() { m_Component = (vp_FPInputMobile)target; if (m_Persister == null) m_Persister = new vp_ComponentPersister(); m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) m_Component.RefreshDefaultState(); }
/// <summary> /// hooks up the object to the inspector target /// </summary> public virtual void OnEnable() { m_Component = (vp_FPWeaponShooter)target; if (m_Persister == null) m_Persister = new vp_ComponentPersister(); m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) m_Component.RefreshDefaultState(); }
/// <summary> /// hooks up the object to the inspector target /// </summary> public virtual void OnEnable() { m_Component = (vp_Shooter)target; if (m_Persister == null) { m_Persister = new vp_ComponentPersister(); } m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) { m_Component.RefreshDefaultState(); } }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSCamera)target; if (m_Persister == null) { m_Persister = new vp_ComponentPersister(); } m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) { m_Component.RefreshDefaultState(); } }
/// <summary> /// draws a field allowing the user to create, reorganize, /// name, assign presets to and delete states on a component /// </summary> public static bool StateFoldout(bool foldout, vp_Component component, List<vp_State> stateList, vp_ComponentPersister persister = null) { RunTimeStateButtonTarget = null; bool before = foldout; foldout = EditorGUILayout.Foldout(foldout, (foldout && !Application.isPlaying) ? "State Preset" : "States" ); if (foldout != before) { m_ShowBlockListFor = null; component.RefreshDefaultState(); if (!Application.isPlaying) UpdateOldStateTypeNames(component); } if (foldout) { if (m_ShowBlockListFor != null) { if (!stateList.Contains(m_ShowBlockListFor)) foldout = false; } } if (foldout) { for (int v = 0; v < stateList.Count; v++) { vp_State s = stateList[v]; if (!Application.isPlaying) { vp_PresetEditorGUIUtility.StateField(s, stateList, component); if ((m_ShowBlockListFor != null) && m_ShowBlockListFor == s) { StateBlockList(component, s); } } else { vp_PresetEditorGUIUtility.RunTimeStateField(component, s, stateList); } } GUILayout.BeginHorizontal(); if (!Application.isPlaying) { if (GUILayout.Button("Add State", GUILayout.MinWidth(90), GUILayout.MaxWidth(90))) { m_ShowBlockListFor = null; string newStateName = "Untitled"; int n = 1; while (GetStateId(component, newStateName) != -1) { n++; newStateName = newStateName.Substring(0, 8) + (n<10?"0":"") + n.ToString(); } stateList.Add(new vp_State(component.GetType().Name, newStateName, "")); component.RefreshDefaultState(); EditorUtility.SetDirty(component); } } else { GUI.color = Color.clear; GUILayout.Button("", GUILayout.MinWidth(36), GUILayout.MaxWidth(36)); GUI.color = Color.white; } if (!Application.isPlaying) GUILayout.EndHorizontal(); if (persister != null) vp_PresetEditorGUIUtility.PersistToggle(persister); if (Application.isPlaying) GUILayout.EndHorizontal(); vp_EditorGUIUtility.Separator(); } return foldout; }
/////////////////////////////////////////////////////////// // draws a field allowing the user to create, reorganize, // name, assign presets to and delete states on a component /////////////////////////////////////////////////////////// public static bool StateFoldout(bool foldout, vp_Component component, List<vp_StateInfo> stateList, vp_ComponentPersister persister = null) { bool before = foldout; foldout = EditorGUILayout.Foldout(foldout, (foldout && !Application.isPlaying) ? "State Preset" : "States" ); if (foldout != before) component.RefreshDefaultState(); if (foldout) { for (int v = 0; v < stateList.Count; v++) { int s = v; if (!Application.isPlaying) { vp_PresetEditorGUIUtility.StateField(stateList[s], stateList); } else { vp_PresetEditorGUIUtility.RunTimeStateField(component, stateList[s], stateList); } } GUILayout.BeginHorizontal(); if (!Application.isPlaying) { if (GUILayout.Button("Add State", GUILayout.MinWidth(90), GUILayout.MaxWidth(90))) { stateList.Add(new vp_StateInfo(component.GetType().Name, "New State", "")); component.RefreshDefaultState(); } } else { GUI.color = Color.clear; GUILayout.Button("", GUILayout.MinWidth(36), GUILayout.MaxWidth(36)); GUI.color = Color.white; } if(!Application.isPlaying) GUILayout.EndHorizontal(); if (persister != null) vp_PresetEditorGUIUtility.PersistToggle(persister); if (Application.isPlaying) GUILayout.EndHorizontal(); vp_EditorGUIUtility.Separator(); } return foldout; }
/////////////////////////////////////////////////////////// // hooks up the FPSController object as the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSController)target; if (m_Persister == null) m_Persister = new vp_ComponentPersister(); m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) m_Component.RefreshDefaultState(); }
/// <summary> /// draws a field allowing the user to create, reorganize, /// name, assign presets to and delete states on a component /// </summary> public static bool StateFoldout(bool foldout, vp_Component component, List <vp_State> stateList, vp_ComponentPersister persister = null) { bool before = foldout; foldout = EditorGUILayout.Foldout(foldout, (foldout && !Application.isPlaying) ? "State Preset" : "States" ); if (foldout != before) { m_ShowBlockListFor = null; component.RefreshDefaultState(); } if (foldout) { if (m_ShowBlockListFor != null) { if (!stateList.Contains(m_ShowBlockListFor)) { foldout = false; } } } if (foldout) { for (int v = 0; v < stateList.Count; v++) { vp_State s = stateList[v]; if (!Application.isPlaying) { vp_PresetEditorGUIUtility.StateField(s, stateList, component); if ((m_ShowBlockListFor != null) && m_ShowBlockListFor == s) { StateBlockList(component, s); } } else { vp_PresetEditorGUIUtility.RunTimeStateField(component, s, stateList); } } GUILayout.BeginHorizontal(); if (!Application.isPlaying) { if (GUILayout.Button("Add State", GUILayout.MinWidth(90), GUILayout.MaxWidth(90))) { m_ShowBlockListFor = null; string newStateName = "Untitled"; int n = 1; while (GetStateId(component, newStateName) != -1) { n++; newStateName = newStateName.Substring(0, 8) + (n < 10?"0":"") + n.ToString(); } stateList.Add(new vp_State(component.GetType().Name, newStateName, "")); component.RefreshDefaultState(); EditorUtility.SetDirty(component); } } else { GUI.color = Color.clear; GUILayout.Button("", GUILayout.MinWidth(36), GUILayout.MaxWidth(36)); GUI.color = Color.white; } if (!Application.isPlaying) { GUILayout.EndHorizontal(); } if (persister != null) { vp_PresetEditorGUIUtility.PersistToggle(persister); } if (Application.isPlaying) { GUILayout.EndHorizontal(); } vp_EditorGUIUtility.Separator(); } return(foldout); }
/////////////////////////////////////////////////////////// // draws a field allowing the user to create, reorganize, // name, assign presets to and delete states on a component /////////////////////////////////////////////////////////// public static bool StateFoldout(bool foldout, vp_Component component, List <vp_StateInfo> stateList, vp_ComponentPersister persister = null) { bool before = foldout; foldout = EditorGUILayout.Foldout(foldout, (foldout && !Application.isPlaying) ? "State Preset" : "States" ); if (foldout != before) { component.RefreshDefaultState(); } if (foldout) { for (int v = 0; v < stateList.Count; v++) { int s = v; if (!Application.isPlaying) { vp_PresetEditorGUIUtility.StateField(stateList[s], stateList); } else { vp_PresetEditorGUIUtility.RunTimeStateField(component, stateList[s], stateList); } } GUILayout.BeginHorizontal(); if (!Application.isPlaying) { if (GUILayout.Button("Add State", GUILayout.MinWidth(90), GUILayout.MaxWidth(90))) { stateList.Add(new vp_StateInfo(component.GetType().Name, "New State", "")); component.RefreshDefaultState(); } } else { GUI.color = Color.clear; GUILayout.Button("", GUILayout.MinWidth(36), GUILayout.MaxWidth(36)); GUI.color = Color.white; } if (!Application.isPlaying) { GUILayout.EndHorizontal(); } if (persister != null) { vp_PresetEditorGUIUtility.PersistToggle(persister); } if (Application.isPlaying) { GUILayout.EndHorizontal(); } vp_EditorGUIUtility.Separator(); } return(foldout); }
public virtual void OnEnable() { m_Component = (ac_PlayerActivitySound)target; if (m_Persister == null) m_Persister = new vp_ComponentPersister(); m_Persister.Component = m_Component; m_Persister.IsActive = true; }