private void OnEnable() { _meshData = (MeshData)EditorGUIUtility.Load(_storageObjectPath); GetMeshData(); }
void ShowEventFolder(TreeItem item, Predicate <TreeItem> filter) { eventStyle.padding.left += 17; { // Highlight first found item if (item.EventRef != null || item.BankRef != null) { if (!String.IsNullOrEmpty(searchString) && itemCount == 0 && selectedItem == null ) { SetSelectedItem(item); } itemCount++; } item.Next = null; item.Prev = lastDrawnItem; if (lastDrawnItem != null) { lastDrawnItem.Next = item; } lastDrawnItem = item; } if (item.EventRef != null) { // Rendering and GUI event handling to show an event GUIContent content = new GUIContent(item.Name, item.EventRef.Path.StartsWith("snapshot") ? snapshotIcon : eventIcon); eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null; GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true)); Event e = Event.current; Rect rect = GUILayoutUtility.GetLastRect(); if (e.type == EventType.MouseDown && e.button == 0 && rect.Contains(e.mousePosition)) { e.Use(); if (fromInspector && e.clickCount >= 2) { outputProperty.stringValue = ""; outputProperty.stringValue = item.EventRef.Path; EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, item.EventRef.Path); outputProperty.serializedObject.ApplyModifiedProperties(); Close(); } SetSelectedItem(item); } if (e.type == EventType.MouseDrag && rect.Contains(e.mousePosition) && !fromInspector) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { Instantiate(item.EventRef) }; DragAndDrop.StartDrag("New FMOD Studio Emitter"); e.Use(); } if (Event.current.type == EventType.Repaint) { item.Rect = rect; } } else if (item.BankRef != null) { // Rendering and event handling for a bank GUIContent content = new GUIContent(item.Name, bankIcon); eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null; GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true)); Event e = Event.current; Rect rect = GUILayoutUtility.GetLastRect(); if (e.type == EventType.MouseDown && e.button == 0 && rect.Contains(e.mousePosition)) { e.Use(); if (fromInspector && e.clickCount >= 2) { outputProperty.stringValue = item.BankRef.Name; outputProperty.serializedObject.ApplyModifiedProperties(); Close(); } SetSelectedItem(item); } if (e.type == EventType.MouseDrag && rect.Contains(e.mousePosition) && !fromInspector) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { Instantiate(item.BankRef) }; DragAndDrop.StartDrag("New FMOD Studio Bank Loader"); e.Use(); } if (Event.current.type == EventType.Repaint) { item.Rect = rect; } } else if (item.ParamRef != null) { // Rendering and event handling for a bank GUIContent content = new GUIContent(item.Name, eventIcon); eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null; GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true)); Event e = Event.current; Rect rect = GUILayoutUtility.GetLastRect(); if (e.type == EventType.MouseDown && e.button == 0 && rect.Contains(e.mousePosition)) { e.Use(); if (fromInspector && e.clickCount >= 2) { outputProperty.stringValue = item.ParamRef.Name; outputProperty.serializedObject.ApplyModifiedProperties(); Close(); } SetSelectedItem(item); } if (e.type == EventType.MouseDrag && rect.Contains(e.mousePosition) && !fromInspector) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { Instantiate(item.ParamRef) }; DragAndDrop.StartDrag("New FMOD Studio Global Parameter Trigger"); e.Use(); } if (Event.current.type == EventType.Repaint) { item.Rect = rect; } } else { eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null; bool expanded = item.Expanded || !string.IsNullOrEmpty(searchString); GUIContent content = new GUIContent(item.Name, expanded ? folderOpenIcon : folderClosedIcon); GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true)); Rect rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) { Event.current.Use(); item.Expanded = !item.Expanded; SetSelectedItem(item); } if (item.Expanded || !string.IsNullOrEmpty(searchString)) { item.Children.Sort((a, b) => a.Name.CompareTo(b.Name)); if (item.Name.ToLower().Contains(searchString.ToLower())) { foreach (var childFolder in item.Children) { ShowEventFolder(childFolder, (x) => true); } } else { foreach (var childFolder in item.Children.FindAll(filter)) { ShowEventFolder(childFolder, filter); } } } if (Event.current.type == EventType.Repaint) { item.Rect = rect; } } eventStyle.padding.left -= 17; }
private void PreviewEvent(Rect previewRect, EditorEventRef selectedEvent) { GUILayout.BeginArea(previewRect); bool isNarrow = previewRect.width < 400; var style = new GUIStyle(EditorStyles.label); EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUIUtility.labelWidth = 75; var copyIcon = EditorGUIUtility.Load("FMOD/CopyIcon.png") as Texture; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Full Path", selectedEvent.Path, style, GUILayout.ExpandWidth(true)); if (GUILayout.Button(copyIcon, GUILayout.ExpandWidth(false))) { EditorGUIUtility.systemCopyBuffer = selectedEvent.Path; } EditorGUILayout.EndHorizontal(); StringBuilder builder = new StringBuilder(); selectedEvent.Banks.ForEach((x) => { builder.Append(Path.GetFileNameWithoutExtension(x.Path)); builder.Append(", "); }); EditorGUILayout.LabelField("Banks", builder.ToString(0, Math.Max(0, builder.Length - 2)), style); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Panning", selectedEvent.Is3D ? "3D" : "2D", style); EditorGUILayout.LabelField("Oneshot", selectedEvent.IsOneShot.ToString(), style); TimeSpan t = TimeSpan.FromMilliseconds(selectedEvent.Length); EditorGUILayout.LabelField("Length", selectedEvent.Length > 0 ? string.Format("{0:D2}:{1:D2}:{2:D3}", t.Minutes, t.Seconds, t.Milliseconds) : "N/A", style); if (!isNarrow) { EditorGUILayout.LabelField("Streaming", selectedEvent.IsStream.ToString(), style); } EditorGUILayout.EndHorizontal(); if (isNarrow) { EditorGUILayout.LabelField("Streaming", selectedEvent.IsStream.ToString(), style); } EditorGUIUtility.labelWidth = 0; EditorStyles.label.fontStyle = FontStyle.Normal; if (Event.current.type == EventType.Repaint) { var lastRect = GUILayoutUtility.GetLastRect(); if (!isNarrow) { previewCustomRect = new Rect(lastRect.width / 2 - 200, lastRect.yMax + 10, 400, 150); } else { previewCustomRect = new Rect(lastRect.width / 2 - 130, lastRect.yMax + 10, 260, 150); } } GUI.Box(new Rect(0, previewCustomRect.yMin, previewRect.width, 1), GUIContent.none); GUI.Box(new Rect(0, previewCustomRect.yMax, previewRect.width, 1), GUIContent.none); GUILayout.BeginArea(previewCustomRect); Texture playOff = EditorGUIUtility.Load("FMOD/TransportPlayButtonOff.png") as Texture; Texture playOn = EditorGUIUtility.Load("FMOD/TransportPlayButtonOn.png") as Texture; Texture stopOff = EditorGUIUtility.Load("FMOD/TransportStopButtonOff.png") as Texture; Texture stopOn = EditorGUIUtility.Load("FMOD/TransportStopButtonOn.png") as Texture; Texture openIcon = EditorGUIUtility.Load("FMOD/transportOpen.png") as Texture; var transportButtonStyle = new GUIStyle(); transportButtonStyle.padding.left = 4; transportButtonStyle.padding.top = 10; var previewState = EditorUtils.PreviewState; bool playing = previewState == PreviewState.Playing; bool paused = previewState == PreviewState.Paused; bool stopped = previewState == PreviewState.Stopped; EditorGUILayout.BeginVertical(); if (!isNarrow) { GUILayout.FlexibleSpace(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(stopped || paused ? stopOn : stopOff, transportButtonStyle, GUILayout.ExpandWidth(false))) { forceRepaint = false; if (paused) { EditorUtils.PreviewStop(); } if (playing) { EditorUtils.PreviewPause(); } } if (GUILayout.Button(playing ? playOn : playOff, transportButtonStyle, GUILayout.ExpandWidth(false))) { if (playing || stopped) { EditorUtils.PreviewEvent(selectedEvent, previewParamValues); } else { EditorUtils.PreviewPause(); } forceRepaint = true; } if (GUILayout.Button(new GUIContent(openIcon, "Show Event in FMOD Studio"), transportButtonStyle, GUILayout.ExpandWidth(false))) { string cmd = string.Format("studio.window.navigateTo(studio.project.lookup(\"{0}\"))", selectedEvent.Guid.ToString("b")); EditorUtils.SendScriptCommand(cmd); } EditorGUILayout.EndHorizontal(); if (!isNarrow) { GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); { Texture circle = EditorGUIUtility.Load("FMOD/preview.png") as Texture; Texture circle2 = EditorGUIUtility.Load("FMOD/previewemitter.png") as Texture; var originalColour = GUI.color; if (!selectedEvent.Is3D) { GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.1f); } Rect rect = new Rect(isNarrow ? 120 : 150, 10, 128, 128); GUI.DrawTexture(rect, circle); Vector2 centre = rect.center; Rect rect2 = new Rect(rect.center.x + eventPosition.x - 6, rect.center.y + eventPosition.y - 6, 12, 12); GUI.DrawTexture(rect2, circle2); GUI.color = originalColour; if (selectedEvent.Is3D && (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag) && rect.Contains(Event.current.mousePosition)) { var newPosition = Event.current.mousePosition; Vector2 delta = (newPosition - centre); float distance = delta.magnitude; if (distance < 60) { eventPosition = newPosition - rect.center; previewDistance = distance / 60.0f * selectedEvent.MaxDistance; delta.Normalize(); float angle = Mathf.Atan2(delta.y, delta.x); previewOrientation = angle + Mathf.PI * 0.5f; } Event.current.Use(); } EditorUtils.PreviewUpdatePosition(previewDistance, previewOrientation); } float hoffset = isNarrow ? 15 : 300; float voffset = isNarrow ? 50 : 10; Texture meterOn = EditorGUIUtility.Load("FMOD/LevelMeter.png") as Texture; Texture meterOff = EditorGUIUtility.Load("FMOD/LevelMeterOff.png") as Texture; float[] metering = EditorUtils.GetMetering(); int meterHeight = isNarrow ? 86 : 128; int meterWidth = (int)((128 / (float)meterOff.height) * meterOff.width); foreach (float rms in metering) { GUI.DrawTexture(new Rect(hoffset, voffset, meterWidth, meterHeight), meterOff); float db = 20.0f * Mathf.Log10(rms * Mathf.Sqrt(2.0f)); db = Mathf.Clamp(db, -80.0f, 10.0f); float visible = 0; int[] segmentPixels = new int[] { 0, 18, 38, 60, 89, 130, 187, 244, 300 }; float[] segmentDB = new float[] { -80.0f, -60.0f, -50.0f, -40.0f, -30.0f, -20.0f, -10.0f, 0, 10.0f }; int segment = 1; while (segmentDB[segment] < db) { segment++; } visible = segmentPixels[segment - 1] + ((db - segmentDB[segment - 1]) / (segmentDB[segment] - segmentDB[segment - 1])) * (segmentPixels[segment] - segmentPixels[segment - 1]); visible *= meterHeight / (float)meterOff.height; Rect levelPosRect = new Rect(hoffset, meterHeight - visible + voffset, meterWidth, visible); Rect levelUVRect = new Rect(0, 0, 1.0f, visible / meterHeight); GUI.DrawTextureWithTexCoords(levelPosRect, meterOn, levelUVRect); hoffset += meterWidth + 5.0f; } GUILayout.EndArea(); Rect paramRect = new Rect(0, previewCustomRect.yMax + 10, previewRect.width, previewRect.height - (previewCustomRect.yMax + 10)); GUILayout.BeginArea(paramRect); paramScroll = GUILayout.BeginScrollView(paramScroll, false, false); foreach (var paramRef in selectedEvent.Parameters) { if (!previewParamValues.ContainsKey(paramRef.Name)) { previewParamValues[paramRef.Name] = paramRef.Default; } previewParamValues[paramRef.Name] = EditorGUILayout.Slider(paramRef.Name, previewParamValues[paramRef.Name], paramRef.Min, paramRef.Max); EditorUtils.PreviewUpdateParameter(paramRef.ID, previewParamValues[paramRef.Name]); } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.EndArea(); }
public void Initialize(EditorWindow debuggerWindow, VisualElement root) { rootVisualElement = root; VisualTreeAsset template = EditorGUIUtility.Load("UIPackageResources/UXML/UIElementsDebugger/UIElementsEventsDebugger.uxml") as VisualTreeAsset; template.CloneTree(rootVisualElement); var toolbar = rootVisualElement.MandatoryQ("toolbar"); m_Toolbar = toolbar; base.Initialize(debuggerWindow); rootVisualElement.AddStyleSheetPath("UIPackageResources/StyleSheets/UIElementsDebugger/UIElementsEventsDebugger.uss"); var eventsDebugger = rootVisualElement.MandatoryQ("eventsDebugger"); eventsDebugger.StretchToParentSize(); m_EventCallbacksScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventCallbacksScrollView"); m_EventTypeFilter = toolbar.MandatoryQ <EventTypeSelectField>("filter-event-type"); m_EventTypeFilter.RegisterCallback <ChangeEvent <ulong> >(OnFilterChange); var refreshButton = toolbar.MandatoryQ <Button>("refresh"); refreshButton.clickable.clicked += Refresh; var clearLogsButton = toolbar.MandatoryQ <Button>("clear-logs"); clearLogsButton.clickable.clicked += () => { ClearLogs(); }; m_ReplaySelectedEventsButton = toolbar.MandatoryQ <Button>("replay-selected-events"); m_ReplaySelectedEventsButton.clickable.clicked += ReplaySelectedEvents; UpdateReplaySelectedEventsButton(); var infoContainer = rootVisualElement.MandatoryQ("eventInfoContainer"); m_LogCountLabel = infoContainer.MandatoryQ <Label>("log-count"); m_SelectionCountLabel = infoContainer.MandatoryQ <Label>("selection-count"); var autoScrollToggle = infoContainer.MandatoryQ <Toggle>("autoscroll"); autoScrollToggle.value = m_AutoScroll; autoScrollToggle.RegisterValueChangedCallback((e) => { m_AutoScroll = e.newValue; }); m_EventPropagationPaths = (Label)rootVisualElement.MandatoryQ("eventPropagationPaths"); m_EventbaseInfo = (Label)rootVisualElement.MandatoryQ("eventbaseInfo"); m_EventsLog = (ListView)rootVisualElement.MandatoryQ("eventsLog"); m_EventsLog.focusable = true; m_EventsLog.selectionType = SelectionType.Multiple; m_EventsLog.onSelectionChange += OnEventsLogSelectionChanged; m_HistogramTitle = (Label)rootVisualElement.MandatoryQ("eventsHistogramTitle"); m_Log = new EventLog(); m_ModificationCount = 0; m_AutoScroll = true; var eventCallbacksScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventCallbacksScrollView"); eventCallbacksScrollView.StretchToParentSize(); var eventPropagationPathsScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventPropagationPathsScrollView"); eventPropagationPathsScrollView.StretchToParentSize(); var eventbaseInfoScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventbaseInfoScrollView"); eventbaseInfoScrollView.StretchToParentSize(); m_EventRegistrationsScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventsRegistrationsScrollView"); DisplayEvents(m_EventRegistrationsScrollView); m_EventRegistrationsScrollView.StretchToParentSize(); m_EventsHistogramScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventsHistogramScrollView"); DisplayHistogram(m_EventsHistogramScrollView); m_EventsHistogramScrollView.StretchToParentSize(); m_EventTimelineScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventTimelineScrollView"); DisplayTimeline(m_EventTimelineScrollView); m_EventTimelineScrollView.SetScrollViewMode(ScrollViewMode.Horizontal); m_EventTimelineScrollView.StretchToParentSize(); m_TimelineLegend = (Label)rootVisualElement.MandatoryQ("eventTimelineTitleLegend"); m_TimelineLegend.RegisterCallback <MouseEnterEvent>(ShowLegend); m_TimelineLegend.RegisterCallback <MouseLeaveEvent>(HideLegend); CreateLegendContainer(); BuildEventsLog(); GlobalCallbackRegistry.IsEventDebuggerConnected = true; }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); EditorGUI.BeginChangeCheck(); editMode = GUILayout.Toggle(editMode, new GUIContent("Edit particles", EditorGUIUtility.Load("EditParticles.psd") as Texture2D), "LargeButton"); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } EditorGUILayout.LabelField("Status: " + (cloth.Initialized ? "Initialized":"Not initialized")); GUI.enabled = (cloth.sharedTopology != null); if (GUILayout.Button("Initialize")) { if (!cloth.Initialized) { CoroutineJob job = new CoroutineJob(); routine = EditorCoroutine.StartCoroutine(job.Start(cloth.GeneratePhysicRepresentationForMesh())); } else { if (EditorUtility.DisplayDialog("Actor initialization", "Are you sure you want to re-initialize this actor?", "Ok", "Cancel")) { CoroutineJob job = new CoroutineJob(); routine = EditorCoroutine.StartCoroutine(job.Start(cloth.GeneratePhysicRepresentationForMesh())); } } } GUI.enabled = true; if (GUILayout.Button("Set Rest State")) { cloth.PullDataFromSolver(new ObiSolverData(ObiSolverData.ParticleData.POSITIONS | ObiSolverData.ParticleData.VELOCITIES)); } if (cloth.sharedTopology == null) { EditorGUILayout.HelpBox("No ObiMeshConnectivity asset present.", MessageType.Info); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Optimize")) { Undo.RecordObject(cloth, "Optimize"); cloth.Optimize(); EditorUtility.SetDirty(cloth); } if (GUILayout.Button("Unoptimize")) { Undo.RecordObject(cloth, "Unoptimize"); cloth.Unoptimize(); EditorUtility.SetDirty(cloth); } GUILayout.EndHorizontal(); Editor.DrawPropertiesExcluding(serializedObject, "m_Script"); // Progress bar: EditorCoroutine.ShowCoroutineProgressBar("Generating physical representation...", routine); // Apply changes to the serializedProperty if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public Blackboard(GraphView associatedGraphView = null) { var tpl = EditorGUIUtility.Load("UXML/GraphView/Blackboard.uxml") as VisualTreeAsset; AddStyleSheetPath(StyleSheetPath); m_MainContainer = tpl.Instantiate(); m_MainContainer.AddToClassList("mainContainer"); m_Root = m_MainContainer.Q("content"); m_HeaderItem = m_MainContainer.Q("header"); m_HeaderItem.AddToClassList("blackboardHeader"); m_AddButton = m_MainContainer.Q(name: "addButton") as Button; m_AddButton.clickable.clicked += () => { if (addItemRequested != null) { addItemRequested(this); } }; m_TitleLabel = m_MainContainer.Q <Label>(name: "titleLabel"); m_SubTitleLabel = m_MainContainer.Q <Label>(name: "subTitleLabel"); m_ContentContainer = m_MainContainer.Q(name: "contentContainer"); hierarchy.Add(m_MainContainer); capabilities |= Capabilities.Movable | Capabilities.Resizable; style.overflow = Overflow.Hidden; ClearClassList(); AddToClassList("blackboard"); m_Dragger = new Dragger { clampToParentEdges = true }; this.AddManipulator(m_Dragger); scrollable = false; hierarchy.Add(new Resizer()); RegisterCallback <DragUpdatedEvent>(e => { e.StopPropagation(); }); // event interception to prevent GraphView manipulators from being triggered // when working with the blackboard // prevent Zoomer manipulator RegisterCallback <WheelEvent>(e => { e.StopPropagation(); }); RegisterCallback <MouseDownEvent>(e => { if (e.button == (int)MouseButton.LeftMouse) { ClearSelection(); } // prevent ContentDragger manipulator e.StopPropagation(); }); RegisterCallback <ValidateCommandEvent>(OnValidateCommand); RegisterCallback <ExecuteCommandEvent>(OnExecuteCommand); m_GraphView = associatedGraphView; focusable = true; }
static EditorStyles() { paneOptionsIconDark = (Texture2D)EditorGUIUtility.Load("Builtin Skins/DarkSkin/Images/pane options.png"); paneOptionsIconLight = (Texture2D)EditorGUIUtility.Load("Builtin Skins/LightSkin/Images/pane options.png"); }
public PackageManagerProjectSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { activateHandler = (s, element) => { ResolveDependencies(); // Create a child to make sure all the style sheets are not added to the root. rootVisualElement = new ScrollView(); rootVisualElement.StretchToParentSize(); rootVisualElement.AddStyleSheetPath(StylesheetPath.scopedRegistriesSettings); rootVisualElement.AddStyleSheetPath(StylesheetPath.projectSettings); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? StylesheetPath.stylesheetDark : StylesheetPath.stylesheetLight); rootVisualElement.AddStyleSheetPath(StylesheetPath.stylesheetCommon); rootVisualElement.styleSheets.Add(m_ResourceLoader.packageManagerCommonStyleSheet); element.Add(rootVisualElement); m_GeneralTemplate = EditorGUIUtility.Load(k_GeneralServicesTemplatePath) as VisualTreeAsset; VisualElement newVisualElement = new VisualElement(); m_GeneralTemplate.CloneTree(newVisualElement); rootVisualElement.Add(newVisualElement); cache = new VisualElementCache(rootVisualElement); advancedSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.advancedSettingsExpanded); m_SettingsProxy.onAdvancedSettingsFoldoutChanged += OnAdvancedSettingsFoldoutChanged; advancedSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == advancedSettingsFoldout) { m_SettingsProxy.advancedSettingsExpanded = changeEvent.newValue; } }); scopedRegistriesSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.scopedRegistriesSettingsExpanded); m_SettingsProxy.onScopedRegistriesSettingsFoldoutChanged += OnScopedRegistriesSettingsFoldoutChanged; scopedRegistriesSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == scopedRegistriesSettingsFoldout) { m_SettingsProxy.scopedRegistriesSettingsExpanded = changeEvent.newValue; } }); preReleaseInfoBox.Q <Button>().clickable.clicked += () => { m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-preview.html"); }; enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); enablePreReleasePackages.RegisterValueChangedCallback(changeEvent => { var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.enablePreReleasePackages) { var saveIt = true; if (newValue && !m_SettingsProxy.oneTimeWarningShown) { if (m_ApplicationProxy.DisplayDialog("showPreReleasePackages", L10n.Tr("Show pre-release packages"), k_Message, L10n.Tr("I understand"), L10n.Tr("Cancel"))) { m_SettingsProxy.oneTimeWarningShown = true; } else { saveIt = false; } } if (saveIt) { m_SettingsProxy.enablePreReleasePackages = newValue; m_SettingsProxy.Save(); PackageManagerWindowAnalytics.SendEvent("togglePreReleasePackages"); } } enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); }); enablePackageDependencies.SetValueWithoutNotify(m_SettingsProxy.enablePackageDependencies); enablePackageDependencies.RegisterValueChangedCallback(changeEvent => { enablePackageDependencies.SetValueWithoutNotify(changeEvent.newValue); var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.enablePackageDependencies) { m_SettingsProxy.enablePackageDependencies = newValue; m_SettingsProxy.Save(); PackageManagerWindowAnalytics.SendEvent("toggleDependencies"); } }); UIUtils.SetElementDisplay(seeAllPackageVersions, Unsupported.IsDeveloperBuild()); seeAllPackageVersions.SetValueWithoutNotify(m_SettingsProxy.seeAllPackageVersions); seeAllPackageVersions.RegisterValueChangedCallback(changeEvent => { seeAllPackageVersions.SetValueWithoutNotify(changeEvent.newValue); var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.seeAllPackageVersions) { m_SettingsProxy.seeAllPackageVersions = newValue; m_SettingsProxy.Save(); } }); }; }
protected override VisualElement CreateView() { VisualTreeAsset memoryModuleViewTree = EditorGUIUtility.Load(ResourcePaths.MemoryModuleUxmlPath) as VisualTreeAsset; var root = memoryModuleViewTree.CloneTree(); m_UIState = new UIState(); var toolbar = root.Q("memory-module__toolbar"); m_UIState.DetailedToolbarSection = toolbar.Q("memory-module__toolbar__detailed-controls"); m_UIState.DetailedMenu = toolbar.Q <UnityEngine.UIElements.Button>("memory-module__toolbar__detail-view-menu"); m_UIState.DetailedMenuLabel = m_UIState.DetailedMenu.Q <Label>("memory-module__toolbar__detail-view-menu__label"); var menu = new GenericMenu(); menu.AddItem(new GUIContent("Simple"), false, () => ViewChanged(ProfilerMemoryView.Simple)); menu.AddItem(new GUIContent("Detailed"), false, () => ViewChanged(ProfilerMemoryView.Detailed)); m_UIState.DetailedMenu.clicked += () => { menu.DropDown(UIElementsHelper.GetRect(m_UIState.DetailedMenu)); }; var takeCapture = toolbar.Q <UnityEngine.UIElements.Button>("memory-module__toolbar__take-sample-button"); takeCapture.clicked += () => m_MemoryModule.RefreshMemoryData(); var gatherObjectReferencesToggle = toolbar.Q <Toggle>("memory-module__toolbar__gather-references-toggle"); gatherObjectReferencesToggle.RegisterValueChangedCallback((evt) => m_MemoryModule.m_GatherObjectReferences = evt.newValue); gatherObjectReferencesToggle.SetValueWithoutNotify(m_MemoryModule.m_GatherObjectReferences); m_UIState.InstallPackageButton = toolbar.Q <UnityEngine.UIElements.Button>("memory-module__toolbar__install-package-button"); // in the main code base, this button offers to install the memory profiler package, here it is swapped to be one that opens it. if (m_InitiatedPackageSearchQuery) { m_UIState.InstallPackageButton.schedule.Execute(CheckPackageAvailabilityStatus).Until(() => !m_InitiatedPackageSearchQuery); } m_UIState.InstallPackageButton.clicked += PackageInstallButtonClicked; UpdatePackageInstallButton(); m_UIState.EditorWarningLabel = toolbar.Q("memory-module__toolbar__editor-warning"); m_ConnectionState = PlayerConnectionGUIUtility.GetConnectionState(ProfilerWindow, ConnectionChanged); UIElementsHelper.SetVisibility(m_UIState.EditorWarningLabel, m_ConnectionState.connectionName == "Editor"); m_UIState.ViewArea = root.Q("memory-module__view-area"); m_UIState.SimpleView = m_UIState.ViewArea.Q("memory-module__simple-area"); m_UIState.CounterBasedUI = m_UIState.SimpleView.Q("memory-module__simple-area__counter-based-ui"); var normalizedToggle = m_UIState.CounterBasedUI.Q <Toggle>("memory-module__simple-area__breakdown__normalized-toggle"); normalizedToggle.value = m_MemoryModule.m_Normalized; normalizedToggle.RegisterValueChangedCallback((evt) => { m_MemoryModule.m_Normalized = evt.newValue; UpdateContent(ProfilerWindow.selectedFrameIndex); }); m_UIState.TopLevelBreakdown = m_UIState.CounterBasedUI.Q <MemoryUsageBreakdown>("memory-usage-breakdown__top-level"); m_UIState.TopLevelBreakdown.Setup(); m_UIState.Breakdown = m_UIState.CounterBasedUI.Q <MemoryUsageBreakdown>("memory-usage-breakdown"); m_UIState.Breakdown.Setup(); var m_ObjectStatsTable = m_UIState.CounterBasedUI.Q("memory-usage-breakdown__object-stats_list"); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__textures"), ref m_UIState.TexturesRow, Content.Textures); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__meshes"), ref m_UIState.MeshesRow, Content.Meshes); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__materials"), ref m_UIState.MaterialsRow, Content.Materials); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__animation-clips"), ref m_UIState.AnimationClipsRow, Content.AnimationClips); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__assets"), ref m_UIState.AssetsRow, Content.Assets, true); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__game-objects"), ref m_UIState.GameObjectsRow, Content.GameObjects, true); SetupObjectTableRow(m_ObjectStatsTable.Q("memory-usage-breakdown__object-stats__scene-objects"), ref m_UIState.SceneObjectsRow, Content.SceneObjects, true); var m_GCAllocExtraRow = m_UIState.CounterBasedUI.Q <VisualElement>("memory-usage-breakdown__object-stats__gc"); SetupObjectTableRow(m_GCAllocExtraRow, ref m_UIState.GCAllocRow, Content.GCAlloc); m_UIState.Text = m_UIState.SimpleView.Q <TextField>("memory-module__simple-area__label"); var detailedView = m_UIState.ViewArea.Q <IMGUIContainer>("memory-module__detaile-snapshot-area");// new IMGUIContainer(); detailedView.onGUIHandler = () => m_MemoryModule.DrawDetailedMemoryPane(); m_UIState.DetailedView = detailedView; m_UIState.NoDataView = m_UIState.ViewArea.Q("memory-module__no-frame-data__area"); m_UIState.NoDataView.Q <Label>("memory-module__no-frame-data__label").text = Content.NoFrameDataAvailable; ViewChanged(m_MemoryModule.m_ShowDetailedMemoryPane); return(root); }
static void Init() { var window = GetWindow <ModSettingsEditorWindow>(); window.titleContent = new GUIContent("Mod Settings", (Texture2D)EditorGUIUtility.Load("icons/SettingsIcon.png")); }
public override void OnInspectorGUI() { Settings settings = target as Settings; EditorGUI.BeginChangeCheck(); hasBankSourceChanged = false; bool hasBankTargetChanged = false; GUIStyle style = new GUIStyle(GUI.skin.label); style.richText = true; GUI.skin.FindStyle("HelpBox").richText = true; SourceType sourceType = settings.HasSourceProject ? SourceType.Project : (settings.HasPlatforms ? SourceType.Multi : SourceType.Single); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); sourceType = GUILayout.Toggle(sourceType == SourceType.Project, "Project", "Button") ? 0 : sourceType; sourceType = GUILayout.Toggle(sourceType == SourceType.Single, "Single Platform Build", "Button") ? SourceType.Single : sourceType; sourceType = GUILayout.Toggle(sourceType == SourceType.Multi, "Multiple Platform Build", "Button") ? SourceType.Multi : sourceType; EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox( "<size=11>Select the way you wish to connect Unity to the FMOD Studio content:\n" + "<b>• Project</b>\t\tIf you have the complete FMOD Studio project avaliable\n" + "<b>• Single Platform</b>\tIf you have only the contents of the <i>Build</i> folder for a single platform\n" + "<b>• Multiple Platforms</b>\tIf you have only the contents of the <i>Build</i> folder for multiple platforms, each platform in it's own sub directory\n" + "</size>" , MessageType.Info, true); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (sourceType == SourceType.Project) { EditorGUILayout.BeginHorizontal(); string oldPath = settings.SourceProjectPathUnformatted; EditorGUILayout.PrefixLabel("Studio Project Path", GUI.skin.textField, style); EditorGUI.BeginChangeCheck(); settings.SourceProjectPathUnformatted = EditorGUILayout.TextField(GUIContent.none, settings.SourceProjectPathUnformatted); if (EditorGUI.EndChangeCheck()) { settings.SourceProjectPath = settings.SourceProjectPathUnformatted; settings.SourceProjectPathUnformatted = MakePathRelativeToProject(settings.SourceProjectPathUnformatted); } if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) { GUI.FocusControl(null); string path = EditorUtility.OpenFilePanel("Locate Studio Project", oldPath, "fspro"); if (!string.IsNullOrEmpty(path)) { settings.SourceProjectPath = path; settings.SourceProjectPathUnformatted = MakePathRelativeToProject(path); Repaint(); } } EditorGUILayout.EndHorizontal(); // Cache in settings for runtime access in play-in-editor mode string bankPath = EditorUtils.GetBankDirectoryUnformatted(); settings.SourceBankPathUnformatted = bankPath; settings.SourceBankPath = bankPath; settings.HasPlatforms = true; settings.HasSourceProject = true; // First time project path is set or changes, copy to streaming assets if (settings.SourceProjectPathUnformatted != oldPath) { hasBankSourceChanged = true; } } if (sourceType == SourceType.Single || sourceType == SourceType.Multi) { EditorGUILayout.BeginHorizontal(); string oldPath = settings.SourceBankPathUnformatted; EditorGUILayout.PrefixLabel("Build Path", GUI.skin.textField, style); EditorGUI.BeginChangeCheck(); settings.SourceBankPathUnformatted = EditorGUILayout.TextField(GUIContent.none, settings.SourceBankPathUnformatted); if (EditorGUI.EndChangeCheck()) { settings.SourceBankPath = Path.GetFullPath(settings.SourceBankPathUnformatted); settings.SourceBankPathUnformatted = MakePathRelativeToProject(settings.SourceBankPathUnformatted); } if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) { GUI.FocusControl(null); var path = EditorUtility.OpenFolderPanel("Locate Build Folder", oldPath, null); if (!string.IsNullOrEmpty(path)) { settings.SourceBankPath = path; settings.SourceBankPathUnformatted = MakePathRelativeToProject(path); Repaint(); } } EditorGUILayout.EndHorizontal(); settings.HasPlatforms = (sourceType == SourceType.Multi); settings.HasSourceProject = false; // First time project path is set or changes, copy to streaming assets if (settings.SourceBankPathUnformatted != oldPath) { hasBankSourceChanged = true; } } if ((settings.HasSourceProject && !string.IsNullOrEmpty(settings.SourceProjectPathUnformatted) && !settings.SourceProjectPathUnformatted.Equals(settings.SourceProjectPath)) || (sourceType >= SourceType.Single && !string.IsNullOrEmpty(settings.SourceBankPathUnformatted) && !settings.SourceBankPathUnformatted.Equals(settings.SourceBankPath))) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField("Local path", sourceType == SourceType.Project ? settings.SourceProjectPath : settings.SourceBankPath); EditorGUI.EndDisabledGroup(); } bool validBanks; string failReason; EditorUtils.ValidateSource(out validBanks, out failReason); if (!validBanks) { EditorGUILayout.HelpBox(failReason, MessageType.Error, true); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } return; } ImportType importType = (ImportType)EditorGUILayout.EnumPopup("Import Type", settings.ImportType); if (importType != settings.ImportType) { hasBankTargetChanged = true; settings.ImportType = importType; } // ----- Text Assets ------------- EditorGUI.BeginDisabledGroup(settings.ImportType != ImportType.AssetBundle); GUI.SetNextControlName("targetAssetPath"); targetAssetPath = EditorGUILayout.TextField("FMOD Asset Folder", string.IsNullOrEmpty(targetAssetPath) ? settings.TargetAssetPath : targetAssetPath); if (GUI.GetNameOfFocusedControl() == "targetAssetPath") { focused = true; if (Event.current.isKey) { switch (Event.current.keyCode) { case KeyCode.Return: case KeyCode.KeypadEnter: settings.TargetAssetPath = targetAssetPath; hasBankTargetChanged = true; break; } } } else if (focused) { settings.TargetAssetPath = targetAssetPath; hasBankTargetChanged = true; focused = false; } EditorGUI.EndDisabledGroup(); // ----- Logging ----------------- EditorGUILayout.Separator(); EditorGUILayout.LabelField("<b>Logging</b>", style); EditorGUI.indentLevel++; settings.LoggingLevel = (FMOD.DEBUG_FLAGS)EditorGUILayout.EnumPopup("Logging Level", settings.LoggingLevel); EditorGUI.indentLevel--; // ----- Loading ----------------- EditorGUI.BeginDisabledGroup(settings.ImportType == ImportType.AssetBundle); EditorGUILayout.Separator(); EditorGUILayout.LabelField("<b>Initialization</b>", style); EditorGUI.indentLevel++; settings.BankLoadType = (BankLoadType)EditorGUILayout.EnumPopup("Load Banks", settings.BankLoadType); switch (settings.BankLoadType) { case BankLoadType.All: break; case BankLoadType.Specified: settings.AutomaticEventLoading = false; Texture upArrowTexture = EditorGUIUtility.Load("FMOD/ArrowUp.png") as Texture; Texture downArrowTexture = EditorGUIUtility.Load("FMOD/ArrowDown.png") as Texture; bankFoldOutState = EditorGUILayout.Foldout(bankFoldOutState, "Specified Banks", true); if (bankFoldOutState) { for (int i = 0; i < settings.BanksToLoad.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; var bankName = settings.BanksToLoad[i]; EditorGUILayout.TextField(bankName.Replace(".bank", "")); if (GUILayout.Button(upArrowTexture, GUILayout.ExpandWidth(false))) { if (i > 0) { var temp = settings.BanksToLoad[i]; settings.BanksToLoad[i] = settings.BanksToLoad[i - 1]; settings.BanksToLoad[i - 1] = temp; } continue; } if (GUILayout.Button(downArrowTexture, GUILayout.ExpandWidth(false))) { if (i < settings.BanksToLoad.Count - 1) { var temp = settings.BanksToLoad[i]; settings.BanksToLoad[i] = settings.BanksToLoad[i + 1]; settings.BanksToLoad[i + 1] = temp; } continue; } if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) { GUI.FocusControl(null); string path = EditorUtility.OpenFilePanel("Locate Bank", Application.streamingAssetsPath, "bank"); if (!string.IsNullOrEmpty(path)) { settings.BanksToLoad[i] = path.Replace(Application.streamingAssetsPath + Path.AltDirectorySeparatorChar, ""); Repaint(); } } if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false))) { Settings.Instance.BanksToLoad.RemoveAt(i); continue; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } GUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button("Add Bank", GUILayout.ExpandWidth(false))) { settings.BanksToLoad.Add(""); } if (GUILayout.Button("Add All Banks", GUILayout.ExpandWidth(false))) { FMODPlatform platform = RuntimeUtils.GetEditorFMODPlatform(); if (platform == FMODPlatform.None) { platform = FMODPlatform.PlayInEditor; } var banksFound = new List <string>(Directory.GetFiles(EditorUtils.GetBankDirectory(), "*.bank", SearchOption.AllDirectories)); for (int i = 0; i < banksFound.Count; i++) { string sourceDir = EditorUtils.GetBankDirectory() + Path.DirectorySeparatorChar + (settings.HasSourceProject ? settings.GetBankPlatform(platform) + Path.DirectorySeparatorChar : ""); string bankShortName = Path.GetFullPath(banksFound[i]).Replace(sourceDir, ""); if (!settings.BanksToLoad.Contains(bankShortName)) { settings.BanksToLoad.Add(bankShortName); } } Repaint(); } if (GUILayout.Button("Clear", GUILayout.ExpandWidth(false))) { settings.BanksToLoad.Clear(); } GUILayout.EndHorizontal(); } break; case BankLoadType.None: settings.AutomaticEventLoading = false; break; default: break; } EditorGUI.BeginDisabledGroup(settings.BankLoadType == BankLoadType.None); settings.AutomaticSampleLoading = EditorGUILayout.Toggle("Load Bank Sample Data", settings.AutomaticSampleLoading); EditorGUI.EndDisabledGroup(); settings.EncryptionKey = EditorGUILayout.TextField("Bank Encryption Key", settings.EncryptionKey); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); // ----- PIE ---------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.LabelField("<b>Play In Editor Settings</b>", style); EditorGUI.indentLevel++; DisplayEditorBool("Live Update", settings.LiveUpdateSettings, FMODPlatform.PlayInEditor); if (settings.IsLiveUpdateEnabled(FMODPlatform.PlayInEditor)) { EditorGUILayout.BeginHorizontal(); settings.LiveUpdatePort = ushort.Parse(EditorGUILayout.TextField("Live Update Port:", settings.LiveUpdatePort.ToString())); if (GUILayout.Button("Reset", GUILayout.ExpandWidth(false))) { settings.LiveUpdatePort = 9264; } EditorGUILayout.EndHorizontal(); } DisplayEditorBool("Debug Overlay", settings.OverlaySettings, FMODPlatform.PlayInEditor); DisplayChildFreq("Sample Rate", settings.SampleRateSettings, FMODPlatform.PlayInEditor); if (settings.HasPlatforms) { DisplayPIEBuildDirectory("Bank Platform", settings.BankDirectorySettings, FMODPlatform.PlayInEditor); } DisplayPIESpeakerMode("Speaker Mode", settings.SpeakerModeSettings, FMODPlatform.PlayInEditor); if (settings.HasPlatforms) { EditorGUILayout.HelpBox(string.Format("Match the speaker mode to the setting of the platform <b>{0}</b> inside FMOD Studio", settings.GetBankPlatform(FMODPlatform.PlayInEditor)), MessageType.Info, false); } else { EditorGUILayout.HelpBox("Match the speaker mode to the setting inside FMOD Studio", MessageType.Info, false); } EditorGUI.indentLevel--; // ----- Default ---------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.LabelField("<b>Default Settings</b>", style); EditorGUI.indentLevel++; DisplayParentBool("Live Update", settings.LiveUpdateSettings, FMODPlatform.Default); if (settings.IsLiveUpdateEnabled(FMODPlatform.Default)) { EditorGUILayout.BeginHorizontal(); settings.LiveUpdatePort = ushort.Parse(EditorGUILayout.TextField("Live Update Port:", settings.LiveUpdatePort.ToString())); if (GUILayout.Button("Reset", GUILayout.ExpandWidth(false))) { settings.LiveUpdatePort = 9264; } EditorGUILayout.EndHorizontal(); } DisplayParentBool("Debug Overlay", settings.OverlaySettings, FMODPlatform.Default); DisplayParentFreq("Sample Rate", settings.SampleRateSettings, FMODPlatform.Default); if (settings.HasPlatforms) { bool prevChanged = GUI.changed; DisplayParentBuildDirectory("Bank Platform", settings.BankDirectorySettings, FMODPlatform.Default); hasBankSourceChanged |= !prevChanged && GUI.changed; } DisplayParentSpeakerMode("Speaker Mode", settings.SpeakerModeSettings, FMODPlatform.Default); if (settings.HasPlatforms) { EditorGUILayout.HelpBox(string.Format("Match the speaker mode to the setting of the platform <b>{0}</b> inside FMOD Studio", settings.GetBankPlatform(FMODPlatform.Default)), MessageType.Info, false); } else { EditorGUILayout.HelpBox("Match the speaker mode to the setting inside FMOD Studio", MessageType.Info, false); } DisplayParentInt("Virtual Channel Count", settings.VirtualChannelSettings, FMODPlatform.Default, 1, 2048); DisplayParentInt("Real Channel Count", settings.RealChannelSettings, FMODPlatform.Default, 1, 256); EditorGUI.indentLevel--; // ----- Plugins ---------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("<b>Plugins</b>", GUI.skin.button, style); if (GUILayout.Button("Add Plugin", GUILayout.ExpandWidth(false))) { settings.Plugins.Add(""); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for (int count = 0; count < settings.Plugins.Count; count++) { EditorGUILayout.BeginHorizontal(); settings.Plugins[count] = EditorGUILayout.TextField("Plugin " + (count + 1).ToString() + ":", settings.Plugins[count]); if (GUILayout.Button("Delete Plugin", GUILayout.ExpandWidth(false))) { settings.Plugins.RemoveAt(count); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; // ----- Windows ---------------------------------------------- DisplayPlatform(FMODPlatform.Desktop, null); DisplayPlatform(FMODPlatform.Mobile, new FMODPlatform[] { FMODPlatform.MobileHigh, FMODPlatform.MobileLow, FMODPlatform.AppleTV }); DisplayPlatform(FMODPlatform.Console, new FMODPlatform[] { FMODPlatform.XboxOne, FMODPlatform.PS4, FMODPlatform.Switch }); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } if (hasBankSourceChanged) { EventManager.RefreshBanks(); } if (hasBankTargetChanged) { EventManager.RefreshBanks(); } }
private static bool IconButton(string iconName, string tooltip) { var icon = (Texture2D)EditorGUIUtility.Load(string.Format("icons/{0}.png", iconName)); return(GUILayout.Button(new GUIContent(icon, tooltip), GUILayout.Width(30), GUILayout.Height(20))); }
private void OnGUI() { lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; GUILayoutHelper.Vertical(() => { GUILayoutHelper.Area(new Rect(0, 0, 3 * position.width / 8, position.height), () => { EditorGUILayout.Space(); GUILayoutHelper.Horizontal(() => { GUILayout.Box((Texture2D)EditorGUIUtility.Load("Assets/Resources/AppIcon1.png"), GUILayout.Width(50), GUILayout.Height(50)); var titleStyle = new GUIStyle(EditorStyles.largeLabel); titleStyle.font = EditorGUIUtility.Load("Assets/Resources/Fonts/TESFonts/Kingthings Petrock.ttf") as Font; titleStyle.fontSize = 50; GUILayout.Label(modName, titleStyle); }); EditorGUILayout.Space(); GUILayoutHelper.Horizontal(() => { GUILayout.Label(localPath); if (IconButton("d_editicon.sml", "Select target path")) { if (!string.IsNullOrEmpty(targetPath = EditorUtility.OpenFolderPanel("Select mod folder", rootPath, "Mod"))) { Load(); } } if (IconButton("d_Refresh", "Reload and discharge unsaved changes")) { Load(); } using (new EditorGUI.DisabledScope(modName == "None" || duplicateSections || duplicateKeys)) if (IconButton("d_P4_CheckOutLocal", "Save settings to disk")) { Save(); } }); saveOnExit = EditorGUILayout.ToggleLeft(new GUIContent("Save on Exit", "Save automatically when window is closed."), saveOnExit); if (data == null) { EditorGUILayout.HelpBox("Select a folder to store settings.", MessageType.Info); return; } if (duplicateSections) { EditorGUILayout.HelpBox("Multiple sections with the same name detected!", MessageType.Error); } if (duplicateKeys) { EditorGUILayout.HelpBox("Multiple keys with the same name in a section detected!", MessageType.Error); } DrawHeader("Header"); EditorGUILayout.HelpBox("Version of settings checked against local values and presets.", MessageType.None); data.Version = EditorGUILayout.TextField("Version", data.Version); DrawHeader("Presets"); EditorGUILayout.HelpBox("Pre-defined values for all or a set of settings. Author is an optional field.", MessageType.None); presetsScrollPosition = GUILayoutHelper.ScrollView(presetsScrollPosition, () => presets.DoLayoutList()); EditorGUILayout.Space(); if (presets.index != -1) { var preset = data.Presets[presets.index]; preset.Author = EditorGUILayout.TextField("Author", preset.Author); EditorGUILayout.PrefixLabel("Description"); preset.Description = EditorGUILayout.TextArea(preset.Description); } GUILayout.FlexibleSpace(); DrawHeader("Tools"); if (GUILayout.Button("Import Legacy INI")) { string iniPath; if (!string.IsNullOrEmpty(iniPath = EditorUtility.OpenFilePanel("Select ini file", rootPath, "ini"))) { data.ImportLegacyIni(new IniParser.FileIniDataParser().ReadFile(iniPath)); } } else if (GUILayout.Button("Merge presets")) { string path; if (!string.IsNullOrEmpty(path = EditorUtility.OpenFilePanel("Select preset file", rootPath, "json"))) { data.LoadPresets(path, true); } } else if (GUILayout.Button("Export localization table")) { string path; if (!string.IsNullOrEmpty(path = EditorUtility.OpenFolderPanel("Select a folder", textPath, ""))) { MakeTextDatabase(Path.Combine(path, string.Format("mod_{0}.txt", modName))); } } EditorGUILayout.Space(); }); if (data == null) { return; } float areaWidth = 5 * position.width / 8; GUILayoutHelper.Area(new Rect(position.width - areaWidth, 0, areaWidth, position.height), () => { EditorGUILayout.Space(); if (data.Presets.Count > 0 && presets.index != -1) { if (GUILayout.SelectionGrid(IsPreset ? 1 : 0, new string[] { "Defaults", data.Presets[presets.index].Title }, 2) == 0) { if (IsPreset) { LoadPreset(-1); } } else { if (currentPreset != presets.index) { LoadPreset(presets.index); } } } mainScrollPosition = GUILayoutHelper.ScrollView(mainScrollPosition, () => { sections.DoLayoutList(); duplicateSections = duplicateKeys = false; var sectionNames = new List <string>(); foreach (var section in data.Sections) { section.Name = !string.IsNullOrEmpty(section.Name) ? section.Name.Replace(" ", string.Empty) : GetUniqueName(sectionNames, "Section"); sectionNames.Add(section.Name); var keyNames = new List <string>(); foreach (var key in section.Keys) { key.Name = !string.IsNullOrEmpty(key.Name) ? key.Name.Replace(" ", string.Empty) : GetUniqueName(keyNames, "Key"); keyNames.Add(key.Name); } duplicateKeys |= DuplicatesDetected(keyNames); this.keyNames.Add(keyNames); } this.sectionNames = sectionNames; duplicateSections |= DuplicatesDetected(sectionNames); }); GUILayout.FlexibleSpace(); EditorGUILayout.Space(); }); }); }
void OnEnable() { if (!EditorGUIUtility.isProSkin) { logo = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Eye Controller/Light/EyeController_logo.png"); } else { logo = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Eye Controller/Dark/EyeController_logo.png"); } myTarget = (EyeController)target; blendSystemNumber = BlendSystemEditor.FindBlendSystems(myTarget); boneUpdateAnimation = serializedObject.FindProperty("boneUpdateAnimation"); blinkingEnabled = serializedObject.FindProperty("blinkingEnabled"); blinkingControlMode = serializedObject.FindProperty("blinkingControlMode"); leftEyeBlinkBlendshape = serializedObject.FindProperty("leftEyeBlinkBlendable"); rightEyeBlinkBlendshape = serializedObject.FindProperty("rightEyeBlinkBlendable"); minimumBlinkGap = serializedObject.FindProperty("minimumBlinkGap"); maximumBlinkGap = serializedObject.FindProperty("maximumBlinkGap"); blinkDuration = serializedObject.FindProperty("blinkDuration"); leftEyeLookAtBone = serializedObject.FindProperty("leftEyeLookAtBone"); rightEyeLookAtBone = serializedObject.FindProperty("rightEyeLookAtBone"); eyeRotationRangeX = serializedObject.FindProperty("eyeRotationRangeX"); eyeRotationRangeY = serializedObject.FindProperty("eyeRotationRangeY"); eyeLookOffset = serializedObject.FindProperty("eyeLookOffset"); eyeForwardAxis = serializedObject.FindProperty("eyeForwardAxis"); eyeTurnSpeed = serializedObject.FindProperty("eyeTurnSpeed"); randomLookingEnabled = serializedObject.FindProperty("randomLookingEnabled"); lookingControlMode = serializedObject.FindProperty("lookingControlMode"); minimumChangeDirectionGap = serializedObject.FindProperty("minimumChangeDirectionGap"); maximumChangeDirectionGap = serializedObject.FindProperty("maximumChangeDirectionGap"); targetEnabled = serializedObject.FindProperty("targetEnabled"); viewTarget = serializedObject.FindProperty("viewTarget"); targetWeight = serializedObject.FindProperty("targetWeight"); autoTarget = serializedObject.FindProperty("autoTarget"); autoTargetTag = serializedObject.FindProperty("autoTargetTag"); autoTargetDistance = serializedObject.FindProperty("autoTargetDistance"); showBlinking = new AnimBool(myTarget.blinkingEnabled, Repaint); showRandomLook = new AnimBool(myTarget.randomLookingEnabled, Repaint); showLookTarget = new AnimBool(myTarget.targetEnabled, Repaint); showAutoTarget = new AnimBool(myTarget.autoTarget, Repaint); showLookShared = new AnimBool(myTarget.randomLookingEnabled || myTarget.targetEnabled, Repaint); showBlinkingClassicControl = new AnimBool(myTarget.blinkingControlMode == EyeController.ControlMode.Classic, Repaint); showLookingClassicControl = new AnimBool(myTarget.lookingControlMode == EyeController.ControlMode.Classic, Repaint); if (myTarget.blendSystem != null) { if (myTarget.blendSystem.isReady) { myTarget.blendSystem.onBlendablesChanged += GetBlendShapes; GetBlendShapes(); BlendSystemEditor.GetBlendSystemButtons(myTarget.blendSystem); } } }
/// <summary> /// Load textures from Resources folder. /// </summary> private void loadTextures() { string dir = "Cinema Suite/Cinema Director/"; string suffix = EditorGUIUtility.isProSkin ? "_Light" : "_Dark"; string filetype_png = ".png"; string missing = " is missing from Resources folder."; settingsImage = EditorGUIUtility.Load(dir + SETTINGS_ICON + suffix + filetype_png) as Texture; if (settingsImage == null) { Debug.Log(SETTINGS_ICON + suffix + missing); } rescaleImage = EditorGUIUtility.Load(dir + HORIZONTAL_RESCALE_ICON + suffix + filetype_png) as Texture; if (rescaleImage == null) { Debug.Log(HORIZONTAL_RESCALE_ICON + suffix + missing); } zoomInImage = EditorGUIUtility.Load(dir + ZOOMIN_ICON + suffix + filetype_png) as Texture; if (zoomInImage == null) { Debug.Log(ZOOMIN_ICON + suffix + missing); } zoomOutImage = EditorGUIUtility.Load(dir + ZOOMOUT_ICON + suffix + filetype_png) as Texture; if (zoomOutImage == null) { Debug.Log(ZOOMOUT_ICON + suffix + missing); } snapImage = EditorGUIUtility.Load(dir + MAGNET_ICON + suffix + filetype_png) as Texture; if (snapImage == null) { Debug.Log(MAGNET_ICON + suffix + missing); } rollingEditImage = EditorGUIUtility.Load(dir + "Director_RollingIcon" + filetype_png) as Texture; if (rollingEditImage == null) { Debug.Log("Rolling edit icon missing from Resources folder."); } rippleEditImage = EditorGUIUtility.Load(dir + "Director_RippleIcon" + filetype_png) as Texture; if (rippleEditImage == null) { Debug.Log("Ripple edit icon missing from Resources folder."); } pickerImage = EditorGUIUtility.Load(dir + PICKER_ICON + suffix + filetype_png) as Texture; if (pickerImage == null) { Debug.Log(PICKER_ICON + suffix + missing); } refreshImage = EditorGUIUtility.Load(dir + REFRESH_ICON + suffix + filetype_png) as Texture; if (refreshImage == null) { Debug.Log(REFRESH_ICON + suffix + missing); } titleImage = EditorGUIUtility.Load(dir + TITLE_ICON + suffix + filetype_png) as Texture; if (titleImage == null) { Debug.Log(TITLE_ICON + suffix + missing); } cropImage = EditorGUIUtility.Load(dir + "Director_Resize_Crop" + suffix + filetype_png) as Texture; if (cropImage == null) { Debug.Log("Director_Resize_Crop" + suffix + missing); } scaleImage = EditorGUIUtility.Load(dir + "Director_Resize_Scale" + suffix + filetype_png) as Texture; if (scaleImage == null) { Debug.Log("Director_Resize_Crop" + suffix + missing); } }
void LoadWindow() { rootVisualElement.Clear(); var mainTemplate = EditorGUIUtility.Load(k_ServicesWindowUxmlPath) as VisualTreeAsset; rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight); mainTemplate.CloneTree(rootVisualElement, new Dictionary <string, VisualElement>(), null); notificationSubscriber = new UIElementsNotificationSubscriber(rootVisualElement); notificationSubscriber.Subscribe( Notification.Topic.AdsService, Notification.Topic.AnalyticsService, Notification.Topic.BuildService, Notification.Topic.CollabService, Notification.Topic.CoppaCompliance, Notification.Topic.CrashService, Notification.Topic.ProjectBind, Notification.Topic.PurchasingService ); rootVisualElement.Q <Button>(k_ProjectSettingsBtnName).clicked += () => { ServicesUtils.OpenServicesProjectSettings(GeneralProjectSettings.generalProjectSettingsPath, typeof(GeneralProjectSettings).Name); }; var dashboardClickable = new Clickable(() => { if (!ServicesConfiguration.instance.pathsReady) { NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Error, L10n.Tr(k_ConnectionFailedMessage)); } else if (UnityConnect.instance.projectInfo.projectBound) { ServicesConfiguration.instance.RequestBaseDashboardUrl(baseDashboardUrl => { EditorAnalytics.SendOpenDashboardForService(new ServicesProjectSettings.OpenDashboardForService() { serviceName = k_WindowTitle, url = baseDashboardUrl, organizationId = UnityConnect.instance.projectInfo.organizationId, projectId = UnityConnect.instance.projectInfo.projectId }); ServicesConfiguration.instance.RequestCurrentProjectDashboardUrl(currentProjectDashboardUrl => { Application.OpenURL(currentProjectDashboardUrl); }); }); } else { NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Warning, L10n.Tr(k_ProjectNotBoundMessage)); ServicesUtils.OpenServicesProjectSettings(GeneralProjectSettings.generalProjectSettingsPath, typeof(GeneralProjectSettings).Name); } }); rootVisualElement.Q(k_DashboardLinkName).AddManipulator(dashboardClickable); m_SortedServices = new SortedList <string, SingleService>(); bool needProjectListOfPackage = false; foreach (var service in ServicesRepository.GetServices()) { m_SortedServices.Add(service.title, service); if (service.isPackage && service.packageId != null) { needProjectListOfPackage = true; } } // Only launch the listing if a service really needs the packages list... m_PackageCollection = null; if (needProjectListOfPackage) { m_ListRequestOfPackage = Client.List(); EditorApplication.update += ListingCurrentPackageProgress; } else { FinalizeServiceSetup(); } }
public void OnDrawGizmos(bool isChallengeSelected) { if (frustumHeightByMonsterId == null) { frustumHeightByMonsterId = new Dictionary <string, float>(); frustumHeightByMonsterId["1100"] = 3; frustumHeightByMonsterId["4003"] = 3; frustumHeightByMonsterId["4004"] = 2; frustumHeightByMonsterId["4005"] = 2; frustumHeightByMonsterId["4006"] = 2; frustumHeightByMonsterId["4007"] = 1; frustumHeightByMonsterId["40010"] = 4; } if (textureByMonsterId == null) { textureByMonsterId = new Dictionary <string, Texture>(); } CharacterId characterId; try { characterId = new CharacterId(monsterId); } catch (Exception e) { DLog.LogError(e); characterId = new CharacterId(1, 1); } Texture icon; bool found = textureByMonsterId.TryGetValue(characterId.ToString(), out icon); if (!found) { string pathToIcon = string.Format(Config.characterIconPathFormat, characterId.GroupId, characterId.SubId); icon = EditorGUIUtility.Load(pathToIcon) as Texture; textureByMonsterId[characterId.StringValue] = icon; } // Gizmos.DrawIcon((Vector3) ShowWorldPosition() + Vector3.up * 3.25f, pathToIcon, true); if (icon) { Gizmos.DrawGUITexture( new Rect(ShowWorldPosition() + new Vector3(-3.25f, 6), new Vector2(6, -6)), icon ); } float height = 4; float newHeight = height; if (frustumHeightByMonsterId.TryGetValue(characterId.GroupId.ToString(), out newHeight)) { height = newHeight; } Gizmos.color = Color.red; Matrix4x4 originalMatrix = Gizmos.matrix; Matrix4x4 rotationMatrix = Matrix4x4.Rotate(Quaternion.LookRotation(Vector3.up, Vector3.up)); Matrix4x4 translationMatrix = Matrix4x4.Translate(ShowWorldPosition() + Vector3.up * height); Gizmos.matrix = Matrix4x4.identity * translationMatrix * rotationMatrix; Gizmos.DrawFrustum(Vector3.zero, 45, 1, 0, 1); Gizmos.matrix = originalMatrix; if (!isChallengeSelected) { return; } Gizmos.color = Color.green; Vector2 rectDimension = new Vector2(xAxisAmplitude, .5f); RectPivotPosition rpp = new RectPivotPosition(RectPivotPosition.PivotType.Center, Vector2.zero, rectDimension); Vector2 offset = rpp.RelativePositionOfPivotAt(RectPivotPosition.PivotType.BottomLeft); Gizmos.DrawCube( ShowWorldPosition() + new Vector3(offset.x * -1, offset.y), rectDimension ); }
public override void EnterState() { //If we haven't received new bound info, fetch them var generalTemplate = EditorGUIUtility.Load(k_CollaborateEnabledUxmlPath) as VisualTreeAsset; var scrollContainer = provider.rootVisualElement.Q(null, k_ServiceScrollContainerClassName); var newVisual = generalTemplate.CloneTree().contentContainer; ServicesUtils.TranslateStringsInTree(newVisual); scrollContainer.Clear(); scrollContainer.Add(newVisual); m_CollabPublishSection = scrollContainer.Q(k_CollabPublishSection); m_CollabHistorySection = scrollContainer.Q(k_CollabHistorySection); // Don't show the Publish and History section by default if (m_CollabHistorySection != null) { m_CollabHistorySection.style.display = DisplayStyle.None; } if (m_CollabPublishSection != null) { m_CollabPublishSection.style.display = DisplayStyle.None; } var openHistory = provider.rootVisualElement.Q(k_OpenHistoryLink) as Button; if (openHistory != null) { openHistory.clicked += () => { if (Collab.ShowHistoryWindow != null) { Collab.ShowHistoryWindow(); } }; } Button openToolbarLinkBtn = provider.rootVisualElement.Q(k_OpenToolbarLink) as Button; if (openToolbarLinkBtn != null) { openToolbarLinkBtn.clicked += () => { Toolbar.requestShowCollabToolbar = true; if (Toolbar.get) { Toolbar.get.Repaint(); } }; } var gotoWebDashboard = scrollContainer.Q(k_GoToWebDashboardLink); if (gotoWebDashboard != null) { var clickable = new Clickable(() => { ServicesConfiguration.instance.RequestBaseCloudUsageDashboardUrl(baseCloudUsageDashboardUrl => { provider.OpenDashboardOrgAndProjectIds(baseCloudUsageDashboardUrl); }); }); gotoWebDashboard.AddManipulator(clickable); } // Prepare the package section and update the package information PreparePackageSection(scrollContainer); UpdatePackageInformation(); provider.HandlePermissionRestrictedControls(); }
public override int OnEditorWindow(Rect rect, HorizontalCallback horizontal, VerticalCallback vertical, Dictionary <string, object> cache) { if (optionsEditor == null) { optionsEditor = new ReorderableList(Options, typeof(string), true, true, true, true); optionsEditor.drawHeaderCallback = r => { EditorGUI.LabelField(r, "Options"); if (GUI.Button(new Rect(r.x + r.width - 30, r.y, 30, EditorGUIUtility.singleLineHeight), (Texture2D)EditorGUIUtility.Load("icons/SettingsIcon.png"), EditorStyles.toolbarButton)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy"), false, () => cache["options"] = Options); if (cache.ContainsKey("options")) { menu.AddItem(new GUIContent("Paste"), false, () => { optionsEditor.list = Options = ((List <string>)cache["options"]).ToList(); }); menu.AddItem(new GUIContent("Paste (linked)"), false, () => { optionsEditor.list = Options = (List <string>)cache["options"]; }); } menu.AddItem(new GUIContent("Unlink"), false, () => optionsEditor.list = Options = Options.ToList()); menu.ShowAsContext(); } }; optionsEditor.onAddCallback = x => x.list.Add(string.Empty); optionsEditor.drawElementCallback = (r, i, a, f) => optionsEditor.list[i] = EditorGUI.TextField(new Rect(r.x, r.y, r.width, EditorGUIUtility.singleLineHeight), (string)optionsEditor.list[i]); } vertical(rect, 1, (r) => Value = EditorGUI.Popup(r, "Selected", Value, Options.ToArray()), (r) => optionsEditor.DoList(r)); return(optionsEditor.count + 3); }
public static void Init() { { var t = new Texture2D(3, 3, TextureFormat.RGBA32, false); var arr = new Color32[t.width * t.height]; for (int i = 0; i < t.width * t.height; ++i) { arr[i] = new Color(0.3f, 0.5f, 1f, 0.5f); } t.SetPixels32(arr); t.Apply(); Styles.connectionTexture = t; } { Styles.background = new GUIStyle(); var t = new Texture2D(1, 1, TextureFormat.RGBA32, false); var arr = new Color32[t.width * t.height]; for (int i = 0; i < t.width * t.height; ++i) { arr[i] = new Color(0.17f, 0.17f, 0.17f, 1f); } t.SetPixels32(arr); t.Apply(); Styles.background.normal.background = t; } Styles.nodeStyle = new GUIStyle(); Styles.nodeStyle.normal.background = EditorStyles.miniButton.normal.scaledBackgrounds[0];//EditorGUIUtility.Load("builtin skins/darkskin/images/node1.png") as Texture2D; Styles.nodeStyle.border = new RectOffset(12, 12, 12, 12); Styles.nodeCustomStyle = new GUIStyle(); Styles.nodeCustomStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node0.png") as Texture2D; Styles.nodeCustomStyle.border = new RectOffset(12, 12, 12, 12); Styles.systemNode = new GUIStyle(); Styles.systemNode.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node2.png") as Texture2D; Styles.systemNode.border = new RectOffset(12, 12, 12, 12); Styles.measureLabelNormal = Color.green; Styles.measureLabelWarning = Color.yellow; Styles.measureLabelError = Color.red; Styles.containerCaption = new GUIStyle(EditorStyles.centeredGreyMiniLabel); Styles.containerCaption.alignment = TextAnchor.UpperCenter; Styles.nodeCaption = new GUIStyle(EditorStyles.label); Styles.nodeCaption.alignment = TextAnchor.LowerCenter; Styles.nodeCaption.padding = new RectOffset(0, 0, 0, 15); Styles.containerStyle = new GUIStyle(EditorStyles.helpBox); Styles.enterStyle = new GUIStyle(); Styles.enterStyle.normal.background = EditorStyles.miniButton.onNormal.scaledBackgrounds[0];//EditorGUIUtility.Load("builtin skins/darkskin/images/node5.png") as Texture2D; Styles.enterStyle.border = new RectOffset(12, 12, 12, 0); Styles.exitStyle = new GUIStyle(); Styles.exitStyle.normal.background = EditorStyles.miniButton.onNormal.scaledBackgrounds[0];//EditorGUIUtility.Load("builtin skins/darkskin/images/node5.png") as Texture2D; Styles.exitStyle.border = new RectOffset(12, 12, 0, 12); Styles.beginTickStyle = new GUIStyle(); Styles.beginTickStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node3.png") as Texture2D; Styles.beginTickStyle.border = new RectOffset(12, 12, 12, 12); Styles.endTickStyle = new GUIStyle(); Styles.endTickStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node4.png") as Texture2D; Styles.endTickStyle.border = new RectOffset(12, 12, 12, 12); if (Styles.fixedFontLabel == null) { Styles.fixedFontLabel = new GUIStyle(EditorStyles.miniLabel); string fontName; if (Application.platform == RuntimePlatform.WindowsEditor) { fontName = "Consolas"; } else { fontName = "Courier"; } Styles.CleanupFont(); Styles.fixedFont = Font.CreateDynamicFontFromOSFont(fontName, Styles.fixedFontLabel.fontSize); Styles.fixedFontLabel.richText = true; Styles.fixedFontLabel.font = Styles.fixedFont; Styles.fixedFontLabel.fontSize = Styles.fixedFontLabel.fontSize; Styles.measureLabel = new GUIStyle(Styles.fixedFontLabel); Styles.measureLabel.richText = true; Styles.measureLabel.padding = new RectOffset(0, 0, 15, 0); Styles.measureLabel.alignment = TextAnchor.UpperCenter; } //Styles.measureLabel = new GUIStyle(EditorStyles.miniBoldLabel); //Styles.measureLabel.richText = true; //Styles.measureLabel.padding = new RectOffset(0, 0, 15, 0); //Styles.measureLabel.alignment = TextAnchor.UpperCenter; }
void LoadResources() { searchIcon = EditorGUIUtility.Load("Assets/AssetFinder/Editor/search_icon.png") as Texture2D; cogIcon = EditorGUIUtility.Load("Assets/AssetFinder/Editor/cog_icon.png") as Texture2D; }
/// <summary> /// Preload icon /// </summary> void Preload() { m_default_tex = EditorGUIUtility.Load(Default_Icon_Path) as Texture2D; SetTexCacheDict(Sample_Icon_Root_Path, Sample_Icon_Extension, Button_Num); }
internal static PanelTextSettings GetDefaultPanelTextSettings() { return(EditorGUIUtility.Load(k_DefaultPanelTextSettingsPath) as PanelTextSettings); }
public override void OnInspectorGUI() { var load = serializedObject.FindProperty("LoadEvent"); var unload = serializedObject.FindProperty("UnloadEvent"); var tag = serializedObject.FindProperty("CollisionTag"); var banks = serializedObject.FindProperty("Banks"); var preload = serializedObject.FindProperty("PreloadSamples"); EditorGUILayout.PropertyField(load, new GUIContent("Load")); EditorGUILayout.PropertyField(unload, new GUIContent("Unload")); if ((load.enumValueIndex >= 3 && load.enumValueIndex <= 6) || (unload.enumValueIndex >= 3 && unload.enumValueIndex <= 6)) { tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue); } EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data")); //EditorGUILayout.PropertyField(banks); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Banks"); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Add Bank", GUILayout.ExpandWidth(false))) { banks.InsertArrayElementAtIndex(banks.arraySize); SerializedProperty newBank = banks.GetArrayElementAtIndex(banks.arraySize - 1); newBank.stringValue = ""; var browser = EventBrowser.CreateInstance <EventBrowser>(); #if UNITY_4_6 || UNITY_4_7 browser.title = "Select FMOD Bank"; #else browser.titleContent = new GUIContent("Select FMOD Bank"); #endif browser.SelectBank(newBank); browser.ShowUtility(); } Texture deleteTexture = EditorGUIUtility.Load("FMOD/Delete.png") as Texture; GUIContent deleteContent = new GUIContent(deleteTexture, "Delete Bank"); var buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.padding.top = buttonStyle.padding.bottom = 1; buttonStyle.margin.top = 2; buttonStyle.padding.left = buttonStyle.padding.right = 4; buttonStyle.fixedHeight = GUI.skin.textField.CalcSize(new GUIContent()).y; for (int i = 0; i < banks.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(banks.GetArrayElementAtIndex(i), GUIContent.none); if (GUILayout.Button(deleteContent, buttonStyle, GUILayout.ExpandWidth(false))) { banks.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); Event e = Event.current; if (e.type == EventType.dragPerform) { if (DragAndDrop.objectReferences.Length > 0 && DragAndDrop.objectReferences[0] != null && DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) { int pos = banks.arraySize; banks.InsertArrayElementAtIndex(pos); var pathProperty = banks.GetArrayElementAtIndex(pos); pathProperty.stringValue = ((EditorBankRef)DragAndDrop.objectReferences[0]).Name; e.Use(); } } if (e.type == EventType.DragUpdated) { if (DragAndDrop.objectReferences.Length > 0 && DragAndDrop.objectReferences[0] != null && DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.AcceptDrag(); e.Use(); } } serializedObject.ApplyModifiedProperties(); }
public static Object LoadResource(string pathName, System.Type type, bool lookForRetinaAssets) { Object resource = null; string hiResPath = string.Empty; lookForRetinaAssets &= (type == typeof(Texture2D)); bool assetIsRetinaTexture = false; if (lookForRetinaAssets) { string ext = Path.GetExtension(pathName); string fileRenamed = Path.GetFileNameWithoutExtension(pathName) + "@2x" + ext; hiResPath = Path.Combine(Path.GetDirectoryName(pathName), fileRenamed); lookForRetinaAssets = !string.IsNullOrEmpty(hiResPath); } if (lookForRetinaAssets) { resource = EditorGUIUtility.Load(hiResPath); assetIsRetinaTexture = (resource as Texture2D != null); } if (resource == null) { resource = EditorGUIUtility.Load(pathName); } if (resource == null && lookForRetinaAssets) { resource = Resources.Load(hiResPath, type); assetIsRetinaTexture = (resource as Texture2D != null); } if (resource == null) { resource = Resources.Load(pathName, type); } // This should be deprecated and removed. // Project asset paths should be resolved at import time. if (resource == null && lookForRetinaAssets) { resource = AssetDatabase.LoadMainAssetAtPath(hiResPath); assetIsRetinaTexture = (resource as Texture2D != null); } // This should be deprecated and removed. // Project asset paths should be resolved at import time. if (resource == null) { resource = AssetDatabase.LoadMainAssetAtPath(pathName); } if (assetIsRetinaTexture) { Texture2D tex = (Texture2D)resource; tex.pixelsPerPoint = 2.0f; } return(resource); }
public void Initialize(EditorWindow debuggerWindow, VisualElement root, DebuggerContext context) { base.Initialize(debuggerWindow); m_Root = root; m_Context = context; m_Context.onStateChange += OnContextChange; var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet; m_Root.styleSheets.Add(sheet); StyleSheet colorSheet; if (EditorGUIUtility.isProSkin) { colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet; } else { colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet; } m_Root.styleSheets.Add(colorSheet); m_Root.Add(m_Toolbar); m_PickToggle = new ToolbarToggle() { name = "pickToggle" }; m_PickToggle.text = "Pick Element"; m_PickToggle.RegisterValueChangedCallback((e) => { m_Context.pickElement = e.newValue; // On OSX, as focus-follow-mouse is not supported, // we explicitly focus the EditorWindow when enabling picking if (Application.platform == RuntimePlatform.OSXEditor) { Panel p = m_Context.selection.panel as Panel; if (p != null) { TryFocusCorrespondingWindow(p.ownerObject); } } }); m_Toolbar.Add(m_PickToggle); m_ShowLayoutToggle = new ToolbarToggle() { name = "layoutToggle" }; m_ShowLayoutToggle.text = "Show Layout"; m_ShowLayoutToggle.RegisterValueChangedCallback((e) => { m_Context.showLayoutBound = e.newValue; }); m_Toolbar.Add(m_ShowLayoutToggle); if (Unsupported.IsDeveloperBuild()) { m_RepaintOverlayToggle = new ToolbarToggle() { name = "repaintOverlayToggle" }; m_RepaintOverlayToggle.text = "Repaint Overlay"; m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_Context.showRepaintOverlay = e.newValue); m_Toolbar.Add(m_RepaintOverlayToggle); m_ShowDrawStatsToggle = new ToolbarToggle() { name = "drawStatsToggle" }; m_ShowDrawStatsToggle.text = "Draw Stats"; m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) => { m_Context.showDrawStats = e.newValue; }); m_Toolbar.Add(m_ShowDrawStatsToggle); } var splitter = new DebuggerSplitter(); m_Root.Add(splitter); m_TreeViewContainer = new DebuggerTreeView(m_Context.selection, SelectElement); m_TreeViewContainer.style.flexGrow = 1f; splitter.leftPane.Add(m_TreeViewContainer); m_StylesDebuggerContainer = new StylesDebugger(m_Context.selection); splitter.rightPane.Add(m_StylesDebuggerContainer); DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this; m_RepaintOverlay = new RepaintOverlayPainter(); m_PickOverlay = new HighlightOverlayPainter(); m_LayoutOverlay = new LayoutOverlayPainter(); OnContextChange(); }
void OnGUI() { if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) { // Brute force hack to stop us calling DLL functions while Unity is starting up // playing in editor mode and will cause us to leak system objects ShowNotification(new GUIContent("Playing In Editor Starting")); return; } if (!EventManager.IsValid) { ShowNotification(new GUIContent("No FMOD Studio banks loaded. Please check your settings.")); return; } if (Event.current.type == EventType.Layout) { RebuildDisplayFromCache(); } //if (eventStyle == null) { eventStyle = new GUIStyle(GUI.skin.button); eventStyle.normal.background = null; eventStyle.focused.background = null; eventStyle.active.background = null; eventStyle.onFocused.background = null; eventStyle.onNormal.background = null; eventStyle.onHover.background = null; eventStyle.onActive.background = null; eventStyle.stretchWidth = false; eventStyle.padding.left = 0; eventStyle.stretchHeight = false; eventStyle.fixedHeight = eventStyle.lineHeight + eventStyle.margin.top + eventStyle.margin.bottom; eventStyle.alignment = TextAnchor.MiddleLeft; eventIcon = EditorGUIUtility.Load("FMOD/EventIcon.png") as Texture; folderOpenIcon = EditorGUIUtility.Load("FMOD/FolderIconOpen.png") as Texture; folderClosedIcon = EditorGUIUtility.Load("FMOD/FolderIconClosed.png") as Texture; searchIcon = EditorGUIUtility.Load("FMOD/SearchIcon.png") as Texture; bankIcon = EditorGUIUtility.Load("FMOD/BankIcon.png") as Texture; snapshotIcon = EditorGUIUtility.Load("FMOD/SnapshotIcon.png") as Texture; borderIcon = EditorGUIUtility.Load("FMOD/Border.png") as Texture2D; } if (fromInspector) { var border = new GUIStyle(GUI.skin.box); border.normal.background = borderIcon; GUI.Box(new Rect(1, 1, position.width - 1, position.height - 1), GUIContent.none, border); } // Split the window int search box, tree view, preview pane (only if full browser) Rect searchRect, listRect, previewRect; SplitWindow(out searchRect, out listRect, out previewRect); // Scroll the selected item in the tree view - put above the search box otherwise it will take // our key presses if (selectedItem != null && Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.UpArrow) { if (selectedItem.Prev != null) { SetSelectedItem(selectedItem.Prev); // make sure it's visible if (selectedItem.Rect.y < treeScroll.y) { treeScroll.y = selectedItem.Rect.y; } } Event.current.Use(); } if (Event.current.keyCode == KeyCode.DownArrow) { if (selectedItem.Next != null) { SetSelectedItem(selectedItem.Next); // make sure it's visible if (selectedItem.Rect.y + selectedItem.Rect.height > treeScroll.y + listRect.height) { treeScroll.y += (selectedItem.Rect.y + selectedItem.Rect.height) - listRect.height; } } Event.current.Use(); } if (Event.current.keyCode == KeyCode.RightArrow) { selectedItem.Expanded = true; Event.current.Use(); } if (Event.current.keyCode == KeyCode.LeftArrow) { selectedItem.Expanded = false; Event.current.Use(); } } // Show the search box at the top GUILayout.BeginArea(searchRect); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(searchIcon), GUILayout.ExpandWidth(false)); GUI.SetNextControlName("SearchBox"); searchString = EditorGUILayout.TextField(searchString); GUILayout.EndHorizontal(); GUILayout.EndArea(); if (fromInspector) { EditorGUI.FocusTextInControl("SearchBox"); if (selectedItem != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return && !(selectedItem.EventRef == null && selectedItem.BankRef == null)) { Event.current.Use(); if (selectedItem.EventRef != null) { outputProperty.stringValue = ""; outputProperty.stringValue = selectedItem.EventRef.Path; EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, selectedItem.EventRef.Path); } else { outputProperty.stringValue = selectedItem.BankRef.Name; } outputProperty.serializedObject.ApplyModifiedProperties(); Close(); } if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape) { Close(); } } // Show the tree view Predicate <TreeItem> searchFilter = null; searchFilter = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) || x.Children.Exists(searchFilter)); // Check if our selected item still matches the search string if (selectedItem != null && !String.IsNullOrEmpty(searchString) && selectedItem.Children.Count == 0) { Predicate <TreeItem> containsSelected = null; containsSelected = (x) => (x == selectedItem || x.Children.Exists(containsSelected)); Predicate <TreeItem> matchForSelected = null; matchForSelected = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) && (x == selectedItem || x.Children.Exists(containsSelected))) || x.Children.Exists(matchForSelected); if (!treeItems.Exists(matchForSelected)) { SetSelectedItem(null); } } GUILayout.BeginArea(listRect); treeScroll = GUILayout.BeginScrollView(treeScroll, GUILayout.ExpandHeight(true)); lastDrawnItem = null; itemCount = 0; if (showEvents) { treeItems[(int)TreeType.Events].Expanded = fromInspector ? true : treeItems[(int)TreeType.Events].Expanded; ShowEventFolder(treeItems[(int)TreeType.Events], searchFilter); ShowEventFolder(treeItems[(int)TreeType.Snapshots], searchFilter); } if (showBanks) { treeItems[(int)TreeType.Banks].Expanded = fromInspector ? true : treeItems[(int)TreeType.Banks].Expanded; ShowEventFolder(treeItems[(int)TreeType.Banks], searchFilter); } if (showParameters) { treeItems[(int)TreeType.GlobalParameters].Expanded = fromInspector ? true : treeItems[(int)TreeType.GlobalParameters].Expanded; ShowEventFolder(treeItems[(int)TreeType.GlobalParameters], searchFilter); } GUILayout.EndScrollView(); GUILayout.EndArea(); // If the standalone event browser show a preview of the selected item if (!fromInspector) { GUI.Box(previewRect, GUIContent.none); if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("event:")) { PreviewEvent(previewRect, selectedItem.EventRef); } if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("snapshot:")) { PreviewSnapshot(previewRect, selectedItem.EventRef); } if (selectedItem != null && selectedItem.BankRef != null) { PreviewBank(previewRect, selectedItem.BankRef); } if (selectedItem != null && selectedItem.ParamRef != null) { PreviewParameter(previewRect, selectedItem.ParamRef); } } }
/// <summary> /// Spools the events and loads the timeline control /// </summary> protected void OnEnable() { EditorApplication.update = (EditorApplication.CallbackFunction)System.Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.DirectorUpdate)); EditorApplication.playmodeStateChanged = (EditorApplication.CallbackFunction)System.Delegate.Combine(EditorApplication.playmodeStateChanged, new EditorApplication.CallbackFunction(this.PlaymodeStateChanged)); //TODO: Depricated in 2017.2 GUISkin skin = ScriptableObject.CreateInstance <GUISkin>(); skin = (EditorGUIUtility.isProSkin) ? EditorGUIUtility.Load("Cinema Suite/Cinema Director/" + PRO_SKIN + ".guiskin") as GUISkin : EditorGUIUtility.Load("Cinema Suite/Cinema Director/" + FREE_SKIN + ".guiskin") as GUISkin; loadTextures(); #if UNITY_5 && !UNITY_5_0 || UNITY_2017_1_OR_NEWER base.titleContent = new GUIContent(TITLE, titleImage); #else base.title = TITLE; #endif directorControl = new DirectorControl(); directorControl.OnLoad(skin); directorControl.PlayCutscene += directorControl_PlayCutscene; directorControl.PauseCutscene += directorControl_PauseCutscene; directorControl.StopCutscene += directorControl_StopCutscene; directorControl.ScrubCutscene += directorControl_ScrubCutscene; directorControl.SetCutsceneTime += directorControl_SetCutsceneTime; directorControl.EnterPreviewMode += directorControl_EnterPreviewMode; directorControl.ExitPreviewMode += directorControl_ExitPreviewMode; directorControl.DragPerformed += directorControl_DragPerformed; isSnappingEnabled = directorControl.IsSnappingEnabled; directorControl.RepaintRequest += directorControl_RepaintRequest; previousTime = DateTime.Now; accumulatedTime = 0; int instanceId = -1; if (EditorPrefs.HasKey("DirectorControl.CutsceneID")) { instanceId = EditorPrefs.GetInt("DirectorControl.CutsceneID"); } if (instanceId >= 0) { Cutscene[] cutscenes = GameObject.FindObjectsOfType <Cutscene>(); for (int i = 0; i < cutscenes.Length; i++) { if (cutscenes[i].GetInstanceID() == instanceId) { cutscene = cutscenes[i]; } } } LoadSettings(); }
void SetupChannelSettings(Material material) { if (m_texIconVisible == null) { m_texIconVisible = (Texture2D)EditorGUIUtility.Load( EditorGUIUtility.isProSkin ? GetAppropriateIcon("d_scenevis_visible_hover") : GetAppropriateIcon("scenevis_visible_hover")); } if (m_texIconInvisible == null) { m_texIconInvisible = (Texture2D)EditorGUIUtility.Load( EditorGUIUtility.isProSkin ? GetAppropriateIcon("d_SceneViewVisibility") : GetAppropriateIcon("scenevis_hidden_hover")); } if (m_ToggleStyle == null) { m_ToggleStyle = new GUIStyle(EditorStyles.toggle); m_ToggleStyle.normal.background = m_texIconInvisible; m_ToggleStyle.normal.scaledBackgrounds = new Texture2D[] { m_texIconInvisible }; m_ToggleStyle.onNormal.background = m_texIconVisible; m_ToggleStyle.onNormal.scaledBackgrounds = new Texture2D[] { m_texIconVisible }; m_ToggleStyle.active.background = m_texIconInvisible; m_ToggleStyle.active.scaledBackgrounds = new Texture2D[] { m_texIconInvisible }; m_ToggleStyle.onActive.background = m_texIconVisible; m_ToggleStyle.onActive.scaledBackgrounds = new Texture2D[] { m_texIconVisible }; m_ToggleStyle.focused.background = m_texIconInvisible; m_ToggleStyle.focused.scaledBackgrounds = new Texture2D[] { m_texIconInvisible }; m_ToggleStyle.onFocused.background = m_texIconVisible; m_ToggleStyle.onFocused.scaledBackgrounds = new Texture2D[] { m_texIconVisible }; m_ToggleStyle.hover.background = m_texIconInvisible; m_ToggleStyle.hover.scaledBackgrounds = new Texture2D[] { m_texIconInvisible }; m_ToggleStyle.onHover.background = m_texIconVisible; m_ToggleStyle.onHover.scaledBackgrounds = new Texture2D[] { m_texIconVisible }; } if (m_channelNames == null) { m_channelNames = new List <string>(); m_channelNames.Add(_ChannelEnum.BaseColor.ToString()); m_channelNames.Add(_ChannelEnum.FirstShade.ToString()); m_channelNames.Add(_ChannelEnum.SecondShade.ToString()); m_channelNames.Add(_ChannelEnum.Highlight.ToString()); m_channelNames.Add(_ChannelEnum.AngelRing.ToString()); m_channelNames.Add(_ChannelEnum.RimLight.ToString()); m_channelNames.Add(_ChannelEnum.Outline.ToString()); } if (m_clippingMatte == null) { m_clippingMatte = new List <string>(); m_clippingMatte.Add("None"); m_clippingMatte.Add(_ChannelEnum.BaseColor.ToString()); m_clippingMatte.Add(_ChannelEnum.FirstShade.ToString()); m_clippingMatte.Add(_ChannelEnum.SecondShade.ToString()); m_clippingMatte.Add(_ChannelEnum.Highlight.ToString()); m_clippingMatte.Add(_ChannelEnum.AngelRing.ToString()); } if (m_colorPickerContent == null) { m_colorPickerContent = new GUIContent(string.Empty); } const int toggleWholeWidth = 170; const int toggleWidth = 20; if (m_channelMaskReorderableList == null) { m_channelMaskReorderableList = new ReorderableList(m_channelNames, typeof(string)); m_channelMaskReorderableList.displayAdd = false; m_channelMaskReorderableList.displayRemove = false; m_channelMaskReorderableList.draggable = false; m_channelMaskReorderableList.drawHeaderCallback = rect => { using (new EditorGUI.DisabledScope(m_selectedIndex != 0)) { Rect fieldRect = rect; Rect toggleRect = rect; fieldRect.width = rect.width - toggleWholeWidth; EditorGUI.LabelField(fieldRect, "Channel Mask Setting"); const string propCompositorMaskMode = "_ComposerMaskMode"; toggleRect.width = toggleWholeWidth; toggleRect.x += fieldRect.width; bool isVisible = material.GetFloat(propCompositorMaskMode) > 0.0f; EditorGUI.BeginChangeCheck(); var store = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = toggleWholeWidth - toggleWidth; isVisible = EditorGUI.Toggle(toggleRect, m_strCompositoerMaskSetting, isVisible); EditorGUIUtility.labelWidth = store; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(material, "Compositor mask setting is changed."); material.SetFloat(propCompositorMaskMode, isVisible ? 1.0f : 0.0f); } } }; m_channelMaskReorderableList.drawElementCallback = (rect_, index, isActive, isFocused) => { Rect toggleRectVislble = new Rect(rect_) { height = 16, width = 16, x = rect_.x + 6, y = rect_.y }; Rect toggleRectOverride = new Rect(rect_) { height = 16, width = 16, x = rect_.x + 6 + 22, y = rect_.y }; Rect colorPickerRect = new Rect(rect_) { height = 16, width = 16, x = rect_.x + 6 + 22 * 2, y = rect_.y }; Rect nameRect = new Rect(rect_) { height = 16, width = 120, x = rect_.x + 6 + 22 * 3, y = rect_.y }; using (new EditorGUI.DisabledScope(m_selectedIndex != 0)) { string propNameVisible = "_" + m_channelNames[index].ToString() + "Visible"; string propNameOverriden = "_" + m_channelNames[index].ToString() + "Overridden"; string propNameColor = "_" + m_channelNames[index].ToString() + "MaskColor"; bool isVisible = material.GetFloat(propNameVisible) > 0.0f; EditorGUI.BeginChangeCheck(); isVisible = EditorGUI.Toggle(toggleRectVislble, isVisible, m_ToggleStyle); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(material, "Layer visiblity is changed"); material.SetFloat(propNameVisible, isVisible ? 1.0f : 0.0f); } using (new EditorGUI.DisabledScope(isVisible == false)) { EditorGUI.BeginChangeCheck(); bool toggleOverride = material.GetFloat(propNameOverriden) > 0.0f; toggleOverride = EditorGUI.Toggle(toggleRectOverride, toggleOverride); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(material, "Layer mask is changed"); material.SetFloat(propNameOverriden, toggleOverride ? 1.0f : 0.0f); } Color color = material.GetColor(propNameColor); //color *= toggleOverride == false ? 0.5f : 1.0f; if (m_selectedIndex == 0) { EditorGUI.BeginChangeCheck(); color = EditorGUI.ColorField(colorPickerRect, m_colorPickerContent, color, false, true, false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(material, "Layer mask color is changed"); material.SetColor(propNameColor, color); } } EditorGUI.LabelField(nameRect, m_channelNames[index]); } } }; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Texture browseIcon = EditorGUIUtility.Load("FMOD/SearchIconBlack.png") as Texture; Texture openIcon = EditorGUIUtility.Load("FMOD/BrowserIcon.png") as Texture; Texture addIcon = EditorGUIUtility.Load("FMOD/AddIcon.png") as Texture; label = EditorGUI.BeginProperty(position, label, property); SerializedProperty pathProperty = property; Event e = Event.current; if (e.type == EventType.DragPerform && position.Contains(e.mousePosition)) { if (DragAndDrop.objectReferences.Length > 0 && DragAndDrop.objectReferences[0] != null && DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef)) { pathProperty.stringValue = ((EditorEventRef)DragAndDrop.objectReferences[0]).Path; GUI.changed = true; e.Use(); } } if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition)) { if (DragAndDrop.objectReferences.Length > 0 && DragAndDrop.objectReferences[0] != null && DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef)) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.AcceptDrag(); e.Use(); } } float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.padding.top = 1; buttonStyle.padding.bottom = 1; Rect addRect = new Rect(position.x + position.width - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight); Rect openRect = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight); Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight); Rect pathRect = new Rect(position.x, position.y, searchRect.x - position.x - 3, baseHeight); EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none); if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle)) { var eventBrowser = ScriptableObject.CreateInstance <EventBrowser>(); eventBrowser.ChooseEvent(property); var windowRect = position; windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); windowRect.height = openRect.height + 1; eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400)); } if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle)) { var addDropdown = EditorWindow.CreateInstance <CreateEventPopup>(); addDropdown.SelectEvent(property); var windowRect = position; windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); windowRect.height = openRect.height + 1; addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500)); } if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle) && !string.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null ) { EventBrowser.ShowWindow(); EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>(); eventBrowser.FrameEvent(pathProperty.stringValue); } if (!string.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null) { Rect foldoutRect = new Rect(position.x + 10, position.y + baseHeight, position.width, baseHeight); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "Event Properties"); if (property.isExpanded) { var style = new GUIStyle(GUI.skin.label); style.richText = true; EditorEventRef eventRef = EventManager.EventFromPath(pathProperty.stringValue); float width = style.CalcSize(new GUIContent("<b>Oneshot</b>")).x; Rect labelRect = new Rect(position.x, position.y + baseHeight * 2, width, baseHeight); Rect valueRect = new Rect(position.x + width + 10, position.y + baseHeight * 2, pathRect.width, baseHeight); if (pathProperty.stringValue.StartsWith("{")) { GUI.Label(labelRect, new GUIContent("<b>Path</b>"), style); EditorGUI.SelectableLabel(valueRect, eventRef.Path); } else { GUI.Label(labelRect, new GUIContent("<b>GUID</b>"), style); EditorGUI.SelectableLabel(valueRect, eventRef.Guid.ToString("b")); } labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("<b>Banks</b>"), style); GUI.Label(valueRect, string.Join(", ", eventRef.Banks.Select(x => x.Name).ToArray())); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("<b>Panning</b>"), style); GUI.Label(valueRect, eventRef.Is3D ? "3D" : "2D"); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("<b>Stream</b>"), style); GUI.Label(valueRect, eventRef.IsStream.ToString()); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("<b>Oneshot</b>"), style); GUI.Label(valueRect, eventRef.IsOneShot.ToString()); labelRect.y += baseHeight; valueRect.y += baseHeight; } } else { Rect labelRect = new Rect(position.x, position.y + baseHeight, position.width, baseHeight); GUI.Label(labelRect, new GUIContent("Event Not Found", EditorGUIUtility.Load("FMOD/NotFound.png") as Texture2D)); } EditorGUI.EndProperty(); }