Exemplo n.º 1
0
        protected static T DrawObjectField <T>(string label, string key, T value) where T : Object
        {
            value = PlayerPrefsEx.GetObject(key, value) as T;
            T newValue = EditorGUILayout.ObjectField(label, value, typeof(T), false) as T;

            if (newValue != value)
            {
                PlayerPrefsEx.SetObject(key, newValue);
            }
            return(newValue);
        }
    protected virtual void Start()
    {
        TrackedObject obj = GetComponent <TrackedObject>();

        if (obj != null)
        {
            controller = obj.source;
        }
        if (controller == ControllerType.None)
        {
            m_ControllerInput = ControllerInputManager.instance.GetControllerInput(name);
        }
        else
        {
            m_ControllerInput = ControllerInputManager.instance.GetControllerInput(controller);
        }
        //
        if (PlayerPrefsEx.GetBool("UINotification-OutOfRange.enabled", false))
        {
            uiOutOfRange = PlayerPrefsEx.GetObject("UINotification-OutOfRange-" + controller.ToString(), null) as GameObject;
            if (uiOutOfRange != null)
            {
                Transform uiRoot = VRContext.uiRootVR;
                if (uiRoot != null)
                {
                    GameObject go = Instantiate(uiOutOfRange);
                    Transform  t = go.transform, raw = uiOutOfRange.transform;
                    t.SetParent(uiRoot);
                    t.localPosition  = raw.localPosition;
                    t.localRotation  = raw.localRotation;
                    t.localScale     = raw.localScale;
                    uiOutOfRange     = go;
                    m_FadeOutOfRange = uiOutOfRange.GetComponent <Ximmerse.UI.UIFade>();
                    //
                    if (m_FadeOutOfRange != null)
                    {
                        m_FadeOutOfRange.alpha = 0.0f;
                    }
                    SetUiOutOfRange(false);
                }
            }
        }
    }
Exemplo n.º 3
0
        protected virtual int GetVRDeviceTypeIndex()
        {
            Ximmerse.VR.VRDevice d  = null;
            GameObject           go = (GameObject)PlayerPrefsEx.GetObject("VRDevice.source");

            if (go != null)
            {
                d = go.GetComponent <Ximmerse.VR.VRDevice>();
            }
            //
            for (int i = 0, imax = s_VRDeviceTypeSources.Length; i < imax; ++i)
            {
                if (s_VRDeviceTypeSources[i] == d)
                {
                    return(i);
                }
            }
            return(0);
        }
Exemplo n.º 4
0
 protected virtual void DrawPlayAreaFeature()
 {
     EditorGUILayout.LabelField("Play Area", m_HeaderStyle);
     EditorGUI.BeginChangeCheck();
     if (DrawToggle("Enabled", "PlayArea.enabled", true))
     {
         //
         BeginGroup();
         PlayAreaRenderer prefab = null;
         GameObject       go     = PlayerPrefsEx.GetObject("PlayAreaRenderer") as GameObject;
         if (go == null)
         {
             go = EditorGUILayout.ObjectField("Prefab", null, typeof(GameObject), true) as GameObject;
             if (go == null)
             {
                 EndGroup();
                 return;
             }
             else
             {
                 PlayerPrefsEx.SetObject("PlayAreaRenderer", go);
             }
         }
         if (go != null)
         {
             prefab = go.GetComponent <PlayAreaRenderer>();
         }
         if (prefab == null)
         {
             EndGroup();
             return;
         }
         //
         DrawToggle("Show Camera Model", "PlayArea.showCameraModel", true);
         //EditorGUILayout.HelpBox("",MessageType.Info);
         DrawSlider("Warning Distance", "PlayArea.warningDistance", 0.5f, 0.01f, 1.0f);
         if (DrawToggle("Draw Ground", "PlayArea.drawGround", true))
         {
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(m_PlayerPrefsEx);
             }
             BeginGroup();
             EditorGUI.BeginChangeCheck();
             prefab.groundColor     = EditorGUILayout.ColorField("Color", prefab.groundColor);
             prefab.borderThickness = EditorGUILayout.Slider("Thickness", prefab.borderThickness, 0.01f, 1.0f);
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(prefab);
             }
             EndGroup();
         }
         else
         {
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(m_PlayerPrefsEx);
             }
         }
         EditorGUI.BeginChangeCheck();
         if (DrawToggle("Draw Wall", "PlayArea.drawWall", true))
         {
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(m_PlayerPrefsEx);
             }
             BeginGroup();
             EditorGUI.BeginChangeCheck();
             prefab.wallColor = EditorGUILayout.ColorField("Color", prefab.wallColor);
             prefab.thickness = EditorGUILayout.Slider("Thickness", prefab.thickness, 0.001f, 1.0f);
             prefab.cellSize  = EditorGUILayout.Slider("Cell Size", prefab.cellSize, 0.01f, 1.0f);
             prefab.emptySize = EditorGUILayout.Slider("Empty Size", prefab.emptySize, 0.01f, 1.0f);
             prefab.height    = EditorGUILayout.Slider("Height", prefab.height, 1.0f, 3.0f);
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(prefab);
             }
             EndGroup();
         }
         EditorGUI.BeginChangeCheck();
         if (DrawToggle("Draw Plane", "PlayArea.drawPlane", true))
         {
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(m_PlayerPrefsEx);
             }
             BeginGroup();
             EditorGUI.BeginChangeCheck();
             prefab.planeColor = EditorGUILayout.ColorField("Color", prefab.planeColor);
             if (EditorGUI.EndChangeCheck())
             {
                 EditorUtility.SetDirty(prefab);
             }
             EndGroup();
         }
         EndGroup();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        public virtual void InitVRContext()
        {
            //
            if (m_IsInited)
            {
                return;
            }
            m_IsInited = true;
            // Init Hmd SDK.
            if (vrDevice == null)
            {
                GameObject go = (GameObject)PlayerPrefsEx.GetObject("VRDevice.source", null);
                if (go == null || (vrDevice = go.GetComponent <VRDevice>()) == null)
                {
                }
                else
                {
                }
            }
            //
            string name = vrDevice.name;

            vrDevice      = Instantiate(vrDevice) as VRDevice;
            vrDevice.name = name;
            //
            Transform t = vrDevice.transform;

            t.SetParent(transform);
            t.localPosition = Vector3.zero;
            t.localRotation = Quaternion.identity;
            t.localScale    = Vector3.one;
            // The center eye may be replaced in this function.
            vrDevice.InitDevice(this);
            //
            // Check existed anchors
            Transform trackingSpace   = GetAnchor(VRNode.TrackingSpace, null);
            Transform centerEyeAnchor = GetAnchor(VRNode.CenterEye, null);

            // Auto fill the trackingSpace field if it is null.
            if (trackingSpace == null)
            {
                if (centerEyeAnchor != null)
                {
                    SetAnchor(VRNode.TrackingSpace, trackingSpace = centerEyeAnchor.parent);
                }
            }
            // Instantiate anchors.
            if (trackingSpace != null)
            {
                for (int i = 0, imax = m_Anchors.Length; i < imax; ++i)
                {
                    switch (m_Anchors[i].key)
                    {
                    // Ignored anchors.
                    case VRNode.TrackingSpace:
                    case VRNode.Count:
                        break;

                    //
                    default:
                        if (m_Anchors[i].value != null)
                        {
                            if (!InScene(m_Anchors[i].value))                                     // This anchor is a prefab.
                            {
                                Transform copy = Instantiate <Transform>(m_Anchors[i].value);
                                copy.SetParent(trackingSpace);
                                copy.name = m_Anchors[i].key.ToString() + "Anchor";
                                CopyTransform(m_Anchors[i].value, copy);
                                //
                                m_Anchors[i].value = copy;
                            }
                        }
                        break;
                    }
                }
            }
            if (vrDevice.family != "Dummy")
            {
                if (trackingSpace == null && centerEyeAnchor == null)
                {
                    Ximmerse.Log.e("VRContext", "trackingSpace==null&&centerEyeAnchor==null at InitVRContext()");
                }
                else if (centerEyeAnchor == null)
                {
                    Ximmerse.Log.e("VRContext", "centerEyeAnchor==null at InitVRContext()");
                }
            }
            // Optional :
            if (PlayerPrefsEx.GetBool("VRDevice.useFade", false))
            {
                if (fadeFx != null)
                {
                    fadeFx.FadeOut();
                }
            }
            // Optional :
            if (PlayerPrefsEx.GetBool("VRDevice.useReticle", false))
            {
                GameObject go = PlayerPrefsEx.GetObject("VRDevice.reticleObject", null) as GameObject;
                if (go != null)
                {
                    Transform rawT = go.transform;
                    go = Instantiate(go);
                    Transform newT = go.transform;
                    //
                    newT.SetParent(uiRootVR);
                    CopyTransform(rawT, newT);
                }
            }
            //
            // Send the initialization message.
            vrDevice.OnVRContextInited(this);
            for (int i = 0, imax = m_Anchors.Length; i < imax; ++i)
            {
                if (m_Anchors[i].value != null)
                {
                    m_Anchors[i].value.SendMessage("OnVRContextInited", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
Exemplo n.º 6
0
    protected virtual void Start()
    {
        m_Transform = transform;
        //
        m_TrackerHandle = -1;
        if (showOnTrackingLost)
        {
            XDevicePlugin.Init();
            m_TrackerHandle = XDevicePlugin.GetInputDeviceHandle(trackerName);
            if (m_TrackerHandle < 0)
            {
                showOnTrackingLost = false;
            }
        }
        //
        m_ReadyForModel = (controlPoints.Length == 8);
        // Cache values.

        /*
         * m_CosFovX=Mathf.Cos(Mathf.Deg2Rad*fovX*.5f);
         * m_CosFovY=Mathf.Cos(Mathf.Deg2Rad*fovY*.5f);
         * m_SqrNearZ=nearZ*nearZ;
         * m_SqrFarZ=farZ*farZ;
         *
         * m_SqrOrthographicSize=orthographicSize*.5f;
         * m_SqrOrthographicSize=Vector2.Scale(m_SqrOrthographicSize,m_SqrOrthographicSize);
         */
        //
        if (m_Corners != null && m_Corners.Length != 0)
        {
            m_CachedCorners = m_Corners;
        }
        m_Corners = null;
        //
        m_GroundAlpha      = PlayerPrefsEx.GetInt("PlayArea.drawGround", 1);
        m_WallAlpha        = PlayerPrefsEx.GetInt("PlayArea.drawWall", 1);
        m_PlaneAlpha       = PlayerPrefsEx.GetInt("PlayArea.drawPlane", 1);
        autoCreatePlayArea = PlayerPrefsEx.GetBool("PlayArea.enabled", autoCreatePlayArea);
        showCameraModel    = PlayerPrefsEx.GetBool("PlayArea.showCameraModel", showCameraModel);
        if (m_cameraModel != null)
        {
            m_cameraModel.SetActive(showCameraModel);
        }
        warningDistance = PlayerPrefsEx.GetFloat("PlayArea.warningDistance", 0.5f);
        //
        if (autoCreatePlayArea)
        {
            Transform t = null;
            Transform trackingSpaceAnchor = VRContext.GetAnchor(VRNode.TrackingSpace);

            if (m_PlayArea == null)
            {
                if (trackingSpaceAnchor != null)
                {
                    m_PlayArea = trackingSpaceAnchor.GetComponentInChildren <PlayAreaRenderer>();
                }
                if (m_PlayArea == null)
                {
                    GameObject go = PlayerPrefsEx.GetObject("PlayAreaRenderer") as GameObject;
                    m_PlayArea      = Instantiate(go).GetComponent <PlayAreaRenderer>();
                    m_PlayArea.name = go.name;
                }
            }
            m_PlayArea.handedness = -1;
            //
            t = m_PlayArea.transform;
            t.SetParent(trackingSpaceAnchor);
            t.localPosition = (VRContext.trackingOrigin == TrackingOrigin.FloorLevel) ? Vector3.zero :
                              new Vector3(0f, -XDevicePlugin.GetFloat(m_TrackerHandle, XDevicePlugin.kField_TrackerHeightFloat, 0f), 0f);
            t.localRotation = Quaternion.identity;
            t.localScale    = Vector3.one;
        }
        //
        UpdateModel();
    }
Exemplo n.º 7
0
 public static void LoadLocal()
 {
     data = PlayerPrefsEx.GetObject("Profile.Data", data);
 }
Exemplo n.º 8
0
 static Payload()
 {
     list = PlayerPrefsEx.GetObject("PurchaseSystem.Payload.list", new List <string>());
 }