Ejemplo n.º 1
0
        //!
        //! Use this for initialization
        //!
        void Awake()
        {
            //cache reference to main Controller
            mainController = GameObject.Find("MainController").GetComponent <MainController>();

            //cache reference to animation timeline
            timeLineObject = GameObject.Find("GUI/Canvas/UI/TimeLine");
            if (timeLineObject == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find TimeLine (GUI/Canvas/UI/TimeLine).", this.GetType()));
            }

            timeLine = timeLineObject.GetComponent <TimeLineWidget>();
            if (timeLine == null)
            {
                Debug.LogError(string.Format("{0}: No TimeLine script attached.", this.GetType()));
            }
            // assign callback for frame changes on timeline (on user drag)
            timeLine.Callback = this.setTime;

            // listen to ui changes to adjust mapping values
            UI.OnUIChanged.AddListener(timeLine.initMappingValues);

            //cache reference to keyframe Sphere container
            frameSphereContainer = GameObject.Find("FrameSphereContainer");

            // cache key prefab
            keySpherePrefab = Resources.Load <GameObject>("VPET/Prefabs/KeySphere");
            if (keySpherePrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cant find Resources: KeySphere.", this.GetType()));
            }

            //cache reference to dragArea and deactivate it
            //dragArea = timeline.transform.GetChild(7).gameObject;
            //dragArea.SetActive(false);

            //cache Reference to animation data
            animData = AnimationData.Data;

            //initalize keyframe list
            keyframeSpheres = new List <GameObject>();

            //initalize animated scene objects list
            if (animatedObjects == null)
            {
                animatedObjects = new List <SceneObject>();
            }

            //initialize animation layers
            for (int i = 0; i < animationLayers.Length; ++i)
            {
                animationLayers[i] = new AnimationLayer();
            }

            //initalize lineRenderer
            lineRenderer          = gameObject.AddComponent <LineRenderer>();
            lineRenderer.material = Resources.Load <Material>("VPET/Materials/LineRendererMaterial");
            lineRenderer.SetColors(lineColor, lineColor);
            lineRenderer.SetWidth(0.02f, 0.02f);
            lineRenderer.useWorldSpace = true;
            lineRenderer.SetVertexCount(0);
        }
Ejemplo n.º 2
0
        //!
        //! Use this for initialization
        //!
        void Awake()
        {
            updateAppearance = true;

            //cache reference to main Controller
            mainController = GameObject.Find("MainController").GetComponent <MainController>();

            //cache reference to animation timeline
            timeLineObject = GameObject.Find("GUI/Canvas/UI/TimeLine");
            if (timeLineObject == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find TimeLine (GUI/Canvas/UI/TimeLine).", this.GetType()));
            }

            timeLine = timeLineObject.GetComponent <TimeLineWidget>();
            if (timeLine == null)
            {
                Debug.LogError(string.Format("{0}: No TimeLine script attached.", this.GetType()));
            }
            // assign callback for frame changes on timeline (on user drag)
            timeLine.Callback = this.setTime;

            //cache reference to keyframe Sphere container
            if (!frameSphereContainer)
            {
                frameSphereContainer = new GameObject("FrameSphereContainer");
                frameSphereContainer.transform.parent        = GameObject.Find("Scene").transform;
                frameSphereContainer.transform.localPosition = Vector3.zero;
                frameSphereContainer.transform.localRotation = Quaternion.identity;
                frameSphereContainer.transform.localScale    = Vector3.one;
            }

            // cache key prefab
            keySpherePrefab = Resources.Load <GameObject>("VPET/Prefabs/KeySphere");
            if (keySpherePrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cant find Resources: KeySphere.", this.GetType()));
            }

            //cache reference to dragArea and deactivate it
            //dragArea = timeline.transform.GetChild(7).gameObject;
            //dragArea.SetActive(false);

            //cache Reference to animation data
            animData = AnimationData.Data;

            //initalize keyframe list
            keyframeSpheres = new List <GameObject>();

            //initalize animated scene objects list
            if (animatedObjects == null)
            {
                animatedObjects = new List <SceneObject>();
            }

            //initialize animation layers
            for (int i = 0; i < animationLayers.Length; ++i)
            {
                animationLayers[i] = new AnimationLayer();
            }

            //initalize lineRenderer
            lineRenderer               = gameObject.AddComponent <LineRenderer>();
            lineRenderer.material      = Resources.Load <Material>("VPET/Materials/LineRendererMaterial");
            lineRenderer.useWorldSpace = true;
            lineRenderer.positionCount = 0;
        }