Пример #1
0
    void ApplyHungerFx()
    {
        float newStiffness = Mathf.Lerp(_hungrySpringiness, _fullSpringiness, _hunger);

        if (newStiffness != _jellyMesh.m_Stiffness)
        {
            _jellyMesh.m_Stiffness = newStiffness;
            _jellyMesh.UpdateJoints();
            _jellyMesh.WakeUp();
        }

        _renderer.sharedMaterial.color = Color.Lerp(_hungryColour, _fullColour, _hunger);
    }
Пример #2
0
    protected virtual void CheckForObjectChanges()
    {
        serializedObject.ApplyModifiedProperties();

        // Update the visible mesh if the mesh or vertex density was changed
        if (m_InitialMeshScale != m_MeshScale.vector3Value ||
            m_InitialMesh != m_SourceMesh.objectReferenceValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellyMesh targetObjectMesh = targetObject as JellyMesh;
                targetObjectMesh.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)
            {
                JellyMesh targetObjectMesh = targetObject as JellyMesh;
                targetObjectMesh.UpdateJoints();
                targetObjectMesh.WakeUp();
            }
        }

        // Recalculate weighting values if the exponent changes
        if (m_InitialDistanceExponent != m_DistanceExponent.floatValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellyMesh targetObjectMesh = targetObject as JellyMesh;
                targetObjectMesh.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_InitialDrag != m_Drag.floatValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellyMesh targetObjectMesh = targetObject as JellyMesh;
                targetObjectMesh.InitMass();
                targetObjectMesh.WakeUp();
            }
        }

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

        if (m_InitialLockRotationX != m_LockRotationX.boolValue ||
            m_InitialLockRotationY != m_LockRotationY.boolValue ||
            m_InitialLockRotationZ != m_LockRotationZ.boolValue ||
            m_InitialCentralBodyKinematic != m_CentralBodyKinematic.boolValue)
        {
            foreach (UnityEngine.Object targetObject in targets)
            {
                JellyMesh targetObjectMesh = targetObject as JellyMesh;
                targetObjectMesh.UpdateRotationLock();
            }
        }
    }