Ejemplo n.º 1
0
        //-------------------------------------------------
        void Awake()
        {
            Debug.LogError(name + "  is using linear animation");
            if (animation == null)
            {
                animation = GetComponent <Animation>();
            }

            if (linearMapping == null)
            {
                linearMapping = GetComponent <LinearMapping>();
            }

            //We're assuming the animation has a single clip, and that's the one we're
            //going to scrub with the linear mapping.
            animation.playAutomatically = true;
            animState = animation[animation.clip.name];

            //If the anim state's (i.e. clip's) wrap mode is Once (the default) or ClampForever,
            //Unity will automatically stop playing the anim, regardless of subsequent changes
            //to animState.time. Thus, we set the wrap mode to PingPong.
            animState.wrapMode = WrapMode.PingPong;
            animState.speed    = 0;
            animLength         = animState.length;
        }
        //-------------------------------------------------
        void Start()
        {
            Debug.LogError(name + "  is using linear displacesment");
            initialPosition = transform.localPosition;

            if (linearMapping == null)
            {
                linearMapping = GetComponent <LinearMapping>();
            }
        }
        //-------------------------------------------------
        void Awake()
        {
            Debug.LogError(name + "  is using linear audio pitch");
            if (audioSource == null)
            {
                audioSource = GetComponent <AudioSource>();
            }

            if (linearMapping == null)
            {
                linearMapping = GetComponent <LinearMapping>();
            }
        }
Ejemplo n.º 4
0
        //-------------------------------------------------
        private void Start()
        {
            if (childCollider == null)
            {
                childCollider = GetComponentInChildren <Collider>();
            }

            if (linearMapping == null)
            {
                linearMapping = GetComponent <LinearMapping>();
            }

            if (linearMapping == null)
            {
                linearMapping = gameObject.AddComponent <LinearMapping>();
            }

            worldPlaneNormal = new Vector3(0.0f, 0.0f, 0.0f);
            worldPlaneNormal[(int)axisOfRotation] = 1.0f;

            localPlaneNormal = worldPlaneNormal;

            if (transform.parent)
            {
                worldPlaneNormal = transform.parent.localToWorldMatrix.MultiplyVector(worldPlaneNormal).normalized;
            }

            if (limited)
            {
                start    = Quaternion.identity;
                outAngle = transform.localEulerAngles[(int)axisOfRotation];

                if (forceStart)
                {
                    outAngle = Mathf.Clamp(startAngle, minAngle, maxAngle);
                }
            }
            else
            {
                start    = Quaternion.AngleAxis(transform.localEulerAngles[(int)axisOfRotation], localPlaneNormal);
                outAngle = 0.0f;
            }

            if (debugText)
            {
                debugText.alignment = TextAlignment.Left;
                debugText.anchor    = TextAnchor.UpperLeft;
            }

            UpdateAll();
        }
        //-------------------------------------------------
        void Awake()
        {
            Debug.LogError(name + "  is using linear animator");
            if (animator == null)
            {
                animator = GetComponent <Animator>();
            }

            animator.speed = 0.0f;

            if (linearMapping == null)
            {
                linearMapping = GetComponent <LinearMapping>();
            }
        }
Ejemplo n.º 6
0
        protected virtual void Start()
        {
            linearMapping = GetComponent <LinearMapping>();
            if (linearMapping == null)
            {
                linearMapping = gameObject.AddComponent <LinearMapping>();
            }

            initialMappingOffset = linearMapping.value;

            if (repositionGameObject)
            {
                UpdateLinearMapping(transform);
            }
        }