public static string ProjectFileBrowser(string title, string description, string file, string extention) { string path = file; EGL.BeginHorizontal(); { EGL.PrefixLabel(title); GUILayout.Label(file, Skin.textField); string newPath = file; if (GUILayout.Button("Browse", GUILayout.Width(64f))) { newPath = EditorUtility.OpenFilePanel(description, Path.GetFullPath(UPath.GetAbsolutePath(file)), extention); if (newPath != string.Empty) { newPath = UPath.GetProjectPath(newPath); } else { newPath = file; } } path = newPath; } EGL.EndHorizontal(); return(path); }
public static string ProjectFolderBrowser(string title, string description, string folder, string defaultName) { string path = folder; EGL.BeginHorizontal(); { EGL.PrefixLabel(title); GUILayout.Label(folder, Skin.textField); string newPath = folder; if (GUILayout.Button("Browse", GUILayout.Width(64f))) { newPath = EditorUtility.SaveFolderPanel(description, folder, defaultName); if (newPath != string.Empty) { newPath = UPath.GetProjectPath(newPath); } else { newPath = folder; } } path = newPath; } EGL.EndHorizontal(); return(path); }
public static string OnGUI(this SearchField self, string label, string content) { EGL.BeginHorizontal(); EGL.PrefixLabel(label); content = self.OnGUI(content); EGL.EndHorizontal(); return(content); }
public static IntRange FrameRangeInput(string text, IntRange range) { EGL.BeginHorizontal(); EGL.PrefixLabel(text); range.from = EGL.IntField(range.from); EGL.LabelField("->", GL.Width(30)); range.to = EGL.IntField(range.to); EGL.EndHorizontal(); return(range); }
string PathSelection(string id, string path) { EGL.BeginHorizontal(); EGL.PrefixLabel(id); path = EGL.TextField(path); if (GL.Button("...", GL.Width(30))) { path = GetAssetPath(EditorUtility.OpenFolderPanel("Select path", path, "")); } EGL.EndHorizontal(); return(path); }
public override void OnInspectorGUI() { transition = (Transition)target; EditorGUI.BeginChangeCheck(); var fromName = transition.fromState.GetStatePreview(); var toName = transition.targetInfo; var displayName = fromName + "->" + toName; EGL.LabelField(displayName); EGL.Space(); FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect); EGL.Space(); transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType); if (transition.triggerRangeType == TriggerRangeType.Range) { transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange); } if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore) { transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec); } transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer); using (new EGL.VerticalScope(EditorStyles.helpBox)) { var conds = transition.conditions; var paramNames = transition.profile.parameters.Select(it => it.name).ToArray(); using (new EGL.HorizontalScope()) { EGL.LabelField("Conditions", EditorStyles.boldLabel); GL.FlexibleSpace(); if (GL.Button("+", GL.Width(30))) { conds.Add(new Condition()); } } for (int i = 0; i < conds.Count; ++i) { var cond = conds[i]; EGL.BeginHorizontal(); int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name)); // cond.name = EGL.TextField(cond.name, GL.Width(70)); condSelectIndex = EGL.Popup(condSelectIndex, paramNames); cond.name = paramNames[condSelectIndex]; var param = transition.profile.FindParam(cond.name); if (param == null) { EGL.LabelField("!Doesn't exist"); } else { var type = param.type; if (type == ParamType.Bool) { cond.boolValue = EGL.Toggle(cond.boolValue); } else if (type != ParamType.Trigger) // Trigger 不需要编辑 { cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50)); if (type == ParamType.Int) { cond.intValue = EGL.IntField(cond.intValue); } else { cond.floatValue = EGL.FloatField(cond.floatValue); } } } GL.FlexibleSpace(); if (GL.Button("-", GL.Width(30))) { conds.RemoveAt(i); --i; } EGL.EndHorizontal(); } } EGL.LabelField("", GUI.skin.horizontalSlider); transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType); if (transition.actionType == ActionType.ChangeState) { EGL.BeginHorizontal(); EGL.PrefixLabel("Target State"); EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames, str => transition.targetStateName = str, ref targetStateRect); transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30)); EGL.LabelField("F", GUILayout.Width(20)); var targetState = transition.profile.FindState(transition.targetStateName); if (targetState) { if (GL.Button("Focus")) { Utils.FocusEditingAnimation(transition.profile, targetState.stateName); } } EGL.EndHorizontal(); if (!targetState) { EGL.HelpBox("No target state " + targetState, MessageType.Error); } } else // SendMessage { transition.messageName = EGL.TextField("Message Name", transition.messageName); EGL.Space(); transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType); switch (transition.messageParType) { case MessageParType.Int: transition.messageParInt = EGL.IntField("Value", transition.messageParInt); break; case MessageParType.Float: transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat); break; case MessageParType.Bool: transition.messageParBool = EGL.Toggle("Value", transition.messageParBool); break; } } transition.priority = EGL.IntField("Priority", transition.priority); transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay); if (transition.shouldDelay) { transition.delay = EGL.FloatField("Delay", transition.delay); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(transition); } if (transition.fromState.type == FromStateType.State) { EGL.LabelField("", GUI.skin.horizontalSlider); using (new EGL.VerticalScope(EditorStyles.helpBox)) { EGL.LabelField("From State", EditorStyles.boldLabel); ++EditorGUI.indentLevel; var fromState = transition.profile.FindState(transition.fromState.stateOrTagName); if (fromState) { GUI.enabled = false; if (!fromStateEditor || fromStateEditor.target != fromState) { if (fromStateEditor) { DestroyImmediate(fromStateEditor); } fromStateEditor = Editor.CreateEditor(fromState); } fromStateEditor.OnInspectorGUI(); GUI.enabled = true; } --EditorGUI.indentLevel; } } }
void OnGUI() { if (!profile) { return; } if (Selection.activeObject != profile && Selection.activeObject is TransitionProfile) { BeginEdit(Selection.activeObject as TransitionProfile); } globalPanel = (GlobalPanelType)GL.Toolbar((int)globalPanel, new string[] { "States", "Params", "Tags", "Transitions" }, EditorStyles.toolbarButton); switch (globalPanel) { case GlobalPanelType.States: { profile.controller = (AnimatorController)EGL.ObjectField("Controller", profile.controller, typeof(AnimatorController), allowSceneObjects: false); if (profile.controller) { EGL.BeginHorizontal(); EGL.PrefixLabel("Layer"); profile.controllerLayer = EGL.IntField(profile.controllerLayer); // GL.FlexibleSpace(); if (GL.Button("Sync", EditorStyles.miniButtonRight, GL.Width(40)) && profile.controller) { SyncControllerStates(); statePanelView.Reload(); } EGL.EndHorizontal(); } EGL.Space(); if (statePanelView == null) { statePanelView = new StatesTreeView(statePanelState, profile); statePanelView.searchString = ""; searchFieldState.downOrUpArrowKeyPressed += statePanelView.SetFocusAndEnsureSelectedItem; } statePanelView.searchString = ToolbarSearchField(statePanelView.searchString, searchFieldState); statePanelView.OnGUI(GUILayoutUtility.GetRect(0, 10000, 0, 10000)); } break; case GlobalPanelType.Parameters: { if (paramPanelView == null) { paramPanelView = new ParamsTreeView(paramPanelState, profile); paramPanelView.searchString = ""; } paramPanelView.searchString = ToolbarSearchField(paramPanelView.searchString, searchFieldParam); paramPanelView.OnGUI(GUILayoutUtility.GetRect(0, 10000, 0, 10000)); } break; case GlobalPanelType.Tags: { if (tagsPanelView == null) { tagsPanelView = new TagsTreeView(tagsPanelState, profile); } tagsPanelView.searchString = ToolbarSearchField(tagsPanelView.searchString, searchFieldTag); tagsPanelView.OnGUI(GUILayoutUtility.GetRect(0, 10000, 0, 10000)); var selection = tagsPanelView.GetSelection(); if (selection.Any()) { string selectedTag = profile.tags[selection.First()]; var relatedStates = profile.states.Where(state => state.HasTagAnyFrame(Animator.StringToHash(selectedTag))).Select(it => it.stateName); string statesStr = string.Join(",", relatedStates.ToArray()); GL.Label(statesStr, EditorStyles.textArea); } } break; default: { // Transitions if (transitionPanelView == null) { transitionPanelView = new TransitionTreeView(transitionPanelState, profile); } EditorGUI.BeginChangeCheck(); transitionPanelView.fromStateFilter = searchFieldFromState.OnGUI("From State", transitionPanelView.fromStateFilter); transitionPanelView.targetStateFilter = searchFieldTargetState.OnGUI("Target State", transitionPanelView.targetStateFilter); if (EditorGUI.EndChangeCheck()) { transitionPanelView.Reload(); } EGL.Space(); transitionPanelView.OnGUI(GUILayoutUtility.GetRect(0, 10000, 0, 10000)); Repaint(); } break; } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(m_Sprite, Contents.spriteLabel); EditorGUILayout.PropertyField(m_Color, Contents.colorLabel, true); FlipToggles(); Rect r = GUILayoutUtility.GetRect( EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight); EditorGUI.showMixedValue = m_Material.hasMultipleDifferentValues; Object currentMaterialRef = m_Material.GetArrayElementAtIndex(0).objectReferenceValue; Object returnedMaterialRef = EditorGUI.ObjectField(r, Contents.materialLabel, currentMaterialRef, typeof(Material), false); if (returnedMaterialRef != currentMaterialRef) { m_Material.GetArrayElementAtIndex(0).objectReferenceValue = returnedMaterialRef; } EditorGUI.showMixedValue = false; EditorGUILayout.PropertyField(m_DrawMode, Contents.drawModeLabel); m_ShowDrawMode.target = ShouldShowDrawMode(); if (EditorGUILayout.BeginFadeGroup(m_ShowDrawMode.faded)) { string notFullRectWarning = GetSpriteNotFullRectWarning(); if (notFullRectWarning != null) { EditorGUILayout.HelpBox(notFullRectWarning, MessageType.Warning); } EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(Contents.sizeLabel); EditorGUI.showMixedValue = m_Size.hasMultipleDifferentValues; FloatFieldLabelAbove(Contents.widthLabel, m_Size.FindPropertyRelative("x")); FloatFieldLabelAbove(Contents.heightLabel, m_Size.FindPropertyRelative("y")); EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal(); m_ShowTileMode.target = ShouldShowTileMode(); if (EditorGUILayout.BeginFadeGroup(m_ShowTileMode.faded)) { EditorGUILayout.PropertyField(m_SpriteTileMode, Contents.fullTileLabel); m_ShowAdaptiveThreshold.target = ShouldShowAdaptiveThreshold(); if (EditorGUILayout.BeginFadeGroup(m_ShowAdaptiveThreshold.faded)) { EditorGUI.indentLevel++; EditorGUILayout.Slider(m_AdaptiveModeThreshold, 0.0f, 1.0f, Contents.fullTileThresholdLabel); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); RenderSortingLayerFields(); EditorGUILayout.PropertyField(m_MaskInteraction, Contents.maskInteractionLabel); EditorGUILayout.PropertyField(m_SpriteSortPoint, Contents.spriteSortPointLabel); RenderRenderingLayer(); CheckForErrors(); serializedObject.ApplyModifiedProperties(); }
private void DrawToolbar() { if (!canEditInScene) { EditorGUILayout.HelpBox(Styles.disabledEditMessage, MessageType.Info); } EditorGUILayout.BeginVertical("GroupBox"); GUILayout.Label(Styles.sceneTools); EditorGUI.BeginDisabled(!canEditInScene); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditMode.DoInspectorToolbar(Styles.sceneViewEditModes, Styles.toolContents, GetBounds, this); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // Tools box GUILayout.BeginVertical(EditorStyles.helpBox); string helpText = Styles.baseSceneEditingToolText; if (sceneViewEditing) { int index = ArrayUtility.IndexOf(Styles.sceneViewEditModes, EditMode.editMode); if (index >= 0) { helpText = Styles.ToolNames[index].text; } } GUILayout.Label(helpText, Styles.richTextMiniLabel); GUILayout.EndVertical(); // Editing mode toolbar if (sceneViewEditing) { switch (EditMode.editMode) { case EditMode.SceneViewEditMode.LineRendererEdit: DrawEditPointTools(); break; case EditMode.SceneViewEditMode.LineRendererCreate: CreatePointTools(); break; } } if (!sceneViewEditing) { EditorGUI.BeginChangeCheck(); showSimplifyPreview = EditorGUILayout.Toggle(Styles.simplifyPreview, showSimplifyPreview); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(Styles.tolerance); simplifyTolerance = Mathf.Max(0, EditorGUILayout.FloatField(simplifyTolerance, GUILayout.MaxWidth(35.0f))); if (GUILayout.Button(Styles.simplify, EditorStyles.miniButton)) { SimplifyPoints(); } if (EditorGUI.EndChangeCheck()) { ResetSimplifyPreview(); SceneView.RepaintAll(); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabled(); EditorGUILayout.EndVertical(); }