//==================================== // Show General Settings //==================================== void ShowGeneralSettings() { settings.profileName = EditorGUILayout.TextField("Profile name", settings.profileName); settings.generalMargin = (uint)EditorGUILayout.IntField("Graph Margin", (int)settings.generalMargin); settings.stripFromRelease = EditorGUILayout.Toggle("Strip from release", settings.stripFromRelease); }
public override void OnInspectorGUI() { if (targets.Length > 1) { EditorGUILayout.HelpBox("Cannot edit multiple spline together", MessageType.Info, true); ms_isMultiEdit = true; return; } else { ms_isMultiEdit = false; } CatmullRomUniformBehaviour behaviour = (CatmullRomUniformBehaviour)target; CatmullRomUniform spline = (CatmullRomUniform)behaviour.Spline; GUILayout.Space(5f); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent("Add Point", "hotkey: I"), EditorStyles.toolbarButton)) { _AddPoint(spline); } if (GUILayout.Button(new GUIContent("Del Point", "hotkey: X"), EditorStyles.toolbarButton)) { _DelPoint(spline); } if (GUILayout.Button(spline.Cycle ? "Break Cycle" : "Make Cycle", EditorStyles.toolbarButton)) { _ToggleCycle(spline); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(5f); if (m_curPtIdx >= 0) { EditorGUILayout.BeginHorizontal(); { MUndo.RecordObject(this, "change current point"); GUILayout.Label("Current Point"); if (GUILayout.Button("<<")) { m_curPtIdx = Mathf.Max(0, m_curPtIdx - 1); } EditorGUI.BeginChangeCheck(); m_curPtIdx = EditorGUILayout.IntField(m_curPtIdx); if (EditorGUI.EndChangeCheck()) { m_curPtIdx = Mathf.Clamp(m_curPtIdx, 0, spline.PointCount); } GUILayout.Label(" / " + (spline.PointCount - 1)); if (GUILayout.Button(">>")) { m_curPtIdx = Mathf.Min(m_curPtIdx + 1, spline.PointCount - 1); } } EditorGUILayout.EndHorizontal(); MUndo.RecordObject(target, "modify control point"); EUtil.PushLabelWidth(80f); spline[m_curPtIdx] = EUtil.DrawV3P(new GUIContent("Position"), spline[m_curPtIdx]); spline.SetTilt(m_curPtIdx, EditorGUILayout.FloatField("Tilt", spline.GetTilt(m_curPtIdx))); EUtil.PopLabelWidth(); } ms_foldoutSettings = EditorGUILayout.Foldout(ms_foldoutSettings, "Settings"); if (ms_foldoutSettings) { MUndo.RecordObject(this, "change setting"); spline.Resolution = EditorGUILayout.IntField("Point/Seg", spline.Resolution); spline.TwistMtd = (ETwistMethod)EditorGUILayout.EnumPopup(new GUIContent("Twist Method", "Decide how to calculate the base-up direction before applying tilt"), spline.TwistMtd); ms_drawArrow = EditorGUILayout.Toggle("Draw Arrow", ms_drawArrow); ms_drawUp = EditorGUILayout.Toggle("Draw Up", ms_drawUp); ms_arrowLineLen = EditorGUILayout.FloatField("Arrow LineLen", ms_arrowLineLen); ms_drawPts = EditorGUILayout.Toggle("Draw points", ms_drawPts); ms_ptSize = EditorGUILayout.FloatField("Point size", ms_ptSize); ms_lookAtDist = EditorGUILayout.FloatField(new GUIContent("LookAt dist", "the distance from camera to target point when camera in follow mode"), ms_lookAtDist); } ms_foldoutTSlider = EditorGUILayout.Foldout(ms_foldoutTSlider, "T slider"); if (ms_foldoutTSlider) { EditorGUI.BeginChangeCheck(); EUtil.PushLabelWidth(20f); m_tSlider = EditorGUILayout.Slider("T", m_tSlider, 0, 1f); EUtil.PopLabelWidth(); if (EditorGUI.EndChangeCheck()) { //Transform tr = behaviour.transform; EUtil.SceneViewLookAt( behaviour.GetTransformedPosition(m_tSlider), Quaternion.LookRotation(behaviour.GetTransformedTangent(m_tSlider), behaviour.GetTransformedUp(m_tSlider)), ms_lookAtDist); } } if (GUI.changed) { EUtil.RepaintSceneView(); } }
/// <summary> /// Render a single property value /// </summary> public static void RenderValue(SerializedProperty item, string name, ThemePropertyTypes type) { SerializedProperty floatValue = item.FindPropertyRelative("Float"); SerializedProperty vector2Value = item.FindPropertyRelative("Vector2"); SerializedProperty stringValue = item.FindPropertyRelative("String"); switch (type) { case ThemePropertyTypes.Float: floatValue.floatValue = EditorGUILayout.FloatField(name, floatValue.floatValue); break; case ThemePropertyTypes.Int: SerializedProperty intValue = item.FindPropertyRelative("Int"); intValue.intValue = EditorGUILayout.IntField(name, intValue.intValue); break; case ThemePropertyTypes.Color: SerializedProperty colorValue = item.FindPropertyRelative("Color"); colorValue.colorValue = EditorGUILayout.ColorField(name, colorValue.colorValue); break; case ThemePropertyTypes.ShaderFloat: floatValue.floatValue = EditorGUILayout.FloatField(name, floatValue.floatValue); break; case ThemePropertyTypes.ShaderRange: vector2Value.vector2Value = EditorGUILayout.Vector2Field(name, vector2Value.vector2Value); break; case ThemePropertyTypes.Vector2: vector2Value.vector2Value = EditorGUILayout.Vector2Field(name, vector2Value.vector2Value); break; case ThemePropertyTypes.Vector3: SerializedProperty vector3Value = item.FindPropertyRelative("Vector3"); vector3Value.vector3Value = EditorGUILayout.Vector3Field(name, vector3Value.vector3Value); break; case ThemePropertyTypes.Vector4: SerializedProperty vector4Value = item.FindPropertyRelative("Vector4"); vector4Value.vector4Value = EditorGUILayout.Vector4Field(name, vector4Value.vector4Value); break; case ThemePropertyTypes.Quaternion: SerializedProperty quaternionValue = item.FindPropertyRelative("Quaternion"); Vector4 vect4 = new Vector4(quaternionValue.quaternionValue.x, quaternionValue.quaternionValue.y, quaternionValue.quaternionValue.z, quaternionValue.quaternionValue.w); vect4 = EditorGUILayout.Vector4Field(name, vect4); quaternionValue.quaternionValue = new Quaternion(vect4.x, vect4.y, vect4.z, vect4.w); break; case ThemePropertyTypes.Texture: SerializedProperty texture = item.FindPropertyRelative("Texture"); EditorGUILayout.PropertyField(texture, new GUIContent(name, ""), false); break; case ThemePropertyTypes.Material: SerializedProperty material = item.FindPropertyRelative("Material"); EditorGUILayout.PropertyField(material, new GUIContent(name, ""), false); break; case ThemePropertyTypes.AudioClip: SerializedProperty audio = item.FindPropertyRelative("AudioClip"); EditorGUILayout.PropertyField(audio, new GUIContent(name, ""), false); break; case ThemePropertyTypes.Animaiton: SerializedProperty animation = item.FindPropertyRelative("Animation"); EditorGUILayout.PropertyField(animation, new GUIContent(name, ""), false); break; case ThemePropertyTypes.GameObject: SerializedProperty gameObjectValue = item.FindPropertyRelative("GameObject"); EditorGUILayout.PropertyField(gameObjectValue, new GUIContent(name, ""), false); break; case ThemePropertyTypes.String: stringValue.stringValue = EditorGUILayout.TextField(name, stringValue.stringValue); break; case ThemePropertyTypes.Bool: SerializedProperty boolValue = item.FindPropertyRelative("Bool"); boolValue.boolValue = EditorGUILayout.Toggle(name, boolValue.boolValue); break; case ThemePropertyTypes.AnimatorTrigger: stringValue.stringValue = EditorGUILayout.TextField(name, stringValue.stringValue); break; case ThemePropertyTypes.Shader: SerializedProperty shaderObjectValue = item.FindPropertyRelative("Shader"); EditorGUILayout.PropertyField(shaderObjectValue, new GUIContent(name, ""), false); break; default: break; } }
public override void OnInspectorGUI() { EditorGUI.indentLevel = 0; var ob = target as SimpleSmoothModifier; ob.smoothType = (SimpleSmoothModifier.SmoothType)EditorGUILayout.EnumPopup(new GUIContent("Smooth Type"), ob.smoothType); Undo.RecordObject(ob, "changed settings on Simple Smooth Modifier"); if (ob.smoothType == SimpleSmoothModifier.SmoothType.Simple) { ob.uniformLength = EditorGUILayout.Toggle(new GUIContent("Uniform Segment Length", "Toggle to divide all lines in equal length segments"), ob.uniformLength); if (ob.uniformLength) { ob.maxSegmentLength = EditorGUILayout.FloatField(new GUIContent("Max Segment Length", "The length of each segment in the smoothed path. A high value yields rough paths and low value yields very smooth paths, but is slower"), ob.maxSegmentLength); ob.maxSegmentLength = ob.maxSegmentLength < 0 ? 0 : ob.maxSegmentLength; } else { ob.subdivisions = EditorGUILayout.IntField(new GUIContent("Subdivisions", "The number of times to subdivide (divide in half) the path segments. [0...inf] (recommended [1...10])"), ob.subdivisions); if (ob.subdivisions < 0) { ob.subdivisions = 0; } } ob.iterations = EditorGUILayout.IntField(new GUIContent("Iterations", "Number of times to apply smoothing"), ob.iterations); ob.iterations = ob.iterations < 0 ? 0 : ob.iterations; ob.strength = EditorGUILayout.Slider(new GUIContent("Strength", "Determines how much smoothing to apply in each smooth iteration. 0.5 usually produces the nicest looking curves"), ob.strength, 0.0F, 1.0F); } else if (ob.smoothType == SimpleSmoothModifier.SmoothType.OffsetSimple) { ob.iterations = EditorGUILayout.IntField(new GUIContent("Iterations", "Number of times to apply smoothing"), ob.iterations); ob.iterations = ob.iterations < 0 ? 0 : ob.iterations; ob.iterations = ob.iterations > 12 ? 12 : ob.iterations; ob.offset = EditorGUILayout.FloatField(new GUIContent("Offset", "Offset to apply in each smoothing iteration"), ob.offset); if (ob.offset < 0) { ob.offset = 0; } } else if (ob.smoothType == SimpleSmoothModifier.SmoothType.Bezier) { ob.subdivisions = EditorGUILayout.IntField(new GUIContent("Subdivisions", "The number of times to subdivide (divide in half) the path segments. [0...inf] (recommended [1...10])"), ob.subdivisions); if (ob.subdivisions < 0) { ob.subdivisions = 0; } ob.bezierTangentLength = EditorGUILayout.FloatField(new GUIContent("Tangent Length", "Tangent length factor"), ob.bezierTangentLength); } else if (ob.smoothType == SimpleSmoothModifier.SmoothType.CurvedNonuniform) { ob.maxSegmentLength = EditorGUILayout.FloatField(new GUIContent("Max Segment Length", "The length of each segment in the smoothed path. A high value yields rough paths and low value yields very smooth paths, but is slower"), ob.maxSegmentLength); ob.factor = EditorGUILayout.FloatField(new GUIContent("Roundness Factor", "How much to smooth the path. A higher value will give a smoother path, but might take the character far off the optimal path."), ob.factor); ob.maxSegmentLength = ob.maxSegmentLength < 0 ? 0 : ob.maxSegmentLength; } else { DrawDefaultInspector(); } //GUILayout.Space (5); Color preCol = GUI.color; GUI.color *= new Color(1, 1, 1, 0.5F); ob.Priority = EditorGUILayout.IntField(new GUIContent("Priority", "Higher priority modifiers are executed first\nAdjust this in Seeker-->Modifier Priorities"), ob.Priority); GUI.color = preCol; if (ob.gameObject.GetComponent <Seeker> () == null) { EditorGUILayout.HelpBox("No seeker found, modifiers are usually used together with a Seeker component", MessageType.Warning); } }
public override void OnInspectorGUI() { Tilemap tl = target as Tilemap; bool difference = false; tl.spriteSheet = EditorGUILayout.ObjectField("Spritesheet : ", tl.spriteSheet, typeof(Texture2D), false) as Texture2D; if (tl.width != tl._internalWidth) { GUI.color = Color.red; difference = true; } else { GUI.color = new Color(0.7f, 0.7f, 0.7f, 1.0f); } tl.width = EditorGUILayout.IntField("width", tl.width); if (tl.height != tl._internalHeight) { GUI.color = Color.red; difference = true; } else { GUI.color = new Color(0.7f, 0.7f, 0.7f, 1.0f); } tl.height = EditorGUILayout.IntField("height", tl.height); tl.tileSize = EditorGUILayout.IntField("Tile size", tl.tileSize); GUILayout.BeginHorizontal(); if (GUILayout.Button("Make Tilemap", GUILayout.MinHeight(40)) && tl.spriteSheet != null) { tl.BuildMap(); } if (GUILayout.Button("Edit tilemap", GUILayout.MinHeight(40))) { TilemapEditor e = EditorWindow.GetWindow <TilemapEditor>(); e.editedTilemap = target as Tilemap; e.ShowPopup(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Save Tilemap")) { SaveTilemap(); } if (GUILayout.Button("Load Tilemap")) { ReadTilemap(); } if (difference) { GUI.color = Color.red; GUILayout.Label("internal size different from editor size, rebuild tilemap!"); } if (tl.spriteSheet == null) { GUI.contentColor = Color.red; GUILayout.Label("Spritesheet null, can't build map!"); } }
void OnGUI() { GUILayout.Label("TEXTURE COMBINER", EditorStyles.boldLabel); GUILayout.Space(8); EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label("Combined texture: ", GUILayout.ExpandWidth(false)); var newTexture = (Texture2D)EditorGUILayout.ObjectField(textureSaved, typeof(Texture2D), false); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck() && newTexture != textureSaved) { if (Load(newTexture)) { textureSaved = newTexture; } } GUILayout.Space(8f); float space = 8f; var r = EditorGUILayout.GetControlRect(false, (64f + space) * 4f); var texRect = r; texRect.x += 24f; texRect.height = 64f; texRect.width = 64f; textureR = (Texture2D)EditorGUI.ObjectField(texRect, textureR, typeof(Texture2D), false); texRect.y += 64f + space; textureG = (Texture2D)EditorGUI.ObjectField(texRect, textureG, typeof(Texture2D), false); texRect.y += 64f + space; textureB = (Texture2D)EditorGUI.ObjectField(texRect, textureB, typeof(Texture2D), false); texRect.y += 64f + space; textureA = (Texture2D)EditorGUI.ObjectField(texRect, textureA, typeof(Texture2D), false); var lblRect = r; lblRect.width = 20f; lblRect.x += 4f; lblRect.y += 22f; GUI.Label(lblRect, "R", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "G", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "B", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "A", EditorStyles.largeLabel); var chanRect = r; chanRect.width = 120f; chanRect.x += texRect.x + texRect.width + space; chanRect.height = 64f; sourceR = (Channel)GUI_SourceChannel(chanRect, sourceR); chanRect.y += 64f + space; sourceG = (Channel)GUI_SourceChannel(chanRect, sourceG); chanRect.y += 64f + space; sourceB = (Channel)GUI_SourceChannel(chanRect, sourceB); chanRect.y += 64f + space; sourceA = (Channel)GUI_SourceChannel(chanRect, sourceA); var resultRect = r; resultRect.height = (64f + space) * 4f; resultRect.x += lblRect.x + lblRect.width + texRect.width + chanRect.width + 64f; resultRect.width = resultRect.height; if (textureCombined != null || textureSaved != null) { var alphaRect = resultRect; alphaRect.x += resultRect.width + space; //handy way to highlight the saved texture when clicking on the big preview if (textureSaved != null) { EditorGUI.ObjectField(resultRect, textureSaved, typeof(Texture2D), false); EditorGUI.ObjectField(alphaRect, textureSaved, typeof(Texture2D), false); } if (textureCombined != null) { GUI.Box(resultRect, GUIContent.none); GUI.Box(alphaRect, GUIContent.none); //rgb GUI.DrawTexture(resultRect, textureCombined, ScaleMode.StretchToFill, false, 0); //alpha GUI.DrawTexture(alphaRect, textureCombinedAlpha, ScaleMode.StretchToFill, false, 0); } } else { resultRect.width += resultRect.width + space; EditorGUI.HelpBox(resultRect, "texture not generated yet", MessageType.Warning); } GUILayout.Space(8f); GUILayout.BeginHorizontal(); //Texture size EditorGUI.BeginChangeCheck(); textureSize = EditorGUILayout.Popup(textureSize, textureSizes, GUILayout.Width(60f)); using (new EditorGUI.DisabledScope(textureSize != textureSizes.Length - 1)) textureWidth = EditorGUILayout.IntField(textureWidth, GUILayout.Width(60f)); GUILayout.Label("x"); using (new EditorGUI.DisabledScope(textureSize != textureSizes.Length - 1)) textureHeight = EditorGUILayout.IntField(textureHeight, GUILayout.Width(60f)); if (EditorGUI.EndChangeCheck()) { textureWidth = Mathf.Clamp(textureWidth, 1, 16384); textureHeight = Mathf.Clamp(textureHeight, 1, 16384); TextureSizeUpdated(); } GUILayout.FlexibleSpace(); //Save button if (GUILayout.Button("SAVE AS...", GUILayout.Width(120f))) { SaveAs(saveFormat); } GUILayout.EndHorizontal(); //Options GUILayout.BeginHorizontal(); saveFormat = (SaveFormat)EditorGUILayout.EnumPopup(saveFormat, GUILayout.Width(60f)); removeCompression = GUILayout.Toggle(removeCompression, new GUIContent("Remove compression (saved texture)", "Remove compression from input textures for the saved texture"), EditorStyles.miniButton); removeCompressionPreview = GUILayout.Toggle(removeCompressionPreview, new GUIContent("Remove compression (preview)", "Remove compression from input textures for the preview image.\n\nThis is a separate setting because disabling/enabling back compression takes a few seconds and that can be annoying when regularly changing the inputs."), EditorStyles.miniButton); GUILayout.FlexibleSpace(); //Reset button if (GUILayout.Button("RESET", GUILayout.Width(120f))) { Reset(); } GUILayout.EndHorizontal(); if (GUI.changed) { RefreshCombinedTexture(true); } }
public static void ShowLocalParametersGUI(List <ActionParameter> localParameters, List <ActionParameter> assetParameters, bool isAssetFile) { int numParameters = assetParameters.Count; if (numParameters < localParameters.Count) { localParameters.RemoveRange(numParameters, localParameters.Count - numParameters); } else if (numParameters > localParameters.Count) { if (numParameters > localParameters.Capacity) { localParameters.Capacity = numParameters; } for (int i = localParameters.Count; i < numParameters; i++) { ActionParameter newParameter = new ActionParameter(ActionListEditor.GetParameterIDArray(localParameters)); localParameters.Add(newParameter); } } for (int i = 0; i < numParameters; i++) { string label = assetParameters[i].label; localParameters[i].parameterType = assetParameters[i].parameterType; if (assetParameters[i].parameterType == ParameterType.String) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label + ":", GUILayout.Width(145f)); EditorStyles.textField.wordWrap = true; localParameters[i].stringValue = EditorGUILayout.TextArea(localParameters[i].stringValue, GUILayout.MaxWidth(400f)); EditorGUILayout.EndHorizontal(); } else if (assetParameters[i].parameterType == ParameterType.Float) { localParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", localParameters[i].floatValue); } else if (assetParameters[i].parameterType == ParameterType.Integer) { localParameters[i].intValue = EditorGUILayout.IntField(label + ":", localParameters[i].intValue); } else if (assetParameters[i].parameterType == ParameterType.Boolean) { BoolValue boolValue = BoolValue.False; if (localParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue); if (boolValue == BoolValue.True) { localParameters[i].intValue = 1; } else { localParameters[i].intValue = 0; } } else if (assetParameters[i].parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", variablesManager.vars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } else if (assetParameters[i].parameterType == ParameterType.InventoryItem) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; localParameters[i].intValue = ActionRunActionList.ShowInvItemSelectorGUI(label + ":", inventoryManager.items, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } else if (assetParameters[i].parameterType == ParameterType.LocalVariable) { if (KickStarter.localVariables) { localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } if (assetParameters[i].parameterType == ParameterType.GameObject) { if (isAssetFile) { // ID localParameters[i].intValue = EditorGUILayout.IntField(label + " (ID):", localParameters[i].intValue); localParameters[i].gameObject = null; } else { // Gameobject localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true); localParameters[i].intValue = 0; if (localParameters[i].gameObject != null && localParameters[i].gameObject.GetComponent <ConstantID>() == null) { UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (localParameters[i].gameObject); } } } else if (assetParameters[i].parameterType == ParameterType.UnityObject) { localParameters[i].objectValue = (Object)EditorGUILayout.ObjectField(label + ":", localParameters[i].objectValue, typeof(Object), true); } } }
public static object DrawIndividualVariable(ComponentDescription componentDescription, WrappedVariable variable, string fieldName, Type fieldType, object fieldValue, Action <Guid, WrappedVariable> onObjectPicker) { object newValue; if (variable.DataType == DataType.Enum) { newValue = EditorGUILayout.IntPopup(fieldName, (int)fieldValue, variable.MetaData.EnumNames, variable.MetaData.EnumValues); } else if (variable.DataType == DataType.UnityObjectReference) { if (fieldValue is Guid) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(fieldName); if ((Guid)fieldValue != Guid.Empty) { EditorGUILayout.TextField(variable.MetaData.ValueDisplayName); } else { EditorGUILayout.TextField("None (" + variable.MetaData.TypeFullName + ")"); } if (componentDescription != null) { if (GUILayout.Button("...", GUILayout.Width(30))) { onObjectPicker(componentDescription.Guid, variable); } } EditorGUILayout.EndHorizontal(); newValue = fieldValue; } else if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType)) { newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, variable.MetaData.GetTypeFromMetaData(), true); } else { throw new NotSupportedException(); } } else if (fieldType == typeof(int) || (fieldType.IsSubclassOf(typeof(Enum)) && OldInspectorSidekick.Current.Settings.TreatEnumsAsInts)) { newValue = EditorGUILayout.IntField(fieldName, (int)fieldValue); } else if (fieldType == typeof(long)) { newValue = EditorGUILayout.LongField(fieldName, (long)fieldValue); } else if (fieldType == typeof(string)) { newValue = EditorGUILayout.TextField(fieldName, (string)fieldValue); } else if (fieldType == typeof(char)) { string newString = EditorGUILayout.TextField(fieldName, new string((char)fieldValue, 1)); if (newString.Length == 1) { newValue = newString[0]; } else { newValue = fieldValue; } } else if (fieldType == typeof(float)) { newValue = EditorGUILayout.FloatField(fieldName, (float)fieldValue); } else if (fieldType == typeof(double)) { newValue = EditorGUILayout.DoubleField(fieldName, (double)fieldValue); } else if (fieldType == typeof(bool)) { newValue = EditorGUILayout.Toggle(fieldName, (bool)fieldValue); } else if (fieldType == typeof(Vector2)) { newValue = EditorGUILayout.Vector2Field(fieldName, (Vector2)fieldValue); } else if (fieldType == typeof(Vector3)) { newValue = EditorGUILayout.Vector3Field(fieldName, (Vector3)fieldValue); } else if (fieldType == typeof(Vector4)) { newValue = EditorGUILayout.Vector4Field(fieldName, (Vector4)fieldValue); } #if UNITY_2017_2_OR_NEWER else if (fieldType == typeof(Vector2Int)) { newValue = EditorGUILayout.Vector2IntField(fieldName, (Vector2Int)fieldValue); } else if (fieldType == typeof(Vector3Int)) { newValue = EditorGUILayout.Vector3IntField(fieldName, (Vector3Int)fieldValue); } #endif else if (fieldType == typeof(Quaternion)) { //if(InspectorSidekick.Current.Settings.RotationsAsEuler) //{ // Quaternion quaternion = (Quaternion)fieldValue; // Vector3 eulerAngles = quaternion.eulerAngles; // eulerAngles = EditorGUILayout.Vector3Field(fieldName, eulerAngles); // newValue = Quaternion.Euler(eulerAngles); //} //else { Quaternion quaternion = (Quaternion)fieldValue; Vector4 vector = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w); vector = EditorGUILayout.Vector4Field(fieldName, vector); newValue = new Quaternion(vector.x, vector.y, vector.z, vector.z); } } else if (fieldType == typeof(Bounds)) { newValue = EditorGUILayout.BoundsField(fieldName, (Bounds)fieldValue); } #if UNITY_2017_2_OR_NEWER else if (fieldType == typeof(BoundsInt)) { newValue = EditorGUILayout.BoundsIntField(fieldName, (BoundsInt)fieldValue); } #endif else if (fieldType == typeof(Color)) { newValue = EditorGUILayout.ColorField(fieldName, (Color)fieldValue); } else if (fieldType == typeof(Color32)) { newValue = (Color32)EditorGUILayout.ColorField(fieldName, (Color32)fieldValue); } else if (fieldType == typeof(Gradient)) { newValue = InternalEditorGUILayout.GradientField(new GUIContent(fieldName), (Gradient)fieldValue); } else if (fieldType == typeof(AnimationCurve)) { newValue = EditorGUILayout.CurveField(fieldName, (AnimationCurve)fieldValue); } else if (fieldType.IsSubclassOf(typeof(Enum))) { newValue = EditorGUILayout.EnumPopup(fieldName, (Enum)fieldValue); } else if (fieldType == typeof(Rect)) { newValue = EditorGUILayout.RectField(fieldName, (Rect)fieldValue); } #if UNITY_2017_2_OR_NEWER else if (fieldType == typeof(RectInt)) { newValue = EditorGUILayout.RectIntField(fieldName, (RectInt)fieldValue); } #endif else if (fieldType.IsSubclassOf(typeof(UnityEngine.Object))) { newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, fieldType, true); } else { GUILayout.Label(fieldType + " " + fieldName); newValue = fieldValue; } // EditorGUILayout.BoundsField() // EditorGUILayout.ColorField // EditorGUILayout.CurveField // EditorGUILayout.EnumPopup // EditorGUILayout.EnumMaskField // EditorGUILayout.IntSlider // If there's a range attribute maybe? // EditorGUILayout.LabelField // what's this? // EditorGUILayout.ObjectField // EditorGUILayout.RectField // EditorGUILayout.TextArea // EditorGUILayout.TextField // What's this? public static void HelpBox (string message, MessageType type, bool wide) // What's this? public static bool InspectorTitlebar (bool foldout, Object targetObj) return(newValue); }
public override void Draw(int aID) { var windowWidth = m_Rect.width; var windowHeight = m_Rect.height; actionTableRect = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, 0.5f * windowHeight); rightPanelRect = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.5f * windowHeight); descriptionRect = new Rect(0f, 0.6f * windowHeight, 0.95f * windowWidth, 0.2f * windowHeight); effectsRect = new Rect(0f, 0.8f * windowHeight, windowWidth, windowHeight * 0.15f); GUILayout.BeginArea(actionTableRect); GUILayout.BeginHorizontal(); GUILayout.Box(TC.get("Element.Action"), GUILayout.Width(windowWidth * 0.39f)); GUILayout.Box(TC.get("ActionsList.NeedsGoTo"), GUILayout.Width(windowWidth * 0.39f)); GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.1f)); GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandWidth(false)); // Action table for (int i = 0; i < Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions().Count; i++) { if (i == selectedAction) { GUI.skin = selectedAreaSkin; } else { GUI.skin = noBackgroundSkin; } tmpTex = (Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].getConditions() .getBlocksCount() > 0 ? conditionsTex : noConditionsTex); GUILayout.BeginHorizontal(); if (i == selectedAction) { int t = Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].getType(); if (t == Controller.ACTION_USE_WITH || t == Controller.ACTION_GIVE_TO || t == Controller.ACTION_DRAG_TO) { selectedTarget = EditorGUILayout.Popup( Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i] .getTypeName(), selectedTarget, joinedNamesList, GUILayout.Width(windowWidth * 0.39f)); if (selectedTarget != selectedTargetLast) { ChangeActionTarget(selectedTarget); } } else { GUILayout.Label( Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i] .getTypeName(), GUILayout.Width(windowWidth * 0.39f)); } if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER) { if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f))) { OnActionSelectionChange(i); } } else { GUILayout.BeginHorizontal(GUILayout.Width(windowWidth * 0.39f)); Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].setNeedsGoTo( GUILayout.Toggle( Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i] .getNeedsGoTo(), "")); Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i] .setKeepDistance( EditorGUILayout.IntField( Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i] .getKeepDistance())); GUILayout.EndHorizontal(); } if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.1f))) { ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow)); window.Init(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].getConditions ()); } } else { if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].getTypeName(), GUILayout.Width(windowWidth * 0.39f))) { OnActionSelectionChange(i); } if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER) { if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f))) { OnActionSelectionChange(i); } } else { if ( GUILayout.Button( Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[i].getNeedsGoTo().ToString(), GUILayout.Width(windowWidth * 0.39f))) { OnActionSelectionChange(i); } } if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.1f))) { OnActionSelectionChange(i); } } GUILayout.EndHorizontal(); GUI.skin = defaultSkin; } GUILayout.EndScrollView(); GUILayout.EndArea(); /* * Right panel */ GUILayout.BeginArea(rightPanelRect); GUI.skin = noBackgroundSkin; if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth))) { addMenu.menu.ShowAsContext(); } if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth))) { Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList() .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[selectedAction]); } //if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth))) //{ // Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ // GameRources.GetInstance().selectedCharacterIndex].getActionsList().moveElementUp(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ // GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[selectedAction]); //} //if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth))) //{ // Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ // GameRources.GetInstance().selectedCharacterIndex].getActionsList().moveElementDown(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ // GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[selectedAction]); //} if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth))) { Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList() .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[selectedAction], false); if (selectedAction >= 0) { selectedAction--; } } GUI.skin = defaultSkin; GUILayout.EndArea(); GUILayout.BeginArea(descriptionRect); GUILayout.Label(TC.get("Action.Documentation")); GUILayout.Space(20); documentation = GUILayout.TextArea(documentation); if (!documentation.Equals(documentationLast)) { OnDocumentationChanged(documentation); } GUILayout.EndArea(); GUILayout.BeginArea(effectsRect); if (selectedAction < 0) { GUI.enabled = false; } if (GUILayout.Button(TC.get("Element.Effects"))) { EffectEditorWindow window = (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow)); window.Init(Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCs()[ GameRources.GetInstance().selectedCharacterIndex].getActionsList().getActions()[selectedAction] .getEffects()); } GUI.enabled = true; GUILayout.EndArea(); }
// On inspector gui public override void OnInspectorGUI( ) { Uni2DTextureAtlas rAtlas = target as Uni2DTextureAtlas; EditorGUIUtility.LookLikeInspector( ); // Material override EditorGUILayout.BeginVertical( ); { rAtlas.materialOverride = (Material) EditorGUILayout.ObjectField( "Material Override", rAtlas.materialOverride, typeof( Material ), false ); rAtlas.maximumAtlasSize = (AtlasSize) EditorGUILayout.EnumPopup( "Maximum Atlas Size", rAtlas.maximumAtlasSize ); rAtlas.padding = EditorGUILayout.IntField( "Padding", rAtlas.padding ); rAtlas.padding = Mathf.Abs( rAtlas.padding ); // Texture to pack list // Custom list GUI: displays Texture2D objects, handles asset GUIDs serializedObject.Update( ); SerializedProperty rSerializedProperty_Textures = serializedObject.FindProperty( "textures" ); int iContainerIndex = 0; EditorGUILayout.Space( ); while( true ) { string oPropertyPath = rSerializedProperty_Textures.propertyPath; string oPropertyName = rSerializedProperty_Textures.name; bool bIsTextureContainer = oPropertyPath.Contains( "textures" ); // Indent EditorGUI.indentLevel = rSerializedProperty_Textures.depth; if( bIsTextureContainer ) { if( oPropertyName == "textures" ) { GUIContent oGUIContentTexturesLabel = new GUIContent( "Textures" ); Rect rFoldoutRect = GUILayoutUtility.GetRect( oGUIContentTexturesLabel, EditorStyles.foldout ); Event rCurrentEvent = Event.current; switch( rCurrentEvent.type ) { // Drag performed case EventType.DragPerform: { // Check if dragged objects are inside the foldout rect if( rFoldoutRect.Contains( rCurrentEvent.mousePosition ) ) { // Accept and use the event DragAndDrop.AcceptDrag( ); rCurrentEvent.Use( ); EditorGUIUtility.hotControl = 0; DragAndDrop.activeControlID = 0; // Add the textures to the current list foreach( Object rDraggedObject in DragAndDrop.objectReferences ) { if( rDraggedObject is Texture2D ) { int iCurrentSize = rSerializedProperty_Textures.arraySize; ++rSerializedProperty_Textures.arraySize; SerializedProperty rSerializedProperty_Data = rSerializedProperty_Textures.GetArrayElementAtIndex( iCurrentSize ); rSerializedProperty_Data = rSerializedProperty_Data.FindPropertyRelative( "m_oTextureGUID" ); rSerializedProperty_Data.stringValue = rDraggedObject != null ? Uni2DEditorUtils.GetUnityAssetGUID( (Texture2D) rDraggedObject ) : null; } } } } break; case EventType.DragUpdated: { if( rFoldoutRect.Contains( rCurrentEvent.mousePosition ) ) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; } } break; } EditorGUI.indentLevel = 0; ms_bTexturesFoldout = EditorGUI.Foldout( rFoldoutRect, ms_bTexturesFoldout, oGUIContentTexturesLabel ); } else if( oPropertyName == "data" ) { SerializedProperty rSerializedProperty_TextureGUID = rSerializedProperty_Textures.FindPropertyRelative( "m_oTextureGUID" ); Texture2D rTexture = Uni2DEditorUtils.GetAssetFromUnityGUID<Texture2D>( rSerializedProperty_TextureGUID.stringValue ); EditorGUI.BeginChangeCheck( ); { rTexture = (Texture2D) EditorGUILayout.ObjectField( "Element " + iContainerIndex, rTexture, typeof( Texture2D ), false ); ++iContainerIndex; } if( EditorGUI.EndChangeCheck( ) ) { rSerializedProperty_TextureGUID.stringValue = rTexture != null ? Uni2DEditorUtils.GetUnityAssetGUID( rTexture ) : null; } } else { // Default draw of the property field EditorGUILayout.PropertyField( rSerializedProperty_Textures ); } } if( rSerializedProperty_Textures.NextVisible( ms_bTexturesFoldout ) == false ) { break; } } serializedObject.ApplyModifiedProperties( ); EditorGUILayout.Space( ); EditorGUI.indentLevel = 0; ///// Generated assets section ///// // Materials ms_bGeneratedMaterialsFoldout = EditorGUILayout.Foldout( ms_bGeneratedMaterialsFoldout, "Generated Materials" ); if( ms_bGeneratedMaterialsFoldout ) { ++EditorGUI.indentLevel; { if( ms_oAtlasMaterials.Length > 0 ) { foreach( Material rAtlasMaterial in ms_oAtlasMaterials ) { EditorGUILayout.BeginHorizontal( ); { GUILayout.Space( 16.0f ); if( GUILayout.Button( EditorGUIUtility.ObjectContent( rAtlasMaterial, typeof( Material ) ), EditorStyles.label, GUILayout.ExpandWidth( false ), GUILayout.MaxWidth( 225.0f ), GUILayout.MaxHeight( 16.0f ) ) ) { EditorGUIUtility.PingObject( rAtlasMaterial ); } } EditorGUILayout.EndHorizontal( ); } } else { EditorGUILayout.PrefixLabel( "(None)" ); } } --EditorGUI.indentLevel; } EditorGUILayout.Space( ); // Atlas textures ms_bGeneratedTexturesFoldout = EditorGUILayout.Foldout( ms_bGeneratedTexturesFoldout, "Generated Textures" ); if( ms_bGeneratedTexturesFoldout ) { ++EditorGUI.indentLevel; { if( ms_oAtlasTextures.Length > 0 ) { foreach( Texture2D rAtlasTexture in ms_oAtlasTextures ) { EditorGUILayout.BeginHorizontal( ); { GUILayout.Space( 16.0f ); if( GUILayout.Button( EditorGUIUtility.ObjectContent( rAtlasTexture, typeof( Texture2D ) ), EditorStyles.label, GUILayout.ExpandWidth( false ), GUILayout.MaxWidth( 225.0f ), GUILayout.MaxHeight( 16.0f ) ) ) { EditorGUIUtility.PingObject( rAtlasTexture ); } } EditorGUILayout.EndHorizontal( ); } } else { EditorGUILayout.PrefixLabel( "(None)" ); } } --EditorGUI.indentLevel; } bool bUnappliedSettings = rAtlas.UnappliedSettings; EditorGUI.BeginDisabledGroup( bUnappliedSettings == false ); { // Apply/Revert EditorGUILayout.BeginHorizontal( ); { if(GUILayout.Button( "Apply" ) ) { this.ApplySettings( ); } if( GUILayout.Button( "Revert" ) ) { rAtlas.RevertSettings( ); } } EditorGUILayout.EndHorizontal( ); } EditorGUI.EndDisabledGroup(); // Generate if( GUILayout.Button( "Force atlas regeneration" ) ) { this.ApplySettings( ); } } EditorGUILayout.EndVertical( ); }
public override void OnInspectorGUI() { MegaHose mod = (MegaHose)target; EditorGUIUtility.LookLikeControls(); mod.dolateupdate = EditorGUILayout.Toggle("Do Late Update", mod.dolateupdate); mod.InvisibleUpdate = EditorGUILayout.Toggle("Invisible Update", mod.InvisibleUpdate); mod.wiretype = (MegaHoseType)EditorGUILayout.EnumPopup("Wire Type", mod.wiretype); mod.segments = EditorGUILayout.IntField("Segments", mod.segments); mod.capends = EditorGUILayout.Toggle("Cap Ends", mod.capends); mod.calcnormals = EditorGUILayout.Toggle("Calc Normals", mod.calcnormals); mod.calctangents = EditorGUILayout.Toggle("Calc Tangents", mod.calctangents); mod.optimize = EditorGUILayout.Toggle("Optimize", mod.optimize); mod.recalcCollider = EditorGUILayout.Toggle("Calc Collider", mod.recalcCollider); switch (mod.wiretype) { case MegaHoseType.Round: mod.rnddia = EditorGUILayout.FloatField("Diameter", mod.rnddia); mod.rndsides = EditorGUILayout.IntField("Sides", mod.rndsides); mod.rndrot = EditorGUILayout.FloatField("Rotate", mod.rndrot); break; case MegaHoseType.Rectangle: mod.rectwidth = EditorGUILayout.FloatField("Width", mod.rectwidth); mod.rectdepth = EditorGUILayout.FloatField("Depth", mod.rectdepth); mod.rectfillet = EditorGUILayout.FloatField("Fillet", mod.rectfillet); mod.rectfilletsides = EditorGUILayout.IntField("Fillet Sides", mod.rectfilletsides); mod.rectrotangle = EditorGUILayout.FloatField("Rotate", mod.rectrotangle); break; case MegaHoseType.DSection: mod.dsecwidth = EditorGUILayout.FloatField("Width", mod.dsecwidth); mod.dsecdepth = EditorGUILayout.FloatField("Depth", mod.dsecdepth); mod.dsecrndsides = EditorGUILayout.IntField("Rnd Sides", mod.dsecrndsides); mod.dsecfillet = EditorGUILayout.FloatField("Fillet", mod.dsecfillet); mod.dsecfilletsides = EditorGUILayout.IntField("Fillet Sides", mod.dsecfilletsides); mod.dsecrotangle = EditorGUILayout.FloatField("Rotate", mod.dsecrotangle); break; } mod.uvscale = EditorGUILayout.Vector2Field("UV Scale", mod.uvscale); if (GUI.changed) { mod.updatemesh = true; mod.rebuildcross = true; } mod.custnode = (GameObject)EditorGUILayout.ObjectField("Start Object", mod.custnode, typeof(GameObject), true); mod.offset = EditorGUILayout.Vector3Field("Offset", mod.offset); mod.rotate = EditorGUILayout.Vector3Field("Rotate", mod.rotate); mod.scale = EditorGUILayout.Vector3Field("Scale", mod.scale); mod.custnode2 = (GameObject)EditorGUILayout.ObjectField("End Object", mod.custnode2, typeof(GameObject), true); mod.offset1 = EditorGUILayout.Vector3Field("Offset", mod.offset1); mod.rotate1 = EditorGUILayout.Vector3Field("Rotate", mod.rotate1); mod.scale1 = EditorGUILayout.Vector3Field("Scale", mod.scale1); mod.flexon = EditorGUILayout.BeginToggleGroup("Flex On", mod.flexon); mod.flexstart = EditorGUILayout.Slider("Start", mod.flexstart, 0.0f, 1.0f); mod.flexstop = EditorGUILayout.Slider("Stop", mod.flexstop, 0.0f, 1.0f); if (mod.flexstart > mod.flexstop) { mod.flexstart = mod.flexstop; } if (mod.flexstop < mod.flexstart) { mod.flexstop = mod.flexstart; } mod.flexcycles = EditorGUILayout.IntField("Cycles", mod.flexcycles); mod.flexdiameter = EditorGUILayout.FloatField("Diameter", mod.flexdiameter); EditorGUILayout.EndToggleGroup(); mod.usebulgecurve = EditorGUILayout.BeginToggleGroup("Use Bulge Curve", mod.usebulgecurve); mod.bulge = EditorGUILayout.CurveField("Bulge", mod.bulge); mod.bulgeamount = EditorGUILayout.FloatField("Bulge Amount", mod.bulgeamount); mod.bulgeoffset = EditorGUILayout.FloatField("Bulge Offset", mod.bulgeoffset); mod.animatebulge = EditorGUILayout.BeginToggleGroup("Animate", mod.animatebulge); mod.bulgespeed = EditorGUILayout.FloatField("Speed", mod.bulgespeed); mod.minbulge = EditorGUILayout.FloatField("Min", mod.minbulge); mod.maxbulge = EditorGUILayout.FloatField("Max", mod.maxbulge); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndToggleGroup(); mod.tension1 = EditorGUILayout.FloatField("Tension Start", mod.tension1); mod.tension2 = EditorGUILayout.FloatField("Tension End", mod.tension2); mod.freecreate = EditorGUILayout.BeginToggleGroup("Free Create", mod.freecreate); mod.noreflength = EditorGUILayout.FloatField("Free Length", mod.noreflength); EditorGUILayout.EndToggleGroup(); mod.up = EditorGUILayout.Vector3Field("Up", mod.up); mod.displayspline = EditorGUILayout.Toggle("Display Spline", mod.displayspline); if (GUI.changed) //rebuild ) { mod.updatemesh = true; mod.Rebuild(); } }
//Layers void ShowLayers() { _ScrollPos2 = GUILayout.BeginScrollView(_ScrollPos2, GUILayout.Width(position.width - 20), GUILayout.Height(position.height - position.height + 185)); for (int i = 0; i < _MapLayers.Count; i++) { GUILayout.BeginHorizontal("Box"); GUILayout.Label("Layer " + i.ToString()); if (_SelectedLayer == i) { GUI.backgroundColor = new Color(0, 1, 0); } else { GUI.backgroundColor = _DefaultColor; } if (GUILayout.Button("Selected")) { _SelectedLayer = i; } GUI.backgroundColor = _DefaultColor; GUILayout.Label("Obj: (" + _MapLayers[i]._P_Objects.Count.ToString() + ")"); if (GUILayout.Button("Add")) { AddObjectsToLayer(i); } if (GUILayout.Button("Clear")) { _MapLayers[i]._P_Objects.Clear(); } if (GUILayout.Button("Select")) { Selection.objects = _MapLayers[i]._P_Objects.ToArray(); } if (_MapLayers[i]._P_ShowObjects) { GUI.backgroundColor = new Color(0, 1, 0); } else { GUI.backgroundColor = _DefaultColor; } if (GUILayout.Button("Show")) { _MapLayers[i]._P_ShowObjects = !_MapLayers[i]._P_ShowObjects; } if (_MapLayers[i]._P_Visable) { GUI.backgroundColor = new Color(0, 1, 0); } else { GUI.backgroundColor = _DefaultColor; } if (GUILayout.Button("O")) { _MapLayers[i]._P_Visable = !_MapLayers[i]._P_Visable; Visable(i, _MapLayers[i]._P_Visable); } GUI.backgroundColor = _DefaultColor; //Show objects in layer GUI.backgroundColor = _DefaultColor; if (_MapLayers[i]._P_ShowObjects) { GUILayout.EndHorizontal(); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); if (GUILayout.Button("(High/Low)")) { ReordelList(i, false); } if (GUILayout.Button("(Low/High)")) { ReordelList(i, true); } GUILayout.EndHorizontal(); for (int o = 0; o < _MapLayers[i]._P_Objects.Count; o++) { GUILayout.BeginHorizontal(); _MapLayers[i]._P_Objects[o] = (GameObject)EditorGUILayout.ObjectField(_MapLayers[i]._P_Objects[o], typeof(GameObject), true); _MapLayers[i]._P_OrderInLayer[o] = EditorGUILayout.IntField("Order in Layer", _MapLayers[i]._P_OrderInLayer[o]); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.BeginHorizontal(); } GUILayout.EndHorizontal(); } for (int i = 0; i < _MapLayers.Count; i++) { if (_MapLayers[i]._P_ShowObjects) { GUILayout.Space(_MapLayers[i]._P_Objects.Count); } } GUILayout.EndScrollView(); }
public override void OnInspectorGUI() { d = (VIDE_Assign)target; Color defColor = GUI.color; GUI.color = Color.yellow; //Create a button to open up the VIDE Editor and load the currently assigned dialogue if (GUILayout.Button("Open VIDE Editor")) { openVIDE_Editor(d.assignedIndex); } GUI.color = defColor; //Refresh dialogue list if (Event.current.type == EventType.MouseDown) { if (d != null) { loadFiles(); } } GUILayout.BeginHorizontal(); GUILayout.Label("Dialogue name: "); Undo.RecordObject(d, "Changed dialogue name"); d.dialogueName = EditorGUILayout.TextField(d.dialogueName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Assigned dialogue:"); if (d.diags.Count > 0) { EditorGUI.BeginChangeCheck(); Undo.RecordObject(d, "Changed dialogue index"); d.assignedIndex = EditorGUILayout.Popup(d.assignedIndex, d.diags.ToArray()); if (EditorGUI.EndChangeCheck()) { int theID = 0; if (File.Exists(Application.dataPath + "/" + VIDE_Editor.pathToVide + "VIDE/Resources/Dialogues/" + d.diags[d.assignedIndex] + ".json")) { Dictionary <string, object> dict = SerializeHelper.ReadFromFile(d.diags[d.assignedIndex] + ".json") as Dictionary <string, object>; if (dict.ContainsKey("dID")) { theID = ((int)((long)dict["dID"])); } else { Debug.LogError("Could not read dialogue ID!"); } } d.assignedID = theID; d.assignedDialogue = d.diags[d.assignedIndex]; } } else { GUILayout.Label("No saved Dialogues!"); } GUILayout.EndHorizontal(); GUILayout.Label("Interaction Count: " + d.interactionCount.ToString()); GUILayout.BeginHorizontal(); GUILayout.Label("Override Start Node: "); Undo.RecordObject(d, "Changed override start node"); d.overrideStartNode = EditorGUILayout.IntField(d.overrideStartNode); GUILayout.EndHorizontal(); }
//==================================== // Show Console Output Settings //==================================== void ShowConsoleOutputSettings() { settings.consoleColour = EditorGUILayout.ColorField("Console colour", settings.consoleColour); settings.consoleMaxLength = (uint)EditorGUILayout.IntField("Console max length", (int)settings.consoleMaxLength); }
public override void OnInspectorGUI() { if (mMasks == null) { mMasks = M8.EditorExt.Utility.GenerateGenericMaskString(); } SceneState data = target as SceneState; if (!Application.isPlaying) { //Globals initGlobalFoldout = EditorGUILayout.Foldout(initGlobalFoldout, "Scene Global Data"); if (initGlobalFoldout) { GUILayout.BeginVertical(GUI.skin.box); int delSubKey = -1; for (int j = 0; j < data.globalStartData.Length; j++) { SceneState.InitData initDat = data.globalStartData[j]; EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); initDat.name = GUILayout.TextField(initDat.name, GUILayout.MinWidth(200)); GUILayout.Space(32); if (GUILayout.Button("DEL", GUILayout.MaxWidth(40))) { delSubKey = j; } GUILayout.EndHorizontal(); initDat.type = (SceneState.Type)EditorGUILayout.EnumPopup("Type", initDat.type); switch (initDat.type) { case SceneState.Type.Integer: initDat.ival = EditorGUILayout.IntField("Value", initDat.ival); initDat.ival = EditorGUILayout.MaskField("Flags", initDat.ival, mMasks); break; case SceneState.Type.Float: initDat.fval = EditorGUILayout.FloatField("Float", initDat.fval); break; case SceneState.Type.String: initDat.sval = EditorGUILayout.TextField("String", initDat.sval); break; } GUILayout.EndVertical(); if (delSubKey == -1 && EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "SceneState - Edit [" + data.globalStartData[j].name + "]"); data.globalStartData[j] = initDat; } } if (delSubKey != -1) { Undo.RecordObject(target, "SceneState - Removed [" + data.globalStartData[delSubKey].name + "]"); M8.ArrayUtil.RemoveAt(ref data.globalStartData, delSubKey); } if (GUILayout.Button("New Global Value")) { Undo.RecordObject(target, "SceneState - New Global Value"); System.Array.Resize(ref data.globalStartData, data.globalStartData.Length + 1); data.globalStartData[data.globalStartData.Length - 1] = new SceneState.InitData(SceneState.Type.Integer); } GUILayout.EndVertical(); } M8.EditorExt.Utility.DrawSeparator(); //Scene Specifics initFoldout = EditorGUILayout.Foldout(initFoldout, "Scene Data"); if (initFoldout) { //Cache count EditorGUI.BeginChangeCheck(); int cacheCount = EditorGUILayout.IntField("Cache Count", data.localStateCache); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "SceneState - Cache Count Change"); data.localStateCache = cacheCount; } //Scenes int delKey = -1; for (int i = 0; i < data.startData.Length; i++) { SceneState.InitSceneData sceneDat = data.startData[i]; GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); sceneDat.editFoldout = EditorGUILayout.Foldout(sceneDat.editFoldout, "Scene:"); GUILayout.Space(4); //Scene name EditorGUI.BeginChangeCheck(); string newScene = GUILayout.TextField(sceneDat.scene, GUILayout.MinWidth(200)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "SceneState - Change Scene Name from " + sceneDat.scene + " to " + newScene); sceneDat.scene = newScene; } GUILayout.Space(32); if (GUILayout.Button("DEL", GUILayout.MaxWidth(40))) { delKey = i; } GUILayout.EndHorizontal(); if (sceneDat.editFoldout) { GUILayout.Label("Values:"); if (sceneDat.data != null) { int delSubKey = -1; for (int j = 0; j < sceneDat.data.Length; j++) { EditorGUI.BeginChangeCheck(); SceneState.InitData initDat = sceneDat.data[j]; GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); initDat.name = GUILayout.TextField(initDat.name, GUILayout.MinWidth(200)); GUILayout.Space(32); if (GUILayout.Button("DEL", GUILayout.MaxWidth(40))) { delSubKey = j; } GUILayout.EndHorizontal(); initDat.type = (SceneState.Type)EditorGUILayout.EnumPopup("Type", initDat.type); switch (initDat.type) { case SceneState.Type.Integer: initDat.ival = EditorGUILayout.IntField("Value", initDat.ival); initDat.ival = EditorGUILayout.MaskField("Flags", initDat.ival, mMasks); break; case SceneState.Type.Float: initDat.fval = EditorGUILayout.FloatField("Float", initDat.fval); break; case SceneState.Type.String: initDat.sval = EditorGUILayout.TextField("String", initDat.sval); break; } GUILayout.EndVertical(); if (delKey != -1 && delSubKey != -1 && EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "SceneState (" + sceneDat.scene + ") - Edit [" + sceneDat.data[j].name + "]"); sceneDat.data[j] = initDat; } } if (delSubKey != -1) { Undo.RecordObject(target, "SceneState (" + sceneDat.scene + ") - Removed [" + sceneDat.data[delSubKey].name + "]"); M8.ArrayUtil.RemoveAt(ref sceneDat.data, delSubKey); } } if (GUILayout.Button("New Value")) { Undo.RecordObject(target, "SceneState (" + sceneDat.scene + ") - New Value"); if (sceneDat.data == null) { sceneDat.data = new SceneState.InitData[1]; } else { System.Array.Resize(ref sceneDat.data, sceneDat.data.Length + 1); } sceneDat.data[sceneDat.data.Length - 1] = new SceneState.InitData(SceneState.Type.Integer); } } GUILayout.EndVertical(); } if (delKey != -1) { Undo.RecordObject(target, "SceneState - Removed [" + data.startData[delKey].scene + "]"); M8.ArrayUtil.RemoveAt(ref data.startData, delKey); } if (GUILayout.Button("New Scene Data")) { Undo.RecordObject(target, "SceneState - New Scene Set Added"); System.Array.Resize(ref data.startData, data.startData.Length + 1); data.startData[data.startData.Length - 1] = new SceneState.InitSceneData(); } } } else { M8.EditorExt.Utility.DrawSeparator(); //global scene data runtimeGlobalFoldout = EditorGUILayout.Foldout(runtimeGlobalFoldout, "Global Scene Data"); if (runtimeGlobalFoldout && data.global != null) { foreach (var pair in data.global) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label(pair.Key); switch (pair.Value.type) { case SceneState.Type.Integer: EditorGUILayout.LabelField("Value", pair.Value.ival.ToString()); EditorGUILayout.MaskField("Flags", pair.Value.ival, mMasks); break; case SceneState.Type.Float: EditorGUILayout.LabelField("Float", pair.Value.fval.ToString()); break; case SceneState.Type.String: EditorGUILayout.LabelField("String", pair.Value.sval); break; case SceneState.Type.Invalid: EditorGUILayout.LabelField("Invalid!"); break; } GUILayout.EndVertical(); } } M8.EditorExt.Utility.DrawSeparator(); //Scene data runtimeFoldout = EditorGUILayout.Foldout(runtimeFoldout, "Scene Data"); if (runtimeFoldout && data.local != null) { foreach (var pair in data.local) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label(pair.Key); switch (pair.Value.type) { case SceneState.Type.Integer: EditorGUILayout.LabelField("Value", pair.Value.ival.ToString()); EditorGUILayout.MaskField("Flags", pair.Value.ival, mMasks); break; case SceneState.Type.Float: EditorGUILayout.LabelField("Float", pair.Value.fval.ToString()); break; case SceneState.Type.String: EditorGUILayout.LabelField("String", pair.Value.sval); break; case SceneState.Type.Invalid: EditorGUILayout.LabelField("Invalid!"); break; } GUILayout.EndVertical(); } } M8.EditorExt.Utility.DrawSeparator(); //value change GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("Override"); mApplyName = GUILayout.TextField(mApplyName); mApplyType = (SceneState.Type)EditorGUILayout.EnumPopup("Type", mApplyType); switch (mApplyType) { case SceneState.Type.Integer: mApplyValue = EditorGUILayout.IntField("Value", mApplyValue); mApplyValue = EditorGUILayout.MaskField("Flags", mApplyValue, mMasks); break; case SceneState.Type.Float: mApplyFValue = EditorGUILayout.FloatField("Float", mApplyFValue); break; case SceneState.Type.String: mApplySValue = EditorGUILayout.TextField("String", mApplySValue); break; } mApplyToGlobal = GUILayout.Toggle(mApplyToGlobal, "Global"); mApplyPersistent = GUILayout.Toggle(mApplyPersistent, "Persistent"); var table = mApplyToGlobal ? data.global : data.local; if (GUILayout.Button("Apply") && !string.IsNullOrEmpty(mApplyName)) { switch (mApplyType) { case SceneState.Type.Integer: table.SetValue(mApplyName, mApplyValue, mApplyPersistent); break; case SceneState.Type.Float: table.SetValueFloat(mApplyName, mApplyFValue, mApplyPersistent); break; case SceneState.Type.String: table.SetValueString(mApplyName, mApplySValue, mApplyPersistent); break; } Repaint(); } GUILayout.EndVertical(); M8.EditorExt.Utility.DrawSeparator(); //refresh if (GUILayout.Button("Refresh")) { if (!string.IsNullOrEmpty(mApplyName)) { var val = table.GetValueRaw(mApplyName); mApplyValue = val.ival; mApplyFValue = val.fval; mApplySValue = val.sval; } Repaint(); } } }
public override void OnInspectorGUI() { MegaWire mod = (MegaWire)target; undoManager.CheckUndo(); EditorGUIUtility.LookLikeControls(); MegaWire.DisableAll = EditorGUILayout.Toggle("Disable All", MegaWire.DisableAll); if ( GUILayout.Button("Rebuild") ) { mod.Rebuild = true; mod.RebuildWire(); } mod.warmPhysicsTime = EditorGUILayout.FloatField("Warm Physics Time", mod.warmPhysicsTime); if ( GUILayout.Button("Run Physics") ) { mod.RunPhysics(mod.warmPhysicsTime); } if ( GUILayout.Button("Open Select Window") ) { } if ( GUILayout.Button("Add Wire") ) { MegaWireConnectionDef last = mod.connections[mod.connections.Count - 1]; MegaWireConnectionDef cdef = new MegaWireConnectionDef(); cdef.inOffset = last.inOffset; cdef.outOffset = last.outOffset; cdef.radius = last.radius; mod.connections.Add(cdef); mod.RebuildWire(); mod.Rebuild = true; } mod.Enabled = EditorGUILayout.Toggle("Enabled", mod.Enabled); bool ShowWire = EditorGUILayout.Toggle("Show Wire", mod.ShowWire); if ( ShowWire != mod.ShowWire ) { mod.ShowWire = ShowWire; mod.SetWireVisible(ShowWire); } // Lod params mod.disableOnDistance = EditorGUILayout.BeginToggleGroup("Disable On Dist", mod.disableOnDistance); mod.disableDist = EditorGUILayout.FloatField("Disable Dist", mod.disableDist); EditorGUILayout.EndToggleGroup(); mod.disableOnNotVisible = EditorGUILayout.Toggle("Disable On InVisible", mod.disableOnNotVisible); // Physics data mod.showphysics = EditorGUILayout.Foldout(mod.showphysics, "Physics Params"); if ( mod.showphysics ) { EditorGUILayout.BeginVertical("box"); int points = EditorGUILayout.IntSlider("Masses", mod.points, 2, 20); if ( points != mod.points ) { mod.points = points; mod.RebuildWire(); } float Mass = EditorGUILayout.FloatField("Mass", mod.Mass); if ( Mass != mod.Mass ) { mod.Mass = Mass; mod.RebuildWire(); } float massrnd = EditorGUILayout.FloatField("Mass Random", mod.massRand); if ( massrnd != mod.massRand ) { mod.massRand = massrnd; mod.RebuildWire(); } float spring = EditorGUILayout.FloatField("Spring", mod.spring); if ( spring != mod.spring ) { mod.spring = spring; mod.RebuildWire(); } float damp = EditorGUILayout.FloatField("Damp", mod.damp); if ( damp != mod.damp ) { mod.damp = damp; mod.RebuildWire(); } float stretch = EditorGUILayout.FloatField("Stretch", mod.stretch); if ( stretch != mod.stretch ) { mod.stretch = stretch; mod.ChangeStretch(stretch); } mod.gravity = EditorGUILayout.Vector3Field("Gravity", mod.gravity); mod.airdrag = EditorGUILayout.Slider("Aero Drag", mod.airdrag, 0.0f, 1.0f); // These require a rebuild bool lencon = EditorGUILayout.Toggle("Length Constraints", mod.lengthConstraints); if ( lencon != mod.lengthConstraints ) { mod.lengthConstraints = lencon; mod.RebuildWire(); } bool stiff = EditorGUILayout.BeginToggleGroup("Stiff Springs", mod.stiffnessSprings); if ( stiff != mod.stiffnessSprings ) { mod.stiffnessSprings = stiff; mod.RebuildWire(); } float stiffrate = EditorGUILayout.FloatField("Stiff Rate", mod.stiffrate); if ( stiffrate != mod.stiffrate ) { mod.stiffrate = stiffrate; mod.RebuildWire(); } float stiffdamp = EditorGUILayout.FloatField("Stiff Damp", mod.stiffdamp); if ( stiffdamp != mod.stiffdamp ) { mod.stiffdamp = stiffdamp; mod.RebuildWire(); } EditorGUILayout.EndToggleGroup(); mod.doCollisions = EditorGUILayout.BeginToggleGroup("Do Collisions", mod.doCollisions); mod.floor = EditorGUILayout.FloatField("Floor", mod.floor); EditorGUILayout.EndToggleGroup(); mod.showWindParams = EditorGUILayout.Foldout(mod.showWindParams, "Wind Params"); if ( mod.showWindParams ) { mod.wind = (MegaWireWind)EditorGUILayout.ObjectField("Wind Src", mod.wind, typeof(MegaWireWind), true); MegaWire.windDir = EditorGUILayout.Vector3Field("Wind Dir", MegaWire.windDir); MegaWire.windFrc = EditorGUILayout.FloatField("Wind Frc", MegaWire.windFrc); mod.windEffect = EditorGUILayout.FloatField("Wind Effect", mod.windEffect); } mod.showPhysicsAdv = EditorGUILayout.Foldout(mod.showPhysicsAdv, "Advanced Params"); if ( mod.showPhysicsAdv ) { mod.timeStep = EditorGUILayout.FloatField("Time Step", mod.timeStep); mod.fudge = EditorGUILayout.FloatField("Time Mult", mod.fudge); mod.startTime = EditorGUILayout.FloatField("Start Time", mod.startTime); mod.awakeTime = EditorGUILayout.FloatField("Awake Time", mod.awakeTime); mod.frameWait = EditorGUILayout.IntField("Frame Wait", mod.frameWait); mod.frameNum = EditorGUILayout.IntField("Frame Num", mod.frameNum); mod.iters = EditorGUILayout.IntSlider("Constraint Iters", mod.iters, 1, 8); } EditorGUILayout.EndVertical(); } // Meshing options mod.showmeshparams = EditorGUILayout.Foldout(mod.showmeshparams, "Mesh Params"); if ( mod.showmeshparams ) { EditorGUILayout.BeginVertical("box"); Material mat = (Material)EditorGUILayout.ObjectField("Material", mod.material, typeof(Material), true); if ( mat != mod.material ) { mod.material = mat; for ( int i = 0; i < mod.spans.Count; i++ ) { mod.spans[i].renderer.sharedMaterial = mat; } } mod.strandedMesher.sides = EditorGUILayout.IntSlider("Sides", mod.strandedMesher.sides, 2, 32); mod.strandedMesher.segments = EditorGUILayout.IntSlider("Segments", mod.strandedMesher.segments, 1, 64); mod.strandedMesher.SegsPerUnit = EditorGUILayout.FloatField("Segs Per Unit", mod.strandedMesher.SegsPerUnit); mod.strandedMesher.strands = EditorGUILayout.IntSlider("Strands", mod.strandedMesher.strands, 1, 8); mod.strandedMesher.offset = EditorGUILayout.FloatField("Offset", mod.strandedMesher.offset); mod.strandedMesher.strandRadius = EditorGUILayout.FloatField("Strand Radius", mod.strandedMesher.strandRadius); mod.strandedMesher.Twist = EditorGUILayout.FloatField("Twist", mod.strandedMesher.Twist); mod.strandedMesher.TwistPerUnit = EditorGUILayout.FloatField("Twist Per Unit", mod.strandedMesher.TwistPerUnit); bool genuv = EditorGUILayout.BeginToggleGroup("Gen UV", mod.strandedMesher.genuv); if ( genuv != mod.strandedMesher.genuv ) { mod.strandedMesher.genuv = genuv; mod.builduvs = true; } float uvtwist = EditorGUILayout.FloatField("UV Twist", mod.strandedMesher.uvtwist); if ( uvtwist != mod.strandedMesher.uvtwist ) { mod.strandedMesher.uvtwist = uvtwist; mod.builduvs = true; } float uvtilex = EditorGUILayout.FloatField("UV Tile X", mod.strandedMesher.uvtilex); if ( uvtilex != mod.strandedMesher.uvtilex ) { mod.strandedMesher.uvtilex = uvtilex; mod.builduvs = true; } float uvtiley = EditorGUILayout.FloatField("UV Tile Y", mod.strandedMesher.uvtiley); if ( uvtiley != mod.strandedMesher.uvtiley ) { mod.strandedMesher.uvtiley = uvtiley; mod.builduvs = true; } EditorGUILayout.EndToggleGroup(); mod.strandedMesher.linInterp = EditorGUILayout.Toggle("Linear Interp", mod.strandedMesher.linInterp); mod.strandedMesher.calcBounds = EditorGUILayout.Toggle("Calc Bounds", mod.strandedMesher.calcBounds); mod.strandedMesher.calcTangents = EditorGUILayout.Toggle("Calc Tangents", mod.strandedMesher.calcTangents); int vcount = mod.GetVertexCount(); EditorGUILayout.LabelField("Vertex Count: " + vcount); EditorGUILayout.EndVertical(); } mod.showconnections = EditorGUILayout.Foldout(mod.showconnections, "Connections"); if ( mod.showconnections ) { for ( int i = 0; i < mod.connections.Count; i++ ) { MegaWireConnectionDef con = mod.connections[i]; EditorGUILayout.BeginVertical("box"); float radius = EditorGUILayout.FloatField("Radius", con.radius); if ( radius != con.radius ) { con.radius = radius; } Vector3 outOffset = EditorGUILayout.Vector3Field("Out Offset", con.outOffset); if ( outOffset != con.outOffset ) { con.outOffset = outOffset; mod.Rebuild = true; } Vector3 inOffset = EditorGUILayout.Vector3Field("In Offset", con.inOffset); if ( inOffset != con.inOffset ) { con.inOffset = inOffset; mod.Rebuild = true; } if ( GUILayout.Button("Delete") ) { if ( mod.connections.Count > 1 ) { mod.connections.RemoveAt(i); mod.RebuildWire(); mod.Rebuild = true; } } EditorGUILayout.EndVertical(); } } bool hidespans = EditorGUILayout.Toggle("Hide Spans", mod.hidespans); if ( hidespans != mod.hidespans ) { mod.hidespans = hidespans; mod.SetHidden(mod.hidespans); EditorApplication.RepaintHierarchyWindow(); } mod.displayGizmo = EditorGUILayout.BeginToggleGroup("Show Gizmos", mod.displayGizmo); mod.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", mod.gizmoColor); EditorGUILayout.EndToggleGroup(); mod.showAttach = EditorGUILayout.Foldout(mod.showAttach, "Span Connections"); if ( mod.showAttach ) { EditorGUILayout.BeginVertical("Box"); for ( int i = 0; i < mod.spans.Count; i++ ) { if ( i > 0 ) EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Start", GUILayout.MaxWidth(40.0f)); for ( int c = 0; c < mod.spans[i].connections.Count; c++ ) { bool active = EditorGUILayout.Toggle(mod.spans[i].connections[c].constraints[0].active, GUILayout.MaxWidth(10.0f)); if ( active != mod.spans[i].connections[c].constraints[0].active ) mod.spans[i].connections[c].SetEndConstraintActive(0, active, 2.0f); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("End", GUILayout.MaxWidth(40.0f)); for ( int c = 0; c < mod.spans[i].connections.Count; c++ ) { bool active = EditorGUILayout.Toggle(mod.spans[i].connections[c].constraints[1].active, GUILayout.MaxWidth(10.0f)); if ( active != mod.spans[i].connections[c].constraints[1].active ) mod.spans[i].connections[c].SetEndConstraintActive(1, active, 2.0f); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } if ( GUI.changed ) EditorUtility.SetDirty(target); undoManager.CheckDirty(); }
public override void OnInspectorGUI() { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("HTFramework Main Module!", MessageType.Info); GUILayout.EndHorizontal(); #region MainData GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.Label("MainData"); if (GUILayout.Button(_target.MainDataType, "MiniPopup")) { GenericMenu gm = new GenericMenu(); List <Type> types = GlobalTools.GetTypesInRunTimeAssemblies(); gm.AddItem(new GUIContent("<None>"), _target.MainDataType == "<None>", () => { Undo.RecordObject(target, "Set Main Data"); _target.MainDataType = "<None>"; this.HasChanged(); }); for (int i = 0; i < types.Count; i++) { if (types[i].BaseType == typeof(MainData)) { int j = i; gm.AddItem(new GUIContent(types[j].FullName), _target.MainDataType == types[j].FullName, () => { Undo.RecordObject(target, "Set Main Data"); _target.MainDataType = types[j].FullName; this.HasChanged(); }); } } gm.ShowAsContext(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); #endregion #region License GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); this.Toggle(_target.IsPermanentLicense, out _target.IsPermanentLicense, "Permanent License"); GUILayout.EndHorizontal(); if (!_target.IsPermanentLicense) { GUILayout.BeginHorizontal(); GUILayout.Label("Prompt:", "BoldLabel"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); this.TextField(_target.EndingPrompt, out _target.EndingPrompt); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Ending Time:", "BoldLabel"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Year:", GUILayout.Width(45)); int year = EditorGUILayout.IntField(_target.Year, GUILayout.Width(50)); if (year != _target.Year) { Undo.RecordObject(target, "Set Year"); _target.Year = year; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Plus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Year"); _target.Year += 1; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Minus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Year"); _target.Year -= 1; CorrectDateTime(); this.HasChanged(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Month:", GUILayout.Width(45)); int month = EditorGUILayout.IntField(_target.Month, GUILayout.Width(50)); if (month != _target.Month) { Undo.RecordObject(target, "Set Month"); _target.Month = month; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Plus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Month"); _target.Month += 1; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Minus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Month"); _target.Month -= 1; CorrectDateTime(); this.HasChanged(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Day:", GUILayout.Width(45)); int day = EditorGUILayout.IntField(_target.Day, GUILayout.Width(50)); if (day != _target.Day) { Undo.RecordObject(target, "Set Day"); _target.Day = day; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Plus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Day"); _target.Day += 1; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("", "OL Minus", GUILayout.Width(15))) { Undo.RecordObject(target, "Set Day"); _target.Day -= 1; CorrectDateTime(); this.HasChanged(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Now", "MiniButton")) { Undo.RecordObject(target, "Set Now"); _target.Year = DateTime.Now.Year; _target.Month = DateTime.Now.Month; _target.Day = DateTime.Now.Day; CorrectDateTime(); this.HasChanged(); } if (GUILayout.Button("2 Months Later", "MiniButton")) { Undo.RecordObject(target, "Set 2 Months Later"); _target.Month += 2; CorrectDateTime(); this.HasChanged(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); #endregion }
public void ShowInternalData(bool useCustomLabel = false, string customLabel = null) { string label = (useCustomLabel == true && customLabel != null) ? customLabel : m_internalDataPropertyLabel; switch (m_dataType) { case WirePortDataType.OBJECT: case WirePortDataType.FLOAT: { FloatInternalData = EditorGUILayout.FloatField(label, FloatInternalData); } break; case WirePortDataType.FLOAT2: { Vector2InternalData = EditorGUILayout.Vector2Field(label, Vector2InternalData); } break; case WirePortDataType.FLOAT3: { Vector3InternalData = EditorGUILayout.Vector3Field(label, Vector3InternalData); } break; case WirePortDataType.FLOAT4: { Vector4InternalData = EditorGUILayout.Vector4Field(label, Vector4InternalData); } break; case WirePortDataType.FLOAT3x3: case WirePortDataType.FLOAT4x4: { Matrix4x4 matrix = Matrix4x4InternalData; for (int i = 0; i < 4; i++) { Vector4 currVec = matrix.GetRow(i); EditorGUI.BeginChangeCheck(); currVec = EditorGUILayout.Vector4Field(label + "[ " + i + " ]", currVec); if (EditorGUI.EndChangeCheck()) { matrix.SetRow(i, currVec); } } Matrix4x4InternalData = matrix; } break; case WirePortDataType.COLOR: { ColorInternalData = EditorGUILayout.ColorField(label, ColorInternalData); } break; case WirePortDataType.INT: { IntInternalData = EditorGUILayout.IntField(label, IntInternalData); } break; } }
protected override void OnDrawPropertiesGUI(Material material, MaterialProperty[] props) { var _showStencilSettings = EditorGUILayout.Foldout(m_showStencilSettings, m_title); if (m_showStencilSettings) { var comp = CompareFunction.Always; var pass_op = StencilOp.Keep; var fail_op = StencilOp.Keep; var zfail_op = StencilOp.Keep; var sref = 0; var swmask = 255; var srmask = 255; EditorGUI.BeginChangeCheck(); try { EditorGUI.indentLevel++; if (m_prop_StencilComp != null) { GUI.enabled = m_prop_StencilComp_Enabled; var _comp = ( CompareFunction )m_prop_StencilComp.floatValue; comp = ( CompareFunction )EditorGUILayout.EnumPopup(m_prop_StencilComp.displayName, _comp); } if (m_prop_Stencil != null) { GUI.enabled = m_prop_Stencil_Enabled; sref = EditorGUILayout.IntField(m_prop_Stencil.displayName, ( int )m_prop_Stencil.floatValue); sref = Mathf.Clamp(sref, 0, 255); } if (m_prop_StencilWriteMask != null) { GUI.enabled = m_prop_StencilWriteMask_Enabled; swmask = EditorGUILayout.IntField(m_prop_StencilWriteMask.displayName, ( int )m_prop_StencilWriteMask.floatValue); swmask = Mathf.Clamp(swmask, 0, 255); } if (m_prop_StencilReadMask != null) { GUI.enabled = m_prop_StencilReadMask_Enabled; srmask = EditorGUILayout.IntField(m_prop_StencilReadMask.displayName, ( int )m_prop_StencilReadMask.floatValue); srmask = Mathf.Clamp(srmask, 0, 255); } if (m_prop_StencilPass != null) { GUI.enabled = m_prop_StencilPass_Enabled; var _op = ( StencilOp )m_prop_StencilPass.floatValue; pass_op = ( StencilOp )EditorGUILayout.EnumPopup(m_prop_StencilPass.displayName, _op); } if (m_prop_StencilFail != null) { GUI.enabled = m_prop_StencilFail_Enabled; var _op = ( StencilOp )m_prop_StencilFail.floatValue; fail_op = ( StencilOp )EditorGUILayout.EnumPopup(m_prop_StencilFail.displayName, _op); } if (m_prop_StencilZFail != null) { GUI.enabled = m_prop_StencilZFail_Enabled; var _op = ( StencilOp )m_prop_StencilZFail.floatValue; zfail_op = ( StencilOp )EditorGUILayout.EnumPopup(m_prop_StencilZFail.displayName, _op); } } finally { GUI.enabled = true; EditorGUI.indentLevel--; if (EditorGUI.EndChangeCheck()) { if (m_prop_StencilComp != null) { m_prop_StencilComp.floatValue = ( float )comp; } if (m_prop_Stencil != null) { m_prop_Stencil.floatValue = ( float )sref; } if (m_prop_StencilWriteMask != null) { m_prop_StencilWriteMask.floatValue = ( float )swmask; } if (m_prop_StencilReadMask != null) { m_prop_StencilReadMask.floatValue = ( float )srmask; } if (m_prop_StencilPass != null) { m_prop_StencilPass.floatValue = ( float )pass_op; } if (m_prop_StencilFail != null) { m_prop_StencilFail.floatValue = ( float )fail_op; } if (m_prop_StencilZFail != null) { m_prop_StencilZFail.floatValue = ( float )zfail_op; } } } } m_showStencilSettings = _showStencilSettings; }
public override void OnInspectorGUI() { EffectLayer ctarget = (EffectLayer)target; EditorGUIUtility.LookLikeControls(PreLableWidth); EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("render type:"); ctarget.RenderType = EditorGUILayout.Popup(ctarget.RenderType, RenderTypes); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("client transform:"); ctarget.ClientTransform = (Transform)EditorGUILayout.ObjectField(ctarget.ClientTransform, typeof(Transform), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("sync to client pos:"); ctarget.SyncClient = EditorGUILayout.Toggle(ctarget.SyncClient); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("material :"); ctarget.Material = (Material)EditorGUILayout.ObjectField(ctarget.Material, typeof(Material), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("render queue :"); ctarget.Depth = EditorGUILayout.IntField(ctarget.Depth); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); ctarget.StartTime = EditorGUILayout.FloatField("delay(s):", ctarget.StartTime); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); ctarget.MaxFps = EditorGUILayout.FloatField("Max FPS:", ctarget.MaxFps); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); ctarget.DrawDebug = EditorGUILayout.Toggle("Draw Debug?", ctarget.DrawDebug); EditorGUILayout.EndHorizontal(); if (ctarget.DrawDebug) { EditorGUILayout.BeginHorizontal(); ctarget.DebugColor = EditorGUILayout.ColorField("debug color:", ctarget.DebugColor); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.Separator(); if (ctarget.RenderType == 0) { SpriteConfig(ctarget); } else if (ctarget.RenderType == 1) { RibbonTrailConfig(ctarget); } else if (ctarget.RenderType == 2) { ConeConfig(ctarget); } else if (ctarget.RenderType == 3) { CustomMeshConfig(ctarget); } if (ctarget.RenderType == 0 || ctarget.RenderType == 2 || ctarget.RenderType == 3) { EditorGUILayout.Space(); EditorGUILayout.Separator(); RotateConfig(ctarget); EditorGUILayout.Space(); EditorGUILayout.Separator(); ScaleConfig(ctarget); } EditorGUILayout.Space(); EditorGUILayout.Separator(); ColorConfig(ctarget); if (ctarget.RenderType != 3) { EditorGUILayout.Space(); EditorGUILayout.Separator(); UVConfig(ctarget); } EditorGUILayout.Space(); EditorGUILayout.Separator(); EmitterConfig(ctarget); EditorGUILayout.Space(); EditorGUILayout.Separator(); OriginalVelocityConfig(ctarget); EditorGUILayout.Space(); EditorGUILayout.Separator(); AffectorConfig(ctarget); EditorGUILayout.Space(); EditorGUILayout.Separator(); CollisionConfig(ctarget); EditorGUILayout.Space(); EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
void OnGUI() { card = (MonoScript)EditorGUILayout.ObjectField("card script", card, typeof(MonoScript), false); cardFilePath = GUILayout.TextField(cardFilePath); if (!cardFilePath.EndsWith("/")) { cardFilePath += "/"; } if (GUILayout.Button("set prefab location based on cardClass")) { cardFilePath = card.GetClass().Name + "/"; //default names cardAttrabutes.cardIconPath = cardFilePath + "icon"; cardAttrabutes.cardArtPath = cardFilePath + "card art"; cardAttrabutes.cardDescriptionPath = cardFilePath + "description"; cardAttrabutes.cardName = card.GetClass().Name; } //load existing card attributes TextAsset tempChangeCheck = existingCardAttr; existingCardAttr = (TextAsset)EditorGUILayout.ObjectField("CardAttr", existingCardAttr, typeof(TextAsset), false); if (GUILayout.Button("update Existing CardAttr") || tempChangeCheck != existingCardAttr) { if (existingCardAttr != null) { SaveAndLoadJson.loadStructFromString(out cardAttrabutes, existingCardAttr.text); string[] filePath = AssetDatabase.GetAssetPath(existingCardAttr).Split(new char[] { '/' }); int index = 0; while (index < filePath.Length) { if (filePath[index++] == "Resources") { break; } } cardFilePath = ""; for (int i = index; i < filePath.Length - 1; i++) { cardFilePath += filePath[i] + "/"; } } //default names cardAttrabutes.cardIconPath = cardFilePath + "icon"; cardAttrabutes.cardArtPath = cardFilePath + "card art"; cardAttrabutes.cardDescriptionPath = cardFilePath + "description"; } cardAttrabutes.cardName = EditorGUILayout.TextField("card displayed name", cardAttrabutes.cardName); cardAttrabutes.cardResorceCost = EditorGUILayout.FloatField("cost", cardAttrabutes.cardResorceCost); cardAttrabutes.cardReloadTime_seconds = EditorGUILayout.FloatField("slot reload time", cardAttrabutes.cardReloadTime_seconds); cardAttrabutes.removeOnDraw = EditorGUILayout.Toggle("removedOnDraw", cardAttrabutes.removeOnDraw); cardAttrabutes.probabilityOfDraw = EditorGUILayout.FloatField("draw probability", cardAttrabutes.probabilityOfDraw); cardAttrabutes.numberOfCardAllowedInDeck = EditorGUILayout.IntField("Numb Allowed In Deck", cardAttrabutes.numberOfCardAllowedInDeck); cardAttrabutes.cardElements = (DamageTypes)EditorGUILayout.EnumMaskPopup("setCardElements", cardAttrabutes.cardElements); cardAttrabutes.cardType = (CardLocation)EditorGUILayout.EnumMaskPopup("setCardType(s)", cardAttrabutes.cardType); GUILayout.Label("icon,card art, and card description (.txt)\nmust be added to the created folder"); GUIStyle colorset = new GUIStyle(GUI.skin.button); if (timeLeftOnScreen_sec > 0) { colorset.normal.textColor = new Color(0f, 0.4f, 0f); timeLeftOnScreen_sec -= Time.deltaTime; } else { colorset.normal.textColor = Color.black; } if (GUILayout.Button("create card information", colorset) && cardFilePath != "/") { if (!Directory.Exists(SaveAndLoadJson.getResourcePath(cardFilePath))) { Directory.CreateDirectory(SaveAndLoadJson.getResourcePath(cardFilePath)); } //string printer = ""; //SaveAndLoadJson.saveStructToString(cardAttrabutes,out printer); if (SaveAndLoadJson.saveStruct(SaveAndLoadJson.getResourcePath(cardFilePath + "CardAttr"), cardAttrabutes)) { timeLeftOnScreen_sec = timeOnScreenMax_sec; } AssetDatabase.Refresh(); } }
protected void EmitterConfig(EffectLayer ctarget) { DisplayEmitterConfig = EditorGUILayout.Foldout(DisplayEmitterConfig, "Emitter Configuration"); if (DisplayEmitterConfig) { EditorGUILayout.BeginVertical(); ctarget.EmitType = EditorGUILayout.Popup("emitter type:", ctarget.EmitType, EmitTypes); if (ctarget.EmitType == 0) { ctarget.EmitPoint = EditorGUILayout.Vector3Field("emit position:", ctarget.EmitPoint); } else if (ctarget.EmitType == 1) { ctarget.EmitPoint = EditorGUILayout.Vector3Field("box center:", ctarget.EmitPoint); ctarget.BoxSize = EditorGUILayout.Vector3Field("box size:", ctarget.BoxSize); ctarget.BoxInheritRotation = EditorGUILayout.Toggle("inherit rotation?", ctarget.BoxInheritRotation); } else if (ctarget.EmitType == 2) { ctarget.EmitPoint = EditorGUILayout.Vector3Field("sphere center:", ctarget.EmitPoint); ctarget.Radius = EditorGUILayout.FloatField("radius:", ctarget.Radius); } else if (ctarget.EmitType == 3) { ctarget.EmitPoint = EditorGUILayout.Vector3Field("circle center:", ctarget.EmitPoint); ctarget.CircleDir = EditorGUILayout.Vector3Field("circle direction:", ctarget.CircleDir); ctarget.Radius = EditorGUILayout.FloatField("radius:", ctarget.Radius); ctarget.EmitUniform = EditorGUILayout.Toggle("emit uniformly?", ctarget.EmitUniform); } else if (ctarget.EmitType == 4) { ctarget.EmitPoint = EditorGUILayout.Vector3Field("line center:", ctarget.EmitPoint); ctarget.LineLengthLeft = EditorGUILayout.FloatField("line left length:", ctarget.LineLengthLeft); ctarget.LineLengthRight = EditorGUILayout.FloatField("line right length:", ctarget.LineLengthRight); EditorGUILayout.LabelField("[line direction is based on client's forward direction.]"); } else if (ctarget.EmitType == 5) { ctarget.EmitMesh = (Mesh)EditorGUILayout.ObjectField("mesh", ctarget.EmitMesh, typeof(Mesh), true); ctarget.EmitMeshType = EditorGUILayout.Popup("mesh emit pos:", ctarget.EmitMeshType, EmitMeshType); ctarget.EmitUniform = EditorGUILayout.Toggle("emit uniform?", ctarget.EmitUniform); } EditorGUILayout.Space(); ctarget.MaxENodes = EditorGUILayout.IntField("max nodes:", ctarget.MaxENodes); ctarget.IsNodeLifeLoop = EditorGUILayout.Toggle("is node life loop:", ctarget.IsNodeLifeLoop); if (!ctarget.IsNodeLifeLoop) { ctarget.NodeLifeMin = EditorGUILayout.FloatField("node life min:", ctarget.NodeLifeMin); ctarget.NodeLifeMax = EditorGUILayout.FloatField("node life max:", ctarget.NodeLifeMax); } //ctarget.IsEmitByDistance = EditorGUILayout.Toggle("emit by distance:", ctarget.IsEmitByDistance); ctarget.EmitWay = (EEmitWay)EditorGUILayout.EnumPopup("emit method:", ctarget.EmitWay); if (ctarget.EmitWay == EEmitWay.ByDistance) { ctarget.DiffDistance = EditorGUILayout.FloatField("diff distance:", ctarget.DiffDistance); } else if (ctarget.EmitWay == EEmitWay.ByRate) { ctarget.ChanceToEmit = EditorGUILayout.Slider("chance to emit per loop:", ctarget.ChanceToEmit, 1, 100); ctarget.EmitDuration = EditorGUILayout.FloatField("emit duration:", ctarget.EmitDuration); ctarget.EmitRate = EditorGUILayout.FloatField("emit rate:", ctarget.EmitRate); ctarget.EmitLoop = EditorGUILayout.IntField("loop count(-1 is infinite):", ctarget.EmitLoop); ctarget.EmitDelay = EditorGUILayout.FloatField("delay after each loop:", ctarget.EmitDelay); } else { ctarget.EmitterCurve = EditorGUILayout.CurveField("emit curve:", ctarget.EmitterCurve); } EditorGUILayout.EndVertical(); } }
void OnGUI() { // Dragging events if (Event.current.type == EventType.mouseDrag) { if (currentRect.Contains(Event.current.mousePosition)) { if (!dragging) { dragging = true; startPos = currentPos; } } currentPos = Event.current.mousePosition; } if (Event.current.type == EventType.mouseUp) { dragging = false; } scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUI.DrawTexture(imageBackgroundRect, backgroundPreviewTex); for (int i = 0; i < sceneRef.getBarriersList().getBarriersList().Count; i++) { Rect aRect = new Rect(sceneRef.getBarriersList().getBarriersList()[i].getX(), sceneRef.getBarriersList().getBarriersList()[i].getY(), sceneRef.getBarriersList().getBarriersList()[i].getWidth(), sceneRef.getBarriersList().getBarriersList()[i].getHeight()); GUI.DrawTexture(aRect, barrierTex); // Frame around current area if (calledBarrierIndexRef == i) { currentRect = aRect; GUI.DrawTexture(currentRect, selectedBarrierTex); } } GUILayout.EndScrollView(); /* * HANDLE EVENTS */ if (dragging) { OnBeingDragged(); } GUILayout.BeginHorizontal(); GUILayout.Box("X", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box("Y", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Width"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Height"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); x = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getX(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); y = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getY(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); width = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getWidth(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); heigth = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getHeight(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].setValues(x, y, width, heigth); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Ok")) { reference.OnDialogOk("Applied"); this.Close(); } //if (GUILayout.Button(TC.get("GeneralText.Cancel"))) //{ // reference.OnDialogCanceled(); // this.Close(); //} GUILayout.EndHorizontal(); }
void OnGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Navigation", EditorStyles.boldLabel); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Select")) { ShowSelectWndow(); } GUILayout.EndHorizontal(); if (pNavMesh) { GUILayout.BeginHorizontal(); pNavMesh.verticalDrop = EditorGUILayout.IntField("Vertical Drop", pNavMesh.verticalDrop); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); pNavMesh.edgeGap = EditorGUILayout.IntField("Edge Gap", pNavMesh.edgeGap); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(so.FindProperty("gridSize")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(so.FindProperty("worldOrigin")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(so.FindProperty("worldSize")); GUILayout.EndHorizontal(); so.ApplyModifiedProperties(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Update")) { UpdateNavMesh(); } if (GUILayout.Button("Save")) { SaveNavMesh(); } GUILayout.EndHorizontal(); if (!pNavMesh.saved) { //debug GUILayout.BeginHorizontal(); debugDraw = EditorGUILayout.Toggle("Debug Draw", debugDraw); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); drawEdgeLoop = EditorGUILayout.Toggle("Draw Edge Loop", drawEdgeLoop); drawWalkAble = EditorGUILayout.Toggle("Draw Walkable", drawWalkAble); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); drawEdge = EditorGUILayout.Toggle("Draw Edge", drawEdge); drawEdgeGap = EditorGUILayout.Toggle("Draw Edge Gap", drawEdgeGap); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); drawPolygon = EditorGUILayout.Toggle("Draw Polygon", drawPolygon); drawCorner = EditorGUILayout.Toggle("Draw Corner", drawCorner); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); drawAAABB = EditorGUILayout.Toggle("Draw AABB", drawAAABB); drawPolygonGraph = EditorGUILayout.Toggle("Draw Polygon Graph", drawPolygonGraph); GUILayout.EndHorizontal(); } } }
void OnGUI() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); GUILayout.Label("[R] means that this is a requried field", EditorStyles.boldLabel); ///////////////////////////Base GUILayout.Label("Base Settings", EditorStyles.boldLabel); agentName = EditorGUILayout.TextField("Agent Name: ", agentName); EditorGUILayout.Space(); modelRootObject = (GameObject)EditorGUILayout.ObjectField("[R] Model Root Object", modelRootObject, typeof(GameObject), true); targetObjParentTransform = (Transform)EditorGUILayout.ObjectField("[R] Bone To Attach Target To", targetObjParentTransform, typeof(Transform), true); spineBoneToRotate = (Transform)EditorGUILayout.ObjectField("[R] Spine Bone To Rotate", spineBoneToRotate, typeof(Transform), true); eyeTransform = (Transform)EditorGUILayout.ObjectField("[R] Eye Transform", eyeTransform, typeof(Transform), true); EditorGUILayout.Space(); teamNumber = EditorGUILayout.IntField("Team Number", teamNumber); enemyTeamNumber = EditorGUILayout.IntField("Enemy Team Number", enemyTeamNumber); ///////////////////////////Gun EditorGUILayout.Space(); GUILayout.Label("Gun", EditorStyles.boldLabel); //weaponTransform = (Transform)EditorGUILayout.ObjectField("Gun Transform", weaponTransform, typeof(Transform), true); bulletSpawnerTransform = (Transform)EditorGUILayout.ObjectField("Bullet Spawn", bulletSpawnerTransform, typeof(Transform), true); if (bulletSpawnerTransform) { bulletObject = (GameObject)EditorGUILayout.ObjectField("Bullet Object", bulletObject, typeof(GameObject), true); bulletSound = (AudioClip)EditorGUILayout.ObjectField("Bullet Sound", bulletSound, typeof(AudioClip), true); EditorGUILayout.Space(); } ////////////////////////////Hitbox EditorGUILayout.Space(); GUILayout.Label("Hitboxes", EditorStyles.boldLabel); hitBoxTag = EditorGUILayout.TextField("Hitbox Tag", hitBoxTag); defaultHitMultiplier = EditorGUILayout.FloatField("Normal Hitbox Multiplier", defaultHitMultiplier); headHitMultiplier = EditorGUILayout.FloatField("Head Hitbox Multiplier", headHitMultiplier); ///////////////////////////Animation EditorGUILayout.Space(); GUILayout.Label("Animation Settings", EditorStyles.boldLabel); animationController = (AnimatorController)EditorGUILayout.ObjectField("[R] Animation Controller", animationController, typeof(AnimatorController), true); animationAvatar = (Avatar)EditorGUILayout.ObjectField("[R] Animation Avatar", animationAvatar, typeof(Avatar), true); EditorGUILayout.Space(); bool canContinue = (modelRootObject && eyeTransform && (spineBoneToRotate || !bulletSpawnerTransform) && animationController && targetObjParentTransform && animationAvatar); if (canContinue) { GUI.enabled = true; if (!bulletSpawnerTransform) { EditorGUILayout.HelpBox("Bullet Spawn empty! Bullet Spawn must be filled if you want to automatically spawn your bullets in a specific location. (This is the trnaform that marks the position and direction the bullets spawn in)", MessageType.Warning); } if (!bulletObject) { EditorGUILayout.HelpBox("Bullet Object empty! Bullet Object must be filled if you want to automatically allow your agent to fire. (This is the object that your agent will fire)", MessageType.Warning); } //else if (!weaponTransform) // EditorGUILayout.HelpBox("Gun Transform empty! Gun Transform must be filled if you want to automatically create an enemy with a gun. (This is the object that contains the model of your gun)", MessageType.Warning); } else { string strToWrite = ""; if (!modelRootObject) { strToWrite = "'Base Object' cannot be empty! (This is the object that is the parent of all other objects in your agent's hierarchy.)"; } else if (!spineBoneToRotate) { strToWrite = "'Spine Bone To Rotate' cannot be empty! (This is the transform that rotates in order to aim your agent's gun at their target.)"; } else if (!eyeTransform) { strToWrite = "'Eye Transform' cannot be empty! (This is the transform that designates the direction your AI looks in, as well as the position to be used for line of sight checks.)"; } else if (!animationController) { strToWrite = "'Animation Controller' cannot be empty! (This is the the animation controller that governs your agent's animations. You can create one by going to Assets>Create>Paragon AI Animation Controller.)"; } else if (!animationAvatar) { strToWrite = "'Animation Avatar' cannot be empty!"; } else if (!targetObjParentTransform) { strToWrite = "'Bone To Attach Target To' cannot be empty! (This is the transform that other agents will aim at when targetting this agent.)"; } EditorGUILayout.HelpBox(strToWrite, MessageType.Error); GUI.enabled = false; } EditorGUILayout.Space(); if (GUILayout.Button("Create New AI")) { this.CreateANewAI(); this.Close(); } EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { var obj = target as BulletManager; obj.bulletType = (BulletManager.BulletType)EditorGUILayout.EnumPopup("Bullet Type", obj.bulletType); obj.bulletPrefab = (Bullet)EditorGUILayout.ObjectField("Bullet Sprite", obj.bulletPrefab, typeof(Bullet), false); if (obj.bulletType != BulletManager.BulletType.PatternBullets) { obj.shotCount = EditorGUILayout.IntField("Shot Count", obj.shotCount); } if (obj.bulletType == BulletManager.BulletType.DirectionBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.lineCount = 1; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.SpiralBullet) { obj._shotAngle = EditorGUILayout.FloatField("Start Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRate = EditorGUILayout.FloatField("Shot Angle Rate", obj.shotAngleRate); obj.lineCount = 1; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.MultidirectionalSpiralBullet) { obj._shotAngle = EditorGUILayout.FloatField("Start Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRate = EditorGUILayout.FloatField("Shot Angle Rate", obj.shotAngleRate); obj.lineCount = EditorGUILayout.IntField("Spiral Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.TurningAcceleratingSpiralBullet) { obj._shotAngle = EditorGUILayout.FloatField("Start Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRate = EditorGUILayout.FloatField("Shot Angle Rate", obj.shotAngleRate); obj.bulletSpeedRate = EditorGUILayout.FloatField("Bullet Speed Rate", obj.bulletSpeedRate); obj.bulletAngleRate = EditorGUILayout.FloatField("Bullet Angle Rate", obj.bulletAngleRate); obj.lineCount = 1; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.WashingMachineSpiralBullets) { obj._shotAngle = EditorGUILayout.FloatField("Start Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.maxShotAngleRate = EditorGUILayout.FloatField("Max Shot Angle Rate", obj.maxShotAngleRate); obj.maxBulletAngleRate = EditorGUILayout.FloatField("Max Bullet Angle Rate", obj.maxBulletAngleRate); obj.lineCount = EditorGUILayout.IntField("Spiral Count", obj.lineCount); EditorGUILayout.LabelField("Washing Process Intervals"); obj.wInterval_1 = EditorGUILayout.FloatField("Spiral Time", obj.wInterval_1); obj.wInterval_2 = EditorGUILayout.FloatField("Spiral to Reverse Spiral Time", obj.wInterval_2); obj.wInterval_3 = EditorGUILayout.FloatField("Reverse Spiral Time", obj.wInterval_3); obj.wInterval_4 = EditorGUILayout.FloatField("Reverse Spiral to Spiral Time", obj.wInterval_4); EditorGUILayout.Space(); obj.shotAngleRate = 0.0f; obj.shotAngleRange = 360.0f; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.NWayBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.lineCount = EditorGUILayout.IntField("N Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.CircularBullet) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.shotAngleRange = 360; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.TurningAcceleratedCircularBullet) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.shotAngleRate = EditorGUILayout.FloatField("Shot Angle Rate", obj.shotAngleRate); obj.bulletSpeedRate = EditorGUILayout.FloatField("Bullet Speed Rate", obj.bulletSpeedRate); obj.bulletAngleRate = EditorGUILayout.FloatField("Bullet Angle Rate", obj.bulletAngleRate); obj.shotAngleRange = 360; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.AimNWayBullets) { obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.lineCount = EditorGUILayout.IntField("N Count", obj.lineCount); obj.targetTag = EditorGUILayout.TextField("Target Tag Name", obj.targetTag); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.AimRandomNWayBullets) { obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.lineCount = EditorGUILayout.IntField("N Count", obj.lineCount); obj.targetTag = EditorGUILayout.TextField("Target Tag Name", obj.targetTag); obj.randomRange = EditorGUILayout.FloatField("Random Range", obj.randomRange); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.RandomCircularBullet) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.randomRange = EditorGUILayout.FloatField("Random Range", obj.randomRange); obj.shotAngleRange = 360; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.RotationNWayBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.bulletAngleRate = EditorGUILayout.FloatField("Bullet Angle Rate", obj.bulletAngleRate); obj.lineCount = EditorGUILayout.IntField("N Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.WavyNWayBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.wavingAngleRange = EditorGUILayout.FloatField("Waving Angle Range", obj.wavingAngleRange); obj.cycle = EditorGUILayout.FloatField("Waving Cycle", obj.cycle); obj.lineCount = EditorGUILayout.IntField("N Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.WavyCircularBullet) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.wavingAngleRange = EditorGUILayout.FloatField("Waving Angle Range", obj.wavingAngleRange); obj.cycle = EditorGUILayout.FloatField("Waving Cycle", obj.cycle); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.shotAngleRange = 360; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.WinderBullet) { obj.shotAngleBase = EditorGUILayout.FloatField("Shot Angle", obj.shotAngleBase); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.winderAngleRange = EditorGUILayout.FloatField("Winder Angle Range", obj.winderAngleRange); obj.cycle = EditorGUILayout.FloatField("Winder Cycle", obj.cycle); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.DiffusionBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.shotSpeedRate = EditorGUILayout.FloatField("Shot Speed Rate", obj.shotSpeedRate); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.shotInterval = 0.0f; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.RandomDiffusionBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); EditorGUILayout.LabelField("Random Shot Speed Range "); obj.randomRangeMin = EditorGUILayout.FloatField("Min", obj.randomRangeMin); obj.randomRangeMax = EditorGUILayout.FloatField("Max", obj.randomRangeMax); EditorGUILayout.Space(); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.shotInterval = 0.0f; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.OvertakingBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotSpeedRate = EditorGUILayout.FloatField("Add Speed Rate", obj.shotSpeedRate); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.CurveOvertakingBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotAngleRate = EditorGUILayout.FloatField("Shot Angle Rate", obj.shotAngleRate); obj.shotSpeedRate = EditorGUILayout.FloatField("Add Speed Rate", obj.shotSpeedRate); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Range", obj.shotAngleRange); obj.lineCount = EditorGUILayout.IntField("Line Count", obj.lineCount); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; obj.guideTime = 0; } else if (obj.bulletType == BulletManager.BulletType.GuidedMissile) { obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.guideTime = EditorGUILayout.FloatField("Guide Time", obj.guideTime); obj.targetTag = EditorGUILayout.TextField("Target Tag Name", obj.targetTag); obj.lineCount = 1; obj.shotAngleRange = 0.0f; obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; } else if (obj.bulletType == BulletManager.BulletType.PatternBullets) { obj._shotAngle = EditorGUILayout.FloatField("Shot Angle", obj._shotAngle); obj._shotSpeed = EditorGUILayout.FloatField("Shot Speed", obj._shotSpeed); obj.shotAngleRange = EditorGUILayout.FloatField("Shot Angle Range", obj.shotAngleRange); obj.shotInterval = EditorGUILayout.FloatField("Shot Interval", obj.shotInterval); obj.pattern = EditorGUILayout.TextArea(obj.pattern, GUILayout.Height(96.0f)); obj.bulletSpeedRate = 0.0f; obj.bulletAngleRate = 0.0f; } if (GUILayout.Button("Shot")) { obj.Shot(); } }
public void OnGUI() { //dialogue("" + anyToPush); if (headerStyle == null) CreateStyles(); bool haveChanges = changes.Length > 0; // bool anyToPush = execute("git", "log @{u}.. -n 1 --pretty=format:\"%h;%an;%ar;%s\"").Trim() != ""; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUI.backgroundColor = defaultBackgroundColor; GUILayout.Space(8); GUILayout.Label(_name, headerStyle); GUILayout.Label(version, EditorStyles.miniLabel); GUILayout.Space(16); int branchID = Array.IndexOf(branches, currentBranch); if (currentBranch == null) { GUILayout.Label("Initializing. No branch selected."); } else { int newBranchID = EditorGUILayout.Popup("Branch", branchID, branches); if (newBranchID != branchID) { checkout(branches[newBranchID]); } commitMessage = GUILayout.TextArea(commitMessage, GUILayout.Height(70.0f)); if (haveChanges) { if (GUILayout.Button("Commit")) { CreateCommit(); } } else { GUILayout.BeginHorizontal(); if (GUILayout.Button("Push")) { push(); } if (GUILayout.Button("Pull")) { pull(); } GUILayout.EndHorizontal(); } } // now fold out if (changesFoldedOut = EditorGUILayout.Foldout(changesFoldedOut, "View Changes")) { GUILayout.BeginVertical("box"); if (haveChanges) { foreach (string change in changes) { string str = change.Trim(); if (str.StartsWith("M")) GUI.color = modifiedColor; if (str.StartsWith("A")) GUI.color = addedColor; if (str.StartsWith("D")) GUI.color = deletedColor; GUILayout.Label(change.Trim(), EditorStyles.miniLabel); GUI.color = defaultColor; } } else { GUILayout.Label("You are up to date!", EditorStyles.miniLabel); } GUILayout.EndVertical(); } #region commit history if (historyFoldedOut = EditorGUILayout.Foldout(historyFoldedOut, "Commit History")) { // EditorGUILayout.BeginVertical ("box"); if (history == null) { EditorGUILayout.BeginVertical("box"); GUILayout.Label("Loading commits..."); EditorGUILayout.EndVertical(); } else { maxCommits = EditorGUILayout.IntField("History Length", maxCommits); // int hashWidth = 60; // float subjectWidth = (EditorGUIUtility.fieldWidth / 2) - hashWidth - 24; // log (EditorGUIUtility.currentViewWidth); // subjectWidth = 100; foreach (Commit commit in history) { if (commit.local) { GUI.backgroundColor = Color.Lerp(Color.grey, defaultBackgroundColor, 0.5f); } else { GUI.backgroundColor = defaultBackgroundColor; } EditorGUILayout.BeginVertical("box"); // EditorGUILayout.BeginHorizontal (); // GUILayout.Label (commit.subject, EditorStyles.largeLabel, GUILayout.Width(subjectWidth)); // GUILayout.Label (commit.hash, monospaced, GUILayout.Width(hashWidth)); GUILayout.Label(commit.subject, EditorStyles.largeLabel, GUILayout.Width(position.width - 20)); // EditorGUILayout.EndHorizontal (); GUILayout.Label(commit.date + " by " + commit.author, EditorStyles.miniLabel); EditorGUILayout.EndVertical(); } GUI.backgroundColor = defaultBackgroundColor; } // EditorGUILayout.EndVertical (); } #endregion if (advancedOptions = EditorGUILayout.Foldout(advancedOptions, "Advanced/Expirimental Options")) { EditorGUI.indentLevel = 1; if (creatingBranch = EditorGUILayout.Foldout(creatingBranch, "Create New Branch")) { newBranchName = EditorGUILayout.TextField("Branch Name", newBranchName); GUILayout.Button("Create New Branch"); EditorGUI.indentLevel = 0; } if (enableDebug = GUILayout.Toggle(enableDebug, "Enable Debug Panels")) { if (debugPanel = EditorGUILayout.Foldout(debugPanel, "Debug Event Triggers")) { GUILayout.BeginVertical("box"); if (GUILayout.Button("refreshChanges()")) refreshChanges(); if (GUILayout.Button("RefreshInformation()")) refreshInformation(); if (GUILayout.Button("CreateStyles()")) CreateStyles(); if (GUILayout.Button("push()")) push(); if (GUILayout.Button("resetBusiness()")) business.Clear(); GUILayout.EndVertical(); } if (busnessDisplay = EditorGUILayout.Foldout(busnessDisplay, "Debug Business Array")) { GUILayout.BeginVertical("box"); foreach (StringPointer strp in business) { GUILayout.Label(strp.ToString()); } GUILayout.EndVertical(); } } } EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { EditorGUI.indentLevel = 0; var stat = (WorldVariable)target; LevelSettings.Instance = null; // clear cached version DTInspectorUtility.DrawTexture(CoreGameKitInspectorResources.LogoTexture); var isDirty = false; var newName = EditorGUILayout.TextField("Name", stat.transform.name); if (newName != stat.transform.name) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat.gameObject, "change Name"); stat.transform.name = newName; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Variable Type"); GUILayout.FlexibleSpace(); GUI.contentColor = DTInspectorUtility.BrightButtonColor; GUILayout.Label(WorldVariableTracker.GetVariableTypeFriendlyString(stat.varType)); if (Application.isPlaying) { var sValue = ""; switch (stat.varType) { case WorldVariableTracker.VariableType._integer: var _int = WorldVariableTracker.GetExistingWorldVariableIntValue(stat.name, stat.startingValue); sValue = _int.HasValue ? _int.Value.ToString() : ""; break; case WorldVariableTracker.VariableType._float: var _float = WorldVariableTracker.GetExistingWorldVariableFloatValue(stat.name, stat.startingValue); sValue = _float.HasValue ? _float.Value.ToString(CultureInfo.InvariantCulture) : ""; break; default: Debug.Log("add code for varType: " + stat.varType); break; } GUILayout.Label("Value:"); GUILayout.Label(sValue); } GUILayout.Space(110); GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (Application.isPlaying) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Change Value", GUILayout.Width(100)); GUILayout.FlexibleSpace(); switch (stat.varType) { case WorldVariableTracker.VariableType._integer: stat.prospectiveValue = EditorGUILayout.IntField("", stat.prospectiveValue, GUILayout.Width(120)); break; case WorldVariableTracker.VariableType._float: stat.prospectiveFloatValue = EditorGUILayout.FloatField("", stat.prospectiveFloatValue, GUILayout.Width(120)); break; default: Debug.LogError("Add code for varType: " + stat.varType.ToString()); break; } GUI.contentColor = DTInspectorUtility.BrightButtonColor; if (GUILayout.Button("Change Value", EditorStyles.toolbarButton, GUILayout.Width(80))) { var variable = WorldVariableTracker.GetWorldVariable(stat.name); switch (stat.varType) { case WorldVariableTracker.VariableType._integer: variable.CurrentIntValue = stat.prospectiveValue; break; case WorldVariableTracker.VariableType._float: variable.CurrentFloatValue = stat.prospectiveFloatValue; break; default: Debug.LogError("Add code for varType: " + stat.varType.ToString()); break; } } GUI.contentColor = Color.white; GUILayout.Space(10); EditorGUILayout.EndHorizontal(); } var newPersist = (WorldVariable.StatPersistanceMode)EditorGUILayout.EnumPopup("Persistence mode", stat.persistanceMode); if (newPersist != stat.persistanceMode) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Persistence Mode"); stat.persistanceMode = newPersist; } var newChange = (WorldVariable.VariableChangeMode)EditorGUILayout.EnumPopup("Modifications allowed", stat.changeMode); if (newChange != stat.changeMode) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Modifications allowed"); stat.changeMode = newChange; } switch (stat.varType) { case WorldVariableTracker.VariableType._float: { var newStart = EditorGUILayout.FloatField("Starting value", stat.startingValueFloat); if (newStart != stat.startingValueFloat) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Starting value"); stat.startingValueFloat = newStart; } break; } case WorldVariableTracker.VariableType._integer: { var newStart = EditorGUILayout.IntField("Starting value", stat.startingValue); if (newStart != stat.startingValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Starting value"); stat.startingValue = newStart; } break; } } var newNeg = EditorGUILayout.Toggle("Allow negative?", stat.allowNegative); if (newNeg != stat.allowNegative) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "toggle Allow negative"); stat.allowNegative = newNeg; } DTInspectorUtility.StartGroupHeader(); var newTopLimit = GUILayout.Toggle(stat.hasMaxValue, "Has max value?"); if (newTopLimit != stat.hasMaxValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "toggle Has max value"); stat.hasMaxValue = newTopLimit; } EditorGUILayout.EndVertical(); if (stat.hasMaxValue) { EditorGUI.indentLevel = 0; switch (stat.varType) { case WorldVariableTracker.VariableType._integer: var newMax = EditorGUILayout.IntField("Max Value", stat.intMaxValue); if (newMax != stat.intMaxValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Max Value"); stat.intMaxValue = newMax; } break; case WorldVariableTracker.VariableType._float: var newFloatMax = EditorGUILayout.FloatField("Max Value", stat.floatMaxValue); if (newFloatMax != stat.floatMaxValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change Max Value"); stat.floatMaxValue = newFloatMax; } break; default: Debug.Log("add code for varType: " + stat.varType); break; } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel = 0; DTInspectorUtility.AddSpaceForNonU5(); DTInspectorUtility.StartGroupHeader(); var newCanEnd = GUILayout.Toggle(stat.canEndGame, "Triggers game over?"); if (newCanEnd != stat.canEndGame) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "toggle Triggers game over"); stat.canEndGame = newCanEnd; } EditorGUILayout.EndVertical(); if (stat.canEndGame) { EditorGUI.indentLevel = 0; var newMin = EditorGUILayout.IntField("G.O. min value", stat.endGameMinValue); if (newMin != stat.endGameMinValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change G.O. min value"); stat.endGameMinValue = newMin; } var newMax = EditorGUILayout.IntField("G.O. max value", stat.endGameMaxValue); if (newMax != stat.endGameMaxValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "change G.O. max value"); stat.endGameMaxValue = newMax; } } EditorGUILayout.EndVertical(); DTInspectorUtility.StartGroupHeader(); var newFire = GUILayout.Toggle(stat.fireEventsOnChange, "Custom Events"); if (newFire != stat.fireEventsOnChange) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "toggle Custom Events"); stat.fireEventsOnChange = newFire; } EditorGUILayout.EndVertical(); if (stat.fireEventsOnChange) { EditorGUI.indentLevel = 0; DTInspectorUtility.ShowColorWarningBox("When variable value changes, fire the Custom Events below"); EditorGUILayout.BeginHorizontal(); GUI.contentColor = DTInspectorUtility.AddButtonColor; GUILayout.Space(10); if (GUILayout.Button(new GUIContent("Add", "Click to add a Custom Event"), EditorStyles.toolbarButton, GUILayout.Width(50))) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "Add Custom Event"); stat.changeCustomEventsToFire.Add(new CGKCustomEventToFire()); } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (stat.changeCustomEventsToFire.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You have no Custom Events selected to fire."); } DTInspectorUtility.VerticalSpace(2); int?indexToDelete = null; // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < stat.changeCustomEventsToFire.Count; i++) { var anEvent = stat.changeCustomEventsToFire[i].CustomEventName; var buttonClicked = DTInspectorUtility.FunctionButtons.None; anEvent = DTInspectorUtility.SelectCustomEventForVariable(ref isDirty, anEvent, stat, "Custom Event", ref buttonClicked); if (buttonClicked == DTInspectorUtility.FunctionButtons.Remove) { indexToDelete = i; } if (anEvent == stat.changeCustomEventsToFire[i].CustomEventName) { continue; } stat.changeCustomEventsToFire[i].CustomEventName = anEvent; } if (indexToDelete.HasValue) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "Remove Custom Event"); stat.changeCustomEventsToFire.RemoveAt(indexToDelete.Value); } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel = 0; var listenerWasEmpty = stat.listenerPrefab == null; var newListener = (WorldVariableListener)EditorGUILayout.ObjectField("Listener", stat.listenerPrefab, typeof(WorldVariableListener), true); if (newListener != stat.listenerPrefab) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, stat, "assign Listener"); stat.listenerPrefab = newListener; if (listenerWasEmpty && stat.listenerPrefab != null) { // just assigned. var listener = stat.listenerPrefab.GetComponent <WorldVariableListener>(); if (listener == null) { DTInspectorUtility.ShowAlert("You cannot assign a listener that doesn't have a WorldVariableListener script in it."); stat.listenerPrefab = null; } else { listener.variableName = stat.transform.name; listener.vType = stat.varType; } } } if (GUI.changed || isDirty) { EditorUtility.SetDirty(target); // or it won't save the data!! } //DrawDefaultInspector(); }
/// <summary> /// Custom Inspector /// </summary> public override void OnInspectorGUI() { // Start custom Inspector serializedObject.Update(); EditorGUI.BeginChangeCheck(); m_target.layerIndex = m_reorderableTilemapLayerList.index; if (m_target.toolIndex > 0 && m_target.toolIndex < 5) { Tools.hidden = true; } else { Tools.hidden = false; } // // References // m_showReferencesGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showReferencesGroup.isExpanded, "References"); if (m_showReferencesGroup.isExpanded) { GUILayout.Space(1); // Standard diffuse shader GUI.color = m_greenColor; if (!m_legacyShader.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_legacyShader, m_guiContent[7]); // Universal diffuse shader GUI.color = m_greenColor; if (!m_universalShader.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_universalShader, m_guiContent[8]); GUI.color = Color.white; } EditorGUILayout.EndFoldoutHeaderGroup(); // // Settings // m_showSettingsGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showSettingsGroup.isExpanded, "Settings"); if (m_showSettingsGroup.isExpanded) { GUILayout.Space(1); // Render pipeline EditorGUILayout.PropertyField(m_renderPipeline, m_guiContent[9]); if (m_target.renderPipeline == TilemapSystemPipeline.Universal) { EditorGUILayout.HelpBox("Universal Render Pipeline is still a work in progress and is not fully functional.", MessageType.Info); } // Tilemap size EditorGUILayout.IntPopup(m_tilesetSize, m_tilesetSizeContentArray, m_tilesetSizeArray, m_guiContent[16]); // Grid size EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField(m_guiContent[0]); m_gridMapSize.x = EditorGUILayout.IntField(m_guiContent[1], (int)m_target.gridMapSize.x); m_gridMapSize.y = EditorGUILayout.IntField(m_guiContent[2], (int)m_target.gridMapSize.y); EditorGUILayout.EndVertical(); // Layer list m_reorderableTilemapLayerList.DoLayoutList(); } EditorGUILayout.EndFoldoutHeaderGroup(); // // Data // m_showDataGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showDataGroup.isExpanded, "Data"); if (m_showDataGroup.isExpanded) { GUILayout.Space(1); if (m_reorderableTilemapLayerList.count > 0) { EditorGUI.BeginDisabledGroup(true); // Tilemap data if (!m_tilemapData.objectReferenceValue) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_tilemapData, m_guiContent[6]); GUI.color = Color.white; // Tilemap texture field if (!m_target.tilemapTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[13], m_target.tilemapTexture, typeof(Texture3D), false); GUI.color = Color.white; // Tileset texture field if (!m_target.tilesetTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[15], m_target.tilesetTexture, typeof(Texture3D), false); GUI.color = Color.white; // Array texture field if (!m_target.layerArrayTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[17], m_target.layerArrayTexture, typeof(Texture2D), false); GUI.color = Color.white; // Render material field if (!m_target.renderMaterial) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[14], m_target.renderMaterial, typeof(Material), false); GUI.color = Color.white; EditorGUI.EndDisabledGroup(); // Button if (GUILayout.Button("Generate Tilemap Data")) { m_target.GenerateTilemapData(); if (m_target.tilemapData) { TilePalette[] palettes = new TilePalette[m_target.tilemapLayerList.Count]; int[] tilesCount = new int[m_target.tilemapLayerList.Count]; for (int i = 0; i < palettes.Length; i++) { palettes[i] = m_target.tilemapLayerList[i].tilePalette; if (palettes[i]) { tilesCount[i] = m_target.tilemapLayerList[i].tilePalette.tilesCount; } else { tilesCount[i] = 0; } } m_target.tilemapData.settingsState = new TilemapSettings(m_target.tilemapLayerList.Count, tilesCount, palettes, (int)m_gridMapSize.x, (int)m_gridMapSize.y, m_tilesetSize.intValue); m_target.tilemapData.layerIntensity = new float[m_target.tilemapLayerList.Count]; } } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Painting // m_showPantingGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showPantingGroup.isExpanded, "Painting"); if (m_showPantingGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { // Tile palette field EditorGUILayout.BeginVertical("Box"); m_tilePalette = m_reorderableTilemapLayerList.serializedProperty.GetArrayElementAtIndex(m_target.layerIndex).FindPropertyRelative("tilePalette"); GUI.color = m_greenColor; if (!m_tilePalette.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_tilePalette, m_guiContent[5]); GUI.color = Color.white; EditorGUILayout.EndVertical(); if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { // Painting mode EditorGUILayout.BeginVertical("Box"); EditorGUILayout.PropertyField(m_paintingMode, m_guiContent[10]); // Auto tile layout popup if (m_target.paintingMode == TilemapSystemPaintingMode.AutoTiles) { m_autoTileElements = GetAutoTileElements(); if (m_autoTileElements.Length > 0) { m_autoTileLayoutIndex = m_reorderableTilemapLayerList.serializedProperty.GetArrayElementAtIndex(m_target.layerIndex).FindPropertyRelative("layoutIndex"); m_autoTileLayoutIndex.intValue = EditorGUILayout.Popup(m_guiContent[17], m_autoTileLayoutIndex.intValue, m_autoTileElements); } else { EditorGUILayout.HelpBox("The Auto Tile list is empty. Please, set some auto tile layout first.", MessageType.Error); } } EditorGUILayout.EndVertical(); GUILayout.Space(-3); if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { EditorGUILayout.BeginVertical("Box"); if (m_target.tilesetTexture) { if (CanPaint()) { // Reset layer button if (GUILayout.Button("Reset This Layer Using the Selected Tile")) { // Register the texture in the undo stack Undo.RegisterCompleteObjectUndo(m_target.tilemapTexture, "Tilemap Change"); m_target.ResetLayer(m_target.layerIndex); } // Toolbar EditorGUILayout.BeginHorizontal(); m_isPicking = m_target.toolIndex == 1 ? true : false; if (GUILayout.Toggle(m_isPicking, m_paintingToolIcons[0], EditorStyles.miniButtonLeft)) { m_target.toolIndex = 1; } else if (m_target.toolIndex == 1) { m_target.toolIndex = 0; } m_isPainting = m_target.toolIndex == 2 ? true : false; if (GUILayout.Toggle(m_isPainting, m_paintingToolIcons[1], EditorStyles.miniButtonMid)) { m_target.toolIndex = 2; } else if (m_target.toolIndex == 2) { m_target.toolIndex = 0; } m_isFilling = m_target.toolIndex == 3 ? true : false; if (GUILayout.Toggle(m_isFilling, m_paintingToolIcons[2], EditorStyles.miniButtonMid)) { m_target.toolIndex = 3; } else if (m_target.toolIndex == 3) { m_target.toolIndex = 0; } m_isErasing = m_target.toolIndex == 4 ? true : false; if (GUILayout.Toggle(m_isErasing, m_paintingToolIcons[3], EditorStyles.miniButtonRight)) { m_target.toolIndex = 4; } else if (m_target.toolIndex == 4) { m_target.toolIndex = 0; } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("It looks like you have changed some settings. Please, regenerate the Tilemap Data to update the 3D Textures.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no Tileset Texture yet. Please, regenerate the Tilemap Data again to create the 3D Tileset texture so you can start painting.", MessageType.Error); } // Tile grid m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos); EditorGUILayout.LabelField("", GUILayout.Width(442)); GUILayout.Space(-20); m_buttonIndex = 0; // Start the selectable loop for (int vertical = 0; vertical < 256;) { m_controlRect = EditorGUILayout.GetControlRect(GUILayout.Width(24), GUILayout.Height(24)); EditorGUILayout.BeginHorizontal(); for (int horizontal = 0; horizontal < 16; horizontal++) { // Get the tile texture m_tileTexture = m_target.tilemapLayerList[m_target.layerIndex].tilePalette.temporaryTileTextureArray[vertical] ? m_target.tilemapLayerList[m_target.layerIndex].tilePalette.temporaryTileTextureArray[vertical] : emptyIconTexture; // Draw the selectable button m_isSelected = m_target.tileIndex == m_buttonIndex ? true : false; if (GUI.Toggle(m_controlRect, m_isSelected, GUIContent.none, GUI.skin.button)) { m_target.tileIndex = m_buttonIndex; } // Draw the tile texture if (m_isSelected) { GUI.color = m_selectedTileColor; } GUI.DrawTexture(m_controlRect, m_tileTexture, ScaleMode.StretchToFill, true, 0); GUI.color = Color.white; m_controlRect.x += 28; vertical++; m_buttonIndex++; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Auto tiles // m_showAutoTileGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showAutoTileGroup.isExpanded, "Auto Tiles"); if (m_showAutoTileGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here GUILayout.Space(3); m_autoTileDictionary[m_target.layerIndex].DoLayoutList(); } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Random tile painting // EditorGUI.BeginDisabledGroup(true); m_showRandomTilePaintingGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showRandomTilePaintingGroup.isExpanded, "Random Tile Painting"); if (m_showRandomTilePaintingGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // Random tiles m_showRandomizeTileGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showRandomizeTileGroup.isExpanded, "Randomize Tiles"); if (m_showRandomizeTileGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // Tile brushes m_showTileBrushesGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showTileBrushesGroup.isExpanded, "Tile Brushes"); if (m_showTileBrushesGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); EditorGUI.EndDisabledGroup(); // About group m_showAboutGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showAboutGroup.isExpanded, "About"); if (m_showAboutGroup.isExpanded) { EditorGUILayout.HelpBox("3D Tilemap System v1.0.1 by Seven Stars Games", MessageType.None); if (GUILayout.Button(m_guiContent[18])) { Application.OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=S8AB7CVH5VMZS&source=url"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("My other assets you may like:"); if (GUILayout.Button(m_guiContent[19])) { Application.OpenURL("https://assetstore.unity.com/packages/tools/particles-effects/azure-sky-dynamic-skybox-36050"); } if (GUILayout.Button(m_guiContent[20])) { Application.OpenURL("https://assetstore.unity.com/packages/vfx/shaders/azure-sky-lite-89858"); } } // Update layer intensity when there is a change in the Inspector if (m_target.tilemapData) { if (NeedUpdateLayerIntensity()) { m_target.UpdateLayerSettings(); m_target.tilemapData.layerIntensity = new float[m_target.tilemapLayerList.Count]; for (int i = 0; i < m_target.tilemapLayerList.Count; i++) { m_target.tilemapData.layerIntensity[i] = m_target.tilemapLayerList[i].intensity; } } } // End custom Inspector if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_target, "3D Tilemap System"); serializedObject.ApplyModifiedProperties(); m_target.gridMapSize = m_gridMapSize; m_target.UpdateMaterialSettings(); } }
public override void OnInspectorGUI() { SpawnField spawnField = target as SpawnField; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Waves"); if (GUILayout.Button("Add Wave", GUILayout.ExpandWidth(false))) { spawnField.SpawnWaves.Add(new List <Spawn>()); m_showWaves.Add(false); GUI.changed = true; } EditorGUILayout.EndHorizontal(); for (int i = 0; i < spawnField.SpawnWaves.Count; i++) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); m_showWaves[i] = EditorGUILayout.Foldout(m_showWaves[i], "Wave " + i); if (m_showWaves[i]) { EditorGUI.indentLevel++; if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { spawnField.SpawnWaves.RemoveAt(i); GUI.changed = true; } EditorGUILayout.EndHorizontal(); for (int j = 0; j < spawnField.SpawnWaves[i].Count; j++) { EditorGUI.indentLevel++; spawnField.SpawnWaves[i][j].Prefab = EditorGUILayout.ObjectField("Enemy Prefab", null, typeof(GameObject), true) as GameObject; spawnField.SpawnWaves[i][j].Count = EditorGUILayout.IntField("Spawn count", 1); if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { spawnField.SpawnWaves[i].RemoveAt(j); GUI.changed = true; } EditorGUI.indentLevel--; } if (GUILayout.Button("Add Spawn", GUILayout.ExpandWidth(false))) { spawnField.SpawnWaves[i].Add(new Spawn()); GUI.changed = true; } EditorGUI.indentLevel--; } else { EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } if (GUI.changed) { EditorUtility.SetDirty(spawnField); } }