Exemple #1
0
        /// <summary>
        /// 渐渐消失
        /// </summary>
        /// <param name="element"></param>
        /// <param name="duration"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static List <TweenLite> FadeOut(this UIElement element, float duration, Action callback = null)
        {
            var all = element.GetAlphableInterfaces();

            float[] targetAlpha = new float[all.Count];
            for (int i = 0; i < all.Count; i++)
            {
                targetAlpha[i] = all[i].Alpha;
            }

            List <TweenLite> tl = new List <TweenLite>(all.Count);

            for (int i = 0; i < all.Count; i++)
            {
                int index = i;

                var t = TweenLite.To(targetAlpha[index], 0, duration, Linear.EaseIn, v =>
                {
                    all[index].Alpha = v;
                }, () =>
                {
                    //只有在最后一个才回调
                    if (index == all.Count - 1)
                    {
                        callback?.Invoke();
                    }
                });

                tl.Add(t);
            }

            return(tl);
        }
        void CreateRect()
        {
            GameObject   obj          = new GameObject("Rect");
            MeshFilter   meshFilter   = obj.AddComponent <MeshFilter>();
            MeshRenderer meshRenderer = obj.AddComponent <MeshRenderer>();


            Vector3[] vertices  = new Vector3[4];
            int[]     triangles = new int[6];


            vertices[0].Set(0, 0, 0);
            vertices[1].Set(0, 1, 0);
            vertices[2].Set(1, 1, 0);
            vertices[3].Set(1, 0, 0);

            triangles[0] = 0;
            triangles[1] = 1;
            triangles[2] = 2;

            triangles[3] = 0;
            triangles[4] = 2;
            triangles[5] = 3;

            meshFilter.mesh.vertices  = vertices;
            meshFilter.mesh.triangles = triangles;

            TweenLite.To(1, 3, 3000, Linear.EaseIn, v =>
            {
                Debug.Log(v.ToString());

                vertices[3].Set(v, 0, 0);
                meshFilter.mesh.vertices = vertices;
            });
        }
        private void RunTaskAsync()
        {
            string name = NameSimulation.GetRandomChinesePersonalName(2);

            for (int i = 0; i < 10; i++)
            {
                int    idx    = i;
                Thread thread = new Thread(() =>
                {
                    TweenLite.To(0, 10, 2000, Linear.EaseIn, v =>
                    {
                        cube.transform.position = new Vector3(0, 0, v);
                    });
                });
                thread.Start();
            }
        }
        /// <summary>
        /// 内容右移
        /// </summary>
        public void MoveRight()
        {
            //Log.Info($"MoveRight  currentCellIndex:{currentCellIndex}    targetCellIndex:{currentCellIndex - 1}");

            if (currentCellIndex - 1 < 0)
            {
                return;
            }

            float from = content.x;
            float to   = -(currentCellIndex - 1) * cellWidth;

            currentCellIndex--;

            tl?.Release();
            tl = TweenLite.To(from, to, Duration, Cubic.EaseOut, v =>
            {
                content.x = v;
            });

            RefreshArrowState();
        }
        /// <summary>
        /// 内容左移
        /// </summary>
        public void MoveLeft()
        {
            //Log.Info($"MoveLeft  currentCellIndex:{currentCellIndex}    targetCellIndex:{currentCellIndex + 1}    ShownCellCount:{ShownCellCount}    maxCellCount:{maxCellCount}");

            if (currentCellIndex + ShownCellCount >= maxCellCount)
            {
                return;
            }

            float from = content.x;
            float to   = -(currentCellIndex + 1) * cellWidth;

            currentCellIndex++;

            tl?.Release();
            tl = TweenLite.To(from, to, Duration, Cubic.EaseOut, v =>
            {
                content.x = v;
            });

            RefreshArrowState();
        }