Пример #1
0
 void Start()
 {
     input       = FindObjectOfType <BaseInputModule>();
     _selectable = GetComponent <Selectable>();
     PortStein.SetActive(true);
     BackPort.SetActive(false);
 }
Пример #2
0
        public void AddUIInputModule()
        {
            if (TInputSystemUIInputModule == null)
            {
                ExplorerCore.LogWarning("Unable to find UI Input Module Type, Input will not work!");
                return;
            }

            var assetType = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionAsset");

            m_newInputModule = RuntimeProvider.Instance.AddComponent <BaseInputModule>(UIManager.CanvasRoot, TInputSystemUIInputModule);
            var asset = RuntimeProvider.Instance.CreateScriptable(assetType);

            inputExtensions = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionSetupExtensions");

            var addMap = inputExtensions.GetMethod("AddActionMap", new Type[] { assetType, typeof(string) });
            var map    = addMap.Invoke(null, new object[] { asset, "UI" });

            CreateAction(map, "point", new[] { "<Mouse>/position" }, "point");
            CreateAction(map, "click", new[] { "<Mouse>/leftButton" }, "leftClick");
            CreateAction(map, "rightClick", new[] { "<Mouse>/rightButton" }, "rightClick");
            CreateAction(map, "scrollWheel", new[] { "<Mouse>/scroll" }, "scrollWheel");

            UI_Enable = map.GetType().GetMethod("Enable");
            UI_Enable.Invoke(map, new object[0]);
            UI_ActionMap = map;
        }
Пример #3
0
    void Release(BaseInputModule module)
    {
        rbody.useGravity = true;
        if (rbody)
        {
            rbody.isKinematic = false;

            Vector3 force = Vector3.zero;
            for (int i = 1; i < savedPositions.Count; i++)
            {
                Vector3 delta = savedPositions[i] - savedPositions[i - 1];

                //Ignore spurious changes (sudden jumps caused by external scripts or states)
                if (delta.magnitude > 1f)
                {
                    continue;
                }

                //force += delta;
            }
            transform.Translate(Vector3.down * 10f * Time.deltaTime, Space.World);
            rbody.AddForce(force, ForceMode.Impulse);
            //rbody.velocity = transform.forward * 10f;
            savedPositions.Clear();
        }

        offset             = Vector3.zero;
        grabbingModule     = null;
        collider.isTrigger = false;
        rbody.useGravity   = false;
        rbody.isKinematic  = true;
    }
        void Update()
        {
            if (raycaster != null)
            {
                groundMarker.gameObject.SetActive(teleporter.IsReady());

                // If this object is still "hit" by the raycast source, update ground marker position and orientation
                raycastResult.Clear();
                BaseInputModule bim = EventSystem.current.currentInputModule;
                if (bim is GazeInputModule)
                {
                    raycastResult = ((GazeInputModule)bim).GetPointerData().pointerCurrentRaycast;
                }

                if (raycastResult.gameObject != null)
                {
                    Transform hit = raycastResult.gameObject.transform;
                    if ((hit.transform == this.transform) || (hit.parent == this.transform))
                    {
                        float yaw = raycaster.transform.rotation.eulerAngles.y;
                        groundMarker.position      = raycastResult.worldPosition;
                        groundMarker.localRotation = Quaternion.Euler(0, yaw, 0);
                    }
                }
            }
            else
            {
                groundMarker.gameObject.SetActive(false);
            }
        }
Пример #5
0
 private void ToggleHold(BaseInputModule module)
 {
     if (holdingModule)
     {
         //Release
         if (rbody)
         {
             //rbody.isKinematic = false;
         }
         holdingModule = null;
         //collider.isTrigger = false;
         if (OnToggleHold != null)
         {
             OnToggleHold(false);
         }
     }
     else
     {
         //Bind
         holdingModule = module;
         //collider.isTrigger = true;
         if (rbody)
         {
             //rbody.isKinematic = true;
         }
         if (OnToggleHold != null)
         {
             OnToggleHold(true);
         }
     }
 }
        // Token: 0x06002D3F RID: 11583 RVA: 0x0013A7A8 File Offset: 0x001389A8
        protected PlayerPointerEventData GetTouchPointerEventData(int playerId, int touchDeviceIndex, Touch input, out bool pressed, out bool released)
        {
            PlayerPointerEventData playerPointerEventData;
            bool pointerData = this.GetPointerData(playerId, touchDeviceIndex, input.fingerId, out playerPointerEventData, true, PointerEventType.Touch);

            playerPointerEventData.Reset();
            pressed  = (pointerData || input.phase == TouchPhase.Began);
            released = (input.phase == TouchPhase.Canceled || input.phase == TouchPhase.Ended);
            if (pointerData)
            {
                playerPointerEventData.position = input.position;
            }
            if (pressed)
            {
                playerPointerEventData.delta = Vector2.zero;
            }
            else
            {
                playerPointerEventData.delta = input.position - playerPointerEventData.position;
            }
            playerPointerEventData.position = input.position;
            playerPointerEventData.button   = PointerEventData.InputButton.Left;
            base.eventSystem.RaycastAll(playerPointerEventData, this.m_RaycastResultCache);
            RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache);

            playerPointerEventData.pointerCurrentRaycast = pointerCurrentRaycast;
            this.m_RaycastResultCache.Clear();
            return(playerPointerEventData);
        }
Пример #7
0
 void Start()
 {
     input       = FindObjectOfType <BaseInputModule>();
     _selectable = GetComponent <Selectable>();
     HauptPanel.SetActive(true);
     QuizPanel.SetActive(false);
 }
Пример #8
0
    void Release(BaseInputModule module)
    {
        Debug.Log("Got Release" + gameObject.name);
        if (rbody)
        {
            rbody.isKinematic = false;

            Vector3 force = Vector3.zero;
            for (int i = 1; i < savedPositions.Count; i++)
            {
                Vector3 delta = savedPositions[i] - savedPositions[i - 1];

                //Ignore spurious changes (sudden jumps caused by external scripts or states)
                if (delta.magnitude > 1f)
                {
                    continue;
                }

                force += delta;
            }

            rbody.AddForce(force, ForceMode.Impulse);
            savedPositions.Clear();
        }

        offset             = Vector3.zero;
        grabbingModule     = null;
        collider.isTrigger = false;
    }
    protected virtual PointerEventData GetFalconEventData()
    {
        PointerEventData pointerEventData;
        bool             pointerData = base.GetPointerData(-1, out pointerEventData, true);

        pointerEventData.Reset();
        if (pointerData)
        {
            pointerEventData.position = GameObject.Find("CursorCamera").GetComponent <Camera>().WorldToScreenPoint(base.gameObject.transform.position);
        }
        Vector2 vector = GameObject.Find("CursorCamera").GetComponent <Camera>().WorldToScreenPoint(base.gameObject.transform.position);

        pointerEventData.delta    = vector - pointerEventData.position;
        pointerEventData.position = vector;
        RaycastHit raycastHit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(vector), out raycastHit))
        {
            pointerEventData.pointerCurrentRaycast = new RaycastResult
            {
                gameObject = raycastHit.transform.gameObject
            };
        }
        ExecuteEvents.ExecuteHierarchy <IPointerDownHandler>(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, ExecuteEvents.pointerDownHandler);
        base.eventSystem.RaycastAll(pointerEventData, this.m_RaycastResultCache);
        RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache);

        pointerEventData.pointerCurrentRaycast = pointerCurrentRaycast;
        pointerEventData.button = PointerEventData.InputButton.Left;
        this.m_RaycastResultCache.Clear();
        return(pointerEventData);
    }
        protected PlayerPointerEventData GetTouchPointerEventData(
            int playerId,
            int touchDeviceIndex,
            Touch input,
            out bool pressed,
            out bool released)
        {
            PlayerPointerEventData data;
            bool pointerData = this.GetPointerData(playerId, touchDeviceIndex, ((Touch) ref input).get_fingerId(), out data, true, PointerEventType.Touch);

            ((AbstractEventData)data).Reset();
            pressed  = pointerData || ((Touch) ref input).get_phase() == 0;
            released = ((Touch) ref input).get_phase() == 4 || ((Touch) ref input).get_phase() == 3;
            if (pointerData)
            {
                data.set_position(((Touch) ref input).get_position());
            }
            if (pressed)
            {
                data.set_delta(Vector2.get_zero());
            }
            else
            {
                data.set_delta(Vector2.op_Subtraction(((Touch) ref input).get_position(), data.get_position()));
            }
            data.set_position(((Touch) ref input).get_position());
            data.set_button((PointerEventData.InputButton) 0);
            this.get_eventSystem().RaycastAll((PointerEventData)data, (List <RaycastResult>) this.m_RaycastResultCache);
            RaycastResult firstRaycast = BaseInputModule.FindFirstRaycast((List <RaycastResult>) this.m_RaycastResultCache);

            data.set_pointerCurrentRaycast(firstRaycast);
            ((List <RaycastResult>) this.m_RaycastResultCache).Clear();
            return(data);
        }
Пример #11
0
        private PointerEventData GetMousePointerEvent(int index)
        {
            int num = new int[3] {
                -1, -2, -3
            }[index];
            bool             mouseButtonDown = Input.GetMouseButtonDown(num);
            PointerEventData pointerEventData;
            bool             pointerData = this.GetPointerData(num, ref pointerEventData, true);

            ((AbstractEventData)pointerEventData).Reset();
            if (pointerData)
            {
                pointerEventData.set_position(Vector2.op_Implicit(Input.get_mousePosition()));
            }
            Vector2 vector2 = Vector2.op_Implicit(Input.get_mousePosition());

            pointerEventData.set_delta(Vector2.op_Subtraction(vector2, pointerEventData.get_position()));
            pointerEventData.set_position(vector2);
            pointerEventData.set_scrollDelta(Input.get_mouseScrollDelta());
            ((BaseInputModule)this).get_eventSystem().RaycastAll(pointerEventData, (List <RaycastResult>)((BaseInputModule)this).m_RaycastResultCache);
            RaycastResult firstRaycast = BaseInputModule.FindFirstRaycast((List <RaycastResult>)((BaseInputModule)this).m_RaycastResultCache);

            pointerEventData.set_pointerCurrentRaycast(firstRaycast);
            if (mouseButtonDown)
            {
                pointerEventData.set_delta(Vector2.get_zero());
            }
            return(pointerEventData);
        }
 void Start()
 {
     //Anfang sollen Atome nicht angezeigt werden, Acitve = false, da erst nach start gedrückt wurde
     input       = FindObjectOfType <BaseInputModule>();
     _selectable = GetComponent <Selectable>();
     atom1.SetActive(false);
     atom2.SetActive(false);
 }
Пример #13
0
    //public GameObject componentNameM;
    //public GameObject componentNameR;
    //public GameObject componentNameS;
    //public GameObject componentNameF;
    //长按事件
    //void OnFingerLongPress(int fingerIndex, Vector2 fingerPos){
    //	Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    //	RaycastHit hitInfo;
    //	if (Physics.Raycast (ray, out hitInfo)) {

    //		string name = hitInfo.transform.name;
    //		if (name.Contains ("[")) {
    //			int startIndex = name.IndexOf ("[");
    //			int endIndex = name.IndexOf ("]");
    //			string ww = name.Substring (startIndex+1,endIndex-startIndex-1);
    //			ComponentWebGL.instance.Dic [ww].SetActive (false);
    //		}
    //	}

    //}
    //手指按下固定
    void OnFingerTap(int fingerIndex, Vector2 fingerPos, int tapCount)
    {
        ////屏蔽UI层的点击
#if (IPHONE || ANDROID || WEBGL)
        if (BaseInputModule.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
        if (EventSystem.current.IsPointerOverGameObject())
#endif
        { return; }
        // chejuCtrl.touch = true;
        string preSelectedObjectName    = "";
        string preSelectedObjectMatName = "";

        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出到点击坐标的射线
        RaycastHit hitInfo;

        //if (Physics.Raycast(ray, out hitInfo) && !chejuCtrl.ceJuMode && !UICamera.isOverUI)
        //{
        //    if (hitInfo.collider)
        //    {
        //        objname = hitInfo.transform.name;
        //    if (scene == SceneNmae.Vr)
        //    {
        //    SelectName.text = objname;
        //    }

        //        //回复原对象的材质
        //        if (PreSelectedObject != null)
        //        {
        //            PreSelectedObject.GetComponentInChildren<MeshRenderer>().material = PreSelectedObjectMat;
        //            preSelectedObjectName = PreSelectedObject.name;
        //            preSelectedObjectMatName = PreSelectedObjectMat.name;
        //        }

        //        //远程同步
        //        //objname = "远程调用1";
        //        if (IsLocal == "0")
        //        {
        //            object[] para = new object[4];
        //            para[0] = hitInfo.transform.name;
        //            para[1] = mSelectedMat.name;
        //            para[2] = preSelectedObjectName;
        //            para[3] = preSelectedObjectMatName;

        //        }

        //        PreSelectedObject = hitInfo.transform;
        //        PreSelectedObjectMat = hitInfo.transform.GetComponentInChildren<MeshRenderer>().material;

        //        selectedObj = hitInfo.transform;
        //        //当选择某个对象时,要向显隐模块和进度模块传递数据
        //        jingDu.selectedObj = selectedObj;
        //        xianYing.selectObj = selectedObj;
        //        hitInfo.transform.GetComponentInChildren<MeshRenderer>().material = mSelectedMat;

        //    }
        //}
    }
Пример #14
0
 void Start()
 {
     //Panels werden defautlt auf false gesetzt, damit diese nicht angezeigt werden
     input       = FindObjectOfType <BaseInputModule>();
     _selectable = GetComponent <Selectable>();
     dummyPanel1.SetActive(false);
     dummyPanel2.SetActive(false);
     AktiverPanel.SetActive(false);
 }
Пример #15
0
 /// <summary>
 /// Check component by name
 /// </summary>
 /// <param name="_componentName"></param>
 private BaseInputModule CheckInputModule(BaseInputModule _module, Type _componentName)
 {
     if (_module == null)
     {
         var comp = (BaseInputModule)GameObject.Find("EventSystem").gameObject.GetComponent(_componentName);
         _module = comp != null ? comp : (BaseInputModule)this.gameObject.AddComponent(_componentName);
     }
     return(_module);
 }
Пример #16
0
    private FixedJoint AddFixedJoint(BaseInputModule module)
    {
        FixedJoint fx = module.gameObject.AddComponent <FixedJoint>();

        // fx.breakForce = 20000;
        // fx.breakTorque = 20000;
        fx.enablePreprocessing = false;
        return(fx);
    }
Пример #17
0
 static void EnsureDelegate(EventSystem evSys)
 {
     if (registeredInputModule != evSys.currentInputModule)
     {
         var method = (evSys.currentInputModule as StandaloneInputModule).GetType().GetMethod("GetCurrentFocusedGameObject", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
         GetCurrentFocusedGameObject = (System.Func <GameObject>)System.Delegate.CreateDelegate(typeof(System.Func <GameObject>), evSys.currentInputModule, method);
         registeredInputModule       = evSys.currentInputModule;
     }
 }
Пример #18
0
        // Token: 0x0600229E RID: 8862 RVA: 0x000A3CC8 File Offset: 0x000A1EC8
        public bool InputModuleIsAllowed(BaseInputModule inputModule)
        {
            if (this.allowAllEventSystems)
            {
                return(true);
            }
            EventSystem eventSystem = this.eventSystem;

            return(eventSystem && inputModule == eventSystem.currentInputModule);
        }
Пример #19
0
 void Start()
 {
     input       = FindObjectOfType <BaseInputModule>();
     _selectable = GetComponent <Selectable>();
     MainPanel.SetActive(true);
     Weg1.SetActive(false);
     Weg2.SetActive(false);
     Weg3.SetActive(false);
     Weg4.SetActive(false);
 }
Пример #20
0
 protected override void Start()
 {
     base.Start();
     Input            = this;
     mBaseInputModule = GetComponent <BaseInputModule>();
     mBaseInputModule.inputOverride = this;
     mTuioInput  = GetComponent <TuioInput>();
     mMouseInput = GetComponent <MouseInput>();
     mWMInput    = GetComponent <WM_Input>();
 }
Пример #21
0
 static void Postfix(BaseInputModule __instance)
 {
     // triggered at every """menu transition"""
     if (__instance is VRInputModule)
     {
         // Will initialize m_fVanillaStockRumbleStrength once at startup
         // && will refresh m_fRumbleStrength at every "menu transition" => will catch actualized RumbleMod's strengthUI
         FasterScrollController.InitializeRumbleStrengthStuff(__instance as VRInputModule); // only effective once at startup
     }
 }
Пример #22
0
        protected virtual PointerEventData GetAimerPointerEventData()
        {
            GetPointerData(-2, out var data, create: true);
            data.Reset();
            data.position = new Vector2((float)Screen.width * 0.5f, (float)Screen.height * 0.5f) + aimerOffset;
            base.eventSystem.RaycastAll(data, m_RaycastResultCache);
            RaycastResult raycastResult2 = (data.pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(m_RaycastResultCache));

            m_RaycastResultCache.Clear();
            return(data);
        }
Пример #23
0
    void Hold(BaseInputModule module)
    {
        this.transform.position = grabbingModule.transform.position + grabbingModule.transform.rotation * offset;
        this.transform.rotation = grabbingModule.transform.rotation * rotOffset;

        savedPositions.Add(transform.position);
        if (savedPositions.Count > savedPosCount)
        {
            savedPositions.RemoveAt(savedPosCount - 1);
        }
    }
Пример #24
0
        /// <summary>
        /// マウスの入力状態を更新する
        /// </summary>
        void UpdateMouseState()
        {
            // 左ボタンのイベント情報
            PointerEventData eventData1;
            bool             created = _mouseState.GetEventData(ButtonId.Left, out eventData1);

            eventData1.Reset();

            Vector2 mousePosition = this.input.mousePosition;

            if (created)
            {
                eventData1.position = this.input.mousePosition;
            }

            if (Cursor.lockState == CursorLockMode.Locked)
            {
                eventData1.delta    = Vector2.zero;
                eventData1.position = new Vector2(-1f, -1f);
            }
            else
            {
                eventData1.delta    = mousePosition - eventData1.position;
                eventData1.position = mousePosition;
            }

            eventData1.button      = PointerEventData.InputButton.Left;
            eventData1.scrollDelta = base.input.mouseScrollDelta;
            base.eventSystem.RaycastAll(eventData1, base.m_RaycastResultCache);
            RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(base.m_RaycastResultCache);

            eventData1.pointerCurrentRaycast = pointerCurrentRaycast;
            base.m_RaycastResultCache.Clear();

            // 右ボタンのイベント情報
            PointerEventData eventData2;

            _mouseState.GetEventData(ButtonId.Right, out eventData2);
            CopyEventData(eventData1, eventData2);
            eventData2.button = PointerEventData.InputButton.Right;

            // 中ボタンのイベント情報
            PointerEventData eventData3;

            _mouseState.GetEventData(ButtonId.Middle, out eventData3);
            CopyEventData(eventData1, eventData3);
            eventData3.button = PointerEventData.InputButton.Middle;

            // ボタンの状態をチェックし、イベント情報に反映
            _mouseState.SetButtonState(ButtonId.Left, CheckMouseButtonState(0));
            _mouseState.SetButtonState(ButtonId.Right, CheckMouseButtonState(1));
            _mouseState.SetButtonState(ButtonId.Middle, CheckMouseButtonState(2));
        }
Пример #25
0
    /// <summary>
    /// Casts the ray from gaze.
    /// </summary>
    private void CastRayFromGaze()
    {
        if (this.pointerData == null)
        {
            this.pointerData = new PointerEventData(this.eventSystem);
        }

        this.pointerData.Reset();
        this.pointerData.position = new Vector2(this.gazePoint.x * Screen.width, this.gazePoint.y * Screen.height);
        this.eventSystem.RaycastAll(this.pointerData, this.m_RaycastResultCache);

        this.pointerData.pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache);
        this.m_RaycastResultCache.Clear();
    }
        protected override PointerInputModule.MouseState GetMousePointerEventData(int id)
        {
            PointerEventData pointerEventData;
            var pointerData = GetPointerData(-1, out pointerEventData, true);

            pointerEventData.Reset();
            if (pointerData)
            {
                pointerEventData.position = Input.mousePosition;
            }
            Vector2 vector = Input.mousePosition;

            if (Cursor.lockState == CursorLockMode.Locked)
            {
                pointerEventData.position = -Vector2.one;
                pointerEventData.delta    = Vector2.zero;
            }
            else
            {
                pointerEventData.delta    = vector - pointerEventData.position;
                pointerEventData.position = vector;
            }
            pointerEventData.scrollDelta = Input.mouseScrollDelta;
            pointerEventData.button      = PointerEventData.InputButton.Left;
            base.eventSystem.RaycastAll(pointerEventData, m_RaycastResultCache);
            RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(m_RaycastResultCache);

            pointerEventData.pointerCurrentRaycast = pointerCurrentRaycast;
            m_RaycastResultCache.Clear();

            _mouseState.SetButtonState(PointerEventData.InputButton.Left, PointerInputModule.StateForMouseButton(0), pointerEventData);

            if (_useRightMouseButton)
            {
                PointerEventData pointerEventData2;
                GetPointerData(-2, out pointerEventData2, true);
                CopyFromTo(pointerEventData, pointerEventData2);
                pointerEventData2.button = PointerEventData.InputButton.Right;
                _mouseState.SetButtonState(PointerEventData.InputButton.Right, PointerInputModule.StateForMouseButton(1), pointerEventData2);
            }
            if (_useMiddleMouseButton)
            {
                PointerEventData pointerEventData3;
                GetPointerData(-3, out pointerEventData3, true);
                CopyFromTo(pointerEventData, pointerEventData3);
                pointerEventData3.button = PointerEventData.InputButton.Middle;
                _mouseState.SetButtonState(PointerEventData.InputButton.Middle, PointerInputModule.StateForMouseButton(2), pointerEventData3);
            }
            return(_mouseState);
        }
Пример #27
0
 private void TryHold(BaseInputModule module, ButtonType b)
 {
     //Only try to hold object if it's within the bounds of the collider.
     //If the object is already being held, ignore this event call.
     if (collider.bounds.Contains(module.transform.position) && button == b &&
         (holdingModule == null || holdingModule == module))
     {
         //Check for a Holder if one is expected.
         if (!expectHolder || (expectHolder && module.GetComponent <Holder>() != null &&
                               module.GetComponent <Holder>().isActiveAndEnabled))
         {
             ToggleHold(module);
         }
     }
 }
Пример #28
0
        protected override MouseState GetMousePointerEventData(int id)
        {
            PointerEventData pointerEventData;
            bool             pointerData = this.GetPointerData(-1, out pointerEventData, true);

            pointerEventData.Reset();

            // use pointer position instead of mouse position
            Vector2 position;

            if (DpnManager.DPVRPointer)
            {
                position = DpnPointerManager.Pointer != null?DpnPointerManager.Pointer.GetScreenPosition() : new Vector2(-1, -1);
            }
            else
            {
                position = Input.mousePosition;
            }

            position.x = Mathf.Round(position.x);
            position.y = Mathf.Round(position.y);

            pointerEventData.delta = position - pointerEventData.position;

            pointerEventData.position    = position;
            pointerEventData.scrollDelta = Input.mouseScrollDelta;
            pointerEventData.button      = PointerEventData.InputButton.Left;
            base.eventSystem.RaycastAll(pointerEventData, this.m_RaycastResultCache);
            RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache);

            pointerEventData.pointerCurrentRaycast = pointerCurrentRaycast;
            this.m_RaycastResultCache.Clear();
            PointerEventData pointerEventData2;

            this.GetPointerData(-2, out pointerEventData2, true);
            this.CopyFromTo(pointerEventData, pointerEventData2);
            pointerEventData2.button = PointerEventData.InputButton.Right;
            PointerEventData pointerEventData3;

            this.GetPointerData(-3, out pointerEventData3, true);
            this.CopyFromTo(pointerEventData, pointerEventData3);
            pointerEventData3.button = PointerEventData.InputButton.Middle;

            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Left, StateForMouseButton(0), pointerEventData);
            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Right, StateForMouseButton(1), pointerEventData2);
            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Middle, StateForMouseButton(2), pointerEventData3);
            return(m_MouseState);
        }
Пример #29
0
    // Use this for initialization
    void Start()
    {
        //check the Module name
        BaseInputModule bim = EventSystem.current.currentInputModule;

        if (bim != null)
        {
            Debug.Log("Current Input Module name > " + bim.name);
        }
        else
        {
            Debug.Log("check no Input Module found ");
        }

        eventDataCurrentPosition = new PointerEventData(EventSystem.current);
    }
Пример #30
0
    void Grab(BaseInputModule module)
    {
        //Bind the module to this object.
        grabbingModule = module;
        //Save the offset between the module and this object. Undo the current rotation of the module
        offset    = transform.position - grabbingModule.transform.position;
        offset    = Quaternion.Inverse(grabbingModule.transform.rotation) * offset;
        rotOffset = Quaternion.Inverse(grabbingModule.transform.rotation) * transform.rotation;
        savedPositions.Add(transform.position);

        collider.isTrigger = true;

        if (rbody)
        {
            rbody.isKinematic = true;
        }
    }
Пример #31
0
    /// <summary>
    /// Initializes the values associated to this character instance. </summary>
    protected virtual void Awake()
    {
        //Unity Components
        _coordinates = GetComponent<Transform>();
        _controller = GetComponent<CharacterController>();
        _rigidbody = GetComponent<Rigidbody>();

        //Basic Character Components
        charAnimation = GetComponent<Animator> ();
        if (charAnimation != null) charAnimation.SetLayerWeight (1, 1);
        charStats = GetComponent<CharacterStats> ();
        charMoveSet = GetComponent<CharacterMovesetModule> ();

        oldCharAnimation = transform.Find ("Renderer").GetComponent<SkinnedMeshRenderer>().material;

        if (oldCharAnimation == null)
            Debug.LogError (name+"'s material is null");

        //			GetComponentInChildren<MeshRenderer> ().material;

        //Add specialized character components
        switch (charType) {
        case CharacterType.Player:
            charState = gameObject.AddComponent <CharacterStateMachine> ();			//dictates character's moveset and availble actions
            charInput = gameObject.AddComponent <PlayerInput> ();				//dictates characters focus and behaviour
            break;

        case CharacterType.Enemy:
            charState = gameObject.AddComponent <EnemyStateModule> ();
            charInput = gameObject.AddComponent <AIInput> ();
            break;

        default:
            break;
        }
    }
    public virtual void Start()
    {
        //input.Setup ();
        if (stats.Stun != null)
            user.CharStats.Stun.MaxValueEffect = TransitionToStun;
        else
            Debug.LogError ("no stun stat set!");

        stats.Health.MinValueEffect = TransitionToDead;

        switch (user.CharType) {
            case BaseCharacter.CharacterType.Player:
            input = GetComponent<PlayerInput>();
            CharInput.walkSignal += TransitionToWalk;
            CharInput.runSignal += TransitionToRun;
            CharInput.dodgeSignal += TransitionToDodge;
            CharInput.primarySignal += TransitionToPrimary;
            CharInput.sheatheSignal += TransitionToSheatheWeapon;
            break;
        case BaseCharacter.CharacterType.Enemy:
            input = GetComponent<AIInput>();
            break;
        }
        currentState = CharacterActions.Idle;
        StartCoroutine (monitorState());
    }
 //    private void UpdateTargetting (out float speed, out float bearing) {
 ////		bearing = Vector3.Dot ()
 //    }
 public override ActionResult Start(Agent agent, float deltaTime)
 {
     input = agent.Avatar.GetComponent<BaseInputModule> ();
     return ActionResult.SUCCESS;
 }
    protected override void OnAwake()
    {
        base.OnAwake ();
        user = GetComponent<BaseCharacter> ();
        stats = GetComponent<CharacterStats> ();
        moveSet = GetComponent<CharacterMovesetModule> ();									//used to access actions for state activation

        //		_animation = transform.Find ("Renderer").GetComponent<SkinnedMeshRenderer>();
        _animation = user.oldCharAnimation;

        input = GetComponent<BaseInputModule> ();

        armed = false;
        attacking = false;
        running = false;
    }