Ejemplo n.º 1
0
    protected override void CheckForObjectChanges()
    {
        base.CheckForObjectChanges();
        JellySprite targetObject = this.target as JellySprite;

        if (m_InitialSprite != m_Sprite.objectReferenceValue)
        {
            targetObject.RefreshMesh();
        }
    }
Ejemplo n.º 2
0
    protected override void CheckForObjectChanges()
    {
        base.CheckForObjectChanges();
        JellySprite targetObject = this.target as JellySprite;

        if (m_InitialSprite != m_Sprite.objectReferenceValue)
        {
            Sprite sprite = m_Sprite.objectReferenceValue as Sprite;
            Bounds bounds = sprite.bounds;
            float  pivotX = -bounds.center.x / bounds.extents.x;
            float  pivotY = -bounds.center.y / bounds.extents.y;
            targetObject.m_CentralBodyOffset = targetObject.m_SoftBodyOffset = new Vector3(pivotX * bounds.extents.x * targetObject.m_SpriteScale.x, pivotY * bounds.extents.y * targetObject.m_SpriteScale.y, 0.0f);
            targetObject.RefreshMesh();
        }
    }
Ejemplo n.º 3
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;
            }
        }
    }