Ejemplo n.º 1
0
        protected virtual void Awake()
        {
            if (_subtitleOptions == null)
            {
                Debug.LogError("Subtitle options asset is missing!");
            }

            if (subtitleOptions.defaultMode.Equals(Subtitle.Mode.SCREEN) && UnityEngine.XR.XRSettings.enabled)
            {
                Debug.LogWarning("Subtitles will not render in SCREEN mode while running in VR!");

                subtitleOptions.defaultMode = Subtitle.Mode.HEADSET;
            }

            var subtitlePrefab =
                Resources.LoadAll <GameObject>("Prefabs")
                .First(material =>
                       material.name.StartsWith("Subtitle") && material.name.Contains(mode.ToString()));

            _subtitleRenderer = Instantiate(subtitlePrefab).GetComponent <SubtitleRenderer>();

            _subtitleRenderer.mode            = mode;
            _subtitleRenderer.position        = position;
            _subtitleRenderer.targetTransform = gameObject.transform;
            _subtitleRenderer.targetCollider  = gameObject.GetComponent <Collider>();

            _subtitleRenderer.Setup();
            _subtitleRenderer.SetOptions(_subtitleOptions);
        }
 private void Awake()
 {
     _subtitleRenderer = gameObject.GetComponent <SubtitleRenderer>();
 }