Пример #1
0
        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new UnityEngine.TouchPhase();

            ins = (UnityEngine.TouchPhase)o;
            return(ins);
        }
Пример #2
0
        public void PushUnityEngineTouchPhase(RealStatePtr L, UnityEngine.TouchPhase val)
        {
            if (UnityEngineTouchPhase_TypeID == -1)
            {
                bool is_first;
                UnityEngineTouchPhase_TypeID = getTypeId(L, typeof(UnityEngine.TouchPhase), out is_first);

                if (UnityEngineTouchPhase_EnumRef == -1)
                {
                    Utils.LoadCSTable(L, typeof(UnityEngine.TouchPhase));
                    UnityEngineTouchPhase_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
                }
            }

            if (LuaAPI.xlua_tryget_cachedud(L, (int)val, UnityEngineTouchPhase_EnumRef) == 1)
            {
                return;
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, UnityEngineTouchPhase_TypeID);

            if (!CopyByValue.Pack(buff, 0, (int)val))
            {
                throw new Exception("pack fail fail for UnityEngine.TouchPhase ,value=" + val);
            }

            LuaAPI.lua_getref(L, UnityEngineTouchPhase_EnumRef);
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.xlua_rawseti(L, -2, (int)val);
            LuaAPI.lua_pop(L, 1);
        }
Пример #3
0
 public TouchInfo(ref UnityEngine.Touch touch, DefaultCameraMover cameraMover)
 {
     this.ScreenPos        = touch.position;
     this.fingerIdOffseted = touch.fingerId + 1;
     this.HitPos           = cameraMover.GetIntersectionPoint(touch.position);
     this.Phase            = touch.phase;
 }
Пример #4
0
        public static int FromUnityTouch(UnityEngine.TouchPhase uPhase)
        {
            switch (uPhase)
            {
            case UnityEngine.TouchPhase.Began: return(Down);

            case UnityEngine.TouchPhase.Moved:
            case UnityEngine.TouchPhase.Stationary: return(Stay);

            case UnityEngine.TouchPhase.Canceled:
            case UnityEngine.TouchPhase.Ended: return(Up);
            }
            return(None);
        }
Пример #5
0
        static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.TouchPhase instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.TouchPhase[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
Пример #6
0
        static StackObject *set_phase_13(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.TouchPhase value = (UnityEngine.TouchPhase) typeof(UnityEngine.TouchPhase).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            UnityEngine.Touch instance_of_this_method;
            instance_of_this_method = (UnityEngine.Touch) typeof(UnityEngine.Touch).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            instance_of_this_method.phase = value;

            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            return(__ret);
        }
Пример #7
0
        public void UpdateUnityEngineTouchPhase(RealStatePtr L, int index, UnityEngine.TouchPhase val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineTouchPhase_TypeID)
                {
                    throw new Exception("invalid userdata for UnityEngine.TouchPhase");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, (int)val))
                {
                    throw new Exception("pack fail for UnityEngine.TouchPhase ,value=" + val);
                }
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
Пример #8
0
        public void Get(RealStatePtr L, int index, out UnityEngine.TouchPhase val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineTouchPhase_TypeID)
                {
                    throw new Exception("invalid userdata for UnityEngine.TouchPhase");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                int    e;
                if (!CopyByValue.UnPack(buff, 0, out e))
                {
                    throw new Exception("unpack fail for UnityEngine.TouchPhase");
                }
                val = (UnityEngine.TouchPhase)e;
            }
            else
            {
                val = (UnityEngine.TouchPhase)objectCasters.GetCaster(typeof(UnityEngine.TouchPhase))(L, index, null);
            }
        }
Пример #9
0
    protected void HandleTouch()
    {
        int touchCountMax = this.touchInfos.Length;

        for (int i = 0; i < touchCountMax; ++i)
        {
            this.previousTouchInfos[i] = new TouchInfo();
        }

        int touchCount = UnityEngine.Mathf.Min(touchCountMax, UnityEngine.Input.touchCount);

        for (int i = 0; i < touchCount; ++i)
        {
            int sameFinger          = -1;
            UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i);
            for (int previousInputId = 0; previousInputId < touchCountMax; ++previousInputId)
            {
                if (this.touchInfos[previousInputId].SameFingerID(ref touch))
                {
                    sameFinger = previousInputId;
                }
            }

            if (sameFinger != -1)
            {
                this.previousTouchInfos[i] = this.touchInfos[sameFinger];
            }
            else
            {
                this.previousTouchInfos[i] = new TouchInfo();
            }
        }

        this.previousMouseTouchInfo = this.mouseTouchInfo;

        for (int i = 0; i < touchCount; ++i)
        {
            UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i);
            this.touchInfos[i] = new TouchInfo(ref touch, this);
        }

        UnityEngine.TouchPhase mouseTouchPhase = UnityEngine.Input.GetMouseButton(0) ? (UnityEngine.Input.GetMouseButtonDown(0) ? UnityEngine.TouchPhase.Began : UnityEngine.TouchPhase.Moved) : UnityEngine.TouchPhase.Ended;
        this.mouseTouchInfo = new TouchInfo()
        {
            ScreenPos = UnityEngine.Input.mousePosition,
            HitPos    = GetIntersectionPoint(UnityEngine.Input.mousePosition),
            Phase     = mouseTouchPhase
        };

        for (int i = touchCount; i < touchCountMax; ++i)
        {
            this.touchInfos[i] = new TouchInfo();
        }

        if (touchCount == 0 && this.mouseTouchInfo.Phase == UnityEngine.TouchPhase.Moved && this.TouchTranslation)
        {
            UnityEngine.Ray     ray            = this.usedCamera.ScreenPointToRay(this.mouseTouchInfo.ScreenPos);
            float               previousHeight = this.transform.position.y;
            UnityEngine.Vector3 nextPosition   = this.previousMouseTouchInfo.HitPos + ray.direction * (previousHeight / ray.direction.y);
            nextPosition.y          = previousHeight;
            this.transform.position = nextPosition;
        }

        if (touchCount == 1)
        {
            if (this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved &&
                this.previousTouchInfos[0].FingerId != -1 &&
                this.TouchTranslation)
            {
                UnityEngine.Ray     ray            = this.usedCamera.ScreenPointToRay(this.touchInfos[0].ScreenPos);
                float               previousHeight = this.transform.position.y;
                UnityEngine.Vector3 nextPosition   = this.previousTouchInfos[0].HitPos + ray.direction * (previousHeight / ray.direction.y);
                nextPosition.y          = previousHeight;
                this.transform.position = nextPosition;
            }
        }

        if (touchCount == 2)
        {
            if ((this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved || this.touchInfos[1].Phase == UnityEngine.TouchPhase.Moved) &&
                (this.previousTouchInfos[0].FingerId != -1 && this.previousTouchInfos[1].FingerId != -1))
            {
                UnityEngine.Vector3 previousDifHitPos = this.previousTouchInfos[0].HitPos - this.previousTouchInfos[1].HitPos;
                float previousDistance01      = UnityEngine.Vector3.Magnitude(previousDifHitPos);
                UnityEngine.Vector3 difHitPos = this.touchInfos[0].HitPos - this.touchInfos[1].HitPos;
                float currentDistance01       = UnityEngine.Vector3.Magnitude(difHitPos);

                UnityEngine.Vector3 nextPosition      = this.transform.position;
                UnityEngine.Vector2 middleScreenPoint = (this.touchInfos[0].ScreenPos + this.touchInfos[1].ScreenPos) * 0.5f;
                UnityEngine.Ray     ray = this.usedCamera.ScreenPointToRay(middleScreenPoint);
                nextPosition -= ray.direction * (previousDistance01 - currentDistance01);
                if (this.TouchZoom)
                {
                    this.transform.position = nextPosition;
                }

                float deltaAngleAroundY = 0;
                {
                    UnityEngine.Vector2 difScreenPos         = this.touchInfos[0].ScreenPos - this.touchInfos[1].ScreenPos;
                    UnityEngine.Vector2 previousDifScreenPos = this.previousTouchInfos[0].ScreenPos - this.previousTouchInfos[1].ScreenPos;
                    float currentAngle  = UnityEngine.Mathf.Atan2(difScreenPos.y, difScreenPos.x);
                    float previousAngle = UnityEngine.Mathf.Atan2(previousDifScreenPos.y, previousDifScreenPos.x);
                    deltaAngleAroundY += (currentAngle - previousAngle) * 180f / UnityEngine.Mathf.PI;
                }

                float deltaAngleX = 0;
                UnityEngine.Vector2 previousMiddlePoint = (this.previousTouchInfos[0].ScreenPos + this.previousTouchInfos[1].ScreenPos) * 0.5f;

                {
                    UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint;
                    modifiedPreviousMiddlePoint.x = middleScreenPoint.x;
                    UnityEngine.Ray previousRay    = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint);
                    float           absDeltaAngleX = UnityEngine.Vector3.Angle(previousRay.direction, ray.direction);
                    deltaAngleX += (previousMiddlePoint.y < middleScreenPoint.y) ? absDeltaAngleX : -absDeltaAngleX;
                }

                float deltaAngleY = 0;
                {
                    //UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint;
                    //UnityEngine.Ray previousRay = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint);
                    //UnityEngine.Vector3 projectedPreviousRayDirection = previousRay.direction;
                    //projectedPreviousRayDirection.y = 0;
                    //UnityEngine.Vector3 projectedRayDirection = previousRay.direction;
                    //projectedRayDirection.y = 0;
                    //float absDeltaAngleY = UnityEngine.Vector3.Angle(this.transform.forward, previousRay.direction);

                    //deltaAngleY += (previousMiddlePoint.x < middleScreenPoint.x) ? absDeltaAngleY : -absDeltaAngleY;
                }

                if (deltaAngleAroundY != 0 ||
                    deltaAngleX != 0 ||
                    deltaAngleY != 0)
                {
                    UnityEngine.Vector3 rotateAround    = GetIntersectionPoint(middleScreenPoint);
                    UnityEngine.Vector3 nextEulerAngles = this.transform.eulerAngles;
                    nextEulerAngles.y         += deltaAngleAroundY;
                    this.transform.eulerAngles = nextEulerAngles;
                    UnityEngine.Ray nextRay          = this.usedCamera.ScreenPointToRay(middleScreenPoint);
                    float           originalDistance = UnityEngine.Vector3.Magnitude(rotateAround - this.transform.position);
                    this.transform.position = rotateAround - originalDistance * nextRay.direction;

                    nextEulerAngles.x         += this.TouchRotationX ? deltaAngleX : 0;
                    nextEulerAngles.y         += this.TouchRotationY ? deltaAngleY : 0;
                    this.transform.eulerAngles = nextEulerAngles;
                }
            }
        }

        for (int i = 0; i < touchCount; ++i)
        {
            UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i);
            this.touchInfos[i] = new TouchInfo(ref touch, this);
        }

        this.mouseTouchInfo = new TouchInfo()
        {
            ScreenPos = UnityEngine.Input.mousePosition,
            HitPos    = GetIntersectionPoint(UnityEngine.Input.mousePosition),
            Phase     = mouseTouchPhase
        };
    }