예제 #1
0
        public override void OnInspectorGUI()
        {
            Decorate widget = target as Decorate;

            if (GUILayout.Button("加载外部图片", GUILayout.Height(30)))
            {
                UIEditorHelper.SelectPicForDecorate(widget);
            }
        }
예제 #2
0
        public static void CreateDecorate()
        {
            if (Selection.activeTransform != null)
            {
                Canvas canvas = Selection.activeTransform.GetComponentInParent <Canvas>();
                if (canvas != null)
                {
                    Decorate decor = CreateEmptyDecorate(canvas.transform);
                    Selection.activeTransform = decor.transform;

                    if (Configure.OpenSelectPicDialogWhenAddDecorate)
                    {
                        bool isSucceed = UIEditorHelper.SelectPicForDecorate(decor);
                        if (!isSucceed)
                        {
                            GameObject.DestroyImmediate(decor.gameObject);
                        }
                    }
                }
            }
        }
예제 #3
0
        public static void CreateDecorate(object o)
        {
            if (Selection.activeTransform != null)
            {
                Canvas canvas = Selection.activeTransform.GetComponentInParent <Canvas>();
                if (canvas != null)
                {
                    const string file_path       = Configure.ResAssetsPath + "Decorate.prefab";
                    GameObject   decorate_prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(file_path, typeof(UnityEngine.Object)) as GameObject;
                    GameObject   decorate        = GameObject.Instantiate(decorate_prefab) as GameObject;
                    decorate.transform.parent = canvas.transform;
                    RectTransform rectTrans = decorate.transform as RectTransform;
                    rectTrans.SetAsFirstSibling();
                    rectTrans.localPosition   = Vector3.zero;
                    Selection.activeTransform = rectTrans;

                    if (Configure.OpenSelectPicDialogWhenAddDecorate)
                    {
                        Decorate decor = rectTrans.GetComponent <Decorate>();
                        UIEditorHelper.SelectPicForDecorate(decor);
                    }
                }
            }
        }