Beispiel #1
0
        private void SetOneValue(string[] vs)
        {
            GameObject obj = UnityUiUtility.FindUIObject(currentObject, vs[0].Trim());

            if (obj != null)
            {
                Graphic gra = obj.GetComponent <Graphic>();
                if (gra != null)
                {
                    if (gra is Text)
                    {
                        ((Text)gra).text = vs[1].Trim();
                    }

                    if (gra is RawImage || gra is Image)
                    {
                        if (string.IsNullOrEmpty(vs[1]))
                        {
                            if (gra is RawImage)
                            {
                                ((RawImage)gra).texture = ResourceUtility.GetTransparentTexture();
                            }
                            if (gra is Image)
                            {
                                Texture2D tex = ResourceUtility.GetTransparentTexture();
                                ((Image)gra).sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
                            }
                        }
                        else
                        {
                            int    last       = vs[1].Trim().LastIndexOf("/");
                            string buddleName = vs[1].Trim().Substring(0, last);
                            string assetName  = vs[1].Trim().Substring(last + 1);
                            FreeUILoader.Load(gra, buddleName, assetName);
                        }
                    }
                }
            }
        }