Inheritance: MonoBehaviour
    internal GameObject PickObject(ScreenRaycaster raycaster, Vector2 screenPos)
    {
        if (!raycaster || !raycaster.enabled)
        {
            return(null);
        }

        /*if((float)(Time.realtimeSinceStartup - lastTimeRaycast*1.0f) >= timeBetweenRaycast)
         * {
         *      lastTimeRaycast = Time.realtimeSinceStartup;
         *
         *      if( !raycaster.Raycast( screenPos, out lastRaycast ) )
         *              return null;
         * }
         * else
         * {
         *      return null;
         * }*/

        if (!raycaster.Raycast(screenPos, out lastRaycast))
        {
            return(null);
        }

        return(lastRaycast.GameObject);
    }
示例#2
0
    public void OnLevelWasLoaded(int level)
    {
        ScreenRaycaster raycaster = gameObject.GetComponent <ScreenRaycaster>();

        raycaster.Cameras = new Camera[] {
            Camera.main,
        };
    }
示例#3
0
    void Start()
    {
        if (!MessageTarget)
        {
            MessageTarget = this.gameObject;
        }

        screenRaycaster = GetComponent <ScreenRaycaster>();
        if (!screenRaycaster)
        {
            screenRaycaster = gameObject.AddComponent <ScreenRaycaster>();
        }

        // Create the FG instance if not already available
        if (!FingerGestures.Instance)
        {
            gameObject.AddComponent <FingerGestures>();
        }

        GameObject fingerEventsNode = CreateChildNode("Finger Event Detectors");
        {
            FingerDown   = AddFingerEventDetector <FingerDownDetector>(fingerEventsNode);
            FingerUp     = AddFingerEventDetector <FingerUpDetector>(fingerEventsNode);
            FingerMotion = AddFingerEventDetector <FingerMotionDetector>(fingerEventsNode);
            FingerHover  = AddFingerEventDetector <FingerHoverDetector>(fingerEventsNode);
        }

        GameObject singleFingerGestureNode = CreateChildNode("Single Finger Gestures");
        {
            Drag      = AddSingleFingerGesture <DragRecognizer>(singleFingerGestureNode);
            Tap       = AddSingleFingerGesture <TapRecognizer>(singleFingerGestureNode);
            Swipe     = AddSingleFingerGesture <SwipeRecognizer>(singleFingerGestureNode);
            LongPress = AddSingleFingerGesture <LongPressRecognizer>(singleFingerGestureNode);

            DoubleTap = AddSingleFingerGesture <TapRecognizer>(singleFingerGestureNode);
            DoubleTap.RequiredTaps     = 2;
            DoubleTap.EventMessageName = "OnDoubleTap";
        }

        GameObject twoFingerGestures = CreateChildNode("Two-Finger Gestures");
        {
            Pinch              = AddTwoFingerGesture <PinchRecognizer>(twoFingerGestures);
            Twist              = AddTwoFingerGesture <TwistRecognizer>(twoFingerGestures);
            TwoFingerDrag      = AddTwoFingerGesture <DragRecognizer>(twoFingerGestures, "OnTwoFingerDrag");
            TwoFingerTap       = AddTwoFingerGesture <TapRecognizer>(twoFingerGestures, "OnTwoFingerTap");
            TwoFingerSwipe     = AddTwoFingerGesture <SwipeRecognizer>(twoFingerGestures, "OnTwoFingerSwipe");
            TwoFingerLongPress = AddTwoFingerGesture <LongPressRecognizer>(twoFingerGestures, "OnTwoFingerLongPress");
        }

        // we're done, remove component (but not game object)
        // Destroy( this );
    }
示例#4
0
        void Start()
        {
            ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent <ScreenRaycaster>();

            raycaster.Cameras    = new Camera[2];
            raycaster.Cameras[0] = GameObject.Find("Main Camera").GetComponent <Camera>();
            raycaster.Cameras[1] = GameObject.FindObjectOfType <Main>().GetComponent <Camera>();

            raycaster.Cameras[0].tag = "MainCamera";
            raycaster.Cameras[0].GetComponent <Camera>().depth = -1;
            raycaster.Cameras[1].tag = "Untagged";
            raycaster.Cameras[1].GetComponent <Camera>().depth = -2;
        }
示例#5
0
    internal GameObject PickObject(ScreenRaycaster raycaster, Vector2 screenPos)
    {
        if (!raycaster || !raycaster.enabled)
        {
            return(null);
        }

        if (!raycaster.Raycast(screenPos, out lastHit))
        {
            return(null);
        }

        return(lastHit.collider.gameObject);
    }
示例#6
0
    private void InstallGestureRecognizers()
    {
        //xg_IC = GameObject.Find(str_Intell_Control).GetComponent<XgIntellControl>();
        //xg_Pc = GameObject.Find(str_Pic_Control).GetComponent<XgPictrueControl>();

        List <GestureRecognizer> recogniers    = new List <GestureRecognizer>(GetComponents <GestureRecognizer>());
        DragRecognizer           drag          = recogniers.Find(r => r.EventMessageName == "OnDrag") as DragRecognizer;
        DragRecognizer           twoFingerDrag = recogniers.Find(r => r.EventMessageName == "OnTwoFingerDrag") as DragRecognizer;
        PinchRecognizer          pinch         = recogniers.Find(r => r.EventMessageName == "OnPinch") as PinchRecognizer;

        // check if we need to automatically add a screenraycaster
        if (OnlyRotateWhenDragStartsOnObject)
        {
            ScreenRaycaster raycaster = gameObject.GetComponent <ScreenRaycaster>();

            if (!raycaster)
            {
                raycaster = gameObject.AddComponent <ScreenRaycaster>();
            }
        }

        if (!drag)
        {
            drag = gameObject.AddComponent <DragRecognizer>();
            drag.RequiredFingerCount     = 1;
            drag.IsExclusive             = true;
            drag.MaxSimultaneousGestures = 1;
            drag.SendMessageToSelection  = GestureRecognizer.SelectionType.None;
        }

        if (!pinch)
        {
            pinch = gameObject.AddComponent <PinchRecognizer>();
        }

        if (!twoFingerDrag)
        {
            twoFingerDrag = gameObject.AddComponent <DragRecognizer>();
            twoFingerDrag.RequiredFingerCount          = 2;
            twoFingerDrag.IsExclusive                  = true;
            twoFingerDrag.MaxSimultaneousGestures      = 1;
            twoFingerDrag.ApplySameDirectionConstraint = true;
            twoFingerDrag.EventMessageName             = "OnTwoFingerDrag";
        }
    }
示例#7
0
        /// <summary>
        /// 返回菜单界面
        /// </summary>
        public void backMenu()
        {
            treeMenu.clearChildren(treeMenu.treeGrid.transform);
            if (coverTab[coverTab.Length - 1].activeSelf)
            {
                coverTab[coverTab.Length - 1].SetActive(false);
                Title[Title.Length - 1].SetActive(false);
            }
            Title[0].SetActive(true);
            coverTab[0].SetActive(true);
            currentModel = null;
            movieManager.OnStop();
            nowValue   = null;
            nextNumber = 0;
            uiTool.setShiwaiSliderValue(0 / count, 0, count);
            uiTool.setTextl(null);
            uiTool.setPopText(null);
            tabStrip.tabs[0].value = true;
            setSomeUiActive(false);
            DestroyUI(null);
            clear();
            AudioManager.getInstance().SetGroundScale(1f);
            AudioManager.getInstance().SetAudioVolume(AudioManager.MusicNumType.groundMusic, 0.2f, false);            // 修改背景音乐的初始音量大小
            AudioManager.getInstance().AudioPlay(GlobalConfig.backgroundMusic, AudioManager.MusicNumType.groundMusic);
            AudioManager.getInstance().AudioStop(AudioManager.MusicNumType.realtimeMusic);

            if (alertMSG != null)
            {
                ResourceManager.getInstance().getUIPool.Despawn(alertMSG.transform);
            }

            ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent <ScreenRaycaster>();

            raycaster.Cameras    = new Camera[1];
            raycaster.Cameras[0] = GameObject.FindObjectOfType <Main>().GetComponent <Camera>();
            SceneManager.LoadScene("MainUI");
            UIManager.getInstance().setActiveUI(UIType.MainMenu);
            examCamera.GetComponent <Camera>().depth = examCamera.GetComponent <Camera>().depth = -50;
            CoherentUISystem.Instance.UIViews.Remove(examCamera);
        }
    protected virtual void Awake()
    {
        if (string.IsNullOrEmpty(EventMessageName))
        {
            EventMessageName = GetDefaultEventMessageName();
        }

        if (ResetMode == GestureResetMode.Default)
        {
            ResetMode = GetDefaultResetMode();
        }

        if (!EventMessageTarget)
        {
            EventMessageTarget = this.gameObject;
        }

        if (!Raycaster)
        {
            Raycaster = GetComponent <ScreenRaycaster>();
        }
    }
示例#9
0
        public void initCamer()
        {
            ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent <ScreenRaycaster>();

            raycaster.Cameras[0].transform.position = new Vector3(14.5f, 1, -130);
            raycaster.Cameras[0].transform.rotation = Quaternion.Euler(20, 0, 0);
            if (UIManager.getInstance().modename == "设备故障")
            {
                raycaster.Cameras[0].transform.position      = new Vector3(-1.5f, 1.1f, 6.74f);
                raycaster.Cameras[0].transform.rotation      = Quaternion.Euler(10, -30, -2);
                GameObject.Find("Camera").transform.position = new Vector3(-1.5f, 1.1f, 6.74f);
            }

            //ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent<ScreenRaycaster>();
            //raycaster.Cameras = new Camera[2];
            //raycaster.Cameras[0] = GameObject.Find("Main Camera").GetComponent<Camera>();
            //raycaster.Cameras[1] = GameObject.FindObjectOfType<Main>().GetComponent<Camera>();

            //raycaster.Cameras[0].tag = "MainCamera";
            //raycaster.Cameras[0].GetComponent<Camera>().depth = -1;
            //raycaster.Cameras[1].tag = "Untagged";
            //raycaster.Cameras[1].GetComponent<Camera>().depth = -2;
        }
示例#10
0
 internal void PickSelection(ScreenRaycaster raycaster)
 {
     Selection = PickObject(raycaster, Position);
 }
示例#11
0
 internal void PickStartSelection(ScreenRaycaster raycaster)
 {
     StartSelection = PickObject(raycaster, StartPosition);
     Selection      = StartSelection;
 }
示例#12
0
        /// <summary>
        /// 退出培训流程,返回到菜单界面
        /// </summary>
        public void backMenu()
        {
            outExamBtn.SetActive(false);
            uitool.controlPanel.SetActive(true);
            UIManager.getInstance().selectTopicUI.mask.SetActive(false);
            errorCount = 0;
            if (!(alertMSG == null || !alertMSG.gameObject.activeSelf))
            {
                ResourceManager.getInstance().getUIPool.Despawn(alertMSG.transform);
            }
            if (flowMovie.activeSelf)
            {
                flowMovie.SetActive(false);
                movieManager.OnStop();
            }
            flowOperateImage.SetActive(false);
            flowOperateMovie.SetActive(false);
            examCountDown.onStop();
            examCountDown.gameObject.SetActive(false);
            trainEndUI.gameObject.SetActive(false);
            isBackMenu = true;
            //tabStrip.tabs[(int)currentTrainMode].GetComponent<UIToggle>().value = false;
            for (int i = 0; i < coverTabs.Length; i++)
            {
                tabStrip.tabs[i].Set(false);
            }
            if (nextProcess.switchMode.activeSelf)
            {
                nextProcess.switchMode.SetActive(false);
            }
            changeCount = 0;
            uitool.setTextl(null);
            uitool.setPopText(null);
            tabStrip.restTabStrip();
            indexNumber = -1;
            uitool.setShiwaiSliderValue(Convert.ToSingle(indexNumber + 1) / Convert.ToSingle(count), indexNumber + 1, count);
            TrainingManager.ExitFlow();

            //音乐调节
            AudioManager.getInstance().SetGroundScale(1f);
            AudioManager.getInstance().AudioPlay(GlobalConfig.backgroundMusic, AudioManager.MusicNumType.groundMusic);
            AudioManager.getInstance().AudioStop(AudioManager.MusicNumType.realtimeMusic);            //返回的时候停止实时音乐

            SceneManager.LoadScene("MainUI");
            trainEndUI.gameObject.SetActive(false);
            trainStartUI.gameObject.SetActive(false);
            isShowTrainStart       = false;
            isStartTrain           = false;
            this.currentReciprocal = null;

            this.isWalkCamea = true;
            backSuperNodeBtn.gameObject.SetActive(false);
            this.isStartTrain = false;
            UIManager.getInstance().selectTopicUI.gameObject.SetActive(false);
            ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent <ScreenRaycaster>();

            raycaster.Cameras    = new Camera[1];
            raycaster.Cameras[0] = GameObject.FindObjectOfType <Main>().GetComponent <Camera>();
            UIManager.getInstance().setActiveUI(UIType.MainMenu);
            examGrade.GetComponent <Camera>().depth = -50;
            CoherentUISystem.Instance.UIViews.Remove(examGrade);
        }