Ejemplo n.º 1
0
        static StackObject *SetColor_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.Color @value = (UnityEngine.Color) typeof(UnityEngine.Color).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            UnityEngine.Material instance_of_this_method = (UnityEngine.Material) typeof(UnityEngine.Material).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.SetColor(@name, @value);

            return(__ret);
        }
Ejemplo n.º 2
0
 public override void Set(string propertyName, Color value)
 {
     material.SetColor(propertyName, value);
 }
    void FixedUpdate()
    {
        int layerMask = (int)Project.LayerFlag.TDefault;

        UnityEngine.RaycastHit raycastHit;
        var hit = UnityEngine.Physics.SphereCast(
            new UnityEngine.Ray(_root.transform.position, new UnityEngine.Vector3(0.0f, -1.0f, 0.0f)),
            0.5f,
            out raycastHit,
            targetHeight,
            layerMask
            );

        //force
#if true
        {
            var targetVerticalVelocity = 0.0f;
            if (hit)
            {
                targetVerticalVelocity = (targetHeight - raycastHit.distance) * 2.0f;
            }

            var targetVelocity = new UnityEngine.Vector3(
                2.0f * UnityEngine.Input.GetAxis("Horizontal"),
                targetVerticalVelocity, //0.0f, //UnityEngine.Input.GetAxis("Dolly_Alt"),
                2.0f * UnityEngine.Input.GetAxis("Vertical")
                );

            var deltaVelocity = targetVelocity - _rigidbody.velocity;
            var acceleration  = deltaVelocity / UnityEngine.Time.fixedDeltaTime;
            if (false == hit)
            {
                acceleration.y = 0.0f;
                _material.SetColor("_Color", UnityEngine.Color.red);
            }
            else
            {
                _material.SetColor("_Color", UnityEngine.Color.blue);
            }

            _rigidbody.AddForce(acceleration, UnityEngine.ForceMode.Acceleration);
        }
#endif
#if true
        //torque
        //https://answers.unity.com/questions/171859/figuring-out-the-correct-amount-of-torque-to-apply.html
        {
            var fromToRot = UnityEngine.Quaternion.FromToRotation(_root.transform.up, UnityEngine.Vector3.up).eulerAngles;
            var rotEular  = OrientTorque(fromToRot);

            var targetRot = rotEular * UnityEngine.Mathf.Deg2Rad; // * 0.5f;
            targetRot.y += UnityEngine.Input.GetAxis("Horizontal_Alt");
            var deltaRot = targetRot - _rigidbody.angularVelocity;

            var acceleration = deltaRot / UnityEngine.Time.fixedDeltaTime;
            _rigidbody.AddTorque(acceleration, UnityEngine.ForceMode.Acceleration);

            //Bootstrap.Log("up " + _root.transform.up.ToString("F4"));
            //Bootstrap.Log("fromToRot deg " + fromToRot.ToString("F4"));
            //Bootstrap.Log("targetRot " + targetRot.ToString("F4"));
            //Bootstrap.Log("angularVelocity " + _rigidbody.angularVelocity.ToString("F4"));
            //Bootstrap.Log("acceleration " + acceleration.ToString("F4"));
        }
#endif
    }