Miscellaneous helper stuff for EditorGUI.
void OnEnable() { #if UNITY_2018_3_OR_NEWER if (m_ConsoleAttachToPlayerState == null) { m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this); } #endif MakeSureConsoleAlwaysOnlyOne(); titleContent = EditorGUIUtility.TextContentWithIcon("Console", "UnityEditor.ConsoleWindow"); titleContent = new GUIContent(titleContent) { text = "ConsoleT" }; ms_ConsoleWindow = this; #if UNITY_2018_1_OR_NEWER m_DevBuild = Unsupported.IsDeveloperMode(); #else m_DevBuild = Unsupported.IsDeveloperBuild(); #endif LogEntries.wrapped.searchHistory = m_SearchHistory; Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2); Application.logMessageReceived += DoLogChanged; }
public void AddItemsToMenu(GenericMenu menu) { if (Application.platform == RuntimePlatform.OSXEditor) { menu.AddItem(EditorGUIUtility.TextContent("Open Player Log"), false, UnityEditorInternal.InternalEditorUtility.OpenPlayerConsole); } menu.AddItem(EditorGUIUtility.TextContent("Open Editor Log"), false, UnityEditorInternal.InternalEditorUtility.OpenEditorConsole); menu.AddItem(EditorGUIUtility.TextContent("Export Console Log"), false, LogEntries.wrapped.ExportLog); #if UNITY_2018_1_OR_NEWER menu.AddItem(EditorGUIUtility.TrTextContent("Show Timestamp"), LogEntries.wrapped.showTimestamp, SetTimestamp); #endif #if UNITY_2017_3_OR_NEWER for (int i = 1; i <= 10; ++i) #else for (int i = 1; i <= 2; ++i) #endif { var lineString = i == 1 ? "Line" : "Lines"; menu.AddItem(new GUIContent(string.Format("Log Entry/{0} {1}", i, lineString)), i == Constants.LogStyleLineCount, SetLogLineCount, i); } AddStackTraceLoggingMenu(menu); }
static internal void LoadIcons() { if (ms_LoadedIcons) { return; } ms_LoadedIcons = true; iconInfo = EditorGUIUtility.LoadIcon("console.infoicon"); iconWarn = EditorGUIUtility.LoadIcon("console.warnicon"); iconError = EditorGUIUtility.LoadIcon("console.erroricon"); iconInfoSmall = EditorGUIUtility.LoadIcon("console.infoicon.sml"); iconWarnSmall = EditorGUIUtility.LoadIcon("console.warnicon.sml"); iconErrorSmall = EditorGUIUtility.LoadIcon("console.erroricon.sml"); iconFirstErrorSmall = EditorGUIUtility.LoadIcon("sv_icon_dot14_sml"); // TODO: Once we get the proper monochrome images put them here. /*iconInfoMono = EditorGUIUtility.LoadIcon("console.infoicon.mono"); * iconWarnMono = EditorGUIUtility.LoadIcon("console.warnicon.mono"); * iconErrorMono = EditorGUIUtility.LoadIcon("console.erroricon.mono");*/ iconInfoMono = EditorGUIUtility.LoadIcon("console.infoicon.sml"); iconWarnMono = EditorGUIUtility.LoadIcon("console.warnicon.inactive.sml"); iconErrorMono = EditorGUIUtility.LoadIcon("console.erroricon.inactive.sml"); iconFirstErrorMono = EditorGUIUtility.LoadIcon("sv_icon_dot8_sml"); iconCustomFiltersMono = EditorGUIUtility.LoadIcon("sv_icon_dot0_sml"); iconCustomFiltersSmalls = new Texture2D[7]; for (int i = 0; i < 7; i++) { iconCustomFiltersSmalls[i] = EditorGUIUtility.LoadIcon("sv_icon_dot" + (i + 1) + "_sml"); } Constants.Init(); }
private void AddStackTraceLoggingMenu(GenericMenu menu) { // TODO: Maybe remove this, because it basically duplicates UI in PlayerSettings foreach (LogType logType in Enum.GetValues(typeof(LogType))) { foreach (StackTraceLogType stackTraceLogType in Enum.GetValues(typeof(StackTraceLogType))) { StackTraceLogTypeData data; data.logType = logType; data.stackTraceLogType = stackTraceLogType; menu.AddItem(EditorGUIUtility.TextContent("Stack Trace Logging/" + logType + "/" + stackTraceLogType), PlayerSettings.GetStackTraceLogType(logType) == stackTraceLogType, ToggleLogStackTraces, data); } } int stackTraceLogTypeForAll = (int)PlayerSettings.GetStackTraceLogType(LogType.Log); foreach (LogType logType in Enum.GetValues(typeof(LogType))) { if (PlayerSettings.GetStackTraceLogType(logType) != (StackTraceLogType)stackTraceLogTypeForAll) { stackTraceLogTypeForAll = -1; break; } } foreach (StackTraceLogType stackTraceLogType in Enum.GetValues(typeof(StackTraceLogType))) { menu.AddItem(EditorGUIUtility.TextContent("Stack Trace Logging/All/" + stackTraceLogType), (StackTraceLogType)stackTraceLogTypeForAll == stackTraceLogType, ToggleLogStackTracesForAll, stackTraceLogType); } }
void SetActiveEntry(int selectedIndex) { m_ListViewMessage.row = -1; m_ListViewMessage.scrollPos.y = 0; if (selectedIndex != -1) { var instanceID = LogEntries.wrapped.SetSelectedEntry(selectedIndex); // ping object referred by the log entry if (m_ActiveInstanceID != instanceID) { m_ActiveInstanceID = instanceID; if (instanceID != 0) { EditorGUIUtility.PingObject(instanceID); } } } }
public static void Initialize() { LookDevResources.m_ZeroAmbientProbe.Clear(); if (LookDevResources.m_SkyboxMaterial == null) { LookDevResources.m_SkyboxMaterial = new Material(Shader.Find("Skybox/Cubemap")); } if (LookDevResources.m_ScreenQuadMesh == null) { LookDevResources.m_ScreenQuadMesh = new Mesh(); LookDevResources.m_ScreenQuadMesh.vertices = new Vector3[] { new Vector3(-1f, -1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, -1f, 0f), new Vector3(-1f, 1f, 0f) }; LookDevResources.m_ScreenQuadMesh.triangles = new int[] { 0, 1, 2, 1, 0, 3 }; } if (LookDevResources.m_GBufferPatchMaterial == null) { LookDevResources.m_GBufferPatchMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferWhitePatch.shader") as Shader); LookDevResources.m_DrawBallsMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferBalls.shader") as Shader); } if (LookDevResources.m_LookDevCompositing == null) { LookDevResources.m_LookDevCompositing = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCompositing.shader") as Shader); } if (LookDevResources.m_DeferredOverlayMaterial == null) { LookDevResources.m_DeferredOverlayMaterial = (EditorGUIUtility.LoadRequired("SceneView/SceneViewDeferredMaterial.mat") as Material); } if (LookDevResources.m_DefaultHDRI == null) { LookDevResources.m_DefaultHDRI = (EditorGUIUtility.Load("LookDevView/DefaultHDRI.exr") as Cubemap); if (LookDevResources.m_DefaultHDRI == null) { LookDevResources.m_DefaultHDRI = (EditorGUIUtility.Load("LookDevView/DefaultHDRI.asset") as Cubemap); } } if (LookDevResources.m_LookDevCubeToLatlong == null) { LookDevResources.m_LookDevCubeToLatlong = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCubeToLatlong.shader") as Shader); } if (LookDevResources.m_SelectionTexture == null) { LookDevResources.m_SelectionTexture = new RenderTexture(250, 125, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default); } if (LookDevResources.m_BrightestPointRT == null) { LookDevResources.m_BrightestPointRT = new RenderTexture(250, 125, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default); } if (LookDevResources.m_BrightestPointTexture == null) { LookDevResources.m_BrightestPointTexture = new Texture2D(250, 125, TextureFormat.RGBAHalf, false); } }
public static void Show(string publisher) { MetroCreateTestCertificateWindow[] windowArray = (MetroCreateTestCertificateWindow[])Resources.FindObjectsOfTypeAll(typeof(MetroCreateTestCertificateWindow)); MetroCreateTestCertificateWindow window = (windowArray.Length <= 0) ? ScriptableObject.CreateInstance <MetroCreateTestCertificateWindow>() : windowArray[0]; window.path = Path.Combine(Application.dataPath, "WSATestCertificate.pfx").Replace('\\', '/'); window.publisher = publisher; window.password = string.Empty; window.confirm = window.password; window.message = !File.Exists(window.path) ? GUIContent.none : EditorGUIUtility.TextContent("Current file will be overwritten."); window.messageStyle = new GUIStyle(GUI.skin.label); window.messageStyle.fontStyle = FontStyle.Italic; window.focus = "publisher"; if (windowArray.Length > 0) { window.Focus(); } else { window.titleContent = EditorGUIUtility.TextContent("Create Test Certificate for Windows Store"); window.position = new Rect(100f, 100f, 350f, 140f); window.minSize = new Vector2(window.position.width, window.position.height); window.maxSize = window.minSize; window.ShowUtility(); } }
public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo) { Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; bool result = false; Rect[] array = new Rect[events.Length]; Rect[] array2 = new Rect[events.Length]; int num = 1; int num2 = 0; for (int i = 0; i < events.Length; i++) { AnimationEvent animationEvent = events[i]; if (num2 == 0) { num = 1; while (i + num < events.Length && events[i + num].time == animationEvent.time) { num++; } num2 = num; } num2--; float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect)); int num4 = 0; if (num > 1) { float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(1f / this.m_Timeline.PixelDeltaToTime(rect) - (float)(image.width * 2))); num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2))); } Rect rect2 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height); array[i] = rect2; array2[i] = rect2; } this.m_EventRects = new Rect[array.Length]; for (int j = 0; j < array.Length; j++) { this.m_EventRects[j] = new Rect(array[j].x + rect.x, array[j].y + rect.y, array[j].width, array[j].height); } if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0) { this.m_EventsSelected = new bool[events.Length]; this.m_Events = null; } Vector2 zero = Vector2.zero; int num6; float num7; float num8; HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyle.none); if (highLevelEvent != HighLevelEvent.None) { switch (highLevelEvent) { case HighLevelEvent.ContextClick: { int num9 = this.m_EventsSelected.Count((bool selected) => selected); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, events[num6].time, num6, this.m_EventsSelected)); genericMenu.AddItem(new GUIContent((num9 <= 1) ? "Delete Animation Event" : "Delete Animation Events"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, events[num6].time, num6, this.m_EventsSelected)); genericMenu.ShowAsContext(); this.m_InstantTooltipText = null; break; } case HighLevelEvent.BeginDrag: EventManipulationHandler.m_EventsAtMouseDown = events; EventManipulationHandler.m_EventTimes = new float[events.Length]; for (int k = 0; k < events.Length; k++) { EventManipulationHandler.m_EventTimes[k] = events[k].time; } break; case HighLevelEvent.Drag: { for (int l = events.Length - 1; l >= 0; l--) { if (this.m_EventsSelected[l]) { AnimationEvent animationEvent2 = EventManipulationHandler.m_EventsAtMouseDown[l]; animationEvent2.time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[l] + zero.x / rect.width); } } int[] array3 = new int[this.m_EventsSelected.Length]; for (int m = 0; m < array3.Length; m++) { array3[m] = m; } Array.Sort(EventManipulationHandler.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer()); bool[] array4 = (bool[])this.m_EventsSelected.Clone(); float[] array5 = (float[])EventManipulationHandler.m_EventTimes.Clone(); for (int n = 0; n < array3.Length; n++) { this.m_EventsSelected[n] = array4[array3[n]]; EventManipulationHandler.m_EventTimes[n] = array5[array3[n]]; } events = EventManipulationHandler.m_EventsAtMouseDown; result = true; break; } case HighLevelEvent.Delete: result = this.DeleteEvents(ref events, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: this.EditEvents(clipInfo, this.m_EventsSelected); break; } } if (Event.current.type == EventType.ContextClick && rect.Contains(Event.current.mousePosition)) { Event.current.Use(); int num10 = this.m_EventsSelected.Count((bool selected) => selected); float time = Mathf.Max(this.m_Timeline.PixelToTime(Event.current.mousePosition.x, rect), 0f); GenericMenu genericMenu2 = new GenericMenu(); genericMenu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, time, -1, this.m_EventsSelected)); if (num10 > 0) { genericMenu2.AddItem(new GUIContent((num10 <= 1) ? "Delete Animation Event" : "Delete Animation Events"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, time, -1, this.m_EventsSelected)); } genericMenu2.ShowAsContext(); this.m_InstantTooltipText = null; } this.CheckRectsOnMouseMove(rect, events, array); return(result); }
void InitializeToolIcons() { if (s_ToolIcons != null) { return; } s_ToolIcons = new GUIContent[k_TransformToolCount * 2]; int index = 0; s_ToolIcons[index++] = EditorGUIUtility.TrIconContent("MoveTool", "Move Tool"); s_ToolIcons[index++] = EditorGUIUtility.TrIconContent("RotateTool", "Rotate Tool"); s_ToolIcons[index++] = EditorGUIUtility.TrIconContent("ScaleTool", "Scale Tool"); s_ToolIcons[index++] = EditorGUIUtility.TrIconContent("RectTool", "Rect Tool"); s_ToolIcons[index++] = EditorGUIUtility.TrIconContent("TransformTool", "Move, Rotate or Scale selected objects."); s_ToolIcons[index++] = EditorGUIUtility.TrTextContent("Editor tool"); s_ToolIcons[index++] = EditorGUIUtility.IconContent("MoveTool On"); s_ToolIcons[index++] = EditorGUIUtility.IconContent("RotateTool On"); s_ToolIcons[index++] = EditorGUIUtility.IconContent("ScaleTool On"); s_ToolIcons[index++] = EditorGUIUtility.IconContent("RectTool On"); s_ToolIcons[index++] = EditorGUIUtility.IconContent("TransformTool On"); s_ToolIcons[index] = EditorGUIUtility.TrTextContent("Editor tool"); s_CustomToolIcon = EditorGUIUtility.TrIconContent("CustomTool", "Available Custom Editor Tools"); index = 0; s_ToolControlNames = new string[k_ToolCount]; s_ToolControlNames[index++] = "ToolbarPersistentToolsPan"; s_ToolControlNames[index++] = "ToolbarPersistentToolsTranslate"; s_ToolControlNames[index++] = "ToolbarPersistentToolsRotate"; s_ToolControlNames[index++] = "ToolbarPersistentToolsScale"; s_ToolControlNames[index++] = "ToolbarPersistentToolsRect"; s_ToolControlNames[index++] = "ToolbarPersistentToolsTransform"; s_ToolControlNames[index] = "ToolbarPersistentToolsCustom"; s_ShownToolIcons = new GUIContent[k_ToolCount]; string viewToolsTooltipText = "Hand Tool"; s_ViewToolIcons = new GUIContent[] { EditorGUIUtility.TrIconContent("ViewToolOrbit", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolMove", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolZoom", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolOrbit", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolOrbit", "Orbit the Scene view."), EditorGUIUtility.TrIconContent("ViewToolOrbit On", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolMove On", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolZoom On", viewToolsTooltipText), EditorGUIUtility.TrIconContent("ViewToolOrbit On"), EditorGUIUtility.TrIconContent("ViewToolOrbit On", viewToolsTooltipText) }; s_ViewToolOnOffset = s_ViewToolIcons.Length / 2; s_LayerContent = EditorGUIUtility.TrTextContent("Layers", "Which layers are visible in the Scene views."); s_PlayIcons = new GUIContent[] { EditorGUIUtility.TrIconContent("PlayButton", "Play"), EditorGUIUtility.TrIconContent("PauseButton", "Pause"), EditorGUIUtility.TrIconContent("StepButton", "Step"), EditorGUIUtility.TrIconContent("PlayButtonProfile", "Profiler Play"), EditorGUIUtility.IconContent("PlayButton On"), EditorGUIUtility.IconContent("PauseButton On"), EditorGUIUtility.IconContent("StepButton On"), EditorGUIUtility.IconContent("PlayButtonProfile On") }; s_PreviewPackageContent = EditorGUIUtility.TrTextContent("Preview Packages in Use"); s_PreviewPackageIcon = EditorGUIUtility.TrIconContent("PreviewPackageInUse", "Preview Packages in Use"); s_CloudIcon = EditorGUIUtility.IconContent("CloudConnect"); s_AccountContent = EditorGUIUtility.TrTextContent("Account"); }
public override void OnGUI(Rect rect) { if (LayoutDropdownWindow.s_Styles == null) { LayoutDropdownWindow.s_Styles = new LayoutDropdownWindow.Styles(); } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { base.editorWindow.Close(); } GUI.Label(new Rect(rect.x + 5f, rect.y + 3f, rect.width - 10f, 16f), EditorGUIUtility.TrTextContent("Anchor Presets", null, null), EditorStyles.boldLabel); GUI.Label(new Rect(rect.x + 5f, rect.y + 3f + 16f, rect.width - 10f, 16f), EditorGUIUtility.TrTextContent("Shift: Also set pivot Alt: Also set position", null, null), EditorStyles.label); Color color = GUI.color; GUI.color = LayoutDropdownWindow.s_Styles.tableLineColor * color; GUI.DrawTexture(new Rect(0f, 37f, 400f, 1f), EditorGUIUtility.whiteTexture); GUI.color = color; GUI.BeginGroup(new Rect(rect.x, rect.y + 38f, rect.width, rect.height - 38f)); this.TableGUI(rect); GUI.EndGroup(); }
static Styles() { int[] numArray1 = new int[3]; numArray1[1] = 2; numArray1[2] = 1; reflectionProbeModeValues = numArray1; renderTextureSizesValues = new List <int>(); renderTextureSizes = new List <GUIContent>(); clearFlags = new GUIContent[] { new GUIContent("Skybox"), new GUIContent("Solid Color") }; clearFlagsValues = new int[] { 1, 2 }; toolContents = new GUIContent[] { EditorGUIUtility.IconContent("EditCollider"), EditorGUIUtility.IconContent("MoveTool", "|Move the selected objects.") }; sceneViewEditModes = new UnityEditorInternal.EditMode.SceneViewEditMode[] { UnityEditorInternal.EditMode.SceneViewEditMode.ReflectionProbeBox, UnityEditorInternal.EditMode.SceneViewEditMode.ReflectionProbeOrigin }; baseSceneEditingToolText = "<color=grey>Probe Scene Editing Mode:</color> "; toolNames = new GUIContent[] { new GUIContent(baseSceneEditingToolText + "Box Projection Bounds", ""), new GUIContent(baseSceneEditingToolText + "Probe Origin", "") }; commandStyle = "Command"; richTextMiniLabel.richText = true; renderTextureSizesValues.Clear(); renderTextureSizes.Clear(); int minBakedCubemapResolution = ReflectionProbe.minBakedCubemapResolution; do { renderTextureSizesValues.Add(minBakedCubemapResolution); renderTextureSizes.Add(new GUIContent(minBakedCubemapResolution.ToString())); minBakedCubemapResolution *= 2; }while (minBakedCubemapResolution <= ReflectionProbe.maxBakedCubemapResolution); }
static GameObject GetHumanoidFallback() { return((GameObject)EditorGUIUtility.Load("Avatar/DefaultAvatar.fbx")); }
public override void OnInspectorGUI() { base.serializedObject.Update(); Camera camera = (Camera)base.target; this.m_ShowBGColorOptions.target = (!this.m_ClearFlags.hasMultipleDifferentValues && (camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Skybox)); this.m_ShowOrthoOptions.target = (!this.m_Orthographic.hasMultipleDifferentValues && camera.orthographic); this.m_ShowTargetEyeOption.target = (this.m_TargetEye.intValue != 3 || PlayerSettings.virtualRealitySupported); EditorGUILayout.PropertyField(this.m_ClearFlags, new GUILayoutOption[0]); if (EditorGUILayout.BeginFadeGroup(this.m_ShowBGColorOptions.faded)) { EditorGUILayout.PropertyField(this.m_BackgroundColor, new GUIContent("Background", "Camera clears the screen to this color before rendering."), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]); EditorGUILayout.Space(); CameraEditor.ProjectionType projectionType = (!this.m_Orthographic.boolValue) ? CameraEditor.ProjectionType.Perspective : CameraEditor.ProjectionType.Orthographic; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_Orthographic.hasMultipleDifferentValues; projectionType = (CameraEditor.ProjectionType)EditorGUILayout.EnumPopup("Projection", projectionType, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_Orthographic.boolValue = (projectionType == CameraEditor.ProjectionType.Orthographic); } if (!this.m_Orthographic.hasMultipleDifferentValues) { if (EditorGUILayout.BeginFadeGroup(this.m_ShowOrthoOptions.faded)) { EditorGUILayout.PropertyField(this.m_OrthographicSize, new GUIContent("Size"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowOrthoOptions.faded)) { EditorGUILayout.Slider(this.m_FieldOfView, 1f, 179f, new GUIContent("Field of View"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarClippingPlanes, EditorGUI.s_NearAndFarLabels, 35f, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_NormalizedViewPortRect, this.m_ViewportLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_Depth, new GUILayoutOption[0]); EditorGUILayout.IntPopup(this.m_RenderingPath, CameraEditor.kCameraRenderPaths, CameraEditor.kCameraRenderPathValues, EditorGUIUtility.TempContent("Rendering Path"), new GUILayoutOption[0]); if (this.m_ShowOrthoOptions.target && this.wantDeferredRendering) { EditorGUILayout.HelpBox("Deferred rendering does not work with Orthographic camera, will use Forward.", MessageType.Warning, true); } EditorGUILayout.PropertyField(this.m_TargetTexture, new GUILayoutOption[0]); if (!this.m_TargetTexture.hasMultipleDifferentValues) { RenderTexture renderTexture = this.m_TargetTexture.objectReferenceValue as RenderTexture; if (renderTexture && renderTexture.antiAliasing > 1 && this.wantDeferredRendering) { EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true); } } EditorGUILayout.PropertyField(this.m_OcclusionCulling, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_HDR, EditorGUIUtility.TempContent("Allow HDR"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AllowMSAA, new GUILayoutOption[0]); this.DisplayCameraWarnings(); if (PlayerSettings.virtualRealitySupported) { EditorGUILayout.PropertyField(this.m_StereoSeparation, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_StereoConvergence, new GUILayoutOption[0]); } if (this.ShouldShowTargetDisplayProperty()) { int intValue = this.m_TargetDisplay.intValue; EditorGUILayout.Space(); EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]); if (intValue != this.m_TargetDisplay.intValue) { GameView.RepaintAll(); } } if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetEyeOption.faded)) { EditorGUILayout.IntPopup(this.m_TargetEye, CameraEditor.kTargetEyes, CameraEditor.kTargetEyeValues, EditorGUIUtility.TempContent("Target Eye"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); this.DepthTextureModeGUI(); this.CommandBufferGUI(); base.serializedObject.ApplyModifiedProperties(); }
static Styles() { editModeButton = EditorGUIUtility.IconContent("EditCollider"); }
static GameObject GetGenericAnimationFallback() { return((GameObject)EditorGUIUtility.Load("Avatar/DefaultGeneric.fbx")); }
private void DrawCurrentEvent(Rect rect, FrameDebuggerEvent[] descs) { int num = FrameDebuggerUtility.limit - 1; if (num < 0 || num >= descs.Length) { return; } GUILayout.BeginArea(rect); FrameDebuggerEvent frameDebuggerEvent = descs[num]; FrameDebuggerEventData frameDebuggerEventData; bool frameEventData = FrameDebuggerUtility.GetFrameEventData(num, out frameDebuggerEventData); if (frameEventData) { this.DrawRenderTargetControls(frameDebuggerEventData); } GUILayout.Label(string.Format("Event #{0}: {1}", num + 1, FrameDebuggerWindow.s_FrameEventTypeNames[(int)frameDebuggerEvent.type]), EditorStyles.boldLabel, new GUILayoutOption[0]); if (FrameDebuggerUtility.IsRemoteEnabled() && FrameDebuggerUtility.receivingRemoteFrameEventData) { GUILayout.Label("Receiving frame event data...", new GUILayoutOption[0]); } else if (frameEventData && (frameDebuggerEventData.vertexCount > 0 || frameDebuggerEventData.indexCount > 0)) { Shader shader = frameDebuggerEventData.shader; int shaderPassIndex = frameDebuggerEventData.shaderPassIndex; GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button(string.Concat(new object[] { "Shader: ", frameDebuggerEventData.shaderName, " pass #", shaderPassIndex }), GUI.skin.label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { EditorGUIUtility.PingObject(shader); Event.current.Use(); } GUILayout.Label(frameDebuggerEventData.shaderKeywords, EditorStyles.miniLabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); this.DrawStates(frameDebuggerEventData); GUILayout.Space(15f); this.m_AdditionalInfo = (ShowAdditionalInfo)GUILayout.Toolbar((int)this.m_AdditionalInfo, this.m_AdditionalInfoGuiContents, new GUILayoutOption[0]); ShowAdditionalInfo additionalInfo = this.m_AdditionalInfo; if (additionalInfo != ShowAdditionalInfo.Preview) { if (additionalInfo == ShowAdditionalInfo.ShaderProperties) { if (frameEventData) { this.DrawShaderProperties(frameDebuggerEventData.shaderProperties); } } } else if (frameEventData) { if (!this.DrawEventMesh(frameDebuggerEventData)) { GUILayout.Label("Vertices: " + frameDebuggerEventData.vertexCount, new GUILayoutOption[0]); GUILayout.Label("Indices: " + frameDebuggerEventData.indexCount, new GUILayoutOption[0]); } } } GUILayout.EndArea(); }
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) { if (!MaterialToggleDrawer.IsPropertyTypeSuitable(prop)) { GUIContent label1 = EditorGUIUtility.TempContent("Toggle used on a non-float property: " + prop.name, (Texture)EditorGUIUtility.GetHelpIcon(MessageType.Warning)); EditorGUI.LabelField(position, label1, EditorStyles.helpBox); } else { EditorGUI.BeginChangeCheck(); bool flag = (double)Math.Abs(prop.floatValue) > 1.0 / 1000.0; EditorGUI.showMixedValue = prop.hasMixedValue; bool on = EditorGUI.Toggle(position, label, flag); EditorGUI.showMixedValue = false; if (!EditorGUI.EndChangeCheck()) { return; } prop.floatValue = !on ? 0.0f : 1f; this.SetKeyword(prop, on); } }
static Vector3 MoveHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation) { int id = GUIUtility.GetControlID(s_MoveHandleHash, FocusType.Passive); Vector3 newPos = pivot; float discSize = HandleUtility.GetHandleSize(pivot) * 0.2f; float discOpacity = (1 - GUI.color.a); Vector3[] corners = new Vector3[4]; corners[0] = rotation * new Vector2(rect.x, rect.y) + pivot; corners[1] = rotation * new Vector2(rect.xMax, rect.y) + pivot; corners[2] = rotation * new Vector2(rect.xMax, rect.yMax) + pivot; corners[3] = rotation * new Vector2(rect.x, rect.yMax) + pivot; VertexSnapping.HandleMouseMove(id); bool supportsRectSnapping = Selection.transforms.Length == 1 && UnityEditorInternal.InternalEditorUtility.SupportsRectLayout(Selection.activeTransform) && Selection.activeTransform.parent.rotation == rotation; Event evt = Event.current; EventType eventType = evt.GetTypeForControl(id); Plane guiPlane = new Plane(corners[0], corners[1], corners[2]); switch (eventType) { case EventType.MouseDown: { bool acceptClick = false; if (Tools.vertexDragging) { acceptClick = true; } else { acceptClick = evt.button == 0 && evt.modifiers == 0 && RectHandles.RaycastGUIPointToWorldHit(evt.mousePosition, guiPlane, out s_StartMouseWorldPos) && ( SceneViewDistanceToRectangle(corners, evt.mousePosition) == 0f || (discOpacity > 0 && SceneViewDistanceToDisc(pivot, rotation * Vector3.forward, discSize, evt.mousePosition) == 0f) ); } if (acceptClick) { s_StartPosition = pivot; s_StartMousePos = s_CurrentMousePos = evt.mousePosition; s_Moving = false; s_LockAxis = -1; GUIUtility.hotControl = GUIUtility.keyboardControl = id; EditorGUIUtility.SetWantsMouseJumping(1); HandleUtility.ignoreRaySnapObjects = null; evt.Use(); // Calculate snapping values if applicable if (supportsRectSnapping) { Transform transform = Selection.activeTransform; RectTransform rectTransform = transform.GetComponent <RectTransform>(); Transform transformParent = transform.parent; RectTransform rectTransformParent = transformParent.GetComponent <RectTransform>(); s_StartRectPosition = rectTransform.anchoredPosition; RectTransformSnapping.CalculatePositionSnapValues(transformParent, transform, rectTransformParent, rectTransform); } } break; } case EventType.MouseDrag: { if (GUIUtility.hotControl == id) { s_CurrentMousePos += evt.delta; if (!s_Moving && (s_CurrentMousePos - s_StartMousePos).magnitude > 3f) { s_Moving = true; // Re-raycast to get start mouse pos when effective dragging starts. // This prevents a sudden unsnap when the dragging is enabled. RectHandles.RaycastGUIPointToWorldHit(s_CurrentMousePos, guiPlane, out s_StartMouseWorldPos); } if (s_Moving) { if (Tools.vertexDragging) { if (HandleUtility.ignoreRaySnapObjects == null) { Handles.SetupIgnoreRaySnapObjects(); } Vector3 near; if (HandleUtility.FindNearestVertex(s_CurrentMousePos, null, out near)) { // Snap position based on found near vertex newPos = near; GUI.changed = true; } ManipulationToolUtility.minDragDifference = Vector2.zero; } else { ManipulationToolUtility.SetMinDragDifferenceForPos(pivot); Vector3 pos; if (RectHandles.RaycastGUIPointToWorldHit(s_CurrentMousePos, guiPlane, out pos)) { Vector3 offset = pos - s_StartMouseWorldPos; // Snap to axis if (evt.shift) { // Get offset in rect handles space offset = Quaternion.Inverse(rotation) * offset; // Determine lock axis if not already set if (s_LockAxis == -1) { s_LockAxis = Mathf.Abs(offset.x) > Mathf.Abs(offset.y) ? 0 : 1; } // Cancel mocement on other axis offset[1 - s_LockAxis] = 0; // Put offset back in world space offset = rotation * offset; } else { s_LockAxis = -1; } if (supportsRectSnapping) { Transform transformParent = Selection.activeTransform.parent; Vector3 rectPosition = s_StartRectPosition + transformParent.InverseTransformVector(offset); rectPosition.z = 0; Quaternion inverseRotation = Quaternion.Inverse(rotation); Vector2 snapSize = Vector2.one * HandleUtility.GetHandleSize(newPos) * RectTransformSnapping.kSnapThreshold; snapSize.x /= (inverseRotation * transformParent.TransformVector(Vector3.right)).x; snapSize.y /= (inverseRotation * transformParent.TransformVector(Vector3.up)).y; Vector3 newRectPosition = RectTransformSnapping.SnapToGuides(rectPosition, snapSize); ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(rectPosition, newRectPosition); offset = transformParent.TransformVector(newRectPosition - s_StartRectPosition); } newPos = s_StartPosition + offset; GUI.changed = true; } } } evt.Use(); } break; } case EventType.MouseUp: { if (GUIUtility.hotControl == id) { if (!s_Moving) { Selection.activeGameObject = SceneViewPicking.PickGameObject(evt.mousePosition); } GUIUtility.hotControl = 0; EditorGUIUtility.SetWantsMouseJumping(0); HandleUtility.ignoreRaySnapObjects = null; evt.Use(); } break; } case EventType.Repaint: { if (Tools.vertexDragging) { RectHandles.RectScalingHandleCap(id, pivot, rotation, 1, EventType.Repaint); } else { Handles.color = Handles.secondaryColor * new Color(1, 1, 1, 1.5f * discOpacity); Handles.CircleHandleCap(id, pivot, rotation, discSize, EventType.Repaint); Handles.color = Handles.secondaryColor * new Color(1, 1, 1, 0.3f * discOpacity); Handles.DrawSolidDisc(pivot, rotation * Vector3.forward, discSize); } break; } } ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingPosX, eventType); ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingLeft, eventType); ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingRight, eventType); ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingPosY, eventType); ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingTop, eventType); ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingBottom, eventType); return(newPos); }
public void OnGUI() { Event current = Event.current; bool flag = false; bool flag2 = false; if (current.type == EventType.KeyDown) { flag = current.keyCode == KeyCode.Escape; flag2 = (current.keyCode == KeyCode.Return) || (current.keyCode == KeyCode.KeypadEnter); } using (HorizontalLayout.DoLayout()) { GUILayout.Space(10f); using (VerticalLayout.DoLayout()) { GUILayout.FlexibleSpace(); using (HorizontalLayout.DoLayout()) { GUILayoutOption[] options = new GUILayoutOption[] { kLabelWidth }; GUILayout.Label(EditorGUIUtility.TextContent("Publisher|Publisher of the package."), options); GUI.SetNextControlName("publisher"); this.publisher = GUILayout.TextField(this.publisher, new GUILayoutOption[0]); } GUILayout.Space(5f); using (HorizontalLayout.DoLayout()) { GUILayoutOption[] optionArray2 = new GUILayoutOption[] { kLabelWidth }; GUILayout.Label(EditorGUIUtility.TextContent("Password|Certificate password."), optionArray2); GUI.SetNextControlName("password"); this.password = GUILayout.PasswordField(this.password, '●', new GUILayoutOption[0]); } GUILayout.Space(5f); using (HorizontalLayout.DoLayout()) { GUILayoutOption[] optionArray3 = new GUILayoutOption[] { kLabelWidth }; GUILayout.Label(EditorGUIUtility.TextContent("Confirm password|Re-enter certificate password."), optionArray3); GUI.SetNextControlName("confirm"); this.confirm = GUILayout.PasswordField(this.confirm, '●', new GUILayoutOption[0]); } GUILayout.Space(10f); using (HorizontalLayout.DoLayout()) { GUILayout.Label(this.message, this.messageStyle, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayoutOption[] optionArray4 = new GUILayoutOption[] { kButtonWidth }; if (GUILayout.Button(EditorGUIUtility.TextContent("Create"), optionArray4) || flag2) { this.message = GUIContent.none; if (string.IsNullOrEmpty(this.publisher)) { this.message = EditorGUIUtility.TextContent("Publisher must be specified."); this.focus = "publisher"; } else if (this.password != this.confirm) { if (string.IsNullOrEmpty(this.confirm)) { this.message = EditorGUIUtility.TextContent("Confirm the password."); this.focus = "confirm"; } else { this.message = EditorGUIUtility.TextContent("Passwords do not match."); this.password = string.Empty; this.confirm = this.password; this.focus = "password"; } } else { try { EditorUtility.WSACreateTestCertificate(this.path, this.publisher, this.password, true); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); if (!PlayerSettings.WSA.SetCertificate(FileUtil.GetProjectRelativePath(this.path), this.password)) { this.message = EditorGUIUtility.TextContent("Invalid password."); } flag = true; } catch (UnityException exception) { Debug.LogError(exception.Message); } } } } GUILayout.FlexibleSpace(); } GUILayout.Space(10f); } if (flag) { base.Close(); } else if (this.focus != null) { EditorGUI.FocusTextInControl(this.focus); this.focus = null; } }
// shared by compute shader inspector too internal static void ShaderErrorListUI(Object shader, ShaderMessage[] messages, ref Vector2 scrollPosition) { int n = messages.Length; GUILayout.Space(kSpace); GUILayout.Label(string.Format("Errors ({0}):", n), EditorStyles.boldLabel); int errorListID = GUIUtility.GetControlID(kErrorViewHash, FocusType.Passive); float height = Mathf.Min(n * 20f + 40f, 150f); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUISkin.current.box, GUILayout.MinHeight(height)); EditorGUIUtility.SetIconSize(new Vector2(16.0f, 16.0f)); float lineHeight = Styles.messageStyle.CalcHeight(EditorGUIUtility.TempContent(Styles.errorIcon), 100); Event e = Event.current; for (int i = 0; i < n; ++i) { Rect r = EditorGUILayout.GetControlRect(false, lineHeight); string err = messages[i].message; string plat = messages[i].platform.ToString(); bool warn = messages[i].severity != ShaderCompilerMessageSeverity.Error; string fileName = FileUtil.GetLastPathNameComponent(messages[i].file); int line = messages[i].line; // Double click opens shader file at error line if (e.type == EventType.MouseDown && e.button == 0 && r.Contains(e.mousePosition)) { GUIUtility.keyboardControl = errorListID; if (e.clickCount == 2) { string filePath = messages[i].file; Object asset = string.IsNullOrEmpty(filePath) ? null : AssetDatabase.LoadMainAssetAtPath(filePath); // if we don't have an asset and the filePath is an absolute path, it's an error in a system // cginc - open that instead if (asset == null && System.IO.Path.IsPathRooted(filePath)) { ShaderUtil.OpenSystemShaderIncludeError(filePath, line); } else { AssetDatabase.OpenAsset(asset ?? shader, line); } GUIUtility.ExitGUI(); } e.Use(); } // Context menu, "Copy" if (e.type == EventType.ContextClick && r.Contains(e.mousePosition)) { e.Use(); var menu = new GenericMenu(); // need to copy current value to be used in delegate // (C# closures close over variables, not their values) var errorIndex = i; menu.AddItem(EditorGUIUtility.TrTextContent("Copy error text"), false, delegate { string errMsg = messages[errorIndex].message; if (!string.IsNullOrEmpty(messages[errorIndex].messageDetails)) { errMsg += '\n'; errMsg += messages[errorIndex].messageDetails; } EditorGUIUtility.systemCopyBuffer = errMsg; }); menu.ShowAsContext(); } // background if (e.type == EventType.Repaint) { if ((i & 1) == 0) { GUIStyle st = Styles.evenBackground; st.Draw(r, false, false, false, false); } } // error location on the right side Rect locRect = r; locRect.xMin = locRect.xMax; if (line > 0) { GUIContent gc; if (string.IsNullOrEmpty(fileName)) { gc = EditorGUIUtility.TempContent(line.ToString(CultureInfo.InvariantCulture)); } else { gc = EditorGUIUtility.TempContent(fileName + ":" + line.ToString(CultureInfo.InvariantCulture)); } // calculate size so we can right-align it Vector2 size = EditorStyles.miniLabel.CalcSize(gc); locRect.xMin -= size.x; GUI.Label(locRect, gc, EditorStyles.miniLabel); locRect.xMin -= 2; // ensure some minimum width so that platform field next will line up if (locRect.width < 30) { locRect.xMin = locRect.xMax - 30; } } // platform to the left of it Rect platRect = locRect; platRect.width = 0; if (plat.Length > 0) { GUIContent gc = EditorGUIUtility.TempContent(plat); // calculate size so we can right-align it Vector2 size = EditorStyles.miniLabel.CalcSize(gc); platRect.xMin -= size.x; // draw platform in dimmer color; it's often not very important information Color oldColor = GUI.contentColor; GUI.contentColor = new Color(1, 1, 1, 0.5f); GUI.Label(platRect, gc, EditorStyles.miniLabel); GUI.contentColor = oldColor; platRect.xMin -= 2; } // error message Rect msgRect = r; msgRect.xMax = platRect.xMin; GUI.Label(msgRect, EditorGUIUtility.TempContent(err, warn ? Styles.warningIcon : Styles.errorIcon), Styles.messageStyle); } EditorGUIUtility.SetIconSize(Vector2.zero); GUILayout.EndScrollView(); }
public bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren) { float num = position.height; position.height = 0f; if (this.m_DecoratorDrawers != null && !this.isCurrentlyNested) { foreach (DecoratorDrawer current in this.m_DecoratorDrawers) { position.height = current.GetHeight(); float labelWidth = EditorGUIUtility.labelWidth; float fieldWidth = EditorGUIUtility.fieldWidth; current.OnGUI(position); EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; position.y += position.height; num -= position.height; } } position.height = num; bool result; if (this.propertyDrawer != null) { float labelWidth = EditorGUIUtility.labelWidth; float fieldWidth = EditorGUIUtility.fieldWidth; this.propertyDrawer.OnGUISafe(position, property.Copy(), label ?? EditorGUIUtility.TempContent(property.displayName)); EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; result = false; } else if (!includeChildren) { result = EditorGUI.DefaultPropertyField(position, property, label); } else { Vector2 iconSize = EditorGUIUtility.GetIconSize(); bool enabled = GUI.enabled; int indentLevel = EditorGUI.indentLevel; int num2 = indentLevel - property.depth; SerializedProperty serializedProperty = property.Copy(); SerializedProperty endProperty = serializedProperty.GetEndProperty(); position.height = EditorGUI.GetSinglePropertyHeight(serializedProperty, label); EditorGUI.indentLevel = serializedProperty.depth + num2; bool enterChildren = EditorGUI.DefaultPropertyField(position, serializedProperty, label) && EditorGUI.HasVisibleChildFields(serializedProperty); position.y += position.height + 2f; while (serializedProperty.NextVisible(enterChildren) && !SerializedProperty.EqualContents(serializedProperty, endProperty)) { EditorGUI.indentLevel = serializedProperty.depth + num2; position.height = EditorGUI.GetPropertyHeight(serializedProperty, null, false); EditorGUI.BeginChangeCheck(); enterChildren = (ScriptAttributeUtility.GetHandler(serializedProperty).OnGUI(position, serializedProperty, null, false) && EditorGUI.HasVisibleChildFields(serializedProperty)); if (EditorGUI.EndChangeCheck()) { break; } position.y += position.height + 2f; } GUI.enabled = enabled; EditorGUIUtility.SetIconSize(iconSize); EditorGUI.indentLevel = indentLevel; result = false; } return result; }
override public void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused) { k_IndentWidth = 18; k_FoldoutWidth = 18; const float k_ToggleWidth = 18f; var pitem = tvItem as PackageImportTreeViewItem; var item = pitem.item; bool repainting = Event.current.type == EventType.Repaint; // 0. Selection row rect if (selected && repainting) { selectionStyle.Draw(rowRect, false, false, true, focused); } bool validItem = (item != null); bool isFolder = (item != null) ? item.isFolder : true; bool assetChanged = (item != null) ? item.assetChanged : false; bool pathConflict = (item != null) ? item.pathConflict : false; bool GUIDOverride = (item != null) ? item.existingAssetPath != string.Empty && item.existingAssetPath != item.destinationAssetPath : false; bool exists = (item != null) ? item.exists : true; bool projectAsset = (item != null) ? item.projectAsset : false; // 1. Foldout if (m_TreeView.data.IsExpandable(tvItem)) { DoFoldout(rowRect, tvItem, row); } // 2. Toggle only for items that are actually in the package. Rect toggleRect = new Rect(k_BaseIndent + tvItem.depth * indentWidth + k_FoldoutWidth, rowRect.y, k_ToggleWidth, rowRect.height); if ((isFolder && !projectAsset) || (validItem && !projectAsset && assetChanged)) { DoToggle(pitem, toggleRect); } using (new EditorGUI.DisabledScope(!validItem || projectAsset)) { // 3. Icon & Text Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height); DoIconAndText(tvItem, contentRect, selected, focused); // 4. Preview popup DoPreviewPopup(pitem, rowRect); // 4. Warning about file/GUID clashing. if (repainting && validItem) { if (pathConflict) { Rect labelRect = new Rect(rowRect.xMax - 58, rowRect.y, rowRect.height, rowRect.height); EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height)); GUI.Label(labelRect, Constants.badgeWarnPathConflict, Constants.paddinglessStyle); EditorGUIUtility.SetIconSize(Vector2.zero); } else if (GUIDOverride) { Rect labelRect = new Rect(rowRect.xMax - 58, rowRect.y, rowRect.height, rowRect.height); EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height)); GUIContent badgeWarnGUIDConflict = EditorGUIUtility.TrIconContent("console.warnicon", "Warning: A file exists in this project with the same GUID. This Asset being imported will be assigned a new GUID. References to the asset being imported in other imported Assets will be replaced with a reference to: " + item.existingAssetPath); GUI.Label(labelRect, badgeWarnGUIDConflict, Constants.paddinglessStyle); EditorGUIUtility.SetIconSize(Vector2.zero); } } // 5. Optional badge ("New") if (repainting && validItem && !(exists || pathConflict)) { // FIXME: Need to enable tooltips here. Texture badge = Constants.badgeNew.image; Rect labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, badge.width, badge.height); GUI.Label(labelRect, Constants.badgeNew, Constants.paddinglessStyle); } // 7. Show what stuff has changed if (repainting && validItem && (exists || pathConflict) && assetChanged) { if (PackageImportWizard.instance.IsProjectSettingStep) { Texture badge = Constants.badgeOverride.image; Rect labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, badge.width, badge.height); GUI.Label(labelRect, Constants.badgeOverride, Constants.paddinglessStyle); } else { Texture badge = Constants.badgeChange.image; Rect labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, rowRect.height, rowRect.height); GUI.Label(labelRect, Constants.badgeChange, Constants.paddinglessStyle); } } } }
private void SearchField(Event e) { string searchBarName = "SearchFilter"; if (e.commandName == "Find") { if (e.type == EventType.ExecuteCommand) { EditorGUI.FocusTextInControl(searchBarName); } if (e.type != EventType.Layout) { e.Use(); } } string searchText = LogEntries.wrapped.searchString; if (e.type == EventType.KeyDown) { if (e.keyCode == KeyCode.Escape) { searchText = string.Empty; GUIUtility.keyboardControl = m_ListView.ID; Repaint(); } else if ((e.keyCode == KeyCode.UpArrow || e.keyCode == KeyCode.DownArrow) && GUI.GetNameOfFocusedControl() == searchBarName) { GUIUtility.keyboardControl = m_ListView.ID; } } GUI.SetNextControlName(searchBarName); Rect rect = GUILayoutUtility.GetRect(0, EditorGUILayout.kLabelFloatMaxW * 1.5f, EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight, EditorStyles.toolbarSearchField, GUILayout.MinWidth(100), GUILayout.MaxWidth(300)); bool showHistory = LogEntries.wrapped.searchHistory[0].Length != 0; Rect popupPosition = rect; popupPosition.width = 20; if (showHistory && Event.current.type == EventType.MouseDown && popupPosition.Contains(Event.current.mousePosition)) { GUIUtility.keyboardControl = 0; EditorUtility.DisplayCustomMenu(rect, EditorGUIUtility.TempContent(LogEntries.wrapped.searchHistory), -1, OnSetFilteringHistoryCallback, null); Event.current.Use(); } LogEntries.wrapped.searchString = EditorGUI.ToolbarSearchField( #if !UNITY_2018_1_OR_NEWER GUIUtility.GetControlID("EditorSearchField".GetHashCode(), FocusType.Keyboard, position), #endif rect, searchText, showHistory); if (GUILayout.Button(new GUIContent(iconCustomFiltersMono, Constants.CustomFiltersLabel), EditorStyles.toolbarDropDown)) { Rect buttonRect = rect; buttonRect.x += buttonRect.width; var menuData = new CustomFiltersItemProvider(LogEntries.wrapped.customFilters); var flexibleMenu = new FlexibleMenu(menuData, -1, new CustomFiltersModifyItemUI(), null); PopupWindow.Show(buttonRect, flexibleMenu); } int iconIndex = 0; foreach (var filter in LogEntries.wrapped.customFilters.filters) { if (iconIndex >= 7) { iconIndex = 0; } filter.toggle = GUILayout.Toggle(filter.toggle, new GUIContent(filter.filter, iconCustomFiltersSmalls[iconIndex++]), Constants.MiniButton); } }
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { if (!ShaderUtil.hardwareSupportsRectRenderTexture) { return(null); } Texture texture = target as Texture; if (IsCubemap()) { return(m_CubemapPreview.RenderStaticPreview(texture, width, height)); } TextureImporter textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; if (textureImporter != null && textureImporter.textureType == TextureImporterType.Sprite && textureImporter.spriteImportMode == SpriteImportMode.Polygon) { // If the texture importer is a Sprite of primitive, use the sprite inspector for generating preview/icon. if (subAssets.Length > 0) { Sprite sprite = subAssets[0] as Sprite; if (sprite) { return(SpriteInspector.BuildPreviewTexture(width, height, sprite, null, true)); } } else { return(null); } } PreviewHelpers.AdjustWidthAndHeightForStaticPreview(texture.width, texture.height, ref width, ref height); RenderTexture savedRT = RenderTexture.active; Rect savedViewport = ShaderUtil.rawViewportRect; RenderTexture tmp = RenderTexture.GetTemporary( width, height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear); Graphics.Blit(texture, tmp, EditorGUI.GetMaterialForSpecialTexture(texture, EditorGUIUtility.GUITextureBlit2SRGBMaterial)); RenderTexture.active = tmp; Texture2D copy; Texture2D tex2d = target as Texture2D; if (tex2d != null && tex2d.alphaIsTransparency) { copy = new Texture2D(width, height, TextureFormat.RGBA32, false); } else { copy = new Texture2D(width, height, TextureFormat.RGB24, false); } copy.ReadPixels(new Rect(0, 0, width, height), 0, 0); copy.Apply(); RenderTexture.ReleaseTemporary(tmp); EditorGUIUtility.SetRenderTextureNoViewport(savedRT); ShaderUtil.rawViewportRect = savedViewport; return(copy); }
public void AvatarTimeControlGUI(Rect rect) { const float kSliderWidth = 150f; const float kSpacing = 4f; Rect timeControlRect = rect; // background GUI.Box(rect, GUIContent.none, EditorStyles.toolbar); timeControlRect.height = kTimeControlRectHeight; timeControlRect.xMax -= kSliderWidth; Rect sliderControlRect = rect; sliderControlRect.height = kTimeControlRectHeight; sliderControlRect.yMin += 1; sliderControlRect.yMax -= 1; sliderControlRect.xMin = sliderControlRect.xMax - kSliderWidth + kSpacing; timeControl.DoTimeControl(timeControlRect); Rect labelRect = new Rect(new Vector2(rect.x, rect.y), EditorStyles.toolbarLabel.CalcSize(EditorGUIUtility.TrTempContent("xxxxxx")));; labelRect.x = rect.xMax - labelRect.width; labelRect.yMin = rect.yMin; labelRect.yMax = rect.yMax; sliderControlRect.xMax = labelRect.xMin; EditorGUI.BeginChangeCheck(); timeControl.playbackSpeed = PreviewSlider(sliderControlRect, timeControl.playbackSpeed, 0.03f); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetFloat(kSpeedPref, timeControl.playbackSpeed); } GUI.Label(labelRect, timeControl.playbackSpeed.ToString("f2", CultureInfo.InvariantCulture.NumberFormat) + "x", EditorStyles.toolbarLabel); // Show current time in seconds:frame and in percentage rect.y = rect.yMax - 24; float time = timeControl.currentTime - timeControl.startTime; EditorGUI.DropShadowLabel(new Rect(rect.x, rect.y, rect.width, 20), UnityString.Format("{0,2}:{1:00} ({2:000.0%}) Frame {3}", (int)time, Repeat(Mathf.FloorToInt(time * fps), fps), timeControl.normalizedTime, Mathf.FloorToInt(timeControl.currentTime * fps)) ); }
public static void OnEditAnimationEvents(AnimationWindowEvent[] awEvents) { AnimationWindowEventData data = GetData(awEvents); if (data.events == null || data.selectedEvents == null || data.selectedEvents.Length == 0) return; AnimationEvent firstEvent = data.selectedEvents[0]; bool singleFunctionName = Array.TrueForAll(data.selectedEvents, evt => evt.functionName == firstEvent.functionName); GUI.changed = false; if (data.root != null) { List<AnimationWindowEventMethod> methods = new List<AnimationWindowEventMethod>(); HashSet<string> overloads = new HashSet<string>(); CollectSupportedMethods(data.root, methods, overloads); var methodsFormatted = new List<string>(methods.Count); for (int i = 0; i < methods.Count; ++i) { AnimationWindowEventMethod method = methods[i]; string postFix = " ( )"; if (method.parameterType != null) { if (method.parameterType == typeof(float)) postFix = " ( float )"; else if (method.parameterType == typeof(int)) postFix = " ( int )"; else postFix = string.Format(" ( {0} )", method.parameterType.Name); } methodsFormatted.Add(method.name + postFix); } int notSupportedIndex = methods.Count; int selected = methods.FindIndex(method => method.name == firstEvent.functionName); if (selected == -1) { selected = methods.Count; AnimationWindowEventMethod newMethod = new AnimationWindowEventMethod(); newMethod.name = firstEvent.functionName; newMethod.parameterType = null; methods.Add(newMethod); if (string.IsNullOrEmpty(firstEvent.functionName)) methodsFormatted.Add(kNoneSelected); else methodsFormatted.Add(firstEvent.functionName + kNotSupportedPostFix); } EditorGUIUtility.labelWidth = 130; EditorGUI.showMixedValue = !singleFunctionName; int wasSelected = singleFunctionName ? selected : -1; selected = EditorGUILayout.Popup("Function: ", selected, methodsFormatted.ToArray()); if (wasSelected != selected && selected != -1 && selected != notSupportedIndex) { foreach (var evt in data.selectedEvents) { evt.functionName = methods[selected].name; evt.stringParameter = string.Empty; } } EditorGUI.showMixedValue = false; var selectedParameter = methods[selected].parameterType; if (singleFunctionName && selectedParameter != null) { EditorGUILayout.Space(); if (selectedParameter == typeof(AnimationEvent)) EditorGUILayout.PrefixLabel("Event Data"); else EditorGUILayout.PrefixLabel("Parameters"); DoEditRegularParameters(data.selectedEvents, selectedParameter); } if (overloads.Count > 0) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(s_OverloadWarning.text, MessageType.Warning, true); } } else { EditorGUI.showMixedValue = !singleFunctionName; string oldFunctionName = singleFunctionName ? firstEvent.functionName : ""; string functionName = EditorGUILayout.TextField(EditorGUIUtility.TrTextContent("Function"), oldFunctionName).Replace(" ", ""); if (functionName != oldFunctionName) { foreach (var evt in data.selectedEvents) { evt.functionName = functionName; evt.stringParameter = string.Empty; } } EditorGUI.showMixedValue = false; if (singleFunctionName) { DoEditRegularParameters(data.selectedEvents, typeof(AnimationEvent)); } else { using (new EditorGUI.DisabledScope(true)) { AnimationEvent dummyEvent = new AnimationEvent(); DoEditRegularParameters(new AnimationEvent[] {dummyEvent}, typeof(AnimationEvent)); } } } if (GUI.changed) SetData(awEvents, data); }
void OnGUI() { Event e = Event.current; LoadIcons(); LogEntries.wrapped.UpdateEntries(); if (!m_HasUpdatedGuiStyles) { m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight); m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom; UpdateListView(); } GUILayout.BeginHorizontal(Constants.Toolbar); if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton)) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.wrapped.GetCount(); if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0) { // scroll bar was at the bottom? if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight; } } if (LogEntries.wrapped.searchFrame) { LogEntries.wrapped.searchFrame = false; int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex(); if (selectedIndex != -1) { int showIndex = selectedIndex + 1; if (currCount > showIndex) { int showCount = ms_LVHeight / RowHeight; showIndex = showIndex + showCount / 2; } m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight; } } EditorGUILayout.Space(); bool wasCollapsed = LogEntries.wrapped.collapse; LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton); bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight; } SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton)); #if UNITY_2019_1_OR_NEWER SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton)); #endif SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton)); #if UNITY_2018_3_OR_NEWER ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown); #endif EditorGUILayout.Space(); if (m_DevBuild) { GUILayout.FlexibleSpace(); SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton)); } GUILayout.FlexibleSpace(); // Search bar GUILayout.Space(4f); SearchField(e); int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { } LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag); if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton)) { int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex(); if (firstErrorIndex != -1) { SetActiveEntry(firstErrorIndex); LogEntries.wrapped.searchFrame = true; } } GUILayout.EndHorizontal(); SplitterGUILayout.BeginVerticalSplit(spl); int rowHeight = RowHeight; EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight)); GUIContent tempContent = new GUIContent(); int id = GUIUtility.GetControlID(0); int rowDoubleClicked = -1; /////@TODO: Make Frame selected work with ListViewState using (new GettingLogEntriesScope(m_ListView)) { int selectedRow = -1; bool openSelectedItem = false; bool collapsed = LogEntries.wrapped.collapse; foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box)) { if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { m_ListView.row = el.row; selectedRow = el.row; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; int entryCount = 0; int searchIndex = 0; int searchEndIndex = 0; string text = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount, ref searchIndex, ref searchEndIndex); ConsoleFlags flag = (ConsoleFlags)mode; bool isSelected = LogEntries.wrapped.IsEntrySelected(el.row); // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, isSelected, false); // Draw the icon #if !UNITY_2017_3_OR_NEWER if (Constants.LogStyleLineCount == 1) { Rect rt = el.position; rt.x += 6f; rt.y += 2f; rt.width = 16f; rt.height = 16f; GUI.DrawTexture(rt, GetIconForErrorMode(flag, false)); } else #endif { GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1); iconStyle.Draw(el.position, false, false, isSelected, false); } // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1); if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length) { errorModeStyle.Draw(el.position, tempContent, id, isSelected); } else { errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex); } if (collapsed) { Rect badgeRect = el.position; tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); badgeRect.xMin = badgeRect.xMax - badgeSize.x; badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f; badgeRect.x -= 5f; GUI.Label(badgeRect, tempContent, Constants.CountBadge); } } } if (selectedRow != -1) { if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1; } } // Make sure the selected entry is up to date if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0) { } else { if (m_ListView.selectionChanged) { SetActiveEntry(m_ListView.row); } } // Open entry using return key if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0)) { selectedRow = m_ListView.row; openSelectedItem = true; } if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { ms_LVHeight = ListViewGUI.ilvState.rectHeight; } if (openSelectedItem) { rowDoubleClicked = selectedRow; e.Use(); } if (selectedRow != -1) { SetActiveEntry(selectedRow); } } // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060. if (rowDoubleClicked != -1) { LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked(); } EditorGUIUtility.SetIconSize(Vector2.zero); StacktraceListView(e, tempContent); SplitterGUILayout.EndVerticalSplit(); // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy") { if (e.type == EventType.ExecuteCommand) { LogEntries.wrapped.StacktraceListView_CopyAll(); } e.Use(); } }
public void OnGUI() { if (AssetStoreLoginWindow.styles == null) { AssetStoreLoginWindow.styles = new AssetStoreLoginWindow.Styles(); } AssetStoreLoginWindow.LoadLogos(); if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn()) { GUI.enabled = false; } GUILayout.BeginVertical(); GUILayout.Space(10f); GUILayout.BeginHorizontal(); GUILayout.Space(5f); GUILayout.Label(AssetStoreLoginWindow.s_AssetStoreLogo, GUIStyle.none, new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label(this.m_LoginReason, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); Rect lastRect = GUILayoutUtility.GetLastRect(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); Rect rect = new Rect(0.0f, 0.0f, 0.0f, 0.0f); if (this.m_LoginRemoteMessage != null) { Color color = GUI.color; GUI.color = Color.red; GUILayout.Label(this.m_LoginRemoteMessage, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); GUI.color = color; rect = GUILayoutUtility.GetLastRect(); } float height = (float)((double)lastRect.height + (double)rect.height + 110.0); if (Event.current.type == EventType.Repaint && (double)height != (double)this.position.height) { this.position = new Rect(this.position.x, this.position.y, this.position.width, height); this.Repaint(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUI.SetNextControlName("username"); this.m_Username = EditorGUILayout.TextField("Username", this.m_Username, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); this.m_Password = EditorGUILayout.PasswordField("Password", this.m_Password, new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button(new GUIContent("Forgot?", "Reset your password"), AssetStoreLoginWindow.styles.link, new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { Application.OpenURL("https://accounts.unity3d.com/password/new"); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUILayout.EndHorizontal(); bool rememberSession = AssetStoreClient.RememberSession; bool flag = EditorGUILayout.Toggle("Remember me", rememberSession, new GUILayoutOption[0]); if (flag != rememberSession) { AssetStoreClient.RememberSession = flag; } GUILayout.EndVertical(); GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create account")) { AssetStore.Open("createuser/"); this.m_LoginRemoteMessage = "Cancelled - create user"; this.Close(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel")) { this.m_LoginRemoteMessage = "Cancelled"; this.Close(); } GUILayout.Space(5f); if (GUILayout.Button("Login")) { this.DoLogin(); this.Repaint(); } GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.EndVertical(); if (Event.current.Equals((object)Event.KeyboardEvent("return"))) { this.DoLogin(); this.Repaint(); } if (!(this.m_Username == string.Empty)) { return; } EditorGUI.FocusTextInControl("username"); }
private void ShowGICache(string searchContext) { { // Show Gigabytes to the user. const int kMinSizeInGigabytes = 5; const int kMaxSizeInGigabytes = 200; // Write size in GigaBytes. m_GICacheSettings.m_MaximumSize = EditorGUILayout.IntSlider(GICacheProperties.maxCacheSize, m_GICacheSettings.m_MaximumSize, kMinSizeInGigabytes, kMaxSizeInGigabytes); WritePreferences(); } GUILayout.BeginHorizontal(); { if (Lightmapping.isRunning) { GUIContent warning = EditorGUIUtility.TextContent(GICacheProperties.cantChangeCacheSettings.text); EditorGUILayout.HelpBox(warning.text, MessageType.Warning, true); } } GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(Lightmapping.isRunning)) { m_GICacheSettings.m_EnableCustomPath = EditorGUILayout.Toggle(GICacheProperties.customCacheLocation, m_GICacheSettings.m_EnableCustomPath); // browse for cache folder if not per project if (m_GICacheSettings.m_EnableCustomPath) { GUIStyle style = EditorStyles.miniButton; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(GICacheProperties.cacheFolderLocation, style); Rect r = GUILayoutUtility.GetRect(GUIContent.none, style); GUIContent guiText = string.IsNullOrEmpty(m_GICacheSettings.m_CachePath) ? Styles.browse : new GUIContent(m_GICacheSettings.m_CachePath); if (EditorGUI.DropdownButton(r, guiText, FocusType.Passive, style)) { string pathToOpen = m_GICacheSettings.m_CachePath; string path = EditorUtility.OpenFolderPanel(GICacheProperties.browseGICacheLocation.text, pathToOpen, ""); if (!string.IsNullOrEmpty(path)) { m_GICacheSettings.m_CachePath = path; WritePreferences(); } } GUILayout.EndHorizontal(); } else { m_GICacheSettings.m_CachePath = ""; } // We use toggle for now, 0 means kCompressionLevelNone, 1 - kCompressionLevelFastest. m_GICacheSettings.m_CompressionLevel = EditorGUILayout.Toggle(GICacheProperties.cacheCompression, m_GICacheSettings.m_CompressionLevel == 1) ? 1 : 0; if (GUILayout.Button(GICacheProperties.cleanCache, GUILayout.Width(120))) { EditorUtility.DisplayProgressBar(GICacheProperties.cleanCache.text, GICacheProperties.pleaseWait.text, 0.0F); Lightmapping.Clear(); EditorUtility.DisplayProgressBar(GICacheProperties.cleanCache.text, GICacheProperties.pleaseWait.text, 0.5F); UnityEditor.Lightmapping.ClearDiskCache(); EditorUtility.ClearProgressBar(); } if (UnityEditor.Lightmapping.diskCacheSize >= 0) { GUILayout.Label(GICacheProperties.cacheSizeIs.text + " " + EditorUtility.FormatBytes(UnityEditor.Lightmapping.diskCacheSize)); } else { GUILayout.Label(GICacheProperties.cacheSizeIs.text + " is being calculated..."); } GUILayout.Label(GICacheProperties.cacheFolderLocation.text + ":"); GUILayout.Label(UnityEditor.Lightmapping.diskCachePath, Constants.cacheFolderLocation); } }
private static void Init() { MovieTextureInspector.s_PlayIcons[0] = EditorGUIUtility.IconContent("preAudioPlayOff"); MovieTextureInspector.s_PlayIcons[1] = EditorGUIUtility.IconContent("preAudioPlayOn"); }