Persist() public static méthode

public static Persist ( Component component ) : void
component Component
Résultat void
    public void OnSceneGUI()
    {
        if (!Application.isPlaying)
        {
            return;
        }


        if (!m_Component.AllowEditTransform)
        {
            return;
        }

        m_Persist = false;

        if (rotationDelta != m_Component.transform.localRotation)
        {
            m_Component.RotationOffset = m_Component.transform.localEulerAngles;
            m_Persist = true;
        }

        if (positionDelta != m_Component.transform.localPosition)
        {
            m_Component.PositionOffset = m_Component.transform.localPosition;
            m_Persist = true;
        }

        if (m_Persist)
        {
            m_Persister.Persist();
        }

        positionDelta = m_Component.transform.position;
        rotationDelta = m_Component.transform.localRotation;
    }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        DoMotorJumpFoldout();
        DoMotorDashFoldout();
        DoMotorDoubleJumpFoldout();
        DoMotorGroundSlideFoldout();
        DoMotorLedgeGrabFoldout();
        DoMotorWallJumpFoldout();
        DoMotorWallHangFoldout();
        DoMotorWallRunFoldout();


        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
    /// <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;
    }
Exemple #4
0
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        string objectInfo = m_Component.gameObject.name;

        if (vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
            objectInfo += " (INACTIVE)";
        }

        if (!vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
            return;
        }

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoProjectileFoldout();
            DoMuzzleFlashFoldout();
            DoShellFoldout();
            DoSoundFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
	/// <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>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        m_Component.DrawDebugObjects = (m_SwingFoldout || m_ImpactFoldout || m_DamageFoldout);

        DoWeaponStatesFoldout();
        DoSwingFoldout();
        DoImpactFoldout();
        DoSoundFoldout();

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        GUILayout.BeginHorizontal();
        GUILayout.Space(10);
        m_Component.AttackPickRandomState = GUILayout.Toggle(m_Component.AttackPickRandomState, "Pick a random state for each attack");
        GUILayout.Space(10);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.HelpBox("Uncheck to use Default state only (or in case you want to enable specific states via script).", MessageType.Info);
        GUILayout.Space(10);
        GUILayout.EndHorizontal();

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update default state and persist in order not to loose inspector tweaks
        // due to state switches during runtime - UNLESS a runtime state button has
        // been pressed (in which case user wants to toggle states as opposed to
        // reset / alter them)
        if (GUI.changed &&
            (!vp_PresetEditorGUIUtility.RunTimeStateButtonTarget == m_Component))
        {
            EditorUtility.SetDirty(target);

            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoRenderingFoldout();
            DoPositionFoldout();
            DoRotationFoldout();
            DoRetractionFoldout();
            DoShakeFoldout();
            DoBobFoldout();
            DoStepFoldout();
            DoSoundFoldout();
            DoAnimationFoldout();
            DoLookDownFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state foldout
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset foldout
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update default state and persist in order not to loose inspector tweaks
        // due to state switches during runtime - UNLESS a runtime state button has
        // been pressed (in which case user wants to toggle states as opposed to
        // reset / alter them)
        if (GUI.changed &&
            (!vp_PresetEditorGUIUtility.RunTimeStateButtonTarget == m_Component))
        {
            EditorUtility.SetDirty(target);

            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoMouseFoldout();
            DoRenderingFoldout();
            DoPositionFoldout();
            DoRotationFoldout();
            DoShakeFoldout();
            DoBobFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        m_Component.DrawDebugObjects = (m_SwingFoldout || m_ImpactFoldout || m_DamageFoldout);

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoWeaponStatesFoldout();
            DoSwingFoldout();
            DoImpactFoldout();
            DoDamageFoldout();
            DoFXFoldout();
            DoSoundFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
Exemple #10
0
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoMotorMoveFoldout();
            DoMotorJumpFoldout();
            DoPhysicsFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update default state and persist in order not to loose inspector tweaks
        // due to state switches during runtime - UNLESS a runtime state button has
        // been pressed (in which case user wants to toggle states as opposed to
        // reset / alter them)
        if (GUI.changed &&
            (!vp_PresetEditorGUIUtility.RunTimeStateButtonTarget == m_Component))
        {
            EditorUtility.SetDirty(target);

            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
Exemple #11
0
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        string objectInfo = m_Component.gameObject.name;

        if (vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
            objectInfo += " (INACTIVE)";
        }

        if (!vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
            return;
        }

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            DoProjectileFoldout();
            DoMotionFoldout();
            DoMuzzleFlashFoldout();
            DoShellFoldout();
            DoSoundFoldout();
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update default state and persist in order not to loose inspector tweaks
        // due to state switches during runtime - UNLESS a runtime state button has
        // been pressed (in which case user wants to toggle states as opposed to
        // reset / alter them)
        if (GUI.changed &&
            (!vp_PresetEditorGUIUtility.RunTimeStateButtonTarget == m_Component))
        {
            EditorUtility.SetDirty(target);

            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            // --- Motor ---
            m_MotorFoldout = EditorGUILayout.Foldout(m_MotorFoldout, "Motor");

            if (m_MotorFoldout)
            {
                m_Component.MotorAcceleration   = EditorGUILayout.Slider("Acceleration", m_Component.MotorAcceleration, 0, 1);
                m_Component.MotorDamping        = EditorGUILayout.Slider("Damping", m_Component.MotorDamping, 0, 1);
                m_Component.MotorJumpForce      = EditorGUILayout.Slider("Jump Force", m_Component.MotorJumpForce, 0, 10);
                m_Component.MotorAirSpeed       = EditorGUILayout.Slider("Air Speed", m_Component.MotorAirSpeed, 0, 1);
                m_Component.MotorSlopeSpeedUp   = EditorGUILayout.Slider("Slope Speed Up", m_Component.MotorSlopeSpeedUp, 0, 2);
                m_Component.MotorSlopeSpeedDown = EditorGUILayout.Slider("Slope Sp. Down", m_Component.MotorSlopeSpeedDown, 0, 2);

                vp_EditorGUIUtility.Separator();
            }

            // --- Physics ---
            m_PhysicsFoldout = EditorGUILayout.Foldout(m_PhysicsFoldout, "Physics");
            if (m_PhysicsFoldout)
            {
                m_Component.PhysicsForceDamping    = EditorGUILayout.Slider("Force Damping", m_Component.PhysicsForceDamping, 0, 1);
                m_Component.PhysicsPushForce       = EditorGUILayout.Slider("Push Force", m_Component.PhysicsPushForce, 0, 100);
                m_Component.PhysicsGravityModifier = EditorGUILayout.Slider("Gravity Modifier", m_Component.PhysicsGravityModifier, 0, 1);
                m_Component.PhysicsWallBounce      = EditorGUILayout.Slider("Wall Bounce", m_Component.PhysicsWallBounce, 0, 1);

                vp_EditorGUIUtility.Separator();
            }
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // --- State ---
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // --- Preset ---
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // --- Persist Play Mode Changes ---
//		vp_PresetEditorGUIUtility.PersistToggle(m_Persister);

        if (GUI.changed)
        {
            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        string objectInfo = m_Component.gameObject.name;

        if (m_Component.gameObject.active)
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
            objectInfo += " (INACTIVE)";
        }

        GUILayout.Label(objectInfo);
        vp_EditorGUIUtility.Separator();

        if (!m_Component.gameObject.active)
        {
            GUI.enabled = true;
            return;
        }

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            // --- Rendering ---
            m_WeaponRenderingFoldout = EditorGUILayout.Foldout(m_WeaponRenderingFoldout, "Rendering");
            if (m_WeaponRenderingFoldout)
            {
                // weapon fov
                Vector2 fovDirty = new Vector2(0.0f, m_Component.RenderingFieldOfView);
                m_Component.RenderingFieldOfView = EditorGUILayout.Slider("Field of View", m_Component.RenderingFieldOfView, 1, 179);
                if (fovDirty != new Vector2(0.0f, m_Component.RenderingFieldOfView))
                {
                    m_Component.Zoom();
                }
                m_Component.RenderingZoomDamping    = EditorGUILayout.Slider("Zoom Damping", m_Component.RenderingZoomDamping, 0.1f, 5.0f);
                m_Component.RenderingClippingPlanes = EditorGUILayout.Vector2Field("Clipping Planes (Near:Far)", m_Component.RenderingClippingPlanes);
                GUI.enabled = false;
                GUILayout.Label("To add weapons, add child GameObjects to the\nFPSCamera transform and add FPSWeapon\nscripts to them. See the docs for more info.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;

                vp_EditorGUIUtility.Separator();
            }

            // --- Position ---
            m_WeaponPositionFoldout = EditorGUILayout.Foldout(m_WeaponPositionFoldout, "Position");
            if (m_WeaponPositionFoldout)
            {
                m_Component.PositionOffset     = EditorGUILayout.Vector3Field("Offset", m_Component.PositionOffset);
                m_Component.PositionExitOffset = EditorGUILayout.Vector3Field("Exit Offset", m_Component.PositionExitOffset);
                Vector3 currentPivot = m_Component.PositionPivot;
                m_Component.PositionPivot = EditorGUILayout.Vector3Field("Pivot", m_Component.PositionPivot);
                m_Component.PositionPivotSpringStiffness = EditorGUILayout.Slider("Pivot Stiffness", m_Component.PositionPivotSpringStiffness, 0, 1);
                m_Component.PositionPivotSpringDamping   = EditorGUILayout.Slider("Pivot Damping", m_Component.PositionPivotSpringDamping, 0, 1);

                if (!Application.isPlaying)
                {
                    GUI.enabled = false;
                }
                bool currentPivotVisible = m_WeaponPivotVisible;
                m_WeaponPivotVisible = EditorGUILayout.Toggle("Show Pivot", m_WeaponPivotVisible);
                if (Application.isPlaying)
                {
                    if (m_Component.PositionPivot != currentPivot)
                    {
                        m_Component.SnapPivot();
                        m_WeaponPivotVisible = true;
                    }
                    if (currentPivotVisible != m_WeaponPivotVisible)
                    {
                        m_Component.SetPivotVisible(m_WeaponPivotVisible);
                    }
                    GUI.enabled = false;
                    GUILayout.Label("Set Pivot Z to about -0.5 to bring it into view.", vp_EditorGUIUtility.NoteStyle);
                    GUI.enabled = true;
                }
                else
                {
                    GUILayout.Label("Pivot can be shown when the game is playing.", vp_EditorGUIUtility.NoteStyle);
                }

                GUI.enabled = true;

                m_Component.PositionSpringStiffness  = EditorGUILayout.Slider("Spring Stiffness", m_Component.PositionSpringStiffness, 0, 1);
                m_Component.PositionSpringDamping    = EditorGUILayout.Slider("Spring Damping", m_Component.PositionSpringDamping, 0, 1);
                m_Component.PositionSpring2Stiffness = EditorGUILayout.Slider("Spring2 Stiffn.", m_Component.PositionSpring2Stiffness, 0, 1);
                m_Component.PositionSpring2Damping   = EditorGUILayout.Slider("Spring2 Damp.", m_Component.PositionSpring2Damping, 0, 1);
                GUI.enabled = false;
                GUILayout.Label("Spring2 is intended for recoil. See the docs for usage.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.PositionKneeling           = EditorGUILayout.Slider("Kneeling", m_Component.PositionKneeling, 0, 1);
                m_Component.PositionFallRetract        = EditorGUILayout.Slider("Fall Retract", m_Component.PositionFallRetract, 0, 10);
                m_Component.PositionWalkSlide          = EditorGUILayout.Vector3Field("Walk Sliding", m_Component.PositionWalkSlide);
                m_Component.PositionInputVelocityScale = EditorGUILayout.Slider("Input Vel. Scale", m_Component.PositionInputVelocityScale, 0, 10);
                m_Component.PositionMaxInputVelocity   = EditorGUILayout.FloatField("Max Input Vel.", m_Component.PositionMaxInputVelocity);

                vp_EditorGUIUtility.Separator();
            }

            // --- Rotation ---
            m_WeaponRotationFoldout = EditorGUILayout.Foldout(m_WeaponRotationFoldout, "Rotation");
            if (m_WeaponRotationFoldout)
            {
                m_Component.RotationOffset           = EditorGUILayout.Vector3Field("Offset", m_Component.RotationOffset);
                m_Component.RotationExitOffset       = EditorGUILayout.Vector3Field("Exit Offset", m_Component.RotationExitOffset);
                m_Component.RotationSpringStiffness  = EditorGUILayout.Slider("Spring Stiffness", m_Component.RotationSpringStiffness, 0, 1);
                m_Component.RotationSpringDamping    = EditorGUILayout.Slider("Spring Damping", m_Component.RotationSpringDamping, 0, 1);
                m_Component.RotationSpring2Stiffness = EditorGUILayout.Slider("Spring2 Stiffn.", m_Component.RotationSpring2Stiffness, 0, 1);
                m_Component.RotationSpring2Damping   = EditorGUILayout.Slider("Spring2 Damp.", m_Component.RotationSpring2Damping, 0, 1);
                GUI.enabled = false;
                GUILayout.Label("Spring2 is intended for recoil. See the docs for usage.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.RotationLookSway   = EditorGUILayout.Vector3Field("Look Sway", m_Component.RotationLookSway);
                m_Component.RotationStrafeSway = EditorGUILayout.Vector3Field("Strafe Sway", m_Component.RotationStrafeSway);
                m_Component.RotationFallSway   = EditorGUILayout.Vector3Field("Fall Sway", m_Component.RotationFallSway);
                m_Component.RotationSlopeSway  = EditorGUILayout.Slider("Slope Sway", m_Component.RotationSlopeSway, 0, 1);
                GUI.enabled = false;
                GUILayout.Label("SlopeSway multiplies FallSway when grounded\nand will take effect on slopes.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.RotationInputVelocityScale = EditorGUILayout.Slider("Input Rot. Scale", m_Component.RotationInputVelocityScale, 0, 10);
                m_Component.RotationMaxInputVelocity   = EditorGUILayout.FloatField("Max Input Rot.", m_Component.RotationMaxInputVelocity);

                vp_EditorGUIUtility.Separator();
            }

            // --- Shake ---
            m_WeaponShakeFoldout = EditorGUILayout.Foldout(m_WeaponShakeFoldout, "Shake");
            if (m_WeaponShakeFoldout)
            {
                m_Component.ShakeSpeed     = EditorGUILayout.Slider("Speed", m_Component.ShakeSpeed, 0, 1);
                m_Component.ShakeAmplitude = EditorGUILayout.Vector3Field("Amplitude", m_Component.ShakeAmplitude);

                vp_EditorGUIUtility.Separator();
            }

            // --- Bob ---
            m_WeaponBobFoldout = EditorGUILayout.Foldout(m_WeaponBobFoldout, "Bob");
            if (m_WeaponBobFoldout)
            {
                m_Component.BobRate               = EditorGUILayout.Vector4Field("Rate", m_Component.BobRate);
                m_Component.BobAmplitude          = EditorGUILayout.Vector4Field("Amplitude", m_Component.BobAmplitude);
                m_Component.BobInputVelocityScale = EditorGUILayout.Slider("Input Vel. Scale", m_Component.BobInputVelocityScale, 0, 10);
                m_Component.BobMaxInputVelocity   = EditorGUILayout.FloatField("Max Input Vel.", m_Component.BobMaxInputVelocity);
                GUI.enabled = false;
                GUILayout.Label("XYZ is angular bob... W is position along the\nforward vector. X & Z rate should be (Y/2) for a\nclassic weapon bob.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;

                vp_EditorGUIUtility.Separator();
            }

            // --- Sound ---
            m_WeaponSoundFoldout = EditorGUILayout.Foldout(m_WeaponSoundFoldout, "Sound");
            if (m_WeaponSoundFoldout)
            {
                m_Component.SoundWield   = (AudioClip)EditorGUILayout.ObjectField("Wield", m_Component.SoundWield, typeof(AudioClip), false);
                m_Component.SoundUnWield = (AudioClip)EditorGUILayout.ObjectField("Unwield", m_Component.SoundUnWield, typeof(AudioClip), false);

                vp_EditorGUIUtility.Separator();
            }
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // --- State ---
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // --- Preset ---
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // --- Persist Play Mode Changes ---
//		vp_PresetEditorGUIUtility.PersistToggle(m_Persister);

        if (GUI.changed)
        {
            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
Exemple #14
0
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        string objectInfo = m_Component.gameObject.name;

        if (m_Component.gameObject.active)
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
            objectInfo += " (INACTIVE)";
        }

        if (!m_Component.gameObject.active)
        {
            GUI.enabled = true;
            return;
        }

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            // --- Projectile ---
            m_ProjectileFoldout = EditorGUILayout.Foldout(m_ProjectileFoldout, "Projectile");
            if (m_ProjectileFoldout)
            {
                m_Component.ProjectileFiringRate = EditorGUILayout.FloatField("Firing Rate", m_Component.ProjectileFiringRate);
                m_Component.ProjectilePrefab     = (GameObject)EditorGUILayout.ObjectField("Prefab", m_Component.ProjectilePrefab, typeof(GameObject), false);
                GUI.enabled = false;
                GUILayout.Label("Prefab should be a gameobject with a projectile\nlogic script added to it (such as vp_Bullet).", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.ProjectileScale  = EditorGUILayout.Slider("Scale", m_Component.ProjectileScale, 0, 2);
                m_Component.ProjectileCount  = EditorGUILayout.IntField("Count", m_Component.ProjectileCount);
                m_Component.ProjectileSpread = EditorGUILayout.Slider("Spread", m_Component.ProjectileSpread, 0, 360);

                vp_EditorGUIUtility.Separator();
            }

            // --- Motion ---

            m_MotionFoldout = EditorGUILayout.Foldout(m_MotionFoldout, "Motion");
            if (m_MotionFoldout)
            {
                m_Component.MotionPositionRecoil = EditorGUILayout.Vector3Field("Position Recoil", m_Component.MotionPositionRecoil);
                m_Component.MotionRotationRecoil = EditorGUILayout.Vector3Field("Rotation Recoil", m_Component.MotionRotationRecoil);
                GUI.enabled = false;
                GUILayout.Label("Recoil forces are added to the secondary\nposition and rotation springs of the weapon.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.MotionPositionReset = EditorGUILayout.Slider("Position Reset", m_Component.MotionPositionReset, 0, 1);
                m_Component.MotionRotationReset = EditorGUILayout.Slider("Rotation Reset", m_Component.MotionRotationReset, 0, 1);
                GUI.enabled = false;
                GUILayout.Label("Upon firing, primary position and rotation springs\nwill snap back to their rest state by this factor.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.MotionPositionPause = EditorGUILayout.Slider("Position Pause", m_Component.MotionPositionPause, 0, 5);
                m_Component.MotionRotationPause = EditorGUILayout.Slider("Rotation Pause", m_Component.MotionRotationPause, 0, 5);
                GUI.enabled = false;
                GUILayout.Label("Upon firing, primary spring forces will pause and\nease back in over this time interval in seconds.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.MotionDryFireRecoil = EditorGUILayout.Slider("Dry Fire Recoil", m_Component.MotionDryFireRecoil, -1, 1);

                vp_EditorGUIUtility.Separator();
            }

            // --- MuzzleFlash ---
            m_MuzzleFlashFoldout = EditorGUILayout.Foldout(m_MuzzleFlashFoldout, "Muzzle Flash");
            if (m_MuzzleFlashFoldout)
            {
                m_Component.MuzzleFlashPrefab = (GameObject)EditorGUILayout.ObjectField("Prefab", m_Component.MuzzleFlashPrefab, typeof(GameObject), false);
                GUI.enabled = false;
                GUILayout.Label("Prefab should be a mesh with a Particles/Additive\nshader and a vp_MuzzleFlash script added to it.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                Vector3 currentPosition = m_Component.MuzzleFlashPosition;
                m_Component.MuzzleFlashPosition = EditorGUILayout.Vector3Field("Position", m_Component.MuzzleFlashPosition);
                Vector3 currentScale = m_Component.MuzzleFlashScale;
                m_Component.MuzzleFlashScale     = EditorGUILayout.Vector3Field("Scale", m_Component.MuzzleFlashScale);
                m_Component.MuzzleFlashFadeSpeed = EditorGUILayout.Slider("Fade Speed", m_Component.MuzzleFlashFadeSpeed, 0.001f, 0.2f);
                if (!Application.isPlaying)
                {
                    GUI.enabled = false;
                }
                bool currentMuzzleFlashVisible = m_MuzzleFlashVisible;
                m_MuzzleFlashVisible = EditorGUILayout.Toggle("Show Muzzle Fl.", m_MuzzleFlashVisible);
                if (Application.isPlaying)
                {
                    if (m_Component.MuzzleFlashPosition != currentPosition ||
                        m_Component.MuzzleFlashScale != currentScale)
                    {
                        m_MuzzleFlashVisible = true;
                    }

                    vp_MuzzleFlash mf = (vp_MuzzleFlash)m_Component.MuzzleFlash.GetComponent("vp_MuzzleFlash");
                    if (mf != null)
                    {
                        mf.ForceShow = currentMuzzleFlashVisible;
                    }

                    GUI.enabled = false;
                    GUILayout.Label("Set Muzzle Flash Z to about 0.5 to bring it into view.", vp_EditorGUIUtility.NoteStyle);
                    GUI.enabled = true;
                }
                else
                {
                    GUILayout.Label("Muzzle Flash can be shown when the game is playing.", vp_EditorGUIUtility.NoteStyle);
                }
                GUI.enabled = true;

                vp_EditorGUIUtility.Separator();
            }

            // --- Shell ---
            m_ShellFoldout = EditorGUILayout.Foldout(m_ShellFoldout, "Shell");
            if (m_ShellFoldout)
            {
                m_Component.ShellPrefab = (GameObject)EditorGUILayout.ObjectField("Prefab", m_Component.ShellPrefab, typeof(GameObject), false);
                GUI.enabled             = false;
                GUILayout.Label("Prefab should be a mesh with a collider, a rigidbody\nand a vp_Shell script added to it.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled                     = true;
                m_Component.ShellScale          = EditorGUILayout.Slider("Scale", m_Component.ShellScale, 0, 1);
                m_Component.ShellEjectPosition  = EditorGUILayout.Vector3Field("Eject Position", m_Component.ShellEjectPosition);
                m_Component.ShellEjectDirection = EditorGUILayout.Vector3Field("Eject Direction", m_Component.ShellEjectDirection);
                m_Component.ShellEjectVelocity  = EditorGUILayout.Slider("Eject Velocity", m_Component.ShellEjectVelocity, 0, 0.5f);
                m_Component.ShellEjectSpin      = EditorGUILayout.Slider("Eject Spin", m_Component.ShellEjectSpin, 0, 1.0f);
                m_Component.ShellEjectDelay     = Mathf.Abs(EditorGUILayout.FloatField("Eject Delay", m_Component.ShellEjectDelay));
                vp_EditorGUIUtility.Separator();
            }


            // --- Ammo ---
            m_AmmoFoldout = EditorGUILayout.Foldout(m_AmmoFoldout, "Ammo");
            if (m_AmmoFoldout)
            {
                m_Component.AmmoMaxCount   = EditorGUILayout.IntField("Max Count", m_Component.AmmoMaxCount);
                m_Component.AmmoReloadTime = EditorGUILayout.FloatField("Reload Time", m_Component.AmmoReloadTime);

                //GUI.enabled = false;
                //GUILayout.Label("Prefab should be a mesh with a collider, a rigidbody\nand a vp_Shell script added to it.", vp_EditorGUIUtility.NoteStyle);
                //GUI.enabled = true;
                vp_EditorGUIUtility.Separator();
            }

            // --- Sound ---
            m_SoundFoldout = EditorGUILayout.Foldout(m_SoundFoldout, "Sound");
            if (m_SoundFoldout)
            {
                m_Component.SoundFire      = (AudioClip)EditorGUILayout.ObjectField("Fire", m_Component.SoundFire, typeof(AudioClip), false);
                m_Component.SoundDryFire   = (AudioClip)EditorGUILayout.ObjectField("Dry Fire", m_Component.SoundDryFire, typeof(AudioClip), false);
                m_Component.SoundReload    = (AudioClip)EditorGUILayout.ObjectField("Reload", m_Component.SoundReload, typeof(AudioClip), false);
                m_Component.SoundFirePitch = EditorGUILayout.Vector2Field("Fire Pitch (Min:Max)", m_Component.SoundFirePitch);
                EditorGUILayout.MinMaxSlider(ref m_Component.SoundFirePitch.x, ref m_Component.SoundFirePitch.y, 0.5f, 1.5f);
                vp_EditorGUIUtility.Separator();
            }
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // --- State ---
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // --- Preset ---
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // --- Update ---
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        m_Component.DrawDebugObjects = (m_SwingFoldout || m_ImpactFoldout || m_DamageFoldout);

        //if (!Application.isPlaying)
        //{

        DoWeaponStatesFoldout();
        DoSwingFoldout();
        DoImpactFoldout();
        DoDamageFoldout();
        DoFXFoldout();
        DoSoundFoldout();

        //}
        //else
        //{

        //GUI.enabled = false;
        //GUILayout.Label("\nThis component can not be modified at runtime.\n", vp_EditorGUIUtility.NoteStyle);
        //GUI.enabled = true;

        //}

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        GUILayout.BeginHorizontal();
        GUILayout.Space(10);
        m_Component.AttackPickRandomState = GUILayout.Toggle(m_Component.AttackPickRandomState, "Pick a random state for each attack");
        GUILayout.Space(10);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.HelpBox("Uncheck to use Default state only (or in case you want to enable specific states via script).", MessageType.Info);
        GUILayout.Space(10);
        GUILayout.EndHorizontal();

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }
        }
    }
Exemple #16
0
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    public override void OnInspectorGUI()
    {
        GUI.color = Color.white;

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            // --- Mouse ---
            m_CameraMouseFoldout = EditorGUILayout.Foldout(m_CameraMouseFoldout, "Mouse");
            if (m_CameraMouseFoldout)
            {
                m_Component.MouseSensitivity  = EditorGUILayout.Vector2Field("Sensitivity", m_Component.MouseSensitivity);
                m_Component.MouseSmoothSteps  = EditorGUILayout.IntSlider("Smooth Steps", m_Component.MouseSmoothSteps, 1, 20);
                m_Component.MouseSmoothWeight = EditorGUILayout.Slider("Smooth Weight", m_Component.MouseSmoothWeight, 0, 1);
                m_Component.MouseAcceleration = EditorGUILayout.Toggle("Acceleration", m_Component.MouseAcceleration);
                if (!m_Component.MouseAcceleration)
                {
                    GUI.enabled = false;
                }
                m_Component.MouseAccelerationThreshold = EditorGUILayout.Slider("Acc. Threshold", m_Component.MouseAccelerationThreshold, 0, 5);
                GUI.enabled = true;

                vp_EditorGUIUtility.Separator();
            }

            // --- Rendering ---
            m_CameraRenderingFoldout = EditorGUILayout.Foldout(m_CameraRenderingFoldout, "Rendering");
            if (m_CameraRenderingFoldout)
            {
                Vector2 fovDirty = new Vector2(m_Component.RenderingFieldOfView, 0.0f);
                m_Component.RenderingFieldOfView = EditorGUILayout.Slider("Field of View", m_Component.RenderingFieldOfView, 1, 179);
                if (fovDirty != new Vector2(m_Component.RenderingFieldOfView, 0.0f))
                {
                    m_Component.Zoom();
                }
                m_Component.RenderingZoomDamping = EditorGUILayout.Slider("Zoom Damping", m_Component.RenderingZoomDamping, 0.0f, 5.0f);

                vp_EditorGUIUtility.Separator();
            }

            // --- Position ---
            m_CameraPositionFoldout = EditorGUILayout.Foldout(m_CameraPositionFoldout, "Position");
            if (m_CameraPositionFoldout)
            {
                m_Component.PositionOffset           = EditorGUILayout.Vector3Field("Offset", m_Component.PositionOffset);
                m_Component.PositionOffset.y         = Mathf.Max(m_Component.PositionGroundLimit, m_Component.PositionOffset.y);
                m_Component.PositionGroundLimit      = EditorGUILayout.Slider("Ground Limit", m_Component.PositionGroundLimit, -5, 5);
                m_Component.PositionSpringStiffness  = EditorGUILayout.Slider("Spring Stiffness", m_Component.PositionSpringStiffness, 0, 1);
                m_Component.PositionSpringDamping    = EditorGUILayout.Slider("Spring Damping", m_Component.PositionSpringDamping, 0, 1);
                m_Component.PositionSpring2Stiffness = EditorGUILayout.Slider("Spring2 Stiffn.", m_Component.PositionSpring2Stiffness, 0, 1);
                m_Component.PositionSpring2Damping   = EditorGUILayout.Slider("Spring2 Damp.", m_Component.PositionSpring2Damping, 0, 1);
                m_Component.PositionKneeling         = EditorGUILayout.Slider("Kneeling", m_Component.PositionKneeling, 0, 0.5f);
                GUI.enabled = false;
                GUILayout.Label("Spring2 is a scripting feature. See the docs for usage.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;

                vp_EditorGUIUtility.Separator();
            }

            // --- Rotation ---
            m_CameraRotationFoldout = EditorGUILayout.Foldout(m_CameraRotationFoldout, "Rotation");
            if (m_CameraRotationFoldout)
            {
                m_Component.RotationPitchLimit = EditorGUILayout.Vector2Field("Pitch Limit (Min:Max)", m_Component.RotationPitchLimit);
                EditorGUILayout.MinMaxSlider(ref m_Component.RotationPitchLimit.x, ref m_Component.RotationPitchLimit.y, -90.0f, 90.0f);
                m_Component.RotationYawLimit = EditorGUILayout.Vector2Field("Yaw Limit (Min:Max)", m_Component.RotationYawLimit);
                EditorGUILayout.MinMaxSlider(ref m_Component.RotationYawLimit.x, ref m_Component.RotationYawLimit.y, -360.0f, 360.0f);
                m_Component.RotationKneeling   = EditorGUILayout.Slider("Kneeling", m_Component.RotationKneeling, 0, 0.5f);
                m_Component.RotationStrafeRoll = EditorGUILayout.Slider("Strafe Roll", m_Component.RotationStrafeRoll, -5.0f, 5.0f);

                vp_EditorGUIUtility.Separator();
            }

            // --- Shake ---
            m_CameraShakeFoldout = EditorGUILayout.Foldout(m_CameraShakeFoldout, "Shake");
            if (m_CameraShakeFoldout)
            {
                m_Component.ShakeSpeed     = EditorGUILayout.Slider("Speed", m_Component.ShakeSpeed, 0, 1);
                m_Component.ShakeAmplitude = EditorGUILayout.Vector3Field("Amplitude", m_Component.ShakeAmplitude);

                vp_EditorGUIUtility.Separator();
            }

            // --- Bob ---
            m_CameraBobFoldout = EditorGUILayout.Foldout(m_CameraBobFoldout, "Bob");
            if (m_CameraBobFoldout)
            {
                m_Component.BobRate      = EditorGUILayout.Vector4Field("Rate", m_Component.BobRate);
                m_Component.BobAmplitude = EditorGUILayout.Vector4Field("Amplitude", m_Component.BobAmplitude);
                GUI.enabled = false;
                GUILayout.Label("XYZ is positional bob... W is roll around forward vector.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.BobStepThreshold = EditorGUILayout.FloatField("Step Threshold", m_Component.BobStepThreshold);
                GUI.enabled = false;
                GUILayout.Label("Step Threshold is a scripting feature. See docs for usage.", vp_EditorGUIUtility.NoteStyle);
                GUI.enabled = true;
                m_Component.BobInputVelocityScale = EditorGUILayout.Slider("Input Vel. Scale", m_Component.BobInputVelocityScale, 0, 10);
                m_Component.BobMaxInputVelocity   = EditorGUILayout.FloatField("Max Input Vel.", m_Component.BobMaxInputVelocity);

                vp_EditorGUIUtility.Separator();
            }
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // --- State ---
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // --- Preset ---
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // --- Persist Play Mode Changes ---
//		vp_PresetEditorGUIUtility.PersistToggle(m_Persister);

        if (GUI.changed)
        {
            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }
    /// <summary>
    ///
    /// </summary>
    public override void OnInspectorGUI()
    {
        Undo.SetSnapshotTarget(m_Component, "Shooter Snapshot");
        Undo.CreateSnapshot();

        GUI.color = Color.white;

        string objectInfo = m_Component.gameObject.name;

        if (vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
            objectInfo += " (INACTIVE)";
        }

        if (!vp_Utility.IsActive(m_Component.gameObject))
        {
            GUI.enabled = true;
            return;
        }

        if (Application.isPlaying || m_Component.DefaultState.TextAsset == null)
        {
            EditorGUI.indentLevel++;
            m_Component.Distance        = EditorGUILayout.Slider("Distance", m_Component.Distance, 0, 500);
            m_Component.ListeningLayers = vp_AIEditor.LayerMaskField("Listening Layers", m_Component.ListeningLayers);
            m_Component.GlobalEventName = EditorGUILayout.TextField("Global Event Name", m_Component.GlobalEventName);
            m_Component.SendRate        = EditorGUILayout.Slider("Send Event Rate", m_Component.SendRate, 0, 60);
            EditorGUI.indentLevel--;
        }
        else
        {
            vp_PresetEditorGUIUtility.DefaultStateOverrideMessage();
        }

        // state
        m_StateFoldout = vp_PresetEditorGUIUtility.StateFoldout(m_StateFoldout, m_Component, m_Component.States, m_Persister);

        // preset
        m_PresetFoldout = vp_PresetEditorGUIUtility.PresetFoldout(m_PresetFoldout, m_Component);

        // update
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            Undo.RegisterSnapshot();

            // update the default state in order not to loose inspector tweaks
            // due to state switches during runtime
            if (Application.isPlaying)
            {
                m_Component.RefreshDefaultState();
            }

            if (m_Component.Persist)
            {
                m_Persister.Persist();
            }

            m_Component.Refresh();
        }
    }