Ejemplo n.º 1
0
    bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes)
    {
        List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes);

        if (hitResults.Count > 0)
        {
            foreach (var hitResult in hitResults)
            {
                if (allowPlacement)
                {
                    GameObject myob = Instantiate(m_placementObject, UnityARMatrixOps.GetPosition(hitResult.worldTransform), UnityARMatrixOps.GetRotation(hitResult.worldTransform));
                    allowPlacement = false;

                    DemoControls demoControls = GameObject.FindObjectOfType <DemoControls>();
                    if (demoControls)
                    {
                        ARTouchTransformation arTouchTransformation = myob.GetComponent <ARTouchTransformation>();
                        arTouchTransformation.GetComponent <LeanSelectable>().OnSelect.AddListener((LeanFinger finger) => demoControls.OnSelect(arTouchTransformation.gameObject));
                        arTouchTransformation.GetComponent <LeanSelectable>().OnDeselect.AddListener(demoControls.OnDeSelect);
                    }
                }
                return(true);
            }
        }
        return(false);
    }
Ejemplo n.º 2
0
        void InitServices()
        {
            var tThing = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.DemoIFrame);
            var t      = new DemoIFrame(tThing, this);

            var tThing2 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.DemoStandardForm);
            var t2      = new DemoStandardForm(tThing2, this);

            var tThing3 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.DemoControls);
            var t3      = new DemoControls(tThing3, this);

            var tThing4 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.DemoWizard);
            var t4      = new DemoWizard(tThing4, this);

            var tThing5 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.AudioWizard);
            var t5      = new AudioRuleWizard(tThing5, this);

            var tThing9 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.MeshPicker);
            var t9      = new TheMeshPicker(tThing9, this);

            var tThing10 = TheThingRegistry.GetThingByProperty(MyBaseThing.EngineName, Guid.Empty, "DeviceType", eTheDemoScreensTypes.TestAutomationWizard);
            var t10      = new TestAutoWizard(tThing10, this);

            MyBaseEngine.SetStatusLevel(1);
        }
Ejemplo n.º 3
0
    public void OnLoadClick()
    {
        DemoControls.Load();

        InputControlDemo_KeyButtonScript[] keyButtons = GetComponentsInChildren <InputControlDemo_KeyButtonScript>();

        foreach (InputControlDemo_KeyButtonScript keyButton in keyButtons)
        {
            keyButton.updateText();
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// One-time initialization for a player controller.
    /// </summary>
    /// <remarks>
    /// Once spawned, we are reusing player instances over and over. The setup we perform in here,
    /// however, is done only once.
    /// </remarks>
    public void PerformOneTimeInitialization()
    {
        // Each player gets a separate action setup. This makes the state of actions and bindings
        // local to each player and also ensures we're not stepping on the action setup used by
        // DemoGame itself for the main menu (where we are not using control schemes and just blindly
        // bind to whatever devices are available locally).
        controls = new DemoControls();

        Debug.Assert(uiActions != null);
        Debug.Assert(projectilePrefab != null);
        Debug.Assert(controls != null);

        // Wire our callbacks into gameplay actions. We don't need to do the same
        // for menu actions as it's the UI using those and not us.
        controls.gameplay.SetCallbacks(this);

        // Wire our input actions into the UI. Doing this manually here instead of setting it up
        // in the inspector ensure that when we duplicate DemoControls.inputactions above, we
        // end up with the UI using the right actions.
        //
        // NOTE: Our bindings will be effective on the devices assigned to the user which in turn
        //       means that the UI will react only to input from that same user.
        uiActions.BindUIActions(controls.menu);
    }
Ejemplo n.º 5
0
 public GameplayActions(DemoControls wrapper)
 {
     m_Wrapper = wrapper;
 }
Ejemplo n.º 6
0
 public void OnSaveClick()
 {
     DemoControls.Save();
 }
Ejemplo n.º 7
0
 public MenuActions(DemoControls wrapper)
 {
     m_Wrapper = wrapper;
 }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
#if UNITY_EDITOR   //we will only use this script on the editor side, though there is nothing that would prevent it from working on device
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //we'll try to hit one of the plane collider gameobjects that were generated by the plugin
            //effectively similar to calling HitTest with ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent
            if (Physics.Raycast(ray, out hit, maxRayDistance, collisionLayer))
            {
                if (allowPlacement)
                {
                    GameObject myob = Instantiate(m_placementObject, hit.point, hit.transform.rotation);
                    allowPlacement = false;
                    DemoControls demoControls = GameObject.FindObjectOfType <DemoControls>();
                    if (demoControls)
                    {
                        ARTouchTransformation arTouchTransformation = myob.GetComponent <ARTouchTransformation>();
                        arTouchTransformation.GetComponent <LeanSelectable>().OnSelect.AddListener((LeanFinger finger) => demoControls.OnSelect(arTouchTransformation.gameObject));
                        arTouchTransformation.GetComponent <LeanSelectable>().OnDeselect.AddListener(demoControls.OnDeSelect);
                    }
                }
            }
        }
#else
        if (Input.touchCount > 0)
        {
            var touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved)
            {
                var     screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
                ARPoint point          = new ARPoint {
                    x = screenPosition.x,
                    y = screenPosition.y
                };

                // prioritize reults types
                ARHitTestResultType[] resultTypes =
                {
                    //ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingGeometry,
                    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent,
                    // if you want to use infinite planes use this:
                    //ARHitTestResultType.ARHitTestResultTypeExistingPlane,
                    //ARHitTestResultType.ARHitTestResultTypeEstimatedHorizontalPlane,
                    //ARHitTestResultType.ARHitTestResultTypeEstimatedVerticalPlane,
                    //ARHitTestResultType.ARHitTestResultTypeFeaturePoint
                };

                foreach (ARHitTestResultType resultType in resultTypes)
                {
                    if (HitTestWithResultType(point, resultType))
                    {
                        return;
                    }
                }
            }
        }
#endif
    }