Example #1
0
        private void DrawCreateExtensions()
        {
            if (constructorExtensions.Length == 0)
            {
                return;
            }

            GUI.enabled = selectedGroup != null;

            bool doCreate;

            using (new EditorGUILayout.HorizontalScope(GUILayout.Height(30f)))
            {
                extIndex = EditorGUILayout.Popup(extLabel, extIndex, constructorNames);

                bool       canBuild  = false;
                GUIContent createBtn = GUIContent.none;
                if (extIndex > -1 && extIndex < constructorExtensions.Length)
                {
                    createBtn = constructorNames[extIndex];
                    canBuild  = constructorExtensions[extIndex].CanBuild(Selection.activeGameObject);
                }

                GUI.enabled = canBuild && selectedGroup != null;
                doCreate    = GUILayout.Button(createBtn, GUILayout.ExpandHeight(true));
            }

            if (doCreate)
            {
                IPsdConstructor constructor = constructorExtensions[extIndex];
                PsdBuilder.BuildPsd(Selection.activeGameObject, selectedGroup, settings, fileInfo, createAlign, constructor);
            }

            GUI.enabled = true;
        }
Example #2
0
        private void DrawCreateEntry()
        {
            showCreateSprites = EditorGUILayout.Foldout(showCreateSprites, "Sprite Creation", styleBoldFoldout);

            if (!showCreateSprites || !imageLoaded)
            {
                return;
            }

            float labelWidth = EditorGUIUtility.labelWidth;

            using (new EditorGUILayout.HorizontalScope(GUILayout.Height(30f)))
            {
                MessageType boxType = MessageType.Warning;
                string      boxMsg  = "Select a Layer Group";

                if (selectedGroup != null)
                {
                    boxMsg  = string.Format("Creating: {0}", selectedGroup.name);
                    boxType = MessageType.Info;
                }

                EditorGUILayout.HelpBox(boxMsg, boxType);

                using (new EditorGUILayout.VerticalScope(GUILayout.Width(165f)))
                {
                    GUILayout.FlexibleSpace();
                    EditorGUIUtility.labelWidth = 65f;
                    createAlign = (SpriteAlignment)EditorGUILayout.EnumPopup("Alignment", createAlign);
                    GUILayout.FlexibleSpace();
                }
            }

            GUILayout.Space(5f);

            bool createSprites = false;
            bool createUiImgs  = false;
            bool createAllUI   = false;

//			EditorGUIUtility.labelWidth = labelWidth;
//			using (new EditorGUILayout.HorizontalScope())
//			{
//				if (selectedGroup == null)
//					GUI.enabled = false;
//
//				const float buttonHeight = 50f;
//
//				using (new EditorGUILayout.VerticalScope())
//				{
//					GUILayout.Label("2D Sprites", styleHeader);
//					createSprites = GUILayout.Button("Create 2D Sprites",
//													GUILayout.Height(buttonHeight),
//													GUILayout.ExpandHeight(false));
//				}
//
//				using (new EditorGUILayout.VerticalScope())
//				{
//					bool selectionOk = Selection.activeGameObject != null;
//					string btnText = "Select UI Root";
//					if (selectionOk)
//					{
//						selectionOk = uiConstructor.CanBuild(Selection.activeGameObject);
//						if (selectionOk)
//							btnText = "Create UI Images";
//					}
//
//					GUI.enabled = selectionOk && selectedGroup != null;
//
//					GUILayout.Label("UI Images", styleHeader);
//					createUiImgs = GUILayout.Button(btnText,
//													GUILayout.Height(buttonHeight),
//													GUILayout.ExpandHeight(false));
//				}
//				GUI.enabled = true;
//			}


            using (new EditorGUILayout.VerticalScope())
            {
                string btnText = "Create UI Panel";

                createAllUI = GUILayout.Button(btnText,
                                               GUILayout.Height(30),
                                               GUILayout.ExpandHeight(false));

                GUILayout.Space(5);
            }

            if (createSprites)
            {
                PsdBuilder.BuildPsd(Selection.activeGameObject, selectedGroup, settings, fileInfo, createAlign, spriteConstructor);
            }
            if (createUiImgs)
            {
                PsdBuilder.BuildPsd(Selection.activeGameObject, selectedGroup, settings, fileInfo, createAlign, uiConstructor);
            }
            if (createAllUI)
            {
                GameObject gObj = PsdBuilder.FindUIRoot();
                GameObject root = PsdBuilder.BuildPsdRoot(gObj, settings, fileInfo, createAlign, uiConstructor);
                Selection.activeGameObject = root;
            }


//            DrawCreateExtensions();
        }