Example #1
0
    public override void Launch(bool checkOthers)
    {
        //
        XDevicePlugin.Init();
        XDevicePlugin.SetInt(-1, XDevicePlugin.kField_CtxDeviceVersion, 0x3000);
        //
        base.Launch(checkOthers);
        // Create control points in runtime.
        Transform trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace);

        for (int i = 0; i < 3; ++i)
        {
            if (docks[i] != null)
            {
                GameObject go   = Instantiate(docks[i]);
                Transform  t    = docks[i].transform;
                Transform  newT = go.transform;
                //
                go.name = docks[i].name;

                newT.SetParent(trackingSpace);
                newT.localPosition = t.localPosition;
                newT.localRotation = t.localRotation;
                newT.localScale    = t.localScale;
                //
                docks[i] = go;
            }
        }
        // Initialize play area.
        m_PlayAreaRenderer = docks[2].GetComponentInChildren <PlayAreaRenderer>();
        if (m_PlayAreaRenderer != null)
        {
            m_PlayArea    = m_PlayAreaRenderer.transform;
            m_BoundaryPtr = NativeMethods.Boundary_Alloc(-1, 4, -2.0f, 2.0f);
            for (int i = 0, imax = m_PlayAreaRenderer.corners.Length; i < imax; ++i)
            {
                NativeMethods.Boundary_SetCorner(m_BoundaryPtr, i,
                                                 m_PlayAreaRenderer.corners[i].x, -m_PlayAreaRenderer.corners[i].z
                                                 );
            }
        }
        //
        Transform head = VRContext.GetAnchor(VRNode.Head);

        if (head != null)
        {
            TrackedHead trackedHead = head.GetComponent <TrackedHead>();
            if (trackedHead != null)
            {
                trackedHead.markTransform.localPosition =
                    head.InverseTransformPoint(anchor.position);
            }
        }
    }
Example #2
0
 protected virtual void OnCreate(Object createBy)
 {
     m_TrackedHead = (TrackedHead)createBy;
     if (uiRoot == null)
     {
         uiRoot = transform.GetChild(0).gameObject;
     }
     if (textFixMark == null)
     {
         textFixMark = uiRoot.GetComponentInChildren <UnityEngine.UI.Text>();
     }
     //
     if (uiRoot != null)
     {
         uiRoot.SetActive(false);
     }
 }