public UINode DrawLayer(Layer layer, UINode parent)
        {
            UINode node = PSDImportUtility.InstantiateItem(PSDImporterConst.PREFAB_PATH_TOGGLE, layer.name, parent);// GameObject.Instantiate(temp) as UnityEngine.UI.Toggle;

            UnityEngine.UI.Toggle toggle = node.InitComponent <UnityEngine.UI.Toggle>();
            if (layer.images != null)
            {
                for (int imageIndex = 0; imageIndex < layer.images.Length; imageIndex++)
                {
                    Image  image     = layer.images[imageIndex];
                    string lowerName = image.name.ToLower();
                    if (lowerName.StartsWith("b_"))
                    {
                        PSDImportUtility.SetPictureOrLoadColor(image, toggle.targetGraphic);
                        PSDImportUtility.SetRectTransform(image, toggle.GetComponent <RectTransform>());
                    }
                    else if (lowerName.StartsWith("m_"))
                    {
                        PSDImportUtility.SetPictureOrLoadColor(image, toggle.graphic);
                    }
                    else
                    {
                        ctrl.DrawImage(image, node);
                    }
                }
            }
            return(node);
        }
Beispiel #2
0
        public void DrawLayer(Layer layer, GameObject parent)
        {
            //UnityEngine.UI.Toggle temp = AssetDatabase.LoadAssetAtPath(PSDImporterConst.PREFAB_PATH_TOGGLE, typeof(UnityEngine.UI.Toggle)) as UnityEngine.UI.Toggle;
            UnityEngine.UI.Toggle toggle = PSDImportUtility.LoadAndInstant <UnityEngine.UI.Toggle>(PSDImporterConst.ASSET_PATH_TOGGLE, layer.name, parent);// GameObject.Instantiate(temp) as UnityEngine.UI.Toggle;

            if (layer.image != null)
            {
                //for (int imageIndex = 0; imageIndex < layer.images.Length; imageIndex++)
                //{
                PSImage image = layer.image;

                if (image.name.ToLower().Contains("background"))
                {
                    if (image.imageSource == ImageSource.Common || image.imageSource == ImageSource.Custom)
                    {
                        string assetPath = PSDImportUtility.baseDirectory + image.name + PSDImporterConst.PNG_SUFFIX;
                        Sprite sprite    = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite)) as Sprite;
                        toggle.image.sprite = sprite;

                        RectTransform rectTransform = toggle.GetComponent <RectTransform>();
                        rectTransform.sizeDelta        = new Vector2(image.size.width, image.size.height);
                        rectTransform.anchoredPosition = new Vector2(image.position.x, image.position.y);

                        //rectTransform.SetParent(parent.transform, true);

                        //PosLoader posloader = toggle.gameObject.AddComponent<PosLoader>();
                        //posloader.worldPos = rectTransform.position;
                    }
                }
                else if (image.name.ToLower().Contains("mask"))
                {
                    if (image.imageSource == ImageSource.Common || image.imageSource == ImageSource.Custom)
                    {
                        string assetPath = PSDImportUtility.baseDirectory + image.name + PSDImporterConst.PNG_SUFFIX;
                        Sprite sprite    = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite)) as Sprite;
                        toggle.graphic.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    }
                }
                else
                {
                    ctrl.DrawImage(image, toggle.graphic.gameObject);
                }
                //}
            }
        }
Beispiel #3
0
        public void ChangeAgeLimit(UnityEngine.UI.Toggle toggle)
        {
            var toggleValue = toggle.GetComponent <ToggleNumericValue>();

            _artworkCreateController.UpdateAgeLimit((EnumAgeLimit)toggleValue.Value, toggle.isOn);
        }