示例#1
0
        /// <summary>
        /// Determines when to boot the VR code. In most cases, it makes sense to do the check as described here.
        /// </summary>
        void Awake()
        {
            Instance = this;

            CameraResetPos = Vector3.zero;
            CameraResetRot = Quaternion.identity;

            bool vrDeactivated = Environment.CommandLine.Contains("--novr");
            bool vrActivated   = Environment.CommandLine.Contains("--vr");

            VRLog.Info($"Screen Size {Screen.width} x {Screen.height}");

            if (vrActivated || (!vrDeactivated && SteamVRDetector.IsRunning))
            {
                VR_ACTIVATED = true;
                VRLoader.Create(true);

                VRColliderHelper.pluginInstance = this;
                VRColliderHelper.TriggerHelperCoroutine();
            }
            else
            {
                VRLog.Info("Not using VR");
                // Don't do anything
                //VRLoader.Create(false);
            }
        }
示例#2
0
        public static void DisplayVRSubtitle(string text, Color textColor, Color outlineColor, Action <Action> onDestroy)
        {
            if (text.IsNullOrWhiteSpace())
            {
                return;
            }
            InitGUI();

            Font fontFace = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
            int  fsize    = -5;

            fsize = (int)(fsize < 0 ? (fsize * (Screen.height) / -100.0) : fsize);

            GameObject subtitle = new GameObject("SubtitleText");

            subtitle.transform.SetParent(Pane.transform, false);

            var rect = subtitle.GetOrAddComponent <RectTransform>();

            rect.pivot     = new Vector2(0.5f, 0);
            rect.sizeDelta = new Vector2(Screen.width * .5f * 0.990f, fsize + (fsize * 0.05f));

            var subtitleText = subtitle.GetOrAddComponent <Text>();

            subtitleText.font               = fontFace;
            subtitleText.fontSize           = fsize;
            subtitleText.fontStyle          = fontFace.dynamic ? UnityEngine.FontStyle.Bold : UnityEngine.FontStyle.Normal;
            subtitleText.alignment          = TextAnchor.LowerCenter;
            subtitleText.horizontalOverflow = HorizontalWrapMode.Wrap;
            subtitleText.verticalOverflow   = VerticalWrapMode.Overflow;
            subtitleText.color              = textColor;

            var effectDistance = new Vector2(1.5f, -1.5f);
            var subOutline     = subtitle.GetOrAddComponent <Outline>();

            subOutline.effectColor    = outlineColor;
            subOutline.effectDistance = effectDistance;
            var subShadow = subtitle.GetOrAddComponent <Shadow>();

            subShadow.effectColor    = outlineColor;
            subShadow.effectDistance = effectDistance;

            subtitleText.text = text;
            VRLog.Info(text);

            onDestroy(() => VRPlugin.Destroy(subtitle));
        }