private void ShowBodyPartStyles(PixelCharacter.BodyPart bodyPart, SerializedProperty bodyPartProp, ref string tempNewStyleString) { EditorGUILayout.LabelField("New Style Layer", EditorStyles.centeredGreyMiniLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUIUtility.labelWidth = 40; tempNewStyleString = EditorGUILayout.TextField("Name", tempNewStyleString); if (GUILayout.Button("Add Layer")) { bodyPart.styleLayers.Add(new PixelCharacter.StyleLayer(tempNewStyleString)); tempNewStyleString = ""; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = defaultLabelWidth; GUILayout.Space(20); for (int i = 0; i < bodyPartProp.FindPropertyRelative("styleLayers").arraySize; i++) { EditorGUILayout.LabelField(bodyPart.styleLayers[i].name, EditorStyles.centeredGreyMiniLabel); PixelCharacter.StyleLayer temp = bodyPart.styleLayers[i]; temp.drawProbability = EditorGUILayout.Slider("Draw Probability", temp.drawProbability, 0f, 1f); bodyPart.styleLayers[i] = temp; EditorGUILayout.Space(); ShowColorArray(bodyPartProp.FindPropertyRelative("styleLayers").GetArrayElementAtIndex(i).FindPropertyRelative("colors")); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (i != bodyPartProp.FindPropertyRelative("styleLayers").arraySize - 1) { if (GUILayout.Button("Move Down")) { bodyPart.styleLayers[i] = bodyPart.styleLayers[i + 1]; bodyPart.styleLayers[i + 1] = temp; } } if (i != 0) { if (GUILayout.Button("Move Up")) { bodyPart.styleLayers[i] = bodyPart.styleLayers[i - 1]; bodyPart.styleLayers[i - 1] = temp; } } if (GUILayout.Button("Remove Layer")) { bodyPart.styleLayers.RemoveAt(i); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); } }
private void DrawBodyPartSection(int posX, int posY, ref PixelCharacter.BodyPart bodyPart, ref string tempLayerName, ref Vector2 scrollPosition) { float viewHeight = 20 * 2 + spacing * 3; for (int i = 0; i < bodyPart.styleLayers.Count; i++) { viewHeight += spacing * 3; for (int s = 0; s < bodyPart.styleLayers[i].styles.Count; s++) { viewHeight += spacing; } } scrollPosition = GUI.BeginScrollView(new Rect(posX, posY, bodyPartSectionWidth + 20, 300), scrollPosition, new Rect(0, 0, bodyPartSectionWidth, viewHeight)); posX = 0; posY = 0; GUI.Label(new Rect(posX, posY, bodyPartSectionWidth, 20), bodyPart.name + " Section", EditorStyles.boldLabel); posY += 20; //GUI.Label(new Rect(posX, posY, bodyPartSectionWidth, 20), "Body Part", EditorStyles.centeredGreyMiniLabel); //posY += spacing; GUI.Label(new Rect(posX, posY, bodyPartSectionWidth / 3, 20), "● " + bodyPart.name); if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (1f / 3f), posY, bodyPartSectionWidth / 3, 15), "Edit")) { SetVariables(bodyPart, bodyPart.shape, bodyPart.name); } if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (2f / 3f), posY, bodyPartSectionWidth / 3, 15), "Delete")) { if (ShapeCreatorWindow.bodyPart.shape == bodyPart.shape) { variablesSet = false; } character.DeleteBodyPart(bodyPart); } posY += spacing; GUI.Label(new Rect(posX, posY, bodyPartSectionWidth, 20), "New Style Layer", EditorStyles.centeredGreyMiniLabel); posY += spacing; GUI.Label(new Rect(posX, posY, 50, 15), "Name"); tempLayerName = GUI.TextField(new Rect(posX + 50, posY, bodyPartSectionWidth - 50, 15), tempLayerName); posY += 20; if (GUI.Button(new Rect(posX, posY, bodyPartSectionWidth, 15), "Add Layer")) { bodyPart.styleLayers.Add(new PixelCharacter.StyleLayer(tempLayerName)); tempLayerName = ""; } posY += spacing; for (int i = 0; i < bodyPart.styleLayers.Count; i++) { GUI.Label(new Rect(posX, posY, bodyPartSectionWidth, 20), bodyPart.styleLayers[i].name, EditorStyles.centeredGreyMiniLabel); posY += spacing; for (int s = 0; s < bodyPart.styleLayers[i].styles.Count; s++) { GUI.Label(new Rect(posX, posY, bodyPartSectionWidth / 3, 20), "● " + bodyPart.styleLayers[i].name + " " + (s + 1)); if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (1f / 3f), posY, bodyPartSectionWidth / 3, 15), "Edit")) { SetVariables(bodyPart, bodyPart.styleLayers[i].styles[s], bodyPart.styleLayers[i].name + " " + (s + 1)); } if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (2f / 3f), posY, bodyPartSectionWidth / 3, 15), "Delete")) { if (shape == bodyPart.styleLayers[i].styles[s]) { variablesSet = false; } bodyPart.styleLayers[i].styles.RemoveAt(s); } posY += spacing; } if (GUI.Button(new Rect(posX, posY, bodyPartSectionWidth, 15), "Create New Shape")) { bodyPart.styleLayers[i].styles.Add(new PixelTexture(bodyPart.shape.width, bodyPart.shape.height)); SetVariables(bodyPart, bodyPart.styleLayers[i].styles[bodyPart.styleLayers[i].styles.Count - 1], bodyPart.styleLayers[i].name + " " + bodyPart.styleLayers[i].styles.Count); } posY += spacing; if (GUI.Button(new Rect(posX, posY, bodyPartSectionWidth / 3f, 15), "Down")) { PixelCharacter.StyleLayer temp = bodyPart.styleLayers[i]; bodyPart.styleLayers[i] = bodyPart.styleLayers[i + 1]; bodyPart.styleLayers[i + 1] = temp; } if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (1f / 3f), posY, bodyPartSectionWidth / 3f, 15), "Up")) { PixelCharacter.StyleLayer temp = bodyPart.styleLayers[i]; bodyPart.styleLayers[i] = bodyPart.styleLayers[i - 1]; bodyPart.styleLayers[i - 1] = temp; } if (GUI.Button(new Rect(posX + bodyPartSectionWidth * (2f / 3f), posY, bodyPartSectionWidth / 3f, 15), "Remove")) { bodyPart.styleLayers.RemoveAt(i); } posY += spacing; } GUI.EndScrollView(); }