示例#1
0
    void OnTriggerEnter(Collider other)
    {
        // If the Player Enters, grab the main camera, then turn on the billboard
        if (_players.Contains(other.gameObject))
        {
            _lookAtConstraint.SetSources(new List <ConstraintSource>()
            {
                new ConstraintSource {
                    sourceTransform = Camera.main.transform,
                    weight          = 1
                }
            });
            _lookAtConstraint.enabled = true;

            _text.enabled = true;
        }
    }
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private static IEnumerator CoroutineShow(string message, Color color,
                                                 GameObject instance, float duration)
        {
            Canvas canvas = instance.GetComponent <Canvas>();
            Camera camera = HookCamera.Instance != null?HookCamera.Instance.Get <Camera>() : null;

            if (!camera)
            {
                camera = GameObject.FindObjectOfType <Camera>();
            }

            if (canvas != null)
            {
                canvas.worldCamera = camera;
            }

            Animator animator = instance.GetComponentInChildren <Animator>();
            Text     text     = instance.GetComponentInChildren <Text>();

            text.text  = message;
            text.color = color;

            LookAtConstraint constraint = instance.GetComponent <LookAtConstraint>();

            if (constraint != null)
            {
                constraint.SetSources(new List <ConstraintSource>()
                {
                    new ConstraintSource()
                    {
                        sourceTransform = HookCamera.Instance.transform,
                        weight          = 1.0f
                    }
                });

                constraint.constraintActive = true;
            }

            WaitForSecondsRealtime wait = new WaitForSecondsRealtime(duration - TRANSITION_TIME);

            yield return(wait);

            if (animator != null)
            {
                animator.SetTrigger(ANIMATOR_HASH_CLOSE);
            }

            wait = new WaitForSecondsRealtime(TRANSITION_TIME);
            yield return(wait);

            if (instance != null)
            {
                GameObject.Destroy(instance);
            }
        }
示例#3
0
        private void Setup()
        {
            LookAtConstraint constraint = GetComponent <LookAtConstraint>();

            if (constraint == null)
            {
                constraint = gameObject.AddComponent <LookAtConstraint>();
            }
            constraint.rotationOffset = new Vector3(0, 180, 0);
            constraint.SetSources(new List <ConstraintSource>()
            {
                new ConstraintSource()
                {
                    sourceTransform = HookCamera.Instance.transform,
                    weight          = 1.0f
                }
            });

            constraint.constraintActive = true;

            enabled = false;
            Destroy(this);
        }