private static void inspectFont(dfRichTextLabel control) { dfPrefabSelectionDialog.SelectionCallback selectionCallback = delegate(GameObject item) { var font = (item == null) ? null : item.GetComponent <dfDynamicFont>(); dfEditorUtil.MarkUndo(control, "Assign Dynamic Font"); control.Font = font; }; var value = control.Font; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Default Font", "", GUILayout.Width(dfEditorUtil.LabelWidth)); var displayText = value == null ? "[none]" : value.name; GUILayout.Label(displayText, "TextField"); var evt = Event.current; if (evt != null) { Rect textRect = GUILayoutUtility.GetLastRect(); if (evt.type == EventType.mouseDown && evt.clickCount == 2) { if (textRect.Contains(evt.mousePosition)) { if (GUI.enabled && value != null) { Selection.activeObject = value; EditorGUIUtility.PingObject(value); } } } else if (evt.type == EventType.DragUpdated || evt.type == EventType.DragPerform) { if (textRect.Contains(evt.mousePosition)) { var draggedObject = DragAndDrop.objectReferences.First() as GameObject; var draggedFont = draggedObject != null?draggedObject.GetComponent <dfDynamicFont>() : null; DragAndDrop.visualMode = (draggedFont != null) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.None; if (evt.type == EventType.DragPerform) { selectionCallback(draggedObject); } evt.Use(); } } } if (GUI.enabled && GUILayout.Button(new GUIContent(" ", "Select Font"), "IN ObjectField", GUILayout.Width(14))) { dfEditorUtil.DelayedInvoke((System.Action)(() => { var dialog = dfPrefabSelectionDialog.Show("Select Dynamic Font", typeof(dfDynamicFont), selectionCallback, dfFontDefinitionInspector.DrawFontPreview, null); dialog.previewSize = 200; })); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(2); }
private void DrawInputsStage() { if (DialogueManager.instance.displaySettings.inputSettings == null) { DialogueManager.instance.displaySettings.inputSettings = new DisplaySettings.InputSettings(); } EditorGUILayout.LabelField("Input Settings", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); EditorGUILayout.HelpBox("In this section, you'll specify input settings for the dialogue UI.", MessageType.Info); EditorWindowTools.StartIndentedSection(); EditorWindowTools.DrawHorizontalLine(); EditorGUILayout.LabelField("Player Response Menu", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.alwaysForceResponseMenu = EditorGUILayout.Toggle("Always Force Menu", DialogueManager.instance.displaySettings.inputSettings.alwaysForceResponseMenu); EditorGUILayout.HelpBox("Tick to always force the response menu. If unticked, then when the player only has one valid response, the UI will automatically select it without showing the response menu.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.includeInvalidEntries = EditorGUILayout.Toggle("Include Invalid Entries", DialogueManager.instance.displaySettings.inputSettings.includeInvalidEntries); EditorGUILayout.HelpBox("Tick to include entries whose conditions are false in the menu. Their buttons will be visible but non-interactable.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); bool useTimeout = EditorGUILayout.Toggle("Timer", (DialogueManager.instance.displaySettings.inputSettings.responseTimeout > 0)); EditorGUILayout.HelpBox("Tick to make the response menu timed. If unticked, players can take as long as they want to make their selection.", MessageType.None); EditorGUILayout.EndHorizontal(); if (useTimeout) { if (Tools.ApproximatelyZero(DialogueManager.instance.displaySettings.inputSettings.responseTimeout)) { DialogueManager.instance.displaySettings.inputSettings.responseTimeout = DefaultResponseTimeoutDuration; } DialogueManager.instance.displaySettings.inputSettings.responseTimeout = EditorGUILayout.FloatField("Timeout Seconds", DialogueManager.instance.displaySettings.inputSettings.responseTimeout); DialogueManager.instance.displaySettings.inputSettings.responseTimeoutAction = (ResponseTimeoutAction)EditorGUILayout.EnumPopup("If Time Runs Out", DialogueManager.instance.displaySettings.inputSettings.responseTimeoutAction); } else { DialogueManager.instance.displaySettings.inputSettings.responseTimeout = 0; } EditorWindowTools.DrawHorizontalLine(); EditorGUILayout.LabelField("Quick Time Event (QTE) Trigger Buttons", EditorStyles.boldLabel); EditorGUILayout.HelpBox("QTE trigger buttons may be defined on the Dialogue Manager's inspector under Display Settings > Input Settings > QTE Input Buttons.", MessageType.None); if (GUILayout.Button("Inspect Dialogue Manager object", GUILayout.Width(240))) { Selection.activeObject = DialogueManager.instance; } EditorWindowTools.DrawHorizontalLine(); EditorGUILayout.LabelField("Cancel Line", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.cancel.key = (KeyCode)EditorGUILayout.EnumPopup("Key", DialogueManager.instance.displaySettings.inputSettings.cancel.key); EditorGUILayout.HelpBox("Pressing this key interrupts the currently-playing subtitle.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.cancel.buttonName = EditorGUILayout.TextField("Button Name", DialogueManager.instance.displaySettings.inputSettings.cancel.buttonName); EditorGUILayout.HelpBox("Pressing this button interrupts the currently-playing subtitle.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorWindowTools.DrawHorizontalLine(); EditorGUILayout.LabelField("Cancel Conversation", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.cancelConversation.key = (KeyCode)EditorGUILayout.EnumPopup("Key", DialogueManager.instance.displaySettings.inputSettings.cancel.key); EditorGUILayout.HelpBox("Pressing this key cancels the conversation if in the response menu.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DialogueManager.instance.displaySettings.inputSettings.cancelConversation.buttonName = EditorGUILayout.TextField("Button Name", DialogueManager.instance.displaySettings.inputSettings.cancel.buttonName); EditorGUILayout.HelpBox("Pressing this button cancels the conversation if in the response menu.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorWindowTools.EndIndentedSection(); EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, true, false); }
public override void ShowGUI(List <ActionParameter> parameters) { numSockets = EditorGUILayout.DelayedIntField("# of possible values:", numSockets); numSockets = Mathf.Clamp(numSockets, 1, 100); disallowSuccessive = EditorGUILayout.Toggle("Prevent same value twice?", disallowSuccessive); if (disallowSuccessive) { saveToVariable = EditorGUILayout.Toggle("Save last value?", saveToVariable); if (saveToVariable) { location = (VariableLocation)EditorGUILayout.EnumPopup("Variable source:", location); if (location == VariableLocation.Local && KickStarter.localVariables == null) { EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info); } else if (location == VariableLocation.Local && isAssetFile) { EditorGUILayout.HelpBox("Local variables cannot be accessed in ActionList assets.", MessageType.Info); } if ((location == VariableLocation.Global && AdvGame.GetReferences().variablesManager != null) || (location == VariableLocation.Local && KickStarter.localVariables != null && !isAssetFile) || (location == VariableLocation.Component)) { ParameterType _parameterType = ParameterType.GlobalVariable; if (location == VariableLocation.Local) { _parameterType = ParameterType.LocalVariable; } else if (location == VariableLocation.Component) { _parameterType = ParameterType.ComponentVariable; } parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, _parameterType); if (parameterID >= 0) { if (location == VariableLocation.Component) { variablesConstantID = 0; variables = null; } variableID = ShowVarGUI(variableID, false); } else { if (location == VariableLocation.Component) { variables = (Variables)EditorGUILayout.ObjectField("Component:", variables, typeof(Variables), true); variablesConstantID = FieldToID <Variables> (variables, variablesConstantID); variables = IDToField <Variables> (variables, variablesConstantID, false); if (variables != null) { variableID = ShowVarGUI(variableID, true); } } else { EditorGUILayout.BeginHorizontal(); variableID = ShowVarGUI(variableID, true); if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideMenu(); } EditorGUILayout.EndHorizontal(); } } } } } }
private void DoCommands() { Event e = Event.current; switch (e.type) { case EventType.KeyDown: { if (Event.current.keyCode == KeyCode.Delete) { if (TreeView.HasFocus()) { RemoveAsset(); } } break; } } EditorGUILayout.BeginHorizontal(); int selectedRootItemsCount = TreeView.SelectedRootItemsCount; bool hasSelectedRootItems = TreeView.HasSelectedRootItems; if (m_folders != null && m_folders.Length == 1) { if (GUILayout.Button("Add Asset")) { PickObject(); } } if (m_selectedRootItemsCount == 1) { if (GUILayout.Button("Rename Asset")) { RenameAsset(); } if (GUILayout.Button("Ping Asset")) { PingAsset(); } } m_selectedRootItemsCount = TreeView.SelectedRootItemsCount; if (m_hasSelectedRootItems) { if (GUILayout.Button("Remove Asset")) { RemoveAsset(); } } m_hasSelectedRootItems = TreeView.HasSelectedRootItems; EditorGUILayout.EndHorizontal(); if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == m_currentPickerWindow) { m_pickedObject = EditorGUIUtility.GetObjectPickerObject(); } else { if (Event.current.commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == m_currentPickerWindow) { m_currentPickerWindow = -1; if (m_pickedObject != null) { if (m_folders[0].Assets == null || !m_folders[0].Assets.Any(a => a.Object == m_pickedObject || a.Object != null && a.Object.name == m_pickedObject.name && a.Object.GetType() == m_pickedObject.GetType())) { if (m_pickedObject == null || m_pickedObject.GetType().Assembly.FullName.Contains("UnityEditor") && m_pickedObject.GetType() != typeof(AnimatorController)) { EditorUtility.DisplayDialog("Unable to add asset", string.Format("Unable to add asset {0} from assembly {1}", m_pickedObject.GetType().Name, m_pickedObject.GetType().Assembly.GetName()), "OK"); } else { bool moveToNewLocation = MoveToNewLocationDialog(new[] { m_pickedObject }, m_folders[0]); AddAssetToFolder(new[] { m_pickedObject }, m_folders[0], moveToNewLocation); } } m_pickedObject = null; } } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); SwiftShadow.LightVectorSourceEnum lightVectorSource = (SwiftShadow.LightVectorSourceEnum)DoFieldProperty <int>( _lightVectorSource, new GUIContent( "Light direction from: ", "" ), "LightVectorSource", (rect, label, property) => EditorGUI.Popup(rect, label, property.enumValueIndex, EditorGUIUtilityInternal.TempContent(new string[] { "Static vector", "Light source object" }))); EditorGUI.indentLevel++; if (lightVectorSource == SwiftShadow.LightVectorSourceEnum.StaticVector) { DoFieldProperty( _lightVector, new GUIContent( "Direction vector: ", "Light direction vector relative to the object. For example, (0, -1, 0) means the light always come from right above." ), "LightVector", (rect, label, property) => EditorGUI.Vector3Field(rect, label.text, property.vector3Value)); } else { Transform lightSourceObject = DoFieldProperty <Transform>( _lightSourceObject, new GUIContent( "Light source: ", "The GameObject that'll be used as point light source for this shadow." ), "LightSourceObject", (rect, label, property) => (Transform)EditorGUI.ObjectField(rect, label, property.objectReferenceValue, typeof(Transform), true)); if (lightSourceObject == null) { EditorGUILayout.HelpBox("No light source selected. Shadow will use the static vector instead.", MessageType.Warning, false); } } EditorGUI.indentLevel--; DoFieldProperty <LayerMask>( _layerMask, new GUIContent( "Raycast layer mask: ", "Layers to cast shadows on. " + "You must to exclude the layer of the object " + "itself if it has a collider attached to it, otherwise shadow may behave strange." ), "LayerMask", (rect, label, property) => { EditorGUIInternal.LayerMaskField(rect, property, label); return(0); }); if (_layerMask.intValue == 0) { EditorGUILayout.HelpBox("No layer mask is set. Shadows won't project on anything.", MessageType.Warning, false); } EditorGUILayout.HelpBox("Shadow", MessageType.None, true); Material shadowMaterial = DoFieldProperty( _material, new GUIContent( "Material: ", "Material that'll be used for rendering the shadow." ), "Material", (rect, label, property) => (Material)EditorGUI.ObjectField(rect, label, property.objectReferenceValue, typeof(Material), false)); if (shadowMaterial == null) { EditorGUILayout.HelpBox("No material assigned. Shadow will use the default blob shadow.", MessageType.Info, false); } DoFieldProperty( _color, new GUIContent( "Shadow color: ", "The color of the shadow." ), "Color", (rect, label, property) => EditorGUI.ColorField(rect, label, property.colorValue)); DoFieldProperty( _shadowSize, new GUIContent( "Shadow size: ", "Scale of shadow relative to object's max dimensions." ), "ShadowSize", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); EditorGUILayout.BeginHorizontal(); #if !UNITY_3_5 GUILayout.Space(EditorGUIUtilityInternal.labelWidth); #else GUILayout.Space(EditorGUIUtilityInternal.labelWidth + 4f); #endif if (GUILayout.Button("Estimate size")) { GUI.changed = true; foreach (Object targetObject in _shadowSize.serializedObject.targetObjects) { SwiftShadow shadow = (SwiftShadow)targetObject; GameObject go = shadow.gameObject; Quaternion goRotation = go.transform.rotation; go.transform.rotation = Quaternion.identity; Bounds bounds = new Bounds(go.transform.position, Vector3.zero); foreach (Renderer renderer in go.GetComponentsInChildren <Renderer>()) { bounds.Encapsulate(renderer.bounds); } if (bounds.size.magnitude > Vector3.kEpsilon) { float scaleMin = Mathf.Min(go.transform.lossyScale.x, go.transform.lossyScale.y, go.transform.lossyScale.z); shadow.ShadowSize = Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z) / scaleMin; shadow.ShadowSize = (float)Math.Round(shadow.ShadowSize, 5); } go.transform.rotation = goRotation; } _shadowSize.serializedObject.ApplyModifiedProperties(); _shadowSize.serializedObject.SetIsDifferentCacheDirty(); Repaint(); } EditorGUILayout.EndHorizontal(); GUI.enabled = lightVectorSource == SwiftShadow.LightVectorSourceEnum.GameObject; DoFieldProperty( _isPerspectiveProjection, new GUIContent( "Perspective projection: ", "Makes shadows bigger as they move away from the light source. " + "This usually looks more realistic, but may result in artifacts at extreme angles." ), "IsPerspectiveProjection", (rect, label, property) => EditorGUI.Toggle(rect, label, property.boolValue)); GUI.enabled = true; DoFieldProperty( _projectionDistance, new GUIContent( "Projection distance: ", "Maximal distance from the transform position to the surface shadow will fall on." ), "ProjectionDistance", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(GUILayout.Width(100f)); EditorGUILayout.HelpBox("Fading", MessageType.None, true); EditorGUILayout.EndHorizontal(); DoFieldProperty( _fadeDistance, new GUIContent( "Fade distance: ", "Distance at which shadow will start fading out. Used for smooth transition to \"Projection distance\"" ), "FadeDistance", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); DoFieldProperty( _angleFadeMin, new GUIContent( "Angle fade from: ", "The angle at which the shadow will start fading out. Used for smooth transition to \"Max angle\"" ), "AngleFadeMin", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); DoFieldProperty( _angleFadeMax, new GUIContent( "Max angle: ", "The maximum angle at which the shadow is allowed to fall on surface. " + "It it falls at a bigger angle, no shadow will be rendered." ), "AngleFadeMax", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); EditorGUILayout.BeginHorizontal(GUILayout.Width(100f)); EditorGUILayout.HelpBox("Static", MessageType.None, true); EditorGUILayout.EndHorizontal(); DoFieldProperty( _isStatic, new GUIContent( "Static: ", "If checked, the shadow will be calculated only at the creation. " + "Use this for shadows that do not move for a huge perfomance boost."), "IsStatic", (rect, label, property) => { EditorGUILayout.BeginHorizontal(); Rect labelRect = rect; labelRect.width = GUI.skin.label.CalcSize(label).x + EditorGUILayoutExtensions.kIndentationWidth; labelRect.xMin += EditorGUILayoutExtensions.kIndentationWidth; rect.xMin = labelRect.xMax; GUI.Label(labelRect, label); bool result = EditorGUI.Toggle(rect, property.boolValue); EditorGUILayout.EndHorizontal(); return(result); }); DoFieldProperty( _autoStaticTime, new GUIContent( "Set to static if not moving for", "Makes shadow static if it hasn't moved for X seconds. " + "Shadow will return to non-static state when moving or rotating. " + "This is useful for optimizing performance if you have shadow that " + "only move from time to time. Value of 0 disables this setting." ), "AutoStaticTime", (rect, label, property) => { GUIContent secText = new GUIContent("sec."); Rect labelRect = rect; labelRect.width = GUI.skin.label.CalcSize(label).x + EditorGUILayoutExtensions.kIndentationWidth; labelRect.xMin += EditorGUILayoutExtensions.kIndentationWidth; rect.xMin = labelRect.xMax; GUI.Label(labelRect, label); labelRect = rect; labelRect.xMin = rect.xMax - GUI.skin.label.CalcSize(secText).x; rect.xMax = labelRect.xMin; float result = EditorGUI.FloatField(rect, property.floatValue); GUI.Label(labelRect, secText); return(result); } ); EditorGUI.indentLevel--; EditorGUILayout.HelpBox("Advanced", MessageType.None, true); DoFieldProperty( _textureUVRect, new GUIContent( "Texture coordinates: ", "The texture coordinates of shadow. Change this to use multiple shadow cookies within the material texture." ), "TextureUVRect", (rect, label, property) => EditorGUI.RectField(rect, label, property.rectValue)); DoFieldProperty( _aspectRatio, new GUIContent("Aspect ratio: ", "The width/height aspect ratio of shadow."), "AspectRatio", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); DoFieldProperty( _shadowOffset, new GUIContent( "Shadow offset: ", "The distance at which the shadow hovers above the surface. " + "Increase this value if you see shadows flickering due to Z-fighting" ), "ShadowOffset", (rect, label, property) => EditorGUI.FloatField(rect, label, property.floatValue)); DoFieldProperty( _frameSkip, new GUIContent( "Frame skip: ", "Skip N frames before updating the shadow. " + "Can be useful if you don't need to update shadow too often." ), "FrameSkip", (rect, label, property) => EditorGUI.IntSlider(rect, label, property.intValue, 0, 50)); DoFieldProperty( _cullInvisible, new GUIContent( "Ignore culling: ", "If selected, the camera culling will be disabled. " + "Check this for a small performance gain if shadow is always in sight." ), "CullInvisible", (rect, label, property) => !EditorGUI.Toggle(rect, label, !property.boolValue)); bool useForceLayer = DoFieldProperty( _useForceLayer, new GUIContent( "Shadow layer: ", "The layer at which the shadow will be rendered." ), "UseForceLayer", (rect, label, property) => EditorGUI.Popup(rect, label, property.boolValue ? 1 : 0, EditorGUIUtilityInternal.TempContent(new string[] { "Same as GameObject", "Manual" })) == 1); if (useForceLayer) { EditorGUI.indentLevel++; DoFieldProperty( _forceLayer, new GUIContent( "Layer: ", "" ), "ForceLayer", (rect, label, property) => EditorGUI.LayerField(rect, label, _forceLayer.intValue)); EditorGUI.indentLevel--; } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { EditorGUI.indentLevel = 0; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Sorting Layer"); EditorGUI.BeginChangeCheck(); //float old_LabelWidth = EditorGUIUtility.labelWidth; //float old_fieldWidth = EditorGUIUtility.fieldWidth; // SORTING LAYERS var sortingLayerNames = SortingLayerHelper.sortingLayerNames; // Look up the layer name using the current layer ID string oldName = SortingLayerHelper.GetSortingLayerNameFromID(m_Renderer.sortingLayerID); // Use the name to look up our array index into the names list int oldLayerIndex = System.Array.IndexOf(sortingLayerNames, oldName); // Show the pop-up for the names EditorGUIUtility.fieldWidth = 0f; int newLayerIndex = EditorGUILayout.Popup(string.Empty, oldLayerIndex, sortingLayerNames, GUILayout.MinWidth(80f)); // If the index changes, look up the ID for the new index to store as the new ID if (newLayerIndex != oldLayerIndex) { //Undo.RecordObject(renderer, "Edit Sorting Layer"); m_Renderer.sortingLayerID = SortingLayerHelper.GetSortingLayerIDForIndex(newLayerIndex); //EditorUtility.SetDirty(renderer); } // Expose the manual sorting order EditorGUIUtility.labelWidth = 40f; EditorGUIUtility.fieldWidth = 80f; int newSortingLayerOrder = EditorGUILayout.IntField("Order", m_Renderer.sortingOrder); if (newSortingLayerOrder != m_Renderer.sortingOrder) { //Undo.RecordObject(renderer, "Edit Sorting Order"); m_Renderer.sortingOrder = newSortingLayerOrder; } EditorGUILayout.EndHorizontal(); // // If a Custom Material Editor exists, we use it. // if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) // { // Material mat = m_canvasRenderer.GetMaterial(); // //Debug.Log(mat + " " + m_targetMaterial); // if (mat != m_targetMaterial) // { // // Destroy previous Material Instance // //Debug.Log("New Material has been assigned."); // m_targetMaterial = mat; // DestroyImmediate(m_materialEditor); // } // if (m_materialEditor == null) // { // m_materialEditor = Editor.CreateEditor(mat); // } // m_materialEditor.DrawHeader(); // m_materialEditor.OnInspectorGUI(); // } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); // Limit valid characters. // TODO: This might not be necessary since name will need to be sanitized for different needs later (as an enum entry, pre-processor define, etc.) //char chr = Event.current.character; //if ((chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z') && (chr < '0' || chr > '9') && chr != '-' && chr != '_' && chr != ' ') //{ // Event.current.character = '\0'; //} bool show = property.isExpanded; UnityBuildGUIUtility.DropdownHeader(property.FindPropertyRelative("typeName").stringValue, ref show, false); property.isExpanded = show; if (show) { EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle); GUILayout.Label("Basic Info", UnityBuildGUIUtility.midHeaderStyle); SerializedProperty typeName = property.FindPropertyRelative("typeName"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Type Name"); typeName.stringValue = BuildProject.SanitizeFolderName(GUILayout.TextArea(typeName.stringValue)); EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(property.FindPropertyRelative("bundleIdentifier")); EditorGUILayout.PropertyField(property.FindPropertyRelative("productName")); EditorGUILayout.PropertyField(property.FindPropertyRelative("companyName")); GUILayout.Space(20); GUILayout.Label("Build Options", UnityBuildGUIUtility.midHeaderStyle); EditorGUILayout.PropertyField(property.FindPropertyRelative("customDefines")); SerializedProperty buildOptions = property.FindPropertyRelative("buildOptions"); bool enableHeadlessMode = ((BuildOptions)buildOptions.intValue & BuildOptions.EnableHeadlessMode) == BuildOptions.EnableHeadlessMode; bool developmentBuild = ((BuildOptions)buildOptions.intValue & BuildOptions.Development) == BuildOptions.Development; bool allowDebugging = ((BuildOptions)buildOptions.intValue & BuildOptions.AllowDebugging) == BuildOptions.AllowDebugging; enableHeadlessMode = EditorGUILayout.ToggleLeft(" Server Build", enableHeadlessMode); if (enableHeadlessMode) { buildOptions.intValue |= (int)BuildOptions.EnableHeadlessMode; } else { buildOptions.intValue &= ~(int)BuildOptions.EnableHeadlessMode; } developmentBuild = EditorGUILayout.ToggleLeft(" Development Build", developmentBuild); if (developmentBuild) { buildOptions.intValue |= (int)BuildOptions.Development; } else { buildOptions.intValue &= ~(int)BuildOptions.Development; } EditorGUI.BeginDisabledGroup(!developmentBuild); allowDebugging = EditorGUILayout.ToggleLeft(" Script Debugging", allowDebugging); EditorGUI.EndDisabledGroup(); if (allowDebugging) { buildOptions.intValue |= (int)BuildOptions.AllowDebugging; } else { buildOptions.intValue &= ~(int)BuildOptions.AllowDebugging; } buildOptions.intValue = (int)(BuildOptions)EditorGUILayout.EnumFlagsField("Advanced", (BuildOptions)buildOptions.intValue); EditorGUILayout.PropertyField(property.FindPropertyRelative("sceneList")); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Delete", GUILayout.MaxWidth(150))) { BuildReleaseType[] types = BuildSettings.releaseTypeList.releaseTypes; for (int i = 0; i < types.Length; i++) { if (types[i].typeName == property.FindPropertyRelative("typeName").stringValue) { ArrayUtility.RemoveAt <BuildReleaseType>(ref BuildSettings.releaseTypeList.releaseTypes, i); GUIUtility.keyboardControl = 0; break; } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); property.serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); } EditorGUI.EndProperty(); }
public override void Draw() { EditorGUILayout.BeginHorizontal(); base.Draw(); EditorGUILayout.EndHorizontal(); }
void OnGUI() { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); if (updateNeeded) { EditorGUILayout.LabelField("A new version is available : " + version, EditorStyles.wordWrappedLabel); GUILayout.Space(20); if (_automaticUpdate) { EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); EditorPrefs.SetBool("PiXYZ.AutoUpdate", !EditorGUILayout.Toggle("Do not show Again", !EditorPrefs.GetBool("PiXYZ.AutoUpdate"))); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Download")) { Application.OpenURL(link); this.Close(); } if (GUILayout.Button("Later")) { this.Close(); } GUILayout.EndHorizontal(); } else if (errorMessage == "") { EditorGUILayout.LabelField("Your version is up to date", EditorStyles.wordWrappedLabel); GUILayout.Space(20); GUILayout.BeginHorizontal(); if (GUILayout.Button("Close")) { this.Close(); } GUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(errorMessage, EditorStyles.wordWrappedLabel); GUILayout.Space(20); GUILayout.BeginHorizontal(); if (GUILayout.Button("Retry")) { errorMessage = ""; checkForUpdate(); } if (GUILayout.Button("Close")) { this.Close(); errorMessage = ""; } GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { GUI.skin = Skin; CustomIKSolver t = target as CustomIKSolver; serializedObject.Update(); EditorGUILayout.PrefixLabel(new GUIContent(IKTexture)); //GUI.color = new Color(61.0f / 255.0f, 147.0f / 255.0f, 160.0f / 255.0f); EditorGUILayout.BeginHorizontal("box"); t.label = EditorGUILayout.TextField(t.label); // draw name box EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("box"); // 0 EditorGUILayout.BeginHorizontal("box"); GUILayout.Label(new GUIContent(IKTexture), GUILayout.Width(16)); if (GUILayout.Button("Joints")) // draw joints { IKActive = !IKActive; } EditorGUILayout.EndHorizontal(); if (IKActive) { EditorGUI.indentLevel++; // Enter the array if (t.Joints.Count > 0) { JointsProp = serializedObject.FindProperty("Joints"); JointsProp.Next(true); JointsProp.Next(true); JointsProp.Next(true); } // // loop through array for (int i = 0; i < t.Joints.Count; i++) { GUI.color = new Color(1, 1, 1); EditorGUILayout.BeginVertical("box"); // 1 EditorGUILayout.BeginHorizontal(); // 1 if (t.Joints[i] != null) { EditorGUILayout.LabelField(new GUIContent(t.Joints[i].name), GUILayout.Width(100)); } else { EditorGUILayout.LabelField(new GUIContent("!Empty!"), GUILayout.Width(100)); } EditorGUILayout.PropertyField(JointsProp); if (GUILayout.Button("X")) // remove { t.Joints.RemoveAt(i); } EditorGUILayout.EndHorizontal(); // 1 if (t.Joints[i] != null) { EditorGUILayout.BeginHorizontal(); // 2 if (!t.Joints[i].detailToggle) { GUILayout.Label(new GUIContent(PlusTexture), GUILayout.Width(16)); } else { GUILayout.Label(new GUIContent(MinusTexture), GUILayout.Width(16)); } if (GUILayout.Button("Details", GUILayout.Width(100 - 16))) // { t.Joints[i].detailToggle = !t.Joints[i].detailToggle; } EditorGUILayout.EndHorizontal(); // 2 if (t.Joints[i].detailToggle) { GUILayout.Label(new GUIContent("Start Offset: " + t.Joints[i].transform.localPosition)); GUILayout.Label(new GUIContent("Position: " + t.Joints[i].transform.position)); } } EditorGUILayout.EndVertical();// 1 GUI.color = Color.white; JointsProp.Next(false); } // add EditorGUILayout.BeginHorizontal("box"); GUILayout.Label(new GUIContent(PlusTexture), GUILayout.Width(16)); if (GUILayout.Button("ADD")) { t.Joints.Add(null); } GUILayout.Label(new GUIContent(PlusTexture), GUILayout.Width(16)); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); // 0 EditorGUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(AnkleProp); EditorGUILayout.PropertyField(TargetProp); EditorGUILayout.PropertyField(ItterationsProp); serializedObject.ApplyModifiedProperties(); GUILayout.Space(20); t.Visualise = EditorGUILayout.Toggle("Visualise:", t.Visualise); EditorGUILayout.EndVertical(); GUILayout.Space(20); //base.OnInspectorGUI(); }
private int RenderScreensList <T>(string title, List <T> screens, Action <int> RemoveHandler, Action AddHandler, int firstIndex, string addButtonLabel, bool pickFirst, string firstLabel = null) where T : UIScreen { string[] options = new string[screens.Count]; if (screens.Count > 0) { EditorGUILayout.LabelField(title + ":"); } int removeScreen = -1; for (int i = 0; i < screens.Count; i++) { T screen = screens[i]; EditorGUILayout.BeginHorizontal(); T newScreen = EditorGUILayout.ObjectField(screen, typeof(T), true) as T; if (!IsDuplicate <T>(newScreen, screens)) { screens[i] = newScreen; } if (screen != null) { options[i] = screen.name; } else { options[i] = none; } if (screens[i] != null && screens[i].CustomID != null) { EditorGUILayout.LabelField("ID: \"" + screens[i].CustomID + "\"", GUILayout.MaxWidth(120f)); //EditorGUILayout.SelectableLabel("Custom ID: " + screens[i].CustomID); } if (GUILayout.Button("-", GUILayout.Width(20))) { if (EditorUtility.DisplayDialog("Confirm", "Are you sure?", "Yes", "No")) { removeScreen = i; } } EditorGUILayout.EndHorizontal(); } if (removeScreen >= 0 && RemoveHandler != null) { RemoveHandler(removeScreen); } if (GUILayout.Button(addButtonLabel) && AddHandler != null) { AddHandler(); } if (pickFirst && screens.Count > 0) { GUILayout.Space(4); int index = EditorGUILayout.Popup(firstLabel, firstIndex, options); if (options.Length > 0 && !options[index].Equals(none)) { firstIndex = index; } } else { firstIndex = 0; } return(firstIndex); }
public void DrawEvents(Dictionary <int, EventHandler.GameEvent> dic, string removeString) { // Sort for desired events var Events = ( from e in dic.Values where SelectEvent(e) orderby e.GetEventType() ascending select e ).ToArray(); eventInfoOption = GUILayout.Toolbar(eventInfoOption, eventDisplay); EditorGUILayout.LabelField(string.Format("Event Count : {0}", Events.Length), EditorStyles.boldLabel); EditorGUILayout.LabelField(string.Format("Current Frame : {0}", Time.frameCount)); EditorGUILayout.BeginHorizontal(); searchValue = EditorGUILayout.TextField("Search", searchValue, GUILayout.Width(Screen.width - Screen.width / 5f)); searchType = (SearchType)EditorGUILayout.EnumPopup(searchType); EditorGUILayout.EndHorizontal(); // Draw naviation buttons if there is too many to show if (Events.Length > eventItems) { EditorGUILayout.LabelField(string.Format("Page {0}", window, GUILayout.Width(Screen.width / 6f))); EditorGUILayout.BeginHorizontal(); if (window * eventItems < eventItems) { GUI.enabled = false; } if (GUILayout.Button(string.Format("Previous {0}", eventItems))) { window--; } GUI.enabled = true; if (window * eventItems >= Events.Length) { Debug.Log("Shrink"); window = (Events.Length - Events.Length % eventItems) / eventItems; if (window * eventItems == Events.Length) { window -= 1; } } if (window * eventItems + eventItems >= Events.Length) { GUI.enabled = false; } if (GUILayout.Button(string.Format("Next {0}", eventItems))) { window++; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } else { window = 0; } // Draw Event Info for (int itr = window * eventItems; itr < window * eventItems + eventItems; ++itr) { if (itr > Events.Length - 1) { continue; } var item = Events[itr]; if (item.Subscriber.Count == 0) { continue; } var foldout = item.GetEventType().ToString().Replace(removeString, ""); EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUI.indentLevel++; item.show = EditorGUILayout.Foldout(item.show, new GUIContent(string.Format("{0} : {1}", foldout, item.Subscriber.Count), "Event Name"), true); if (item.show) { if (eventInfoOption == 0) { foreach (var subscriber in item.Subscriber) { if (searchType == SearchType.Subscriber) { if (subscriber == null || !(subscriber.GetType().ToString().IndexOf(searchValue, StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } } if (subscriber == null) { EditorGUILayout.LabelField("NULL SUBSCRIBER"); } else if (subscriber is MonoBehaviour) { var system = subscriber as MonoBehaviour; if (GUI.Button(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect()), string.Format("{1} ({0})", system.gameObject.name, system.GetType().ToString()), EditorStyles.label)) { EditorGUIUtility.PingObject(system); } } else { EditorGUILayout.LabelField(subscriber.GetType().ToString()); } } } else { var invokers = item.EventInvokers.ToArray(); if (invokers.Length > 0) { for (int i = invokers.Length - 1; i >= 0; --i) { var invoker = invokers[i]; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("Frame:{0}", invoker.frame), GUILayout.Width(Screen.width / 4f)); if (invoker.invoker is MonoBehaviour) { var invokeSystem = invoker.invoker as MonoBehaviour; if (invokeSystem == null) { EditorGUILayout.LabelField("Deleted"); } else { if (GUILayout.Button(string.Format("{0}:{1}", invokeSystem.gameObject.name, invokeSystem.GetType().ToString()), EditorStyles.label)) { EditorGUIUtility.PingObject(invokeSystem); } } } else { if (invoker.invoker == null) { EditorGUILayout.LabelField("NULL INVOKER"); } else { EditorGUILayout.LabelField(invoker.invoker.GetType().ToString()); } } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.LabelField("No Invokers"); } } } EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); } }
private void DrawClass(RPGDatabaseManager database) { var weaponTypeIds = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.Id).ToArray(); var weaponTypeNames = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.name).ToArray(); var skillIds = database.FetchEntry <SkillDataList>().entries.Select(l => l.Id).ToArray(); var skillNames = database.FetchEntry <SkillDataList>().entries.Select(l => l.name).ToArray(); var entry = (ActorClassData)entrySelected; EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(400)); classAreaVect = EditorGUILayout.BeginScrollView(classAreaVect, GUILayout.Width(400)); DrawTitle(); entry.name = EditorGUILayout.TextField("Name", entry.name); #region Growth BrightEditorGUILayout.LabelFieldBold("Growth"); entry.expCurve = EditorGUILayout.CurveField(Constants.Attributes.EXP, entry.expCurve, GUILayout.Height(25f)); entry.hpCurve = EditorGUILayout.CurveField(Constants.Attributes.HP, entry.hpCurve, GUILayout.Height(25f)); entry.mpCurve = EditorGUILayout.CurveField(Constants.Attributes.MP, entry.mpCurve, GUILayout.Height(25f)); entry.strCurve = EditorGUILayout.CurveField(Constants.Attributes.STR, entry.strCurve, GUILayout.Height(25f)); entry.intCurve = EditorGUILayout.CurveField(Constants.Attributes.INT, entry.intCurve, GUILayout.Height(25f)); entry.dexCurve = EditorGUILayout.CurveField(Constants.Attributes.DEX, entry.dexCurve, GUILayout.Height(25f)); entry.agiCurve = EditorGUILayout.CurveField(Constants.Attributes.AGI, entry.agiCurve, GUILayout.Height(25f)); entry.lckCurve = EditorGUILayout.CurveField(Constants.Attributes.LCK, entry.lckCurve, GUILayout.Height(25f)); entry.defCurve = EditorGUILayout.CurveField(Constants.Attributes.DEF, entry.defCurve, GUILayout.Height(25f)); entry.resCurve = EditorGUILayout.CurveField(Constants.Attributes.RES, entry.resCurve, GUILayout.Height(25f)); #endregion #region Preview EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); var list = database.FetchEntry <AttributeSpecDataList>(); var level = list.entries.First(x => x.name == Constants.Attributes.LEVEL); var exp = list.entries.First(x => x.name == Constants.Attributes.EXP); var hp = list.entries.First(x => x.name == Constants.Attributes.HP); var mp = list.entries.First(x => x.name == Constants.Attributes.MP); var attr = list.entries.First(x => x.name == Constants.Attributes.COMMON); BrightEditorGUILayout.LabelFieldBold("Preview"); previewLv = EditorGUILayout.IntSlider(Constants.Attributes.LEVEL_SHORT, previewLv, level.start, level.end); float normalizedValue = Mathf.InverseLerp(level.start, level.end, previewLv); float targetCurveValue = 0f; targetCurveValue = entry.expCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.EXP}:\t{exp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.hpCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.HP}:\t{hp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.mpCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.MP}:\t{mp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.strCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.STR_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.intCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.INT_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.dexCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.DEX_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.agiCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.AGI_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.lckCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.LCK_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.defCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.DEF_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.resCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.RES_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); EditorGUILayout.EndVertical(); #endregion #region Weapons EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); BrightEditorGUILayout.LabelFieldBold("Weapon Type"); entry.weaponTypeId = EditorGUILayout.IntPopup(entry.weaponTypeId, weaponTypeNames, weaponTypeIds); EditorGUILayout.EndVertical(); #endregion #region Skills EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); skillUnlockVect = EditorGUILayout.BeginScrollView(skillUnlockVect, GUILayout.MinHeight(90)); BrightEditorGUILayout.LabelFieldBold(Constants.SKILLS); if (entry.skills == null) { entry.skills = new System.Collections.Generic.List <SkillUnlockArgs>(); } for (int i = 0; i < entry.skills.Count; i++) { var skillUnlockArgs = entry.skills[i]; EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); skillUnlockArgs.level = EditorGUILayout.IntField(Constants.Attributes.LEVEL_SHORT, skillUnlockArgs.level); skillUnlockArgs.skillId = EditorGUILayout.IntPopup(skillUnlockArgs.skillId, skillNames, skillIds); if (GUILayout.Button("-", GUILayout.Width(20f))) { entry.skills.RemoveAt(i); break; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+", GUILayout.Width(40f))) { entry.skills.Add(new SkillUnlockArgs()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); #endregion EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { mFont = target as UIFont; NGUIEditorTools.SetLabelWidth(80f); GUILayout.Space(6f); if (mFont.replacement != null) { mType = FontType.Reference; mReplacement = mFont.replacement; } else if (mFont.dynamicFont != null) { mType = FontType.Dynamic; } GUI.changed = false; GUILayout.BeginHorizontal(); mType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (GUI.changed) { if (mType == FontType.Bitmap) { OnSelectFont(null); } if (mType != FontType.Dynamic && mFont.dynamicFont != null) { mFont.dynamicFont = null; } } if (mType == FontType.Reference) { ComponentSelector.Draw <UIFont>(mFont.replacement, OnSelectFont, true); GUILayout.Space(6f); EditorGUILayout.HelpBox("You can have one font simply point to " + "another one. This is useful if you want to be " + "able to quickly replace the contents of one " + "font with another one, for example for " + "swapping an SD font with an HD one, or " + "replacing an English font with a Chinese " + "one. All the labels referencing this font " + "will update their references to the new one.", MessageType.Info); if (mReplacement != mFont && mFont.replacement != mReplacement) { NGUIEditorTools.RegisterUndo("Font Change", mFont); mFont.replacement = mReplacement; NGUITools.SetDirty(mFont); } return; } else if (mType == FontType.Dynamic) { #if UNITY_3_5 EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error); #else Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont, typeof(Font), false) as Font; if (fnt != mFont.dynamicFont) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.dynamicFont = fnt; } Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont); mFont.material = mat; } GUILayout.BeginHorizontal(); int size = EditorGUILayout.IntField("Default Size", mFont.defaultSize, GUILayout.Width(120f)); FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (size != mFont.defaultSize) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.defaultSize = size; } if (style != mFont.dynamicFontStyle) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.dynamicFontStyle = style; } #endif } else { ComponentSelector.Draw <UIAtlas>(mFont.atlas, OnSelectAtlas, true); if (mFont.atlas != null) { if (mFont.bmFont.isValid) { NGUIEditorTools.DrawAdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false); } EditorGUILayout.Space(); } else { // No atlas specified -- set the material and texture rectangle directly Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont); mFont.material = mat; } } // For updating the font's data when importing from an external source, such as the texture packer bool resetWidthHeight = false; if (mFont.atlas != null || mFont.material != null) { TextAsset data = EditorGUILayout.ObjectField("Import Data", null, typeof(TextAsset), false) as TextAsset; if (data != null) { NGUIEditorTools.RegisterUndo("Import Font Data", mFont); BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes); mFont.MarkAsChanged(); resetWidthHeight = true; GameDebug.Log("Imported " + mFont.bmFont.glyphCount + " characters"); } } if (mFont.bmFont.isValid) { Texture2D tex = mFont.texture; if (tex != null && mFont.atlas == null) { // Pixels are easier to work with than UVs Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false); // Automatically set the width and height of the rectangle to be the original font texture's dimensions if (resetWidthHeight) { pixels.width = mFont.texWidth; pixels.height = mFont.texHeight; } // Font sprite rectangle pixels = EditorGUILayout.RectField("Pixel Rect", pixels); // Convert the pixel coordinates back to UV coordinates Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height); if (mFont.uvRect != uvRect) { NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont); mFont.uvRect = uvRect; } //NGUIEditorTools.DrawSeparator(); EditorGUILayout.Space(); } } } // Dynamic fonts don't support emoticons if (!mFont.isDynamic && mFont.bmFont.isValid) { if (mFont.atlas != null) { if (NGUIEditorTools.DrawHeader("Symbols and Emoticons")) { NGUIEditorTools.BeginContents(); List <BMSymbol> symbols = mFont.symbols; for (int i = 0; i < symbols.Count;) { BMSymbol sym = symbols[i]; GUILayout.BeginHorizontal(); GUILayout.Label(sym.sequence, GUILayout.Width(40f)); if (NGUIEditorTools.DrawSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite, GUILayout.MinWidth(100f))) { mSelectedSymbol = sym; } if (GUILayout.Button("Edit", GUILayout.Width(40f))) { if (mFont.atlas != null) { NGUISettings.atlas = mFont.atlas; NGUISettings.selectedSprite = sym.spriteName; NGUIEditorTools.Select(mFont.atlas.gameObject); } } GUI.backgroundColor = Color.red; if (GUILayout.Button("X", GUILayout.Width(22f))) { NGUIEditorTools.RegisterUndo("Remove symbol", mFont); mSymbolSequence = sym.sequence; mSymbolSprite = sym.spriteName; symbols.Remove(sym); mFont.MarkAsChanged(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(4f); ++i; } if (symbols.Count > 0) { GUILayout.Space(6f); } GUILayout.BeginHorizontal(); mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f)); NGUIEditorTools.DrawSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite); bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite); GUI.backgroundColor = isValid ? Color.green : Color.grey; if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid) { NGUIEditorTools.RegisterUndo("Add symbol", mFont); mFont.AddSymbol(mSymbolSequence, mSymbolSprite); mFont.MarkAsChanged(); mSymbolSequence = ""; mSymbolSprite = ""; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (symbols.Count == 0) { EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info); } else { GUILayout.Space(4f); } NGUIEditorTools.EndContents(); } } } if (mFont.bmFont != null && mFont.bmFont.isValid) { if (NGUIEditorTools.DrawHeader("Modify")) { NGUIEditorTools.BeginContents(); UISpriteData sd = mFont.sprite; bool disable = (sd != null && (sd.paddingLeft != 0 || sd.paddingBottom != 0)); EditorGUI.BeginDisabledGroup(disable || mFont.packedFontShader); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20f); EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); NGUISettings.foregroundColor = EditorGUILayout.ColorField("Foreground", NGUISettings.foregroundColor); NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor); GUILayout.EndVertical(); mCurve = EditorGUILayout.CurveField("", mCurve, GUILayout.Width(40f), GUILayout.Height(40f)); GUILayout.EndHorizontal(); if (GUILayout.Button("Add a Shadow")) { ApplyEffect(Effect.Shadow, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Add a Soft Outline")) { ApplyEffect(Effect.Outline, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Rebalance Colors")) { ApplyEffect(Effect.Rebalance, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Alpha")) { ApplyEffect(Effect.AlphaCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Foreground")) { ApplyEffect(Effect.ForegroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Background")) { ApplyEffect(Effect.BackgroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } GUILayout.Space(10f); if (GUILayout.Button("Add Transparent Border (+1)")) { ApplyEffect(Effect.Border, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Remove Border (-1)")) { ApplyEffect(Effect.Crop, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } EditorGUILayout.EndVertical(); GUILayout.Space(20f); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); if (disable) { GUILayout.Space(3f); EditorGUILayout.HelpBox("The sprite used by this font has been trimmed and is not suitable for modification. " + "Try re-adding this sprite with 'Trim Alpha' disabled.", MessageType.Warning); } NGUIEditorTools.EndContents(); } } // The font must be valid at this point for the rest of the options to show up if (mFont.isDynamic || mFont.bmFont.isValid) { if (mFont.atlas == null) { mView = View.Font; mUseShader = false; } } // Preview option if (!mFont.isDynamic && mFont.atlas != null) { GUILayout.BeginHorizontal(); { mView = (View)EditorGUILayout.EnumPopup("Preview", mView); GUILayout.Label("Shader", GUILayout.Width(45f)); mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f)); } GUILayout.EndHorizontal(); } }
void OnGUI() { EditorGUILayout.Space(); EditorGUILayout.LabelField("Simple IAP System comes with billing plugin dependent"); EditorGUILayout.LabelField("packages. Which one would you like to use?"); EditorGUILayout.Space(); EditorGUILayout.LabelField("Please read the PDF documentation after importing."); EditorGUILayout.LabelField("Other links: Window > Simple IAP System > About."); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Prime31", GUILayout.Width(100)); if (GUILayout.Button("Import")) { AssetDatabase.ImportPackage(packagesPath + "Prime31.unitypackage", true); DisableAutoOpen(); } if (GUILayout.Button("?", GUILayout.Width(20))) { Application.OpenURL("https://www.assetstore.unity3d.com/#/publisher/270"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Stans Assets", GUILayout.Width(100)); if (GUILayout.Button("Import")) { AssetDatabase.ImportPackage(packagesPath + "StansAssets.unitypackage", true); DisableAutoOpen(); } if (GUILayout.Button("?", GUILayout.Width(20))) { Application.OpenURL("https://www.assetstore.unity3d.com/#/publisher/2256"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Unibill", GUILayout.Width(100)); if (GUILayout.Button("Import")) { AssetDatabase.ImportPackage(packagesPath + "Unibill.unitypackage", true); DisableAutoOpen(); } if (GUILayout.Button("?", GUILayout.Width(20))) { Application.OpenURL("https://www.assetstore.unity3d.com/#/content/5767"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("OpenIAB (free)", GUILayout.Width(100)); if (GUILayout.Button("Import")) { AssetDatabase.ImportPackage(packagesPath + "OpenIAB.unitypackage", true); DisableAutoOpen(); } if (GUILayout.Button("?", GUILayout.Width(20))) { Application.OpenURL("https://github.com/onepf/OpenIAB-Unity-Plugin"); } EditorGUILayout.EndHorizontal(); }
protected override void gui() { base.gui(); SkeletonAnimation component = (SkeletonAnimation)target; if (!component.valid) { return; } //catch case where SetAnimation was used to set track 0 without using AnimationName if (Application.isPlaying) { TrackEntry currentState = component.state.GetCurrent(0); if (currentState != null) { if (component.AnimationName != animationName.stringValue) { animationName.stringValue = currentState.Animation.Name; } } } // Animation name. { String[] animations = new String[component.skeleton.Data.Animations.Count + 1]; animations[0] = "<None>"; int animationIndex = 0; for (int i = 0; i < animations.Length - 1; i++) { String name = component.skeleton.Data.Animations[i].Name; animations[i + 1] = name; if (name == animationName.stringValue) { animationIndex = i + 1; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Animation", GUILayout.Width(EditorGUIUtility.labelWidth)); animationIndex = EditorGUILayout.Popup(animationIndex, animations); EditorGUILayout.EndHorizontal(); String selectedAnimationName = animationIndex == 0 ? null : animations[animationIndex]; component.AnimationName = selectedAnimationName; animationName.stringValue = selectedAnimationName; } EditorGUILayout.PropertyField(mainColor); EditorGUILayout.PropertyField(loop); EditorGUILayout.PropertyField(timeScale); component.timeScale = Math.Max(component.timeScale, 0); EditorGUILayout.Space(); if (!isPrefab) { if (component.GetComponent <SkeletonUtility>() == null) { if (GUILayout.Button(new GUIContent("Add Skeleton Utility", SpineEditorUtilities.Icons.skeletonUtility), GUILayout.Height(30))) { component.gameObject.AddComponent <SkeletonUtility>(); } } } }
//-----------------------------------------------TaB GUI'S-------------------------------------------------------------------------------------- private void ShowConfigGUI() { if (LocalConfigPresets.Count > 0) { EnableRename = true; } else { EnableRename = false; } //----------------------------------------//Header\\---------------------------------------------------------------------------------------- #region Header EditorGUILayout.BeginHorizontal(); //------------------------------------This is a Horizontal Group. //Chequeo cuantos presets estan disponibles y los muestro, si no hay nada aún, Muestro "Empty". ConfirmIfAviablePresetsExist(); PresetSelected = EditorGUILayout.Popup(PresetSelected, AviablePresets); if (GUILayout.Button("Add")) { var item = new ConfigPreset(); item.isDefault = false; //string name = item.ConfigurationName; LocalConfigPresets.Add(item); if (LocalConfigPresets.Count - 1 >= 0) { PresetSelected = LocalConfigPresets.Count - 1; } else { PresetSelected = 0; } var editWindow = GetWindow <EditPreset>().ToEdit(item); HasBeenModified = true; editWindow.Show(); } if (GUILayout.Button("Duplicate")) { LocalConfigPresets.Add(LocalConfigPresets[PresetSelected].Clone()); } EditorGUI.BeginDisabledGroup(LocalConfigPresets[PresetSelected].isDefault); if (GUILayout.Button("Edit")) { var editWindow = GetWindow <EditPreset>(); editWindow.ToEdit(LocalConfigPresets[PresetSelected]); HasBeenModified = true; editWindow.Show(); } if (GUILayout.Button("Delete")) { LocalConfigPresets.Remove(LocalConfigPresets[PresetSelected]); if (LocalConfigPresets.Count - 1 >= 0) { PresetSelected = LocalConfigPresets.Count - 1; } else { PresetSelected = 0; } HasBeenModified = true; ConfirmIfAviablePresetsExist(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); //--------------------------------------Here ends a Horizontal Group. #endregion //-------------------------------------------//Body\\----------------------------------------------------------------------------------------- #region Body GUILayout.Space(3); HorizontalLine(Color.grey); HorizontalLine(Color.grey); GUILayout.Space(3); ConfigScrollPos = EditorGUILayout.BeginScrollView(ConfigScrollPos, false, false, new GUILayoutOption[] { GUILayout.Height(150) }); if (LocalConfigPresets.Count > 0) { WritableConfigPresetsAviable = true; LocalFolderPresets = LocalConfigPresets[PresetSelected].GetFolderPresets(); foreach (var item in LocalConfigPresets[PresetSelected].GetFolderPresets()) { ShowFolderConfigSet(item); } if (FoldersToClear.Count > 0) { ClearFolderList(); } } else { WritableConfigPresetsAviable = false; } EditorGUILayout.EndScrollView(); GUILayout.Space(3); HorizontalLine(Color.grey); HorizontalLine(Color.grey); GUILayout.Space(3); #endregion //-------------------------------------------//Bottom\\--------------------------------------------------------------------------------------- #region Bottom EditorGUI.BeginDisabledGroup(!WritableConfigPresetsAviable); EditorGUILayout.PrefixLabel("Add New Folders", new GUIStyle() { fontStyle = FontStyle.Bold }); EditorGUILayout.BeginHorizontal(); //------------------------------------This is a Horizontal Group. //---------------------------------------Creo un nuevo Preset de Carpeta--------------------------- //EditorGUILayout.LabelField("New Folder name: ", GUILayout.Width(75)); if (GUILayout.Button("Create New Folder")) { if (LocalConfigPresets.Count > 0) { List <string> NewAviableExtentionList = new List <string> { ".mat" }; //Guardamos la Lista de extensiones. LocalConfigPresets[PresetSelected].AddFolderPreset(newFolderName, newFolderTypeSelected, NewAviableExtentionList); //Guardamos el preset de la carpeta. LocalFolderPresets = LocalConfigPresets[PresetSelected].GetFolderPresets(); newFolderName = DefaultFolderName; //Reseteamos la previsualizacion del nombre. newFolderTypeSelected = 0; //Reseteamos la previsualizacion del tipo. foreach (var preset in LocalConfigPresets) { foreach (var folder in preset.FolderPresets) { MonoBehaviour.print("Presets Creados -->" + " Preset: " + preset.ConfigurationName + "Carpeta: " + folder.FolderName); } } } HasBeenModified = true; } newFolderName = EditorGUILayout.TextField(newFolderName); if (FolderTypeOptions == null) { FolderTypeOptions = new string[] { "Empty" } } ; if (FolderTypeOptions != null) { newFolderTypeSelected = EditorGUILayout.Popup(newFolderTypeSelected, FolderTypeOptions); } EditorGUILayout.EndHorizontal(); //--------------------------------------Here ends a Horizontal Group. EditorGUI.EndDisabledGroup(); #endregion }
public override void OnInspectorGUI() { EasyTouch t = (EasyTouch)target; #region General properties EditorGUILayout.Space(); t.enable = HTGuiTools.Toggle("Enable EasyTouch", t.enable, true); t.enableRemote = HTGuiTools.Toggle("Enable Unity Remote", t.enableRemote, true); EditorGUILayout.Space(); #endregion #region Gui propertie t.showGuiInspector = HTGuiTools.BeginFoldOut("GUI compatibilty", t.showGuiInspector); if (t.showGuiInspector) { HTGuiTools.BeginGroup(); { // UGUI EditorGUILayout.Space(); t.allowUIDetection = HTGuiTools.Toggle("Enable Unity UI detection", t.allowUIDetection, true); if (t.allowUIDetection) { EditorGUI.indentLevel++; t.enableUIMode = HTGuiTools.Toggle("Unity UI compatibilty", t.enableUIMode, true); t.autoUpdatePickedUI = HTGuiTools.Toggle("Auto update picked Unity UI", t.autoUpdatePickedUI, true); EditorGUI.indentLevel--; } EditorGUILayout.Space(); // NGUI t.enabledNGuiMode = HTGuiTools.Toggle("Enable NGUI compatibilty", t.enabledNGuiMode, true); if (t.enabledNGuiMode) { //EditorGUI.indentLevel++; HTGuiTools.BeginGroup(5); { // layers serializedObject.Update(); SerializedProperty layers = serializedObject.FindProperty("nGUILayers"); EditorGUILayout.PropertyField(layers, false); serializedObject.ApplyModifiedProperties(); // Camera if (HTGuiTools.Button("Add camera", Color.green, 100, false)) { t.nGUICameras.Add(null); } for (int i = 0; i < t.nGUICameras.Count; i++) { EditorGUILayout.BeginHorizontal(); if (HTGuiTools.Button("X", Color.red, 19)) { t.nGUICameras.RemoveAt(i); i--; } else { t.nGUICameras[i] = (Camera)EditorGUILayout.ObjectField("", t.nGUICameras[i], typeof(Camera), true); EditorGUILayout.EndHorizontal(); } } } HTGuiTools.EndGroup(); //EditorGUI.indentLevel--; } } HTGuiTools.EndGroup(); } #endregion #region Auto selection properties t.showSelectInspector = HTGuiTools.BeginFoldOut("Automatic selection", t.showSelectInspector); if (t.showSelectInspector) { HTGuiTools.BeginGroup(); { t.autoSelect = HTGuiTools.Toggle("Enable auto-select", t.autoSelect, true); if (t.autoSelect) { EditorGUILayout.Space(); // 3d layer serializedObject.Update(); SerializedProperty layers = serializedObject.FindProperty("pickableLayers3D"); EditorGUILayout.PropertyField(layers, true); serializedObject.ApplyModifiedProperties(); t.autoUpdatePickedObject = HTGuiTools.Toggle("Auto update picked gameobject", t.autoUpdatePickedObject, true); EditorGUILayout.Space(); //2D t.enable2D = HTGuiTools.Toggle("Enable 2D collider", t.enable2D, true); if (t.enable2D) { serializedObject.Update(); layers = serializedObject.FindProperty("pickableLayers2D"); EditorGUILayout.PropertyField(layers, true); serializedObject.ApplyModifiedProperties(); } // Camera GUILayout.Space(5f); HTGuiTools.BeginGroup(5); { if (HTGuiTools.Button("Add Camera", Color.green, 100)) { t.touchCameras.Add(new ECamera(null, false)); } for (int i = 0; i < t.touchCameras.Count; i++) { EditorGUILayout.BeginHorizontal(); if (HTGuiTools.Button("X", Color.red, 19)) { t.touchCameras.RemoveAt(i); i--; } if (i >= 0) { t.touchCameras[i].camera = (Camera)EditorGUILayout.ObjectField("", t.touchCameras[i].camera, typeof(Camera), true, GUILayout.MinWidth(150)); t.touchCameras[i].guiCamera = EditorGUILayout.ToggleLeft("Gui", t.touchCameras[i].guiCamera, GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); } } } HTGuiTools.EndGroup(); } } HTGuiTools.EndGroup(); } #endregion #region General gesture properties t.showGestureInspector = HTGuiTools.BeginFoldOut("General gesture properties", t.showGestureInspector); if (t.showGestureInspector) { HTGuiTools.BeginGroup(); { t.gesturePriority = (EasyTouch.GesturePriority)EditorGUILayout.EnumPopup("Priority to", t.gesturePriority); t.StationaryTolerance = EditorGUILayout.FloatField("Stationary tolerance", t.StationaryTolerance); t.longTapTime = EditorGUILayout.FloatField("Long tap time", t.longTapTime); EditorGUILayout.Space(); t.doubleTapDetection = (EasyTouch.DoubleTapDetection)EditorGUILayout.EnumPopup("Double tap detection", t.doubleTapDetection); if (t.doubleTapDetection == EasyTouch.DoubleTapDetection.ByTime) { t.doubleTapTime = EditorGUILayout.Slider("Double tap time", t.doubleTapTime, 0.15f, 0.4f); } EditorGUILayout.Space(); t.swipeTolerance = EditorGUILayout.FloatField("Swipe tolerance", t.swipeTolerance); t.alwaysSendSwipe = EditorGUILayout.Toggle("always sent swipe event", t.alwaysSendSwipe); } HTGuiTools.EndGroup(); } #endregion #region 2 fingers gesture t.showTwoFingerInspector = HTGuiTools.BeginFoldOut("Two fingers gesture properties", t.showTwoFingerInspector); if (t.showTwoFingerInspector) { HTGuiTools.BeginGroup(); { t.enable2FingersGesture = HTGuiTools.Toggle("2 fingers gesture", t.enable2FingersGesture, true); if (t.enable2FingersGesture) { EditorGUI.indentLevel++; t.twoFingerPickMethod = (EasyTouch.TwoFingerPickMethod)EditorGUILayout.EnumPopup("Pick method", t.twoFingerPickMethod); EditorGUILayout.Separator(); t.enable2FingersSwipe = HTGuiTools.Toggle("Enable swipe & drag", t.enable2FingersSwipe, true); EditorGUILayout.Separator(); t.enablePinch = HTGuiTools.Toggle("Enable Pinch", t.enablePinch, true); if (t.enablePinch) { t.minPinchLength = EditorGUILayout.FloatField("Min pinch length", t.minPinchLength); } EditorGUILayout.Separator(); t.enableTwist = HTGuiTools.Toggle("Enable twist", t.enableTwist, true); if (t.enableTwist) { t.minTwistAngle = EditorGUILayout.FloatField("Min twist angle", t.minTwistAngle); } EditorGUI.indentLevel--; } } HTGuiTools.EndGroup(); } #endregion #region Second Finger simulation t.showSecondFingerInspector = HTGuiTools.BeginFoldOut("Second finger simulation", t.showSecondFingerInspector); if (t.showSecondFingerInspector) { HTGuiTools.BeginGroup(); { t.enableSimulation = HTGuiTools.Toggle("Enable simulation", t.enableSimulation, true); EditorGUILayout.Space(); if (t.enableSimulation) { EditorGUI.indentLevel++; if (t.secondFingerTexture == null) { t.secondFingerTexture = Resources.Load("secondFinger") as Texture; } t.secondFingerTexture = (Texture)EditorGUILayout.ObjectField("Texture", t.secondFingerTexture, typeof(Texture), true); EditorGUILayout.HelpBox("Change the keys settings for a fash compilation, or if you want to change the keys", MessageType.Info); t.twistKey = (KeyCode)EditorGUILayout.EnumPopup("Twist & pinch key", t.twistKey); t.swipeKey = (KeyCode)EditorGUILayout.EnumPopup("Swipe key", t.swipeKey); EditorGUI.indentLevel--; } } HTGuiTools.EndGroup(); } #endregion if (GUI.changed) { EditorUtility.SetDirty(target); #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #endif } }
void OnGUI() { GUILayout.Label("OVR Performance Lint Tool", EditorStyles.boldLabel); if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { RunCheck(); } string lastCategory = ""; mScrollPosition = EditorGUILayout.BeginScrollView(mScrollPosition); for (int x = 0; x < mRecords.Count; x++) { FixRecord record = mRecords[x]; if (!record.category.Equals(lastCategory)) // new category { lastCategory = record.category; EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(lastCategory, EditorStyles.label, GUILayout.Width(200)); bool moreThanOne = (x + 1 < mRecords.Count && mRecords[x + 1].category.Equals(lastCategory)); if (record.buttonNames != null && record.buttonNames.Length > 0) { if (moreThanOne) { GUILayout.Label("Apply to all:", EditorStyles.label, GUILayout.Width(75)); for (int y = 0; y < record.buttonNames.Length; y++) { if (GUILayout.Button(record.buttonNames[y], EditorStyles.toolbarButton, GUILayout.Width(200))) { List <FixRecord> recordsToProcess = new List <FixRecord>(); for (int z = x; z < mRecords.Count; z++) { FixRecord thisRecord = mRecords[z]; bool isLast = false; if (z + 1 >= mRecords.Count || !mRecords[z + 1].category.Equals(lastCategory)) { isLast = true; } if (!thisRecord.complete) { recordsToProcess.Add(thisRecord); } if (isLast) { break; } } UnityEngine.Object[] undoObjects = new UnityEngine.Object[recordsToProcess.Count]; for (int z = 0; z < recordsToProcess.Count; z++) { undoObjects[z] = recordsToProcess[z].targetObject; } Undo.RecordObjects(undoObjects, record.category + " (Multiple)"); for (int z = 0; z < recordsToProcess.Count; z++) { FixRecord thisRecord = recordsToProcess[z]; thisRecord.fixMethod(thisRecord.targetObject, (z + 1 == recordsToProcess.Count), y); thisRecord.complete = true; } } } } } EditorGUILayout.EndHorizontal(); if (moreThanOne || record.targetObject) { GUILayout.Label(record.message); } } EditorGUILayout.BeginHorizontal(); GUI.enabled = !record.complete; if (record.targetObject) { EditorGUILayout.ObjectField(record.targetObject, record.targetObject.GetType(), true); } else { GUILayout.Label(record.message); } if (record.buttonNames != null) { for (int y = 0; y < record.buttonNames.Length; y++) { if (GUILayout.Button(record.buttonNames[y], EditorStyles.toolbarButton, GUILayout.Width(200))) { if (record.targetObject != null) { Undo.RecordObject(record.targetObject, record.category); } record.fixMethod(record.targetObject, true, y); record.complete = true; } } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); }
void OnGUI() { var serializedTable = new UnityEditor.SerializedObject(_table); // Get all screens var displayInfo = MonitorHelper.GetDisplays(); EditorGUILayout.BeginVertical(); // Screen num box var displayInfoAvailable = displayInfo != null && displayInfo.Count > 0; var viewCountProperty = serializedTable.FindProperty("viewCount"); if (!displayInfoAvailable) { EditorGUILayout.PropertyField(viewCountProperty, _textViewCount); } else { viewCountProperty.intValue = displayInfo.Count; } int viewCount = viewCountProperty.intValue; // View-display table var viewTable = serializedTable.FindProperty("viewTable"); for (var i = 0; i < viewCount; i++) { EditorGUILayout.IntPopup( viewTable.GetArrayElementAtIndex(i), _optionLabels, _optionValues, _viewLabels[i] ); // display monitor info below dropdown if (displayInfoAvailable) { EditorGUILayout.LabelField(displayInfo[i].displayDevice.DeviceString, EditorStyles.miniLabel); EditorGUILayout.LabelField(displayInfo[i].MonitorArea.ToString() + ", scale: " + (displayInfo[i].scaleFactor * 100) + "%", EditorStyles.miniLabel); } } for (var i = viewCount; i < viewTable.arraySize; i++) { viewTable.GetArrayElementAtIndex(i).intValue = -1; } EditorGUILayout.Space(); // Function buttons EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Layout")) { LayoutViews(); } EditorGUILayout.Space(); if (GUILayout.Button("Close All")) { CloseAllViews(); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); serializedTable.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (isValid) { EditorGUILayout.HelpBox("Please ensure your camera not controled by other scripts", MessageType.Warning, true); //Updates the object we are editing serializedObject.Update(); //Quick reference to the Quicktakecutscenecontroller script SmoothMoveCamera q = target as SmoothMoveCamera; q.waitUntilFinished = EditorGUILayout.Toggle("等待播放结束开始下一个事件", q.waitUntilFinished); EditorGUILayout.BeginHorizontal(); //Button to manually call the StartCutscene function, only if the game is in play mode if (GUILayout.Button("Play")) { if (Application.isPlaying) { q.ActivateCutscene(); } if (!Application.isPlaying) { Debug.Log("You can only play the cutscene when the game is running"); } } //Button to manually call the StartCutscene function, only if the game is in play mode if (GUILayout.Button("Stop")) { if (Application.isPlaying) { q.EndCutscene(); } if (!Application.isPlaying) { Debug.Log("You can only play/stop the cutscene when the game is running"); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Toggle Path (" + q.showPathType.GetHashCode() + ")")) { q.ToggleShowPath(); } if (GUILayout.Button("Add camera point")) { GameObject g = new GameObject(); g.transform.position = (Selection.activeTransform.position + Random.insideUnitSphere * 5f); g.transform.rotation = Selection.activeTransform.rotation; g.transform.parent = Selection.activeTransform; string n = ("CameraPoint_" + numberOfEvents.ToString()); g.name = n; Undo.RegisterCreatedObjectUndo(g, n); this.OnEnable(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); //Camera selector EditorGUILayout.LabelField(cameraContent); q.mainCutsceneCam = EditorGUILayout.ObjectField(q.mainCutsceneCam, typeof(Camera), true) as Camera; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //Use delta time //EditorGUILayout.BeginHorizontal(); //q.useDeltaTime = EditorGUILayout.Toggle(deltaTimeContent, q.useDeltaTime); //EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //This for loop controls the display of each camera transition event, and the variables relating to it. for (int i = 0; i < (numberOfEvents - 2); i++) { //Handle error which occurs when we undo a deleted CP if (!points[i + 2]) { this.OnEnable(); } else { GUIContent popoutContent = new GUIContent("Camera transition " + (i + 1) + " --> " + (i + 2) + " (" + points[i + 1].name + " -> " + points[i + 2].name + ")"); showEvent[i] = EditorGUILayout.Foldout(showEvent[i], popoutContent);//"Camera transition " + (i+1) + " --> " + (i+2)); } if (showEvent[i] == true) { if (i >= q.cutsceneEventKeyTime.Length) { //Debug.Log("Refreshing Editor GUI"); //EditorGUIUtility.ExitGUI(); this.OnEnable(); } q.cutsceneEventKeyTime[i] = EditorGUILayout.FloatField(delayContent, q.cutsceneEventKeyTime[i]); //EditorGUILayout.Space(); q.cutsceneCameraSpeedOptions[i] = (CameraSpeedOptions)EditorGUILayout.EnumPopup(moveContent, q.cutsceneCameraSpeedOptions[i]); if (q.cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.Curve || q.cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.MobileCurve) { q.curveChoice[i] = true; EditorGUILayout.BeginHorizontal(); q.lerpCurveChoice[i] = EditorGUILayout.Toggle(lerpCurveContent, q.lerpCurveChoice[i]); EditorGUILayout.EndHorizontal(); if (q.lerpCurveChoice[i]) { q.customCurveMovementSpeed[i] = EditorGUILayout.Slider(" >Time (sec)", q.customCurveMovementSpeed[i], 0.0001f, 120f); } else { moveContent = new GUIContent("Movement ", "Movement speed options. Mobile curves require 1 mid-point, normal curves require 2 mid-points."); EditorGUILayout.BeginHorizontal(); q.curveNodeCount[i] = EditorGUILayout.IntSlider(nodesContent, q.curveNodeCount[i], 10, 1000); EditorGUILayout.EndHorizontal(); q.customCurveMovementSpeed[i] = EditorGUILayout.Slider(curveSpeedContent, q.customCurveMovementSpeed[i], 0.0001f, 120f); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(midPointContent); EditorGUILayout.LabelField(midPoints[i + 1].name); EditorGUILayout.EndHorizontal(); if (q.cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.Curve) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(midPointTwoContent); EditorGUILayout.LabelField(cubicPoints[i + 1].name); EditorGUILayout.EndHorizontal(); } } else { q.curveChoice[i] = false; moveContent = new GUIContent("Movement ", "Camera positional movement speed during this event. (Units)"); } //Custom movement speed if (q.cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.Custom) { q.customMovementSpeed[i] = EditorGUILayout.FloatField(" >Movement speed", q.customMovementSpeed[i]); } if (q.cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.Lerp) { q.customMovementSpeed[i] = EditorGUILayout.FloatField(" >Movement time", q.customMovementSpeed[i]); } //EditorGUILayout.Space(); //Rotation speed q.cutsceneCameraRotationSpeedOptions[i] = (CameraRotationSpeedOptions)EditorGUILayout.EnumPopup(rotationContent, q.cutsceneCameraRotationSpeedOptions[i]); if (q.cutsceneCameraRotationSpeedOptions[i] == CameraRotationSpeedOptions.FollowTarget) { q.smoothFollowTarget[i] = (Transform)EditorGUILayout.ObjectField(" >Follow target", q.smoothFollowTarget[i], typeof(Transform), true) as Transform; } //Custom rotation speed if (q.cutsceneCameraRotationSpeedOptions[i] == CameraRotationSpeedOptions.Custom) { q.customRotationSpeed[i] = EditorGUILayout.FloatField(" >Rotation speed", q.customRotationSpeed[i]); } //Custom rotation speed if (q.cutsceneCameraRotationSpeedOptions[i] == CameraRotationSpeedOptions.Lerp) { q.customRotationSpeed[i] = EditorGUILayout.FloatField(" >Rotation time", q.customRotationSpeed[i]); } //EditorGUILayout.Space(); //Camera shake q.doShake[i] = EditorGUILayout.Toggle("Shake camera ", q.doShake[i]); if (q.doShake[i]) { q.cameraShakeAmount[i] = EditorGUILayout.Slider(" >Shake intensity", q.cameraShakeAmount[i], 0.1f, 5f); } //EditorGUILayout.Space(); //time scale and broadcastmessage q.cutsceneEventTimescale[i] = EditorGUILayout.Slider("Time scale", q.cutsceneEventTimescale[i], 0f, 2f); //EditorGUILayout.Space(); q.broadcastMessageChoice[i] = EditorGUILayout.Toggle(broadcastContent, q.broadcastMessageChoice[i]); if (q.broadcastMessageChoice[i] == true) { EditorGUILayout.BeginVertical(); q.broadcastMessageString[i] = EditorGUILayout.TextField(" >Method name", q.broadcastMessageString[i]); q.broadcastMessageTarget[i] = EditorGUILayout.ObjectField(" >Target", q.broadcastMessageTarget[i], typeof(GameObject), true) as GameObject; EditorGUILayout.EndVertical(); } //EditorGUILayout.Space(); q.cutsceneEventZoom[i] = EditorGUILayout.Toggle(zoomContent, q.cutsceneEventZoom[i]); if (q.cutsceneEventZoom[i] == true) { q.cutsceneEventZoomAmount[i] = EditorGUILayout.Slider(" >Field of View", q.cutsceneEventZoomAmount[i], 1f, 144f); q.cutsceneEventZoomSpeed[i] = EditorGUILayout.Slider(" >Zoom speed", q.cutsceneEventZoomSpeed[i], 0.001f, 40f); } //EditorGUILayout.EndVertical(); } } if (GUI.changed) { EditorUtility.SetDirty(target); } //And apply serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { m_ScrollRect.Update(); serializedObject.Update(); EditorGUILayout.LabelField("格子大小"); EditorGUILayout.PropertyField(m_CellWidth, new GUIContent(" 宽度:")); m_CellWidth.intValue = m_CellWidth.intValue < 0 ? 0 : m_CellWidth.intValue; EditorGUILayout.PropertyField(m_CellHeight, new GUIContent(" 高度:")); m_CellHeight.intValue = m_CellHeight.intValue < 0 ? 0 : m_CellHeight.intValue; EditorGUILayout.LabelField("偏移大小"); EditorGUILayout.PropertyField(m_PaddingLeft, new GUIContent(" 宽度:")); m_PaddingLeft.intValue = m_PaddingLeft.intValue < 0 ? 0 : m_PaddingLeft.intValue; EditorGUILayout.PropertyField(m_PaddingTop, new GUIContent(" 高度:")); m_PaddingTop.intValue = m_PaddingTop.intValue < 0 ? 0 : m_PaddingTop.intValue; EditorGUILayout.Space(); EditorGUILayout.LabelField("排序", GUILayout.Width(50)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" 方向:", GUILayout.Width(116)); EditorGUILayout.LabelField("水平", GUILayout.Width(26)); if (EditorGUILayout.Toggle(m_Movement == 1, GUILayout.Width(40)) && m_Movement != 1) { m_Movement = 1; } EditorGUILayout.LabelField("垂直", GUILayout.Width(26)); if (EditorGUILayout.Toggle(m_Movement == 2, GUILayout.Width(40)) && m_Movement != 2) { m_Movement = 2; } EditorGUILayout.EndHorizontal(); m_ScrollRectHorizonta.boolValue = m_Movement == 1; m_ScrollRectVertical.boolValue = m_Movement == 2; if (m_ScrollRectHorizonta.boolValue) { EditorGUILayout.PropertyField(m_GropVerticalValue, new GUIContent(" 行数:")); m_GropVerticalValue.intValue = m_GropVerticalValue.intValue < 0 ? 0 : m_GropVerticalValue.intValue; } else { EditorGUILayout.PropertyField(m_GropHorizontalValue, new GUIContent(" 列数:")); m_GropHorizontalValue.intValue = m_GropHorizontalValue.intValue < 0 ? 0 : m_GropHorizontalValue.intValue; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Tween"); EditorGUILayout.PropertyField(m_MoveTweenSpeed, new GUIContent(" Speed:")); m_MoveTweenSpeed.intValue = m_MoveTweenSpeed.intValue < 0 ? 0 : m_MoveTweenSpeed.intValue; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("编辑时试用:", GUILayout.Width(116)); if (GUILayout.Button("排版")) { m_EasyScrollView.ResetPos(); } EditorGUILayout.EndHorizontal(); m_ScrollRect.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { #if UNITY_5_6_OR_NEWER serializedObject.UpdateIfRequiredOrScript(); #else serializedObject.UpdateIfDirtyOrScript(); #endif if (sectionHeaderStyle == null) { sectionHeaderStyle = new GUIStyle(EditorStyles.foldout); } sectionHeaderStyle.normal.textColor = titleColor; sectionHeaderStyle.margin = new RectOffset(12, 0, 0, 0); sectionHeaderStyle.fontStyle = FontStyle.Bold; if (titleLabelStyle == null) { titleLabelStyle = new GUIStyle(EditorStyles.label); } titleLabelStyle.normal.textColor = titleColor; titleLabelStyle.fontStyle = FontStyle.Bold; EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("General Settings", titleLabelStyle); if (GUILayout.Button("Help", GUILayout.Width(40))) { if (!EditorUtility.DisplayDialog("Dynamic Fog & Mist", "To learn more about a property in this inspector move the mouse over the label for a quick description (tooltip).\n\nPlease check README file in the root of the asset for details and contact support.\n\nIf you like Dynamic Fog & Mist, please rate it on the Asset Store. For feedback and suggestions visit our support forum on kronnect.com.", "Close", "Visit Support Forum")) { Application.OpenURL("http://kronnect.com/taptapgo"); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(sun, new GUIContent("Sun", "Assign a game object (a directional light acting as Sun for example) to make the fog color sync automatically with the Sun orientation and light intensity.")); EditorGUILayout.Separator(); expandSection [FOG_PROPERTIES] = EditorGUILayout.Foldout(expandSection [FOG_PROPERTIES], sectionNames [FOG_PROPERTIES], sectionHeaderStyle); if (expandSection [FOG_PROPERTIES]) { EditorGUILayout.PropertyField(alpha, new GUIContent("Alpha", "Global fog transparency. You can also change the transparency at color level.")); EditorGUILayout.PropertyField(distance, new GUIContent("Distance", "The starting distance of the fog measure in linear 0-1 values (0=camera near clip, 1=camera far clip).")); EditorGUILayout.PropertyField(distanceFallOff, new GUIContent("Distance Fall Off", "Makes the fog appear smoothly on the near distance.")); EditorGUILayout.PropertyField(height, new GUIContent("Height", "Height of the fog in meters.")); EditorGUILayout.PropertyField(heightFallOff, new GUIContent("Height Fall Off", "Increase to make the fog change gradually its density based on height.")); EditorGUILayout.PropertyField(baselineHeight, new GUIContent("Baseline Height", "Vertical position of the fog in meters. Height is counted above this baseline height.")); EditorGUILayout.PropertyField(color); } EditorGUILayout.Separator(); if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "UndoRedoPerformed")) { DynamicFogManager fog = (DynamicFogManager)target; fog.UpdateMaterialProperties(); } }
public override void OnInspectorGUI () { serObj.Update(); GUILayout.Label("HDR " + (hdr.enumValueIndex == 0 ? "auto detected, " : (hdr.enumValueIndex == 1 ? "forced on, " : "disabled, ")) + (useSrcAlphaAsMask.floatValue < 0.1f ? " ignoring alpha channel glow information" : " using alpha channel glow information"), EditorStyles.miniBoldLabel); EditorGUILayout.PropertyField (tweakMode, new GUIContent("Tweak mode")); EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode")); EditorGUILayout.PropertyField (hdr, new GUIContent("HDR")); // display info text when screen blend mode cannot be used var bloomAndFlares = target as BloomAndFlares; if (bloomAndFlares != null) { Camera cam = bloomAndFlares.GetComponent<Camera>(); if (cam != null) { if (screenBlendMode.enumValueIndex==0 && ((cam.allowHDR && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) { EditorGUILayout.HelpBox("Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info); } } } if (1 == tweakMode.intValue) EditorGUILayout.PropertyField (lensflares, new GUIContent("Cast lens flares")); EditorGUILayout.Separator (); EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity")); bloomthreshold.floatValue = EditorGUILayout.Slider ("threshold", bloomthreshold.floatValue, -0.05f, 4.0f); bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", bloomBlurIterations.intValue, 1, 4); sepBlurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", sepBlurSpread.floatValue, 0.1f, 10.0f); if (1 == tweakMode.intValue) useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (new GUIContent("Use alpha mask", "Make alpha channel define glowiness"), useSrcAlphaAsMask.floatValue, 0.0f, 1.0f); else useSrcAlphaAsMask.floatValue = 0.0f; if (1 == tweakMode.intValue) { EditorGUILayout.Separator (); if (lensflares.boolValue) { // further lens flare tweakings if (0 != tweakMode.intValue) EditorGUILayout.PropertyField (lensflareMode, new GUIContent("Lens flare mode")); else lensflareMode.enumValueIndex = 0; EditorGUILayout.PropertyField(lensFlareVignetteMask, new GUIContent("Lens flare mask", "This mask is needed to prevent lens flare artifacts")); EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent("Local intensity")); lensflarethreshold.floatValue = EditorGUILayout.Slider ("Local threshold", lensflarethreshold.floatValue, 0.0f, 1.0f); if (lensflareMode.intValue == 0) { // ghosting EditorGUILayout.BeginHorizontal (); EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color")); EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color")); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color")); EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color")); EditorGUILayout.EndHorizontal (); } else if (lensflareMode.intValue == 1) { // hollywood EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width")); hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4); EditorGUILayout.PropertyField (flareColorA, new GUIContent("Tint Color")); } else if (lensflareMode.intValue == 2) { // both EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width")); hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4); EditorGUILayout.BeginHorizontal (); EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color")); EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color")); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color")); EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color")); EditorGUILayout.EndHorizontal (); } } } else lensflares.boolValue = false; // disable lens flares in simple tweak mode serObj.ApplyModifiedProperties(); }
private void DrawFileChanges() { var size = EditorGUIUtility.singleLineHeight; var square = new GUILayoutOption[] { GUILayout.MinWidth(size), GUILayout.MinHeight(size), GUILayout.MaxWidth(size), GUILayout.MaxHeight(size) }; var button = new GUILayoutOption[] { GUILayout.MinWidth(size * 2 - 4), GUILayout.MinHeight(size - 2), GUILayout.MaxWidth(size * 2 - 4), GUILayout.MaxHeight(size - 2) }; EditorGUILayout.BeginHorizontal(); all = EditorGUILayout.Toggle(all, square); var newAll = all; EditorGUILayout.LabelField(GUIContent.none, square); var oldFontStyle = GUI.skin.label.fontStyle; GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Path"); GUI.skin.label.fontStyle = oldFontStyle; EditorGUILayout.EndHorizontal(); // Remove toggle entries for files that are no longer changed var toRemove = new List <string>(); toggled = toggled ?? new ToggledDictionary(); foreach (var file in toggled.Dictionary.Keys) { if (!State.Files.Select(x => x.FilePath).Contains(file)) { toRemove.Add(file); } } foreach (var file in toRemove) { toggled.Dictionary.Remove(file); } foreach (var file in State.Files) { EditorGUILayout.BeginHorizontal(); // Draw toggle if (all) { newAll = EditorGUILayout.Toggle(all, square); } else { if (!toggled.Dictionary.ContainsKey(file.FilePath)) { toggled[file.FilePath] = false; } toggled[file.FilePath] = EditorGUILayout.Toggle(toggled[file.FilePath], square); } // Draw change type image switch (file.State) { case FileStatus.DeletedFromIndex: case FileStatus.DeletedFromWorkdir: GUILayout.Label(Content(ImageCache.Deleted, "This file has been deleted."), square); break; case FileStatus.ModifiedInIndex: case FileStatus.ModifiedInWorkdir: case FileStatus.RenamedInIndex: case FileStatus.RenamedInWorkdir: case FileStatus.TypeChangeInIndex: case FileStatus.TypeChangeInWorkdir: GUILayout.Label(Content(ImageCache.Modified, "This file has been modified."), square); break; case FileStatus.NewInIndex: case FileStatus.NewInWorkdir: GUILayout.Label(Content(ImageCache.Added, "This file has been added."), square); break; case FileStatus.Ignored: GUI.enabled = false; break; } // Draw file label EditorGUILayout.LabelField(file.FilePath); EditorGUILayout.Space(); if (GUILayout.Button(Content(ImageCache.X, "Discard Changes"), button)) { var msg = "Are you sure you want to discard the changes to " + file.FilePath + "?"; if (EditorUtility.DisplayDialog("Discard Changes?", msg, "Yes", "No")) { CheckoutFile(file.FilePath); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } if (newAll != all) { all = newAll; } }
void OnGUI() { FindAndCacheReaktors(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.Label("Reaktor List", EditorStyles.boldLabel); foreach (var reaktor in cachedReaktors) { EditorGUILayout.BeginHorizontal(); // Slider if (EditorApplication.isPlaying) { if (reaktor.IsOverridden) { // Already overridden: show the override value. var value = EditorGUILayout.Slider(reaktor.name, reaktor.Override, 0, 1); if (!reaktor.Bang) { reaktor.Override = value; } } else { // Not overridden: show the output value and begin override when touched. var value = EditorGUILayout.Slider(reaktor.name, reaktor.Output, 0, 1); if (value != reaktor.Output) { reaktor.Override = value; } } } else { // Not playing: show a dummy slider. EditorGUILayout.Slider(reaktor.name, 0, 0, 1); } // Bang button if (GUILayout.RepeatButton("!", EditorStyles.miniButtonLeft, GUILayout.Width(18))) { reaktor.Bang = true; } else if (reaktor.Bang && Event.current.type == EventType.Repaint) { reaktor.Override = 0; } // Release/Select button if (reaktor.IsOverridden) { if (GUILayout.Button("Release", EditorStyles.miniButtonRight, GUILayout.Width(46))) { reaktor.StopOverride(); } } else { if (GUILayout.Button("Select", EditorStyles.miniButtonRight, GUILayout.Width(46))) { Selection.activeGameObject = reaktor.gameObject; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { if (target == null) { return; } var proCamera2DPixelPerfect = (ProCamera2DPixelPerfect)target; if (proCamera2DPixelPerfect.ProCamera2D == null) { EditorGUILayout.HelpBox("ProCamera2D is not set.", MessageType.Error, true); return; } var isOrthographic = false; #if PC2D_TK2D_SUPPORT if (proCamera2DPixelPerfect.ProCamera2D.Tk2dCam != null && proCamera2DPixelPerfect.ProCamera2D.Tk2dCam.CameraSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic) { isOrthographic = true; } else { #endif isOrthographic = proCamera2DPixelPerfect.ProCamera2D.GameCamera.orthographic; #if PC2D_TK2D_SUPPORT } #endif if (!isOrthographic) { EditorGUILayout.HelpBox("Pixel perfect only works with orthographic cameras!", MessageType.Error, true); } serializedObject.Update(); // Show script link GUI.enabled = false; _script = EditorGUILayout.ObjectField("Script", _script, typeof(MonoScript), false) as MonoScript; GUI.enabled = true; // ProCamera2D _tooltip = new GUIContent("Pro Camera 2D", ""); EditorGUILayout.PropertyField(serializedObject.FindProperty("_pc2D"), _tooltip); EditorGUI.BeginChangeCheck(); // Pixels per unit _tooltip = new GUIContent("Pixels per Unit", "How many pixels in a sprite correspond to one unit in the world"); EditorGUILayout.PropertyField(serializedObject.FindProperty("PixelsPerUnit"), _tooltip); #if PC2D_TK2D_SUPPORT if (proCamera2DPixelPerfect.GetComponent <tk2dCamera>() != null) { // Pixels per meter _tooltip = new GUIContent("TK2D Sprites PPM", "The pixels per meter value of your TK2D sprite collections."); EditorGUILayout.PropertyField(serializedObject.FindProperty("Tk2DPixelsPerMeter"), _tooltip); if (proCamera2DPixelPerfect.Tk2DPixelsPerMeter < 1f) { proCamera2DPixelPerfect.Tk2DPixelsPerMeter = 1f; } } #endif // Viewport auto-scale EditorGUILayout.BeginHorizontal(); _tooltip = new GUIContent("Viewport AutoScale", "If not None, the camera will automatically calculate the best scale across all resolutions based on the art viewport."); EditorGUILayout.PropertyField(serializedObject.FindProperty("ViewportAutoScale"), _tooltip); // Viewport Scale if (proCamera2DPixelPerfect.ViewportAutoScale != AutoScaleMode.None) { GUI.enabled = false; EditorGUILayout.LabelField(proCamera2DPixelPerfect.CalculateViewportScale() + "x", GUILayout.MaxWidth(60)); GUI.enabled = true; } EditorGUILayout.EndHorizontal(); // Viewport size in pixels if (proCamera2DPixelPerfect.ViewportAutoScale != AutoScaleMode.None) { _tooltip = new GUIContent("Game Viewport (pixels)", "Set it that if the screen was of this size, each pixel on the screen would correspond to a pixel on your art. On a pixel-art game this probably has low values."); EditorGUILayout.PropertyField(serializedObject.FindProperty("TargetViewportSizeInPixels"), _tooltip); } // Zoom _tooltip = new GUIContent("Zoom", "The zoom level of the camera"); EditorGUILayout.PropertyField(serializedObject.FindProperty("Zoom"), _tooltip); // Snap movement to grid EditorGUILayout.BeginHorizontal(); _tooltip = new GUIContent("Snap Movement to Grid", "If checked, the the sprites will snap to the grid. Might create some stuttering on your camera targets, especially if you're using a large grid and a follow smoothness greater than zero."); EditorGUILayout.PropertyField(serializedObject.FindProperty("SnapMovementToGrid"), _tooltip); if (proCamera2DPixelPerfect.SnapMovementToGrid) { _tooltip = new GUIContent("Snap Camera", "If checked, the camera will also snap to the grid. If you notice some stuttering in your game elements try to leave this on."); EditorGUILayout.PropertyField(serializedObject.FindProperty("SnapCameraToGrid"), _tooltip); } EditorGUILayout.EndHorizontal(); // Draw grid EditorGUILayout.BeginHorizontal(); _tooltip = new GUIContent("Draw Grid", "If checked, the camera will draw a pixel grid. 'Gizmos' button must be enabled on the Game window."); EditorGUILayout.PropertyField(serializedObject.FindProperty("DrawGrid"), _tooltip); if (proCamera2DPixelPerfect.DrawGrid) { _tooltip = new GUIContent("Grid Color", ""); EditorGUILayout.PropertyField(serializedObject.FindProperty("GridColor"), _tooltip); } EditorGUILayout.EndHorizontal(); // Grid density warning if (proCamera2DPixelPerfect.DrawGrid && proCamera2DPixelPerfect.GridDensity < 4) { EditorGUILayout.HelpBox("Grid density is too high to draw, so we're skipping it to avoid performance issues with the editor.", MessageType.None, true); } // Save properties serializedObject.ApplyModifiedProperties(); // Limit values if (proCamera2DPixelPerfect.PixelsPerUnit < 1f) { proCamera2DPixelPerfect.PixelsPerUnit = 1f; } if (proCamera2DPixelPerfect.TargetViewportSizeInPixels.x < 1) { proCamera2DPixelPerfect.TargetViewportSizeInPixels.x = 1; } if (proCamera2DPixelPerfect.TargetViewportSizeInPixels.y < 1) { proCamera2DPixelPerfect.TargetViewportSizeInPixels.y = 1; } // Resize camera if (EditorGUI.EndChangeCheck() || !Application.isPlaying) { proCamera2DPixelPerfect.ResizeCameraToPixelPerfect(); } }
public override void OnInspectorGUI() { GUI.DrawTexture(new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon()); LeanTweenVisual tween = target as LeanTweenVisual; EditorGUI.BeginChangeCheck(); float overallDelay = 0; bool clicked, deleted; Vector3 vec; clicked = false; bool playOnStartBefore = tween.playOnStart; bool playOnStartNow = EditorGUILayout.Toggle(new GUIContent("Play on Start", "Tweens won't start automatically, you can start them via code with .start()"), tween.playOnStart); if (playOnStartBefore != playOnStartNow) { Undo.RecordObject(tween, "Toggling play on start"); tween.playOnStart = playOnStartNow; } EditorGUILayout.BeginHorizontal(); tween.restartOnEnable = EditorGUILayout.Toggle(new GUIContent("Restart on enable", "When you enable the gameobject these set of tweens will start again"), tween.restartOnEnable); tween.repeat = EditorGUILayout.Toggle(new GUIContent("Repeat All", "Repeat the whole set of tween groups once they finish"), tween.repeat); EditorGUILayout.EndHorizontal(); if (tween.repeat) { tween.repeatDelay = EditorGUILayout.FloatField("All Delay", tween.repeatDelay); tween.repeatCount = EditorGUILayout.IntField("All Repeat Count", tween.repeatCount); } float addedGroupDelay = 0f; foreach (LeanTweenGroup group in tween.groupList) { EditorGUILayout.Space(); GUI.color = LTEditor.shared.colorGroupName; EditorGUILayout.BeginHorizontal(); group.foldout = EditorGUILayout.Foldout(group.foldout, "", LTEditor.shared.styleGroupFoldout); clicked = GUILayout.Button("Group: " + group.name + " " + (group.startTime) + "s - " + (group.endTime) + "s", LTEditor.shared.styleGroupButton); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteGroupButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (clicked) { group.foldout = !group.foldout; } if (deleted) { Undo.RecordObject(tween, "Removing group item"); tween.groupList.Remove(group); break; } float addedTweenDelay = 0f; if (group.foldout) { group.name = EditorGUILayout.TextField("Group Name", group.name); EditorGUILayout.BeginHorizontal(); group.repeat = EditorGUILayout.Toggle("Group Repeat", group.repeat); group.delay = EditorGUILayout.FloatField("Group Delay", group.delay); EditorGUILayout.EndHorizontal(); group.gameObject = EditorGUILayout.ObjectField("Group GameObject", group.gameObject, typeof(GameObject), true) as GameObject; if (group.gameObject == null) // Should default to the current object { group.gameObject = tween.gameObject; } if (group.repeat) { group.repeatCount = EditorGUILayout.IntField("Group Repeat Count", group.repeatCount); } int i = 0; foreach (LeanTweenItem item in group.itemList) { TweenAction a = (TweenAction)item.action; EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); item.foldout = EditorGUILayout.Foldout(item.foldout, "Tween "); GUI.color = LTEditor.shared.colorTweenName; int actionIndex = EditorGUILayout.Popup(LTVisualShared.actionIndex(item), LTVisualShared.methodLabels); LTVisualShared.setActionIndex(item, actionIndex); // clicked = GUILayout.Button(""+a + " " + ( group.delay + item.delay) + "s - " + ( group.delay + item.delay + item.duration) + "s"); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (clicked) { item.foldout = !item.foldout; } if (deleted) { Undo.RecordObject(tween, "Removing tween item"); group.itemList.Remove(item); break; } if (item.foldout) { a = item.action; bool tweenTypeChanged = (int)item.action != item.actionLast; if (tweenTypeChanged && item.actionLast >= 0) { // Setup with the helpful default values // Debug.Log("Setting up to default values a:"+a); /*item.to = Vector3.zero; * if((a>=TweenAction.MOVE_X && a<=TweenAction.MOVE_LOCAL_Z) || a==TweenAction.MOVE || a==TweenAction.MOVE_LOCAL) * item.to = item.from = tween.gameObject.transform.position; * else if((a>=TweenAction.SCALE_X && a<=TweenAction.SCALE_Z) || a==TweenAction.SCALE) * item.to = item.from = tween.gameObject.transform.localScale; #if !UNITY_4_3 && !UNITY_4_5 * else if(a==TweenAction.CANVAS_MOVE) * item.to = item.from = tween.gameObject.GetComponent<RectTransform>().anchoredPosition; * else if(a==TweenAction.CANVAS_SCALE) * item.to = item.from = tween.gameObject.GetComponent<RectTransform>().localScale; #endif */ } item.actionLast = (int)item.action; // Debug.Log("a:"+a); item.gameObject = EditorGUILayout.ObjectField(" GameObject", item.gameObject, typeof(GameObject), true, GUILayout.Width(250)) as GameObject; if (item.gameObject == null) // Should default to the current object { item.gameObject = tween.gameObject; } // Path bool isCurve = false; if (a == TweenAction.MOVE_CURVED || a == TweenAction.MOVE_CURVED_LOCAL) { item.bezierPath = EditorGUILayout.ObjectField(" LeanTweenPath:", item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath; EditorGUILayout.BeginHorizontal(); change(ref item.orientToPath, EditorGUILayout.Toggle(" Orient to Path", item.orientToPath), tween, "Orient to path"); // if(orientToPath!=item.orientToPath){ // Undo.RecordObject(tween,"Orient to path"); // item.orientToPath = orientToPath; // } isCurve = true; item.isPath2d = EditorGUILayout.Toggle(" 2D Path", item.isPath2d); EditorGUILayout.EndHorizontal(); } else if (a == TweenAction.MOVE_SPLINE || a == TweenAction.MOVE_SPLINE_LOCAL) { item.splinePath = EditorGUILayout.ObjectField(" LeanTweenPath:", item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath; item.orientToPath = EditorGUILayout.Toggle(" Orient to Path", item.orientToPath); isCurve = true; } if (isCurve == false) { bool isVector = a == TweenAction.MOVE || a == TweenAction.MOVE_LOCAL || a == TweenAction.CANVAS_MOVE || a == TweenAction.ROTATE || a == TweenAction.ROTATE_LOCAL || a == TweenAction.SCALE || a == TweenAction.CANVAS_SCALE || a == TweenAction.CANVAS_SIZEDELTA || a == TweenAction.DELAYED_SOUND; bool isColor = a >= TweenAction.COLOR && a < TweenAction.CALLBACK; bool isPlay = a == TweenAction.CANVAS_PLAYSPRITE; bool usesFrom = !isColor && !isPlay; // From Values EditorGUILayout.BeginHorizontal(); if (usesFrom) // Not a Color tween { EditorGUILayout.LabelField(new GUIContent(" From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50)); LeanTweenBetween between = EditorGUILayout.Toggle("", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To; if (between != item.between) { Undo.RecordObject(tween, "Changing to from/to"); item.between = between; } } if (item.between == LeanTweenBetween.FromTo) { if (isVector) { // item.from = EditorGUILayout.Vector3Field("", item.from); change(ref item.from, EditorGUILayout.Vector3Field("", item.from), tween, "Changing from"); } else if (isColor) { } else { vec = Vector3.zero; vec.x = EditorGUILayout.FloatField("From", item.from.x); if (vec.x != item.from.x) { Undo.RecordObject(tween, "Setting new from value"); item.from = vec; } } } EditorGUILayout.EndHorizontal(); // To Values EditorGUILayout.BeginHorizontal(); if (isVector) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); change(ref item.to, EditorGUILayout.Vector3Field("", item.to), tween, "Changing vector3 to"); } else if (isColor) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); change(ref item.colorTo, EditorGUILayout.ColorField("", item.colorTo), tween, "Change color to"); } else if (isPlay) { GUILayout.Space(24); item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized, "Sprites"); if (item.spritesMaximized) { EditorGUILayout.LabelField("Add", GUILayout.Width(35)); UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("", null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite; if (sprite != null) { Undo.RecordObject(tween, "Adding a sprite"); item.sprites = add(item.sprites, sprite); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); } } else { vec = Vector3.zero; EditorGUILayout.LabelField(" To", GUILayout.Width(85)); float setToX = EditorGUILayout.FloatField("", item.to.x); if (setToX != vec.x) { Undo.RecordObject(tween, "Setting x to"); vec.x = setToX; item.to = vec; } } EditorGUILayout.EndHorizontal(); // Sprite List if (isPlay && item.spritesMaximized) { for (int j = 0; j < item.sprites.Length; j++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" sprite" + j, GUILayout.Width(85)); item.sprites[j] = EditorGUILayout.ObjectField("", item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite; GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (deleted) { Undo.RecordObject(tween, "Removing sprite"); item.sprites = remove(item.sprites, j); break; } } } if (a == TweenAction.ROTATE_AROUND || a == TweenAction.ROTATE_AROUND_LOCAL #if !UNITY_4_3 && !UNITY_4_5 || a == TweenAction.CANVAS_ROTATEAROUND || a == TweenAction.CANVAS_ROTATEAROUND_LOCAL #endif ) { item.axis = ShowAxis(" Axis", item.axis); } } EditorGUILayout.Space(); // Easing if (a == TweenAction.DELAYED_SOUND) { change(ref item.audioClip, EditorGUILayout.ObjectField(" AudioClip:", item.audioClip, typeof(AudioClip), true) as AudioClip, tween, "set audio clip"); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Easing", GUILayout.Width(80)); int easeIndex = LTVisualShared.easeIndex(item); int easeIndexNew = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128)); if (easeIndex != easeIndexNew) { Undo.RecordObject(tween, "changing easing type"); LTVisualShared.setEaseIndex(item, easeIndexNew); } EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); if (item.ease == LeanTweenType.animationCurve) { Undo.RecordObject(tween, "changing easing type anim curve"); item.animationCurve = EditorGUILayout.CurveField(" Ease Curve", item.animationCurve); } EditorGUILayout.Space(); } if (item.ease >= LeanTweenType.once && item.ease < LeanTweenType.animationCurve) { EditorGUILayout.LabelField(new GUIContent(" ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel); } // Speed EditorGUILayout.BeginHorizontal(); change(ref item.useSpeed, EditorGUILayout.Toggle(" Use Speed", item.useSpeed), tween, "toggled use speed"); EditorGUILayout.EndHorizontal(); // Timing if (i > 0) { change(ref item.alignWithPrevious, EditorGUILayout.Toggle(new GUIContent(" Align with Previous", "When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious), tween, "toggle align with previous"); } EditorGUILayout.BeginHorizontal(); if (i > 0 && item.alignWithPrevious) { change(ref item.delay, addedTweenDelay, tween, "change delay"); EditorGUILayout.LabelField(" Delay: " + item.delay, GUILayout.Width(50)); } else { EditorGUILayout.LabelField(" Delay", GUILayout.Width(50)); change(ref item.delay, EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)), tween, "change delay"); } if (a == TweenAction.DELAYED_SOUND) { EditorGUILayout.LabelField("Volume", GUILayout.Width(50)); change(ref item.duration, EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)), tween, "change volume"); } else if (a == TweenAction.CANVAS_PLAYSPRITE) { EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85)); change(ref item.frameRate, EditorGUILayout.FloatField("", item.frameRate, GUILayout.Width(50)), tween, "change volume"); } else if (item.useSpeed) { EditorGUILayout.LabelField("Speed", GUILayout.Width(50)); change(ref item.speed, EditorGUILayout.FloatField("", item.speed, GUILayout.Width(50)), tween, "change speed"); } else { EditorGUILayout.LabelField("Time", GUILayout.Width(50)); float newDuration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)); if (newDuration <= 0.0f) { newDuration = 0.0001f; } change(ref item.duration, newDuration, tween, "change timing"); } EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); // Repeat EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Loops", GUILayout.Width(50)); change(ref item.doesLoop, EditorGUILayout.Toggle("", item.doesLoop, GUILayout.Width(50)), tween, "toggled does loop"); if (item.doesLoop) { EditorGUILayout.LabelField(new GUIContent("Repeat", "-1 repeats infinitely"), GUILayout.Width(50)); change(ref item.loopCount, EditorGUILayout.IntField(new GUIContent("", ""), item.loopCount, GUILayout.Width(50)), tween, "changed loop count"); EditorGUILayout.LabelField(new GUIContent(" Wrap", "How the tween repeats\nclamp: restart from beginning\npingpong: goes back and forth"), GUILayout.Width(50)); int index = item.loopType == LeanTweenType.pingPong ? 1 : 0; index = EditorGUILayout.Popup("", index, new string[] { "Clamp", "Ping Pong" }, GUILayout.Width(70)); LeanTweenType newLoopType = index == 0 ? LeanTweenType.clamp : LeanTweenType.pingPong; if (newLoopType != item.loopType) { Undo.RecordObject(tween, "change loop type"); item.loopType = newLoopType; } } EditorGUILayout.EndHorizontal(); addedTweenDelay = item.duration + item.delay; EditorGUILayout.Separator(); EditorGUILayout.Separator(); i++; } } if (ShowLeftButton("+ Tween", LTEditor.shared.colorAddTween, 15)) { Undo.RecordObject(tween, "adding another tween"); LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay); newItem.alignWithPrevious = true; group.itemList.Add(newItem); } addedGroupDelay += addedTweenDelay; EditorGUILayout.Separator(); } overallDelay += group.endTime; } if (ShowLeftButton("+ Group", LTEditor.shared.colorAddGroup)) { Undo.RecordObject(tween, "adding another group"); // Debug.Log("adding group with delay:"+addedGroupDelay); tween.groupList.Add(new LeanTweenGroup(addedGroupDelay)); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel); if (Application.isPlaying == false) { scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150)); EditorGUILayout.TextArea(tween.buildAllTweens(true), LTEditor.shared.styleCodeTextArea); EditorGUILayout.EndScrollView(); } else { EditorGUILayout.LabelField(" Not available during runtime"); } if (EditorGUI.EndChangeCheck()) { // Debug.Log("Saving time:"+Time.time); //Undo.RecordObject(tween, "LeanTweenVisual change"); } }
private void CameraCullingSettings(bool helpEnabled) { //Monitor for changes EditorGUI.BeginChangeCheck(); GaiaSceneCullingProfile cullingProfile = m_profile.CullingProfile; m_editorUtils.Heading("TerrainCulling"); EditorGUI.indentLevel++; m_profile.m_terrainCullingEnabled = m_editorUtils.Toggle("UseTerrainCulling", m_profile.m_terrainCullingEnabled, helpEnabled); EditorGUI.indentLevel--; EditorGUILayout.Space(); m_editorUtils.Heading("CameraCulling"); EditorGUI.indentLevel++; bool cullingEnabled = m_profile.m_enableLayerCulling; cullingEnabled = m_editorUtils.Toggle("EnableLayerCulling", cullingEnabled, helpEnabled); if (m_profile.m_enableLayerCulling != cullingEnabled) { m_profile.m_enableLayerCulling = cullingEnabled; if (Application.isPlaying) { GaiaScenePlayer.UpdateCullingDistances(); } else { GaiaScenePlayer.ApplySceneSetup(cullingEnabled); } } if (m_profile.m_enableLayerCulling) { m_editorUtils.LabelField("GeneralSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); cullingProfile = (GaiaSceneCullingProfile)m_editorUtils.ObjectField("CullingProfile", cullingProfile, typeof(GaiaSceneCullingProfile), false); if (m_editorUtils.Button("NewProfile", GUILayout.MaxWidth(40f))) { GaiaSceneCullingProfile profile = GaiaSceneCullingProfile.CreateCullingProfile(); cullingProfile = AssetDatabase.LoadAssetAtPath <GaiaSceneCullingProfile>(AssetDatabase.GetAssetPath(profile)); m_profile.CullingProfile = cullingProfile; GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); m_editorUtils.InlineHelp("CullingProfile", helpEnabled); if (cullingProfile != m_profile.CullingProfile) { m_profile.CullingProfile = cullingProfile; if (cullingProfile != null) { GaiaScenePlayer.ApplySceneSetup(cullingProfile.m_applyToEditorCamera); } } #if GAIA_PRO_PRESENT if (ProceduralWorldsGlobalWeather.Instance == null) { m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled); if (m_profile.m_sunLight == null) { m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight(); } } #else m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled); if (m_profile.m_sunLight == null) { m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight(); } #endif if (m_profile.CullingProfile != null) { m_profile.CullingProfile.m_applyToEditorCamera = m_editorUtils.Toggle("ApplyInEditor", m_profile.CullingProfile.m_applyToEditorCamera, helpEnabled); m_profile.CullingProfile.m_realtimeUpdate = m_editorUtils.Toggle("RealtimeUpdate", m_profile.CullingProfile.m_realtimeUpdate, helpEnabled); } EditorGUI.indentLevel--; if (m_profile.CullingProfile != null) { //Objects EditorGUILayout.Space(); m_editorUtils.LabelField("ObjectCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ObjectCullingSettings", helpEnabled); for (int i = 0; i < m_profile.CullingProfile.m_layerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_profile.CullingProfile.m_layerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_layerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertCullingToDefaults")) { m_profile.CullingProfile.UpdateCulling(m_gaiaSettings); EditorUtility.SetDirty(m_profile.CullingProfile); } //Shadows EditorGUILayout.Space(); m_editorUtils.LabelField("ShadowCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ShadowCullingSettings", helpEnabled); for (int i = 0; i < m_profile.CullingProfile.m_shadowLayerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_profile.CullingProfile.m_shadowLayerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_shadowLayerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertShadowToDefaults")) { m_profile.CullingProfile.UpdateShadow(); EditorUtility.SetDirty(m_profile.CullingProfile); } EditorGUI.indentLevel--; } //Check for changes, make undo record, make changes and let editor know we are dirty if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_profile, "Made camera culling changes"); EditorUtility.SetDirty(m_profile); if (m_profile.CullingProfile != null) { EditorUtility.SetDirty(m_profile.CullingProfile); if (Application.isPlaying) { GaiaScenePlayer.UpdateCullingDistances(); } else { GaiaScenePlayer.ApplySceneSetup(m_profile.CullingProfile.m_applyToEditorCamera); } } } } }
public void RenderField(AIInspectorState state) { var evt = Event.current; var mousePos = evt.mousePosition; var boxStyle = new GUIStyle("Box"); if (_reorderable && _dragging) { // don't let the mouse affect the X position of the rect being dragged mousePos.x = _draggedRect.x; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(_label); EditorGUILayout.Separator(); if (GUILayout.Button(SharedStyles.addTooltip, SharedStyles.BuiltIn.addButtonSmall)) { AddNew(mousePos, state); } EditorGUILayout.EndHorizontal(); var count = _editorItems.Count; if (count == 0) { return; } EditorGUILayout.BeginVertical(boxStyle); var removeIdx = -1; if (!_reorderable || count <= 1) { for (int i = 0; i < count; i++) { // if list is not reorderable, just draw items EditorGUILayout.BeginVertical(); if (DrawEditorItem(_editorItems[i], state, false)) { removeIdx = i; } EditorGUILayout.EndVertical(); } } else { // Reorderable list int drawIdx = 0; for (int i = 0; i < count; i++) { if (_dragging && _draggingIndex == drawIdx) { drawIdx++; } Rect dragHandle; Rect itemRect; if (i == _dropIndex) { dragHandle = new Rect(); itemRect = EditorGUILayout.BeginVertical(); GUILayout.Space(_dragRectHeight); EditorGUILayout.EndVertical(); } else { itemRect = EditorGUILayout.BeginVertical(); var item = _editorItems[drawIdx++]; if (DrawEditorItem(item, state, true)) { removeIdx = i; } EditorGUILayout.EndVertical(); dragHandle = DrawDragHandle(); } if (evt.button == MouseButton.left && evt.isMouse) { if (!_dragging) { if (dragHandle.Contains(mousePos) && evt.type == EventType.MouseDrag) { _dragging = true; _draggingIndex = _dropIndex = i; _draggedRect = itemRect; _dragOffsetY = itemRect.y - mousePos.y; break; } } else { if (itemRect.Contains(mousePos)) { _dropIndex = i; break; } } } } if (_dragging && evt.type == EventType.MouseUp) { if (_draggingIndex != _dropIndex) { _list.Reorder(_draggingIndex, _dropIndex); _editorItems.Reorder(_draggingIndex, _dropIndex); state.currentAIUI.undoRedo.Do(new ReorderOperation(_draggingIndex, _dropIndex, _list)); state.MarkDirty(); if (Application.isPlaying) { HandleVisualizerReorder(state, _draggingIndex, _dropIndex); } } _dragging = false; _dropIndex = _draggingIndex = -1; } } EditorGUILayout.EndVertical(); if (removeIdx >= 0 && DisplayHelper.ConfirmDelete("item")) { DoRemove(removeIdx, state); _editorItems.RemoveAt(removeIdx); state.MarkDirty(); if (Application.isPlaying) { HandleVisualizerRemove(state, removeIdx); } } if (_reorderable && _dragging) { if (evt.type == EventType.Layout || evt.type == EventType.Repaint) { GUI.Box(new Rect(_draggedRect.x, mousePos.y + _dragOffsetY, _draggedRect.width, _dragRectHeight), _editorItems[_draggingIndex].name, boxStyle); AIInspectorEditor.instance.Repaint(); } } }