Ejemplo n.º 1
0
        public void ViewShortClipWithClipInFromNearAtBeginning()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 0.05, //3  frames
                TimeScale             = 1,
                ClipIn                = 0.05,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 0.05,
                VisibleLocalEndTime   = 0.0834165304899216,
                VisibleRect           = new Rect()
                {
                    x      = 0,
                    y      = 1,
                    width  = 263,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 2);
            Assert.AreEqual(0, drawList[0].DrawRect.x, EPSILON);
            Assert.AreEqual(0.05, drawList[0].LocalTime, EPSILON);

            float xDiff = drawList[1].DrawRect.x - drawList[0].DrawRect.x;

            Assert.AreEqual(131.1726, xDiff, EPSILON);
        }
Ejemplo n.º 2
0
        public void ViewScaledClipWithClipInFromNearAtEnd()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 200,
                TimeScale             = 0.5,
                ClipIn                = 10,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 109.956161499023,
                VisibleLocalEndTime   = 110,
                VisibleRect           = new Rect()
                {
                    x      = 1849484.00f,
                    y      = 1,
                    width  = 811,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 2);
            Assert.AreEqual(1849524.125, drawList[0].DrawRect.x, EPSILON);
            Assert.AreEqual(109.95833333333334, drawList[0].LocalTime, EPSILON);

            float xDiff = drawList[1].DrawRect.x - drawList[0].DrawRect.x;

            Assert.AreEqual(154.125, xDiff, EPSILON);
        }
Ejemplo n.º 3
0
        public void ViewShortClipFromNearAtEnd()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 0.1, //6 frames
                TimeScale             = 1,
                ClipIn                = 0,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 0.0751406848430634,
                VisibleLocalEndTime   = 0.1,
                VisibleRect           = new Rect()
                {
                    x      = 1435,
                    y      = 1,
                    width  = 475,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 1);
            Assert.AreEqual(1591.54126f, drawList[0].DrawRect.x, EPSILON);
            Assert.AreEqual(0.08333, drawList[0].LocalTime, EPSILON);
        }
Ejemplo n.º 4
0
        public void ViewScaledClipFromNearAtBeginning()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 30, //1800 frames
                TimeScale             = 1,
                ClipIn                = 0,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 29.9543800354004,
                VisibleLocalEndTime   = 30,
                VisibleRect           = new Rect()
                {
                    x      = 276922,
                    y      = 1,
                    width  = 422,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 2);
            Assert.AreEqual(276881.4687f, drawList[0].DrawRect.x, EPSILON);
            Assert.AreEqual(29.95f, drawList[0].LocalTime, EPSILON);

            float xDiff = drawList[1].DrawRect.x - drawList[0].DrawRect.x;

            Assert.AreEqual(154.187f, xDiff, EPSILON);
        }
Ejemplo n.º 5
0
        public void ViewScaledClipWithClipInFromFar()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 0.25, //15  frames
                TimeScale             = 1,
                ClipIn                = 0.25,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 0.25,
                VisibleLocalEndTime   = 0.50,
                VisibleRect           = new Rect()
                {
                    x      = 0,
                    y      = 1,
                    width  = 652,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 2);
            Assert.AreEqual(0f, drawList[0].DrawRect.x, EPSILON);
            Assert.AreEqual(0.25, drawList[0].LocalTime, EPSILON);

            float xDiff = drawList[1].DrawRect.x - drawList[0].DrawRect.x;

            Assert.AreEqual(43.46667, xDiff, EPSILON);
        }
Ejemplo n.º 6
0
        public void ViewShortClipFromNearAtBeginning()
        {
            PreviewClipInfo clipInfo = new PreviewClipInfo()
            {
                Duration              = 0.1, //6 frames
                TimeScale             = 1,
                ClipIn                = 0,
                FramePerSecond        = 60,
                ImageDimensionRatio   = 1.684f,
                VisibleLocalStartTime = 0,
                VisibleLocalEndTime   = 0.1,
                VisibleRect           = new Rect()
                {
                    x      = 0,
                    y      = 1,
                    width  = 722,
                    height = 25,
                },
            };
            List <PreviewDrawInfo> drawList = new List <PreviewDrawInfo>();

            PreviewUtility.EnumeratePreviewImages(ref clipInfo, (PreviewDrawInfo drawInfo) => {
                drawList.Add(drawInfo);
            });

            Assert.GreaterOrEqual(drawList.Count, 1);
            Assert.AreEqual(0f, drawList[0].DrawRect.x);
            Assert.AreEqual(0f, drawList[0].LocalTime);

            float xDiff = drawList[1].DrawRect.x - drawList[0].DrawRect.x;

            Assert.AreEqual(120.3333f, xDiff, EPSILON);
        }
Ejemplo n.º 7
0
 public void Cleanup()
 {
     if (PreviewUtility != null)
     {
         PreviewUtility.Cleanup();
         PreviewUtility = null;
     }
 }
Ejemplo n.º 8
0
        public void InitInstance(GameObject go)
        {
            InitPreviewScene();

            if (go != null && go.transform.GetComponentsInChildren <MeshRenderer>().Length > 0)
            {
                if (PreviewObjectInstance != null)
                {
                    DestroyObject(PreviewObjectInstance);
                }

                PreviewObjectInstance = PreviewUtility.InstantiatePrefabInScene(go);

                SetScaleGO(PreviewObjectInstance);
            }
        }
Ejemplo n.º 9
0
        private void SetCameraSettings()
        {
            PreviewCamera = PreviewUtility.camera;

            GameObject tempCameraContainer = new GameObject();

            PreviewUtility.AddSingleGO(tempCameraContainer);
            CameraContainer = tempCameraContainer;
            CameraContainer.transform.localRotation = Quaternion.Euler(-19, 309, 0);
            PreviewCamera.transform.SetParent(CameraContainer.transform);

            PreviewCamera.cameraType              = CameraType.Preview;
            PreviewCamera.clearFlags              = CameraClearFlags.SolidColor;
            PreviewCamera.backgroundColor         = Color.white;
            PreviewCamera.fieldOfView             = 30.0f;
            PreviewCamera.transform.localPosition = new Vector3(0, 0, 4);
            PreviewCamera.transform.LookAt(Vector3.zero);
            PreviewCamera.nearClipPlane = 0.1f;
            PreviewCamera.farClipPlane  = 100;
        }
Ejemplo n.º 10
0
        private void CreateArrows()
        {
            GameObject arrowMesh = Resources.Load <GameObject>("Models/direction arrow");

            Light1Arrow = PreviewUtility.InstantiatePrefabInScene(arrowMesh.gameObject);
            Light2Arrow = PreviewUtility.InstantiatePrefabInScene(arrowMesh.gameObject);

            Light1Arrow.transform.position = new Vector3(0, 0.75f, 0);
            Light2Arrow.transform.position = new Vector3(0, 0.75f, 0);

            Light1MeshRenderer = Light1Arrow.GetComponentInChildren <MeshRenderer>();
            Light2MeshRenderer = Light2Arrow.GetComponentInChildren <MeshRenderer>();

            Light1MeshRenderer.sharedMaterial = new Material(Shader.Find("Standard"));
            Light2MeshRenderer.sharedMaterial = new Material(Shader.Find("Standard"));

            Light1MeshRenderer.sharedMaterial.color = Color.green;
            Light2MeshRenderer.sharedMaterial.color = Color.yellow;

            Light1MeshRenderer.enabled = false;
            Light2MeshRenderer.enabled = false;
        }