コード例 #1
0
        NGUI2DRootPanel OnLoadRootUI(string uiName)
        {
            float      sTime = Time.realtimeSinceStartup;
            GameObject uiObj = Instantiate(mUIList[uiName]) as GameObject;

            uiObj.name = uiName;
            uiObj.SetActive(true);
            NGUI2DRootPanel ret = uiObj.GetComponent <NGUI2DRootPanel>();

            LogSys.Debug("~~~inst ui[" + uiName + "]used:" + (Time.realtimeSinceStartup - sTime).ToString());
            return(ret);
        }
コード例 #2
0
 public static UnityEngine.GameObject FindUIResTemplate(UIHlp.UI资源模板 wen)
 {
     if (!UIResList.ContainsKey((byte)wen))
     {
         NGUI2DRootPanel    uiRoot      = NGUI2DRootPanel.Inst;
         string             tempName    = UIViewTemplayePath + wen.ToString();
         UnityEngine.Object assetObject = UnityEngine.Resources.Load(tempName);
         if (null != assetObject)
         {
             UnityEngine.GameObject newObj = NGUITools.AddChild(uiRoot.gameObject, assetObject as UnityEngine.GameObject);
             assetObject = null;
             UnityEngine.Resources.UnloadUnusedAssets();
             UIResList.Add((byte)wen, newObj);
             return(newObj);
         }
         else
         {
             return(null);
         }
     }
     return(UIResList[(byte)wen]);
 }
コード例 #3
0
 void Update()
 {
     if (null != RootAnchor && null == RootAnchor.uiCamera)
     {
         NGUI2DRootPanel root = NGUI2DRootPanel.Inst;
         if (null == root || null == root.mUICamera || null == root.mUICamera.GetComponent <Camera>())
         {
             return;
         }
         Camera cam = root.mUICamera.GetComponent <Camera>();
         RootAnchor.uiCamera = cam;
         RootAnchor.enabled  = true;
         UIAnchor[] anchors = GetComponentsInChildren <UIAnchor>();
         for (int i = 0; i < anchors.Length; ++i)
         {
             anchors[i].uiCamera = cam;
             anchors[i].enabled  = true;
         }
     }
     UpdateBefore();
     if (mFadeIn)
     {
         RootPanel.alpha = 1.0f * (mFadeTime * mFadeSpeed);
         if (RootPanel.alpha > 1.0f)
         {
             RootPanel.alpha = 1.0f;
         }
         if (null != 关联淡入淡出面板)
         {
             for (int i = 0; i < 关联淡入淡出面板.Length; ++i)
             {
                 if (!忽略淡入关联面板.Contains(关联淡入淡出面板[i]))
                 {
                     关联淡入淡出面板[i].alpha = RootPanel.alpha;
                 }
             }
         }
         if (null != Background)
         {
             Color color1 = 淡出背景色;
             Color color2 = 淡入背景色;
             color1.r = color1.r + Mathf.Abs(color2.r - color1.r) * (mFadeTime * mFadeSpeed);
             color1.g = color1.g + Mathf.Abs(color2.g - color1.g) * (mFadeTime * mFadeSpeed);
             color1.b = color1.b + Mathf.Abs(color2.b - color1.b) * (mFadeTime * mFadeSpeed);
             color1.a = color1.a + Mathf.Abs(color2.a - color1.a) * (mFadeTime * mFadeSpeed);
             if (color1.r > color2.r)
             {
                 color1.r = color2.r;
             }
             if (color1.g > color2.g)
             {
                 color1.g = color2.g;
             }
             if (color1.b > color2.b)
             {
                 color1.b = color2.b;
             }
             if (color1.a > color2.a)
             {
                 color1.a = color2.a;
             }
             Background.color = color1;
             Background.alpha = Background.color.a;
             if (color1.r >= color2.r && color1.g >= color2.g &&
                 color1.b >= color2.b && color1.a >= color2.a && RootPanel.alpha >= 1)
             {
                 OnFadeOvered(true);
             }
         }
         else if (RootPanel.alpha >= 1)
         {
             OnFadeOvered(true);
         }
         mFadeTime += Time.deltaTime;
     }
     else if (mFadeOut)
     {
         RootPanel.alpha = 1.0f - mFadeTime * mFadeSpeed;
         if (RootPanel.alpha < 0)
         {
             RootPanel.alpha = 0;
         }
         if (null != 关联淡入淡出面板)
         {
             for (int i = 0; i < 关联淡入淡出面板.Length; ++i)
             {
                 关联淡入淡出面板[i].alpha = RootPanel.alpha;
             }
         }
         if (null != Background)
         {
             Color color1 = 淡入背景色;
             Color color2 = 淡出背景色;
             color1.r = color1.r - Mathf.Abs(color2.r - color1.r) * (mFadeTime * mFadeSpeed);
             color1.g = color1.g - Mathf.Abs(color2.g - color1.g) * (mFadeTime * mFadeSpeed);
             color1.b = color1.b - Mathf.Abs(color2.b - color1.b) * (mFadeTime * mFadeSpeed);
             color1.a = color1.a - Mathf.Abs(color2.a - color1.a) * (mFadeTime * mFadeSpeed);
             if (color1.r < color2.r)
             {
                 color1.r = color2.r;
             }
             if (color1.g < color2.g)
             {
                 color1.g = color2.g;
             }
             if (color1.b < color2.b)
             {
                 color1.b = color2.b;
             }
             if (color1.a < color2.a)
             {
                 color1.a = color2.a;
             }
             Background.color = color1;
             Background.alpha = Background.color.a;
             if (color1.r <= color2.r && color1.g <= color2.g &&
                 color1.b <= color2.b && color1.a <= color2.a && RootPanel.alpha <= 0)
             {
                 OnFadeOvered(false);
             }
         }
         else if (RootPanel.alpha <= 0)
         {
             OnFadeOvered(false);
         }
         mFadeTime += Time.deltaTime;
     }
     else if (mFadeOuted)
     {
         OnFadeOuted();
     }
     UpdateAfter();
 }