static bool Vector4_Scale__Vector4(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.Vector4 arg0    = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Vector4 argThis = (UnityEngine.Vector4)vc.csObj;        argThis.Scale(arg0);
            JSMgr.changeJSObj(vc.jsObjID, argThis);
        }

        return(true);
    }
Пример #2
0
 static public int Scale(IntPtr l)
 {
     try{
         UnityEngine.Vector4 self = (UnityEngine.Vector4)checkSelf(l);
         UnityEngine.Vector4 a1;
         checkType(l, 2, out a1);
         self.Scale(a1);
         setBack(l, self);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #3
0
 static int Scale(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Vector4 obj  = (UnityEngine.Vector4)ToLua.CheckObject(L, 1, typeof(UnityEngine.Vector4));
         UnityEngine.Vector4 arg0 = (UnityEngine.Vector4)ToLua.CheckObject(L, 2, typeof(UnityEngine.Vector4));
         obj.Scale(arg0);
         ToLua.SetBack(L, 1, obj);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #4
0
        public static void TestScaleBy()
        {
            const float floatScale = 4.8f;
            const float floatStart = 1.2f;
            float floatVal = floatStart;
            Ref<float> floatRef = new Ref<float>(
            () => floatVal,
            t => floatVal = t
            );

            const double doubleScale = 3.2;
            const double doubleStart = 9.2;
            double doubleVal = doubleStart;
            Ref<double> doubleRef = new Ref<double>(
            () => doubleVal,
            t => doubleVal = t
            );

            Vector2 vec2Scale = new Vector2(9.5f, 2.0f);
            Vector2 vec2Start = new Vector2(4.0f, 5.0f);
            Vector2 vec2Val = vec2Start;
            Ref<Vector2> vec2Ref = new Ref<Vector2>(
            () => vec2Val,
            t =>  vec2Val = t
            );

            Vector3 vec3Scale = new Vector3(4.0f, 19.0f, 2.0f);
            Vector3 vec3Start = new Vector3(92.0f, 0.5f, 34.0f);
            Vector3 vec3Val = vec3Start;
            Ref<Vector3> vec3Ref = new Ref<Vector3>(
            () =>  vec3Val,
            t => vec3Val = t
            );

            Vector4 vec4Scale = new Vector4(92.0f, 0.5f, 14.0f, 7.0f);
            Vector4 vec4Start = new Vector4(0.4f, 10.0f, 3.0f, 82.0f);
            Vector4 vec4Val = vec4Start;
            Ref<Vector4> vec4Ref = new Ref<Vector4>(
            () => vec4Val,
            t => vec4Val = t
            );

            CommandQueue queue = new CommandQueue();
            queue.Enqueue(
            Commands.Repeat(2,
                Commands.Sequence(
                    Commands.Parallel(
                        Commands.ScaleBy(floatRef, floatScale, 1.0),
                        Commands.ScaleBy(doubleRef, doubleScale, 1.0),
                        Commands.ScaleBy(vec2Ref, vec2Scale, 1.0),
                        Commands.ScaleBy(vec3Ref, vec3Scale, 1.0),
                        Commands.ScaleBy(vec4Ref, vec4Scale, 1.0)
                    ),
                    Commands.WaitForFrames(1)
                )
            )
            );

            queue.Update(0.2f);

            Vector2 vec2ExpectedScale = vec2Scale;
            Vector3 vec3ExpectedScale = vec3Scale;
            Vector4 vec4ExpectedScale = vec4Scale;
            vec2ExpectedScale.Scale(new Vector2(0.2f, 0.2f));
            vec3ExpectedScale.Scale(new Vector3(0.2f, 0.2f, 0.2f));
            vec4ExpectedScale.Scale(new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            vec2ExpectedScale += new Vector2(0.8f, 0.8f);
            vec3ExpectedScale += new Vector3(0.8f, 0.8f, 0.8f);
            vec4ExpectedScale += new Vector4(0.8f, 0.8f, 0.8f, 0.8f);
            vec2ExpectedScale.Scale(vec2Start);
            vec3ExpectedScale.Scale(vec3Start);
            vec4ExpectedScale.Scale(vec4Start);
            AreEqual(floatVal, floatStart * (0.8f + floatScale * 0.2f), 0.001f);
            AreEqual(doubleVal, doubleStart * (0.8 + doubleScale * 0.2), 0.001f);
            AreEqual(vec2Val, vec2ExpectedScale, 0.001f);
            AreEqual(vec3Val, vec3ExpectedScale, 0.001f);
            AreEqual(vec4Val, vec4ExpectedScale, 0.001f);

            queue.Update(0.8);
            vec2ExpectedScale = vec2Scale;
            vec3ExpectedScale = vec3Scale;
            vec4ExpectedScale = vec4Scale;
            vec2ExpectedScale.Scale(vec2Start);
            vec3ExpectedScale.Scale(vec3Start);
            vec4ExpectedScale.Scale(vec4Start);
            AreEqual(floatVal,  floatStart * floatScale, 0.001f);
            AreEqual(doubleVal,  doubleStart * doubleScale, 0.001f);
            AreEqual(vec2Val, vec2ExpectedScale, 0.001f);
            AreEqual(vec3Val, vec3ExpectedScale, 0.001f);
            AreEqual(vec4Val, vec4ExpectedScale, 0.001f);

            floatVal = floatStart;
            doubleVal = doubleStart;
            vec2Val = vec2Start;
            vec3Val = vec3Start;
            vec4Val = vec4Start;
            queue.Update(0.0);
            queue.Update(0.5);
            vec2ExpectedScale = vec2Scale;
            vec3ExpectedScale = vec3Scale;
            vec4ExpectedScale = vec4Scale;
            vec2ExpectedScale.Scale(new Vector2(0.5f, 0.5f));
            vec3ExpectedScale.Scale(new Vector3(0.5f, 0.5f, 0.5f));
            vec4ExpectedScale.Scale(new Vector4(0.5f, 0.5f, 0.5f, 0.5f));
            vec2ExpectedScale += new Vector2(0.5f, 0.5f);
            vec3ExpectedScale += new Vector3(0.5f, 0.5f, 0.5f);
            vec4ExpectedScale += new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
            vec2ExpectedScale.Scale(vec2Start);
            vec3ExpectedScale.Scale(vec3Start);
            vec4ExpectedScale.Scale(vec4Start);
            AreEqual(floatVal, floatStart * (0.5f + floatScale * 0.5f), 0.001f);
            AreEqual(doubleVal, doubleStart * (0.5 + doubleScale * 0.5), 0.001f);
            AreEqual(vec2Val, vec2ExpectedScale, 0.001f);
            AreEqual(vec3Val, vec3ExpectedScale, 0.001f);
            AreEqual(vec4Val, vec4ExpectedScale, 0.001f);
        }