コード例 #1
0
        public IEnumerator MoveTo(IMCUIBehaviour obj, Vector3 targetPos, float time, UnityAction callback = null)
        {
            float recordTime     = 0;    //记录
            float operationTime  = time; //运算
            float normalizedTime = 0;    //归一化

            RectTransform objRT     = obj.rectTransform;
            Vector3       beforePos = objRT.anchoredPosition3D;
            Vector3       vec       = targetPos - obj.anchoredPosition3D;

            while (normalizedTime <= 1)
            {
                recordTime              += Time.deltaTime;
                normalizedTime           = recordTime / operationTime;
                objRT.anchoredPosition3D = beforePos + vec * Mathf.Clamp01(normalizedTime);
                yield return(new WaitForEndOfFrame());
            }
            yield return(0);

            if (callback != null)
            {
                callback();
            }
            Destroy(this);
        }
コード例 #2
0
ファイル: IMCButton.cs プロジェクト: pilipalaBeng/UIFrame
 private IMCCanvas FindCanvas()
 {
     if (parentUi == null)
     {
         parentUi = this;
     }
     if (parentUi.GetComponent <IMCUIBehaviour>())
     {
         if (parentUi.GetComponent <IMCForm>() == null)
         {
             if (parentUi.parent == null)
             {
                 return(null);
             }
             parentUi = parentUi.parent;
             IMCCanvas canvas;
             if ((canvas = FindCanvas()) != null)
             {
                 return(canvas);
             }
         }
         else
         {
             return(parentUi.GetComponent <IMCForm>().canvas);
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
 /// <summary>
 /// 在使用TabView的AddControl函数需要调用这个函数
 /// </summary>
 /// <param name="content">contents数组中对应的元素</param>
 public void AddControl(IMCUIBehaviour content, IMCUIBehaviour control)//2017年7月21日16:02:13 添加函数
 {
     if (contents.Contains(content))
     {
         MAddControl(content, control);
     }
 }
コード例 #4
0
 public override void Initialize()
 {
     if (!m_Dynamic)
     {
         if (initialize)
         {
             return;
         }
         for (int i = 0; i < this.content.transform.childCount; i++)
         {
             IMCUIBehaviour imc = this.content.transform.GetChild(i).GetComponent <IMCUIBehaviour>();
             if (imc)
             {
                 imc.Initialize();
                 AddControl(imc);
                 IMCViewItem imcVI = imc.gameObject.GetComponent <IMCViewItem>();
                 if (imcVI != null)
                 {
                     imcVI.SetValue(imcVI, i);
                     imcVI.Index = i;
                 }
             }
         }
         initialize = true;
     }
 }
コード例 #5
0
        /// <summary>
        /// 推荐time设置为0.1f
        /// </summary>
        public IEnumerator ScaleTo(IMCUIBehaviour obj, Vector3 targetScale, float time, UnityAction callback = null)
        {
            float recordTime     = 0;
            float operationTime  = time;
            float normalizedTime = 0;

            Transform objTF         = obj.transform;
            Vector3   beforeSize    = obj.transform.localScale;
            Vector3   distanceScale = targetScale - obj.transform.localScale;

            while (normalizedTime <= 1)
            {
                recordTime              += Time.deltaTime;
                normalizedTime           = recordTime / operationTime;
                obj.transform.localScale = beforeSize + distanceScale * Mathf.Clamp01(normalizedTime);
                yield return(new WaitForEndOfFrame());
            }
            yield return(0);

            if (callback != null)
            {
                callback();
            }
            Destroy(this);
        }
コード例 #6
0
        //public IEnumerator ColorTo(IMCUIBehaviour obj,Color targetColor,float time,UnityAction callback=null)
        //{

        //}
        public IEnumerator AlphaTo(IMCUIBehaviour obj, float alpha, float time, UnityAction callback = null)
        {
            float recordTime     = 0;
            float operationTime  = time;
            float normalizedTime = 0;

            Transform objTF = obj.transform;

            float beforeAlpha   = obj.alpha;
            float distanceAlpha = alpha - obj.alpha;

            while (normalizedTime <= 1)
            {
                recordTime    += Time.deltaTime;
                normalizedTime = recordTime / operationTime;
                obj.alpha      = beforeAlpha + distanceAlpha * Mathf.Clamp01(normalizedTime);
                yield return(new WaitForEndOfFrame());
            }
            yield return(0);

            if (callback != null)
            {
                callback();
            }
            Destroy(this);
        }
コード例 #7
0
 /// <summary>
 /// 移除controls数组中对应的元素,并将其销毁(无论control是否在controls数组中,函数执行完毕后,都会销毁control对象)
 /// </summary>
 public virtual void RemoveControlAndDestroy(IMCUIBehaviour control)
 {
     if (control)
     {
         RemoveControl(control);
         control.UnInit();
     }
 }
コード例 #8
0
 /// <summary>
 /// 向controls数组添加一个IMCUIBehaviour 类型的组件(在tabView容器对象中的AddControl函数与当前AddControl函数不同)
 /// </summary>
 public virtual void AddControl(IMCUIBehaviour control)
 {
     control.Unparent();
     control.parent = this;
     control.rectTransform.SetParent(SetParentObject());
     control.transform.localScale = Vector3.one;//2017年5月25日14:34:46  添加 被添加 空间强制缩放大小为  1.1.1
     control.Initialize();
     controls.Add(control.gameObject);
 }
コード例 #9
0
 /// <summary>
 /// 移除controls数组中对应的元素
 /// </summary>
 public virtual void RemoveControl(IMCUIBehaviour control)
 {
     if (controls.Contains(control.gameObject))
     {
         control.parent = null;
         control.rectTransform.SetParent(null);
         controls.Remove(control.gameObject);
     }
 }
コード例 #10
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
 private void MAddControl(IMCUIBehaviour content, IMCUIBehaviour control)
 {
     control.Unparent();
     control.parent = this;
     control.transform.SetParent(content.transform);
     control.transform.localScale = Vector3.one;
     control.Initialize();
     base.AddControl(control);
     //GetChildControls().Add(control.gameObject);
 }
コード例 #11
0
        private void SetTexture2DToImageControl(IMCTaskLoader loader, Texture2D texture)
        {
            loader.loadState = LoadState.Complete;
            IMCUIBehaviour behaviour = loader.target;

            behaviour.SetTexture(texture);
            taskQueues.Remove(loader);
            loader.target.LoadComplete(loader);
            loader = null;
            NextTask();
        }
コード例 #12
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
        /// <summary>
        /// 在使用TabView的AddControl函数需要调用这个函数
        /// </summary>
        /// <param name="index">contents数组中的索引</param>
        public void AddControl(int index, IMCUIBehaviour control)
        {
            if (index < 0)
            {
                index = 0;
            }
            else if (index > contents.Count - 1)
            {
                index = contents.Count - 1;
            }

            MAddControl(contents[index], control);
        }
コード例 #13
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
        /// <summary>
        /// 在使用TabView的AddControl函数需要调用这个函数
        /// </summary>
        /// <param name="index">contents数组中的索引</param>
        public void AddControl(int index, IMCUIBehaviour control, Vector3 pos)
        {
            if (index < 0)
            {
                index = 0;
            }
            else if (index > contents.Count - 1)
            {
                index = contents.Count - 1;
            }

            MAddControl(contents[index], control);
            control.rectTransform.anchoredPosition3D = pos;
        }
コード例 #14
0
 public void RemoveStack(IMCUIBehaviour removeTarget)
 {
     if (targets.Count > 0)
     {
         for (int i = 0; i < targets.Count; i++)
         {
             if (targets[i].targetUis.Contains(removeTarget))
             {
                 targets.RemoveAt(i);
             }
         }
     }
     EliminateLayer();
 }
コード例 #15
0
        protected virtual void InitializeChildControls()//获取子物体
        {
            controls.Clear();
            bool tempToggle = true;

            //if (this.controlType == ControlType.IMCForm)
            //    this.form = (IMCForm)this;
            for (int i = 0; i < this.transform.childCount; i++)
            {
                IMCUIBehaviour imc = this.transform.GetChild(i).GetComponent <IMCUIBehaviour>();
                if (imc)
                {
                    //imc.form = this.form;
                    for (int k = 0; k < imc.GetComponents <IMCUIBehaviour>().Length; k++)
                    {
                        if (tempToggle)
                        {
                            if (imc.GetComponent <IMCUIContainer>())
                            {
                                if (imc.GetComponent <IMCScrollRect>())
                                {
                                    imc.GetComponent <IMCScrollRect>().Initialize();
                                }
                                else if (imc.GetComponent <IMCTabView>())
                                {
                                    imc.GetComponent <IMCTabView>().Initialize();
                                }
                                else
                                {
                                    imc.GetComponent <IMCUIContainer>().Initialize();
                                }
                                tempToggle = false;
                            }
                            else
                            {
                                imc.GetComponents <IMCUIBehaviour>()[k].Initialize();
                            }
                        }
                        imc.GetComponents <IMCUIBehaviour>()[k].parent = this;
                    }
                    tempToggle = true;
                    controls.Add(imc.gameObject);
                }
            }
        }
コード例 #16
0
 /// <summary>
 /// 搬家函数,将control对象从form容器对象中移至to容器对象中(如果control不存在于form容器controls数组中,程序不会执行任何操作。如果to容器是tabView类型容器,还需要指定tabViewIndex传入具体的tabcontent索引。)
 /// </summary>
 public static void MoveHouse(IMCUIBehaviour control, IMCUIContainer form, IMCUIContainer to, Vector2 pos, int tabViewIndex = 0)
 {
     if (form.GetChildControls().Contains(control))
     {
         form.RemoveControl(control);
         if (to.GetComponent <IMCTabView>())
         {
             to.GetComponent <IMCTabView>().AddControl(tabViewIndex, control, pos);
         }
         else if (to.GetComponent <IMCScrollRect>())
         {
             to.GetComponent <IMCScrollRect>().AddControl(control, pos);
         }
         else
         {
             to.AddControl(control, pos);
         }
     }
 }
コード例 #17
0
 protected override void InitializeChildControls()
 {
     RemoveAllControlAndDestroy();
     for (int i = 0; i < this.content.transform.childCount; i++)
     {
         IMCUIBehaviour imc = this.content.transform.GetChild(i).GetComponent <IMCUIBehaviour>();
         if (imc)
         {
             for (int j = 0; j < imc.GetComponents <IMCUIBehaviour>().Length; j++)
             {
                 if (imc.GetComponent <IMCUIContainer>())
                 {
                     imc.GetComponent <IMCUIContainer>().Initialize();
                 }
                 else
                 {
                     imc.GetComponent <IMCUIBehaviour>().Initialize();
                 }
             }
             AddControl(imc);
         }
     }
 }
コード例 #18
0
        public IEnumerator RotationTo(IMCUIBehaviour obj, Vector3 targetAngle, float time, UnityAction callbacke = null)
        {
            float recordTime     = 0;
            float operationTime  = time;
            float normalizedTime = 0;

            Vector3 beforeAngle   = obj.transform.eulerAngles;
            Vector3 distanceAngle = targetAngle - obj.transform.eulerAngles;

            while (normalizedTime <= 1)
            {
                recordTime               += Time.deltaTime;
                normalizedTime            = recordTime / operationTime;
                obj.transform.eulerAngles = beforeAngle + distanceAngle * Mathf.Clamp01(normalizedTime);
                yield return(new WaitForEndOfFrame());
            }
            yield return(0);

            if (callbacke != null)
            {
                callbacke();
            }
            Destroy(this);
        }
コード例 #19
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
 /// <summary>
 /// 在使用TabView的AddControl函数需要调用这个函数
 /// </summary>
 /// <param name="content">contents数组中对应的元素</param>
 public void AddControl(IMCUIBehaviour content, IMCUIBehaviour control, Vector2 pos)
 {
     MAddControl(content, control);
     control.rectTransform.anchoredPosition3D = pos;
 }
コード例 #20
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
 public override void AddControl(IMCUIBehaviour control)
 {
     AddControl(0, control);
 }
コード例 #21
0
ファイル: IMCTabView.cs プロジェクト: pilipalaBeng/UIFrame
 public override void AddControl(IMCUIBehaviour control, Vector3 pos)
 {
     AddControl(0, control, pos);
 }
コード例 #22
0
 /// <summary>
 /// 向controls数组添加一个IMCUIBehaviour类型的组件,并指定其Vector2类型的位置(在tabView容器对象中的AddControl函数与当前AddControl函数不同)
 /// </summary>
 public virtual void AddControl(IMCUIBehaviour control, Vector3 pos)
 {
     AddControl(control);
     control.rectTransform.anchoredPosition3D = pos;
 }