Exemplo n.º 1
0
        protected static Color DrawColorField(string label, string key, Color value)
        {
            value = PlayerPrefsEx.GetColor(key, value);
            Color newValue = EditorGUILayout.ColorField(label, value);

            if (newValue != value)
            {
                PlayerPrefsEx.SetColor(key, newValue);
            }
            return(newValue);
        }
Exemplo n.º 2
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);
        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;
            if (m_PlayArea == null)
            {
                //
                m_PlayArea            = new GameObject("_PlayArea", typeof(PlayAreaRenderer)).GetComponent <PlayAreaRenderer>();
                m_PlayArea.handedness = -1;

                m_PlayArea.groundColor     = PlayerPrefsEx.GetColor("PlayArea.groundColor", Color.cyan);
                m_PlayArea.groundMaterial  = new Material(Shader.Find("Sprites/Default"));
                m_PlayArea.borderThickness = PlayerPrefsEx.GetFloat("PlayArea.borderThickness", .15f);

                m_PlayArea.wallColor    = PlayerPrefsEx.GetColor("PlayArea.wallColor", Color.cyan);
                m_PlayArea.wallMaterial = new Material(Shader.Find("Sprites/Default"));
                m_PlayArea.thickness    = PlayerPrefsEx.GetFloat("PlayArea.thickness", 0.0075f);
                m_PlayArea.height       = PlayerPrefsEx.GetFloat("PlayArea.height", 2.5f);
                m_PlayArea.cellSize     = PlayerPrefsEx.GetFloat("PlayArea.cellSize", 0.25f);
                m_PlayArea.emptySize    = PlayerPrefsEx.GetFloat("PlayArea.emptySize", 0.05f);
            }
            t = m_PlayArea.transform;
            t.SetParent(VRContext.GetAnchor(VRNode.TrackingSpace));
            t.localPosition = (VRContext.trackingOrigin == TrackingOrigin.FloorLevel) ? Vector3.zero :
                              new Vector3(0f, -XDevicePlugin.GetFloat(m_TrackerHandle, XDevicePlugin.kField_TrackerHeight, 0f), 0f);
            t.localRotation = Quaternion.identity;
            t.localScale    = Vector3.one;
        }
        //
        UpdateModel();
    }