Пример #1
0
    protected virtual void CheckForObjectChanges()
    {
        serializedObject.ApplyModifiedProperties();

        // Update the visible mesh if the sprite or vertex density was changed
        if (m_InitialVertexDensity != m_VertexDensity.intValue ||
            m_InitialSpriteScale != m_SpriteScale.vector2Value)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.RefreshMesh();
            }
        }

        // Update the springs if we altered any of their settings
        if (m_InitialStiffness != m_Stiffness.floatValue || m_InitialDamping != m_DampingRatio.floatValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.UpdateJoints();
                targetObjectSprite.WakeUp();
            }
        }

        // Recalculate weighting values if the exponent changes
        if (m_InitialDistanceExponent != m_DistanceExponent.floatValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.CalculateWeightingValues();
            }
        }

        // Update the mass of each body if the value changed
        if (m_InitialMassStyle != m_MassStyle.enumValueIndex ||
            m_InitialMass != m_Mass.floatValue ||
            m_InitialGravityScale != m_GravityScale.floatValue ||
            m_InitialAngularDrag != m_AngularDrag.floatValue ||
            m_InitialInterpolation != m_InterpolationMode.enumValueIndex ||
            m_InitialInterpolation2D != m_InterpolationMode2D.enumValueIndex ||
            m_InitialDrag != m_Drag.floatValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.InitMass();
                targetObjectSprite.WakeUp();
            }
        }

        if (m_InitialNumAttachPoints != m_NumAttachPoints.intValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.ResizeAttachPoints();
            }
        }

        if (m_InitialFlipX != m_FlipX.boolValue ||
            m_InitialFlipY != m_FlipY.boolValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.UpdateTextureCoords();
            }
        }

        if (m_InitialLockRotation != m_LockRotation.boolValue ||
            m_InitialCentralBodyKinematic != m_CentralBodyKinematic.boolValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.UpdateRotationLock();
            }
        }

        if (m_InitialColor != m_Color.colorValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellySprite targetObjectSprite = targetObject as JellySprite;
                targetObjectSprite.GetComponent <Renderer>().sharedMaterial.color = m_Color.colorValue;
            }
        }
    }