Пример #1
0
        public static void SetPictureOrLoadColor(Image image, UnityEngine.UI.Graphic graph)
        {
            if (image.arguments != null && image.arguments.Length > 0)
            {
                if (image.arguments.Length > 0)
                {
                    Debug.Log(image.arguments[0]);
                    Color color;
                    if (ColorUtility.TryParseHtmlString(image.arguments[0], out color))
                    {
                        graph.color = color;
                    }
                }
            }
            else
            {
                string assetPath = PSDImportUtility.GetPicturePath(image);

                Object sprite = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite));
                if (sprite != null)
                {
                    if (graph is UnityEngine.UI.Image)
                    {
                        ((UnityEngine.UI.Image)graph).sprite = sprite as Sprite;
                    }
                    else if (graph is UnityEngine.UI.RawImage)
                    {
                        ((UnityEngine.UI.RawImage)graph).texture = sprite as Texture;
                    }
                }
                else
                {
                    Debug.Log("loading asset at path: " + assetPath + "\nname:" + image.name);
                }
            }
        }