예제 #1
0
 public override void Initialize(CUIFormScript formScript)
 {
     if (this.m_isInitialized)
     {
         return;
     }
     base.Initialize(formScript);
     this.m_axisRectTransform = (base.gameObject.transform.FindChild("Axis") as RectTransform);
     if (this.m_axisRectTransform != null)
     {
         this.m_axisRectTransform.anchoredPosition = Vector2.zero;
         this.m_axisOriginalScreenPosition         = CUIUtility.WorldToScreenPoint(this.m_belongedFormScript.GetCamera(), this.m_axisRectTransform.position);
         this.m_axisImage           = this.m_axisRectTransform.gameObject.GetComponent <Image>();
         this.m_cursorRectTransform = (this.m_axisRectTransform.FindChild("Cursor") as RectTransform);
         if (this.m_cursorRectTransform != null)
         {
             this.m_cursorRectTransform.anchoredPosition = Vector2.zero;
             this.m_cursorImage = this.m_cursorRectTransform.gameObject.GetComponent <Image>();
         }
         this.AxisFadeout();
     }
     this.m_borderRectTransform = (base.gameObject.transform.FindChild("Axis/Border") as RectTransform);
     if (this.m_borderRectTransform != null)
     {
         this.m_borderCanvasGroup = this.m_borderRectTransform.gameObject.GetComponent <CanvasGroup>();
         if (this.m_borderCanvasGroup == null)
         {
             this.m_borderCanvasGroup = this.m_borderRectTransform.gameObject.AddComponent <CanvasGroup>();
         }
         this.HideBorder();
     }
 }
예제 #2
0
 public void Hide(enFormHideFlag hideFlag = enFormHideFlag.HideByCustom, bool dispatchVisibleChangedEvent = true)
 {
     if (this.m_alwaysKeepVisible)
     {
         return;
     }
     this.m_hideFlags |= (int)hideFlag;
     if (this.m_hideFlags == 0 || this.m_isHided)
     {
         return;
     }
     this.m_isHided = true;
     if (this.m_canvas != null)
     {
         this.m_canvas.enabled = false;
     }
     if (this.m_graphicRaycaster)
     {
         this.m_graphicRaycaster.enabled = false;
     }
     for (int i = 0; i < this.m_relatedScenes.get_Count(); i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_relatedScenes.get_Item(i), 31);
         this.SetSceneCameraEnable(i, false);
     }
     this.HideComponent();
     if (this.m_revertToHideEvent != enUIEventID.None)
     {
         Singleton <CUIEventManager> .GetInstance().DispatchUIEvent(this.m_revertToHideEvent);
     }
     if (dispatchVisibleChangedEvent)
     {
         this.DispatchVisibleChangedEvent();
     }
 }
예제 #3
0
        public static T GetComponentInChildren <T>(GameObject go) where T : Component
        {
            if (go == null)
            {
                return((T)((object)null));
            }
            T t = go.GetComponent <T>();

            if (t != null)
            {
                return(t);
            }
            Transform transform  = go.transform;
            int       childCount = transform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                t = CUIUtility.GetComponentInChildren <T>(transform.GetChild(i).gameObject);
                if (t != null)
                {
                    return(t);
                }
            }
            return((T)((object)null));
        }
예제 #4
0
 public void Appear(enFormHideFlag hideFlag = enFormHideFlag.HideByCustom, bool dispatchVisibleChangedEvent = true)
 {
     if (this.m_alwaysKeepVisible)
     {
         return;
     }
     this.m_hideFlags &= (int)(~(int)hideFlag);
     if (this.m_hideFlags != 0 || !this.m_isHided)
     {
         return;
     }
     this.m_isHided = false;
     if (this.m_canvas != null)
     {
         this.m_canvas.enabled      = true;
         this.m_canvas.sortingOrder = this.m_sortingOrder;
     }
     if (this.m_graphicRaycaster && !this.m_disableInput)
     {
         this.m_graphicRaycaster.enabled = true;
     }
     for (int i = 0; i < this.m_relatedScenes.get_Count(); i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_relatedScenes.get_Item(i), 18);
         this.SetSceneCameraEnable(i, true);
     }
     this.AppearComponent();
     this.DispatchRevertVisibleFormEvent();
     if (dispatchVisibleChangedEvent)
     {
         this.DispatchVisibleChangedEvent();
     }
 }
예제 #5
0
 public void Appear(enFormHideFlag hideFlag = 1, bool dispatchVisibleChangedEvent = true)
 {
     if (!this.m_alwaysKeepVisible)
     {
         this.m_hideFlags &= ~hideFlag;
         if ((this.m_hideFlags == 0) && this.m_isHided)
         {
             this.m_isHided = false;
             if (this.m_canvas != null)
             {
                 this.m_canvas.enabled      = true;
                 this.m_canvas.sortingOrder = this.m_sortingOrder;
             }
             if ((this.m_graphicRaycaster != null) && !this.m_disableInput)
             {
                 this.m_graphicRaycaster.enabled = true;
             }
             for (int i = 0; i < this.m_relatedScenes.Count; i++)
             {
                 CUIUtility.SetGameObjectLayer(this.m_relatedScenes[i], 0x12);
                 this.SetSceneCameraEnable(i, true);
             }
             this.AppearComponent();
             this.DispatchRevertVisibleFormEvent();
             if (dispatchVisibleChangedEvent)
             {
                 this.DispatchVisibleChangedEvent();
             }
         }
     }
 }
예제 #6
0
 public void Hide(enFormHideFlag hideFlag = 1, bool dispatchVisibleChangedEvent = true)
 {
     if (!this.m_alwaysKeepVisible)
     {
         this.m_hideFlags |= hideFlag;
         if ((this.m_hideFlags != 0) && !this.m_isHided)
         {
             this.m_isHided = true;
             if (this.m_canvas != null)
             {
                 this.m_canvas.enabled = false;
             }
             if (this.m_graphicRaycaster != null)
             {
                 this.m_graphicRaycaster.enabled = false;
             }
             for (int i = 0; i < this.m_relatedScenes.Count; i++)
             {
                 CUIUtility.SetGameObjectLayer(this.m_relatedScenes[i], 0x1f);
                 this.SetSceneCameraEnable(i, false);
             }
             this.HideComponent();
             if (this.m_revertToHideEvent != enUIEventID.None)
             {
                 Singleton <CUIEventManager> .GetInstance().DispatchUIEvent(this.m_revertToHideEvent);
             }
             if (dispatchVisibleChangedEvent)
             {
                 this.DispatchVisibleChangedEvent();
             }
         }
     }
 }
예제 #7
0
 public void ChangeScreenPositionToWorld(GameObject gameObject, ref Vector2 screenPosition)
 {
     if (gameObject != null)
     {
         gameObject.transform.position = CUIUtility.ScreenToWorldPoint(this.m_renderCamera, screenPosition, 100f);
     }
 }
예제 #8
0
 public static void SetGameObjectLayer(GameObject gameObject, int layer)
 {
     gameObject.layer = layer;
     for (int i = 0; i < gameObject.transform.childCount; i++)
     {
         CUIUtility.SetGameObjectLayer(gameObject.transform.GetChild(i).gameObject, layer);
     }
 }
예제 #9
0
 public void ResetAxis()
 {
     this.m_axisRectTransform.anchoredPosition   = Vector2.zero;
     this.m_cursorRectTransform.anchoredPosition = Vector2.zero;
     this.m_axisOriginalScreenPosition           = CUIUtility.WorldToScreenPoint(this.m_belongedFormScript.GetCamera(), this.m_axisRectTransform.position);
     this.m_axisCurrentScreenPosition            = Vector2.zero;
     this.m_axisTargetScreenPosition             = Vector2.zero;
     this.UpdateAxis(Vector2.zero);
     this.AxisFadeout();
 }
예제 #10
0
 public override void Hide()
 {
     base.Hide();
     this.m_renderCamera.enabled = false;
     for (int i = 0; i < this.m_3DGameObjects.Count; i++)
     {
         st3DGameObject obj2 = this.m_3DGameObjects[i];
         CUIUtility.SetGameObjectLayer(obj2.m_gameObject, 0x1f);
     }
 }
예제 #11
0
 public override void Appear()
 {
     base.Appear();
     this.m_renderCamera.enabled = true;
     for (int i = 0; i < this.m_3DGameObjects.Count; i++)
     {
         st3DGameObject obj2 = this.m_3DGameObjects[i];
         CUIUtility.SetGameObjectLayer(obj2.m_gameObject, s_cameraLayers[(int)this.m_imageLayer]);
     }
 }
예제 #12
0
 public static void SetGenderImageSprite(Image image, byte bGender)
 {
     if (bGender == 1)
     {
         CUIUtility.SetImageSprite(image, string.Format("{0}icon/Ico_boy.prefab", "UGUI/Sprite/Dynamic/"), null, true, false, false, false);
     }
     else if (bGender == 2)
     {
         CUIUtility.SetImageSprite(image, string.Format("{0}icon/Ico_girl.prefab", "UGUI/Sprite/Dynamic/"), null, true, false, false, false);
     }
 }
예제 #13
0
 public override void Appear()
 {
     base.Appear();
     if (this.m_renderCamera != null)
     {
         this.m_renderCamera.enabled = true;
     }
     for (int i = 0; i < this.m_3DGameObjects.get_Count(); i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_3DGameObjects.get_Item(i).m_gameObject, CUI3DImageScript.s_cameraLayers[(int)this.m_imageLayer]);
     }
 }
예제 #14
0
 public override void Hide()
 {
     base.Hide();
     if (this.m_renderCamera != null)
     {
         this.m_renderCamera.enabled = false;
     }
     for (int i = 0; i < this.m_3DGameObjects.get_Count(); i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_3DGameObjects.get_Item(i).m_gameObject, 31);
     }
 }
예제 #15
0
        public void OpenTips(string strContent, bool bReadDatabin = false, float timeDuration = 1.5f, GameObject referenceGameObject = null, params object[] replaceArr)
        {
            string text = strContent;

            if (bReadDatabin)
            {
                text = Singleton <CTextManager> .GetInstance().GetText(strContent);
            }
            if (!string.IsNullOrEmpty(text))
            {
                if (replaceArr != null)
                {
                    try
                    {
                        text = string.Format(text, replaceArr);
                    }
                    catch (FormatException exception)
                    {
                        object[] inParameters = new object[] { text, exception.Message };
                        DebugHelper.Assert(false, "Format Exception for string \"{0}\", Exception:{1}", inParameters);
                    }
                }
                CUIFormScript script = Singleton <CUIManager> .GetInstance().OpenForm("UGUI/Form/Common/Form_Tips.prefab", false, false);

                if (script != null)
                {
                    script.gameObject.transform.Find("Panel/Text").GetComponent <Text>().text = text;
                }
                if ((script != null) && (referenceGameObject != null))
                {
                    RectTransform component  = referenceGameObject.GetComponent <RectTransform>();
                    RectTransform transform2 = script.gameObject.transform.Find("Panel") as RectTransform;
                    if ((component != null) && (transform2 != null))
                    {
                        Vector3[] fourCornersArray = new Vector3[4];
                        component.GetWorldCorners(fourCornersArray);
                        float   num         = Math.Abs((float)(CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[2]).x - CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[0]).x));
                        float   num2        = Math.Abs((float)(CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[2]).y - CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[0]).y));
                        Vector2 screenPoint = new Vector2(CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[0]).x + (num / 2f), CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, fourCornersArray[0]).y + (num2 / 2f));
                        transform2.position = CUIUtility.ScreenToWorldPoint(null, screenPoint, transform2.position.z);
                    }
                }
                if (script != null)
                {
                    CUITimerScript script2 = script.gameObject.transform.Find("Timer").GetComponent <CUITimerScript>();
                    script2.EndTimer();
                    script2.m_totalTime = timeDuration;
                    script2.StartTimer();
                }
                Singleton <CSoundManager> .instance.PostEvent("UI_Click", null);
            }
        }
예제 #16
0
        public static CUIFormScript GetFormScript(Transform transform)
        {
            if (transform == null)
            {
                return(null);
            }
            CUIFormScript component = transform.gameObject.GetComponent <CUIFormScript>();

            if (component != null)
            {
                return(component);
            }
            return(CUIUtility.GetFormScript(transform.parent));
        }
예제 #17
0
        public static void GetComponentsInChildren <T>(GameObject go, T[] components, ref int count) where T : Component
        {
            T component = go.GetComponent <T>();

            if (component != null)
            {
                components[count] = component;
                count++;
            }
            for (int i = 0; i < go.transform.childCount; i++)
            {
                CUIUtility.GetComponentsInChildren <T>(go.transform.GetChild(i).gameObject, components, ref count);
            }
        }
예제 #18
0
 private void SetUnCheckToggleEnable(bool enable)
 {
     for (int i = 0; i < this.m_elementAmount; i++)
     {
         if (!this.m_multiSelected[i])
         {
             Toggle component = this.m_elementScripts[i].gameObject.transform.GetComponent <Toggle>();
             if (component)
             {
                 this.GetOrgToggleTextColor(component);
                 CUIUtility.SetToggleEnable(component, enable, this.m_elementScripts[i].m_orgToggleTextColor);
             }
         }
     }
 }
예제 #19
0
 public static void SetImageSprite(Image image, string prefabPath, CUIFormScript formScript, bool loadSync = true, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false, bool isShowSpecMatrial = false)
 {
     if (image == null)
     {
         return;
     }
     if (loadSync)
     {
         CUIUtility.SetImageSprite(image, CUIUtility.GetSpritePrefeb(prefabPath, needCached, unloadBelongedAssetBundleAfterLoaded), isShowSpecMatrial);
     }
     else
     {
         image.color = new Color(image.color.r, image.color.g, image.color.b, 0f);
         formScript.AddASyncLoadedImage(image, prefabPath, needCached, unloadBelongedAssetBundleAfterLoaded, isShowSpecMatrial);
     }
 }
예제 #20
0
 private void UpdateAxisPosition()
 {
     if (this.m_axisCurrentScreenPosition != this.m_axisTargetScreenPosition)
     {
         Vector2 vector = this.m_axisTargetScreenPosition - this.m_axisCurrentScreenPosition;
         Vector2 b      = (this.m_axisTargetScreenPosition - this.m_axisCurrentScreenPosition) / 3f;
         if (vector.sqrMagnitude <= 1f)
         {
             this.m_axisCurrentScreenPosition = this.m_axisTargetScreenPosition;
         }
         else
         {
             this.m_axisCurrentScreenPosition += b;
         }
         this.m_axisRectTransform.position = CUIUtility.ScreenToWorldPoint(this.m_belongedFormScript.GetCamera(), this.m_axisCurrentScreenPosition, this.m_axisRectTransform.position.z);
     }
 }
예제 #21
0
 public void Appear()
 {
     this.m_isHided = false;
     if (this.m_canvas != null)
     {
         this.m_canvas.enabled      = true;
         this.m_canvas.sortingOrder = this.m_sortingOrder;
     }
     if ((this.m_graphicRaycaster != null) && !this.m_disableInput)
     {
         this.m_graphicRaycaster.enabled = true;
     }
     for (int i = 0; i < this.m_relatedScenes.Count; i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_relatedScenes[i], 0x12);
         this.SetSceneCameraEnable(i, true);
     }
     this.AppearComponent();
 }
예제 #22
0
 private void Initialize3DGameObjects()
 {
     for (int i = 0; i < base.gameObject.transform.childCount; i++)
     {
         GameObject gameObject = base.gameObject.transform.GetChild(i).gameObject;
         CUIUtility.SetGameObjectLayer(gameObject, s_cameraLayers[(int)this.m_imageLayer]);
         if (this.m_renderCamera.orthographic)
         {
             this.ChangeScreenPositionToWorld(gameObject, ref this.m_pivotScreenPosition);
         }
         st3DGameObject item = new st3DGameObject {
             m_path              = gameObject.name,
             m_gameObject        = gameObject,
             m_useGameObjectPool = false,
             m_protogenic        = true,
             m_bindPivot         = true
         };
         this.m_3DGameObjects.Add(item);
     }
     this.m_renderCamera.enabled = this.m_3DGameObjects.Count > 0;
 }
예제 #23
0
 private void Initialize3DGameObjects()
 {
     this.m_3DGameObjects.Clear();
     for (int i = 0; i < base.gameObject.transform.childCount; i++)
     {
         GameObject gameObject = base.gameObject.transform.GetChild(i).gameObject;
         CUIUtility.SetGameObjectLayer(gameObject, CUI3DImageScript.s_cameraLayers[(int)this.m_imageLayer]);
         if (this.m_renderCamera.orthographic)
         {
             this.ChangeScreenPositionToWorld(gameObject, ref this.m_pivotScreenPosition);
         }
         CUI3DImageScript.C3DGameObject c3DGameObject = new CUI3DImageScript.C3DGameObject();
         c3DGameObject.m_path              = gameObject.name;
         c3DGameObject.m_gameObject        = gameObject;
         c3DGameObject.m_useGameObjectPool = false;
         c3DGameObject.m_protogenic        = true;
         c3DGameObject.m_bindPivot         = true;
         this.m_3DGameObjects.Add(c3DGameObject);
     }
     this.m_renderCamera.enabled = (this.m_3DGameObjects.get_Count() > 0);
 }
예제 #24
0
        private void UpdateASyncLoadedImage()
        {
            if (this.m_asyncLoadedImages == null)
            {
                return;
            }
            bool flag = false;
            int  i    = 0;

            while (i < this.m_asyncLoadedImages.get_Count())
            {
                CUIFormScript.CASyncLoadedImage cASyncLoadedImage = this.m_asyncLoadedImages.get_Item(i);
                Image image = cASyncLoadedImage.m_image;
                if (image != null)
                {
                    GameObject gameObject = null;
                    string     prefabPath = cASyncLoadedImage.m_prefabPath;
                    if (!this.m_loadedSpriteDictionary.TryGetValue(prefabPath, ref gameObject) && !flag)
                    {
                        gameObject = CUIUtility.GetSpritePrefeb(prefabPath, cASyncLoadedImage.m_needCached, cASyncLoadedImage.m_unloadBelongedAssetBundleAfterLoaded);
                        this.m_loadedSpriteDictionary.Add(prefabPath, gameObject);
                        flag = true;
                    }
                    if (gameObject != null)
                    {
                        image.color = new Color(image.color.r, image.color.g, image.color.b, 1f);
                        image.SetSprite(gameObject, cASyncLoadedImage.m_isShowSpecMatrial);
                        this.m_asyncLoadedImages.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
                else
                {
                    this.m_asyncLoadedImages.RemoveAt(i);
                }
            }
        }
예제 #25
0
 public void Hide(bool dispatchHideEvent = true)
 {
     this.m_isHided = true;
     if (this.m_canvas != null)
     {
         this.m_canvas.enabled = false;
     }
     if (this.m_graphicRaycaster != null)
     {
         this.m_graphicRaycaster.enabled = false;
     }
     for (int i = 0; i < this.m_relatedScenes.Count; i++)
     {
         CUIUtility.SetGameObjectLayer(this.m_relatedScenes[i], 0x1f);
         this.SetSceneCameraEnable(i, false);
     }
     this.HideComponent();
     if (dispatchHideEvent)
     {
         this.DispatchHideFormEvent();
     }
 }
예제 #26
0
        public override void Initialize(CUIFormScript formScript)
        {
            if (this.m_isInitialized)
            {
                return;
            }
            base.Initialize(formScript);
            this.m_scrollRectScript = CUIUtility.GetComponentInChildren <ScrollRect>(base.gameObject);
            this.m_textScript       = ((!(this.m_scrollRectScript != null)) ? null : CUIUtility.GetComponentInChildren <Text>(this.m_scrollRectScript.gameObject));
            Transform transform = base.gameObject.transform.FindChild("Title");

            this.m_titleTextScript = ((!(transform != null)) ? null : CUIUtility.GetComponentInChildren <Text>(transform.gameObject));
            this.m_httpTextState   = enHttpTextState.Unload;
            if (this.m_loadingCover != null)
            {
                this.m_loadingCover.CustomSetActive(true);
            }
            if (base.gameObject.activeInHierarchy && !string.IsNullOrEmpty(this.m_textUrl))
            {
                this.LoadText(this.m_textUrl);
            }
        }
예제 #27
0
        private void MoveAxis(Vector2 position, bool isDown)
        {
            if (isDown || (this.m_axisCurrentScreenPosition == Vector2.zero && this.m_axisTargetScreenPosition == Vector2.zero))
            {
                this.m_axisCurrentScreenPosition = this.GetFixAixsScreenPosition(position);
                this.m_axisTargetScreenPosition  = this.m_axisCurrentScreenPosition;
                DebugHelper.Assert(this.m_belongedFormScript != null);
                this.m_axisRectTransform.position = CUIUtility.ScreenToWorldPoint((!(this.m_belongedFormScript != null)) ? null : this.m_belongedFormScript.GetCamera(), this.m_axisCurrentScreenPosition, this.m_axisRectTransform.position.z);
            }
            Vector2 vector    = position - this.m_axisCurrentScreenPosition;
            Vector2 vector2   = vector;
            float   magnitude = vector.magnitude;
            float   num       = magnitude;

            if (this.m_belongedFormScript != null)
            {
                num       = this.m_belongedFormScript.ChangeScreenValueToForm(magnitude);
                vector2.x = this.m_belongedFormScript.ChangeScreenValueToForm(vector.x);
                vector2.y = this.m_belongedFormScript.ChangeScreenValueToForm(vector.y);
            }
            DebugHelper.Assert(this.m_cursorRectTransform != null);
            this.m_cursorRectTransform.anchoredPosition = ((num <= this.m_cursorDisplayMaxRadius) ? vector2 : (vector2.normalized * this.m_cursorDisplayMaxRadius));
            if (this.m_isAxisMoveable && num > this.m_cursorDisplayMaxRadius)
            {
                DebugHelper.Assert(this.m_belongedFormScript != null);
                this.m_axisTargetScreenPosition = this.m_axisCurrentScreenPosition + (position - CUIUtility.WorldToScreenPoint((!(this.m_belongedFormScript != null)) ? null : this.m_belongedFormScript.GetCamera(), this.m_cursorRectTransform.position));
                this.m_axisTargetScreenPosition = this.GetFixAixsScreenPosition(this.m_axisTargetScreenPosition);
            }
            if (num < this.m_cursorRespondMinRadius)
            {
                this.UpdateAxis(Vector2.zero);
            }
            else
            {
                this.UpdateAxis(vector);
            }
        }
예제 #28
0
 private void UpdateASyncLoadedImage()
 {
     if (this.m_asyncLoadedImages != null)
     {
         bool flag  = false;
         int  index = 0;
         while (index < this.m_asyncLoadedImages.Count)
         {
             Image image = this.m_asyncLoadedImages[index].m_image;
             if (image != null)
             {
                 GameObject obj2 = null;
                 if (!this.m_loadedSpriteDictionary.TryGetValue(this.m_asyncLoadedImages[index].m_prefabPath, out obj2) && !flag)
                 {
                     obj2 = CUIUtility.GetSpritePrefeb(this.m_asyncLoadedImages[index].m_prefabPath, this.m_asyncLoadedImages[index].m_needCached, this.m_asyncLoadedImages[index].m_unloadBelongedAssetBundleAfterLoaded);
                     this.m_loadedSpriteDictionary.Add(this.m_asyncLoadedImages[index].m_prefabPath, obj2);
                     flag = true;
                 }
                 if (obj2 != null)
                 {
                     image.color = new Color(image.color.r, image.color.g, image.color.b, 1f);
                     image.SetSprite(obj2);
                     this.m_asyncLoadedImages.RemoveAt(index);
                 }
                 else
                 {
                     index++;
                 }
             }
             else
             {
                 this.m_asyncLoadedImages.RemoveAt(index);
             }
         }
     }
 }
예제 #29
0
        public static void SetImageSprite(Image image, GameObject prefab, bool isShowSpecMatrial = false)
        {
            if (image == null)
            {
                return;
            }
            if (prefab == null)
            {
                image.sprite = null;
                return;
            }
            SpriteRenderer component = prefab.GetComponent <SpriteRenderer>();

            if (component != null)
            {
                image.sprite      = component.sprite;
                isShowSpecMatrial = false;
                if (isShowSpecMatrial && component.sharedMaterial != null && component.sharedMaterial.shader != null && !component.sharedMaterial.shader.name.Equals(CUIUtility.s_ui_defaultShaderName))
                {
                    float[] materailMaskPars = CUIUtility.GetMaterailMaskPars(image.material);
                    image.material = component.sharedMaterial;
                    image.material.shaderKeywords = component.sharedMaterial.shaderKeywords;
                    CUIUtility.SetMaterailMaskPars(materailMaskPars, image.material);
                }
                else if (isShowSpecMatrial)
                {
                    image.material = null;
                }
            }
            if (image is Image2)
            {
                SGameSpriteSettings component2 = prefab.GetComponent <SGameSpriteSettings>();
                Image2 image2 = image as Image2;
                image2.alphaTexLayout = ((!(component2 != null)) ? ImageAlphaTexLayout.None : component2.layout);
            }
        }
예제 #30
0
 public static void SetSprite(this Image image, string prefabPath, CUIFormScript formScript, bool loadSync = true, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false)
 {
     CUIUtility.SetImageSprite(image, prefabPath, formScript, loadSync, needCached, unloadBelongedAssetBundleAfterLoaded);
 }