Class used to display popup windows that inherit from PopupWindowContent.
void ShowSettingsWindow() { var rect = EditorWindow.focusedWindow.position; rect.xMin = rect.width - SettingsMixturePopupWindow.width; rect.yMin = 21; rect.size = Vector2.zero; PopupWindow.Show(rect, new SettingsMixturePopupWindow(graphView)); }
void ShowImproveMixtureWindow() { var rect = EditorWindow.focusedWindow.position; rect.xMin = rect.width - ImproveMixturePopupWindow.width; rect.yMin = 21; rect.size = Vector2.zero; PopupWindow.Show(rect, new ImproveMixturePopupWindow()); }
internal static void DoPickProxyPresetButton(MARSEntity childEntity, Rect rect) { PopupWindow.Show(rect, new ChangeProxyWindow(childEntity)); EditorEvents.RulesUiUsed.Send(new RuleUiArgs { label = k_PickProxyPresetButtonAnalyticsLabel }); }
public void Show(Rect rect, string currentValue, IEnumerable <Item> items) { m_CurrentActiveValue = currentValue; m_Items.Clear(); m_Items.AddRange(items); m_Size = new Vector2(rect.width, 225); PopupWindow.Show(rect, this); }
public void DrawDropdown() { var dropdownRect = new Rect(130, 0, 40, 22); var hasConnectedDevices = m_LinkConnections.Any(c => c.Status == LiveLinkConnectionStatus.Connected); var icon = hasConnectedDevices ? Icons.LiveLinkOn : Icons.LiveLink; icon.tooltip = hasConnectedDevices ? "View linked devices." : "No devices currently linked. Create a Live Link build to connect a device."; if (EditorGUI.DropdownButton(dropdownRect, icon, FocusType.Keyboard, LiveLinkStyles.Dropdown)) { PopupWindow.Show(dropdownRect, this); } }
public void DrawDropdown() { var dropdownRect = new Rect(130, 0, 40, 22); var target = LiveLinkBuildSettings.CurrentLiveLinkBuildSettings?.GetComponent <ClassicBuildProfile>().Target ?? BuildTarget.NoTarget; var icon = Icons.Platform.GetIcon(target) ?? Icons.BuildSettingsDropdownDefaultIcon; icon.tooltip = LiveLinkBuildSettings.CurrentLiveLinkBuildSettings != null ? $"Current Live Link build settings: {Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(LiveLinkBuildSettings.CurrentLiveLinkBuildSettings))}." : "Set current Live Link build settings."; if (EditorGUI.DropdownButton(dropdownRect, icon, FocusType.Keyboard, LiveLinkStyles.Dropdown)) { PopupWindow.Show(dropdownRect, this); } }
// Compiled shader code button+dropdown private void ShowCompiledCodeButton(Shader s) { EditorGUILayout.BeginVertical(); ShaderImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(s.GetInstanceID())) as ShaderImporter; using (new EditorGUI.DisabledScope(!EditorSettings.cachingShaderPreprocessor && importer && importer.preprocessorOverride != PreprocessorOverride.ForceCachingPreprocessor)) m_PreprocessOnly = EditorGUILayout.Toggle(Styles.togglePreprocess, m_PreprocessOnly); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Compiled code", EditorStyles.miniButton); var hasCode = ShaderUtil.HasShaderSnippets(s) || ShaderUtil.HasSurfaceShaders(s) || ShaderUtil.HasFixedFunctionShaders(s); if (hasCode) { // button with a drop-down part on the right var modeContent = Styles.showCurrent; var modeRect = GUILayoutUtility.GetRect(modeContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)); var modeDropRect = new Rect(modeRect.xMax - 16, modeRect.y, 16, modeRect.height); if (EditorGUI.DropdownButton(modeDropRect, GUIContent.none, FocusType.Passive, GUIStyle.none)) { Rect rect = GUILayoutUtility.topLevel.GetLast(); PopupWindow.Show(rect, new ShaderInspectorPlatformsPopup(s)); GUIUtility.ExitGUI(); } if (GUI.Button(modeRect, modeContent, EditorStyles.miniButton)) { ShaderUtil.OpenCompiledShader(s, ShaderInspectorPlatformsPopup.currentMode, ShaderInspectorPlatformsPopup.currentPlatformMask, ShaderInspectorPlatformsPopup.currentVariantStripping == 0, m_PreprocessOnly); GUIUtility.ExitGUI(); } } else { // Note: PrefixLabel is sometimes buggy if followed by a non-control (like Label). // We just want to show a label here, but have to pretend it's a button so it is treated like // a control. GUILayout.Button("none (precompiled shader)", GUI.skin.label); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private void DrawLabelList(bool partiallySelected, float xMax) { GUIStyle labelStyle = partiallySelected ? EditorStyles.assetLabelPartial : EditorStyles.assetLabel; Event evt = Event.current; foreach (GUIContent content in (from i in m_AssetLabels.m_ListElements where (partiallySelected ? i.partiallySelected : i.selected) orderby i.text.ToLower() select i.m_Content).Take(s_MaxShownLabels)) { Rect rt = GUILayoutUtility.GetRect(content, labelStyle); if (Event.current.type == EventType.Repaint && rt.xMax >= xMax) { break; } GUI.Label(rt, content, labelStyle); if (rt.xMax <= xMax && evt.type == EventType.MouseDown && rt.Contains(evt.mousePosition) && evt.button == 0 && GUI.enabled) { evt.Use(); rt.x = xMax; PopupWindow.Show(rt, new PopupList(m_AssetLabels, content.text), null, ShowMode.PopupMenuWithKeyboardFocus); } } }
private void CreateNewItemButton(Rect itemRect) { if (this.m_ModifyItemUI == null) { return; } Rect rect = new Rect(itemRect.x + 25f, itemRect.y, 15f, 15f); if (!GUI.Button(rect, FlexibleMenu.s_Styles.plusButtonText, (GUIStyle)"OL Plus")) { return; } rect.y -= 15f; this.m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, this.m_ItemProvider.Create(), (System.Action <object>)(obj => { this.ClearCachedWidth(); this.SelectItem(this.m_ItemProvider.Add(obj)); EditorApplication.RequestRepaintAllViews(); })); PopupWindow.Show(rect, (PopupWindowContent)this.m_ModifyItemUI); }
private void CreateNewItemButton(Rect itemRect) { if (this.m_ModifyItemUI == null) { return; } Rect rect = new Rect(itemRect.x + 25f, itemRect.y, 15f, 15f); if (GUI.Button(rect, FlexibleMenu.s_Styles.plusButtonText, "OL Plus")) { rect.y -= 15f; this.m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, this.m_ItemProvider.Create(), delegate(object obj) { this.ClearCachedWidth(); int index = this.m_ItemProvider.Add(obj); this.SelectItem(index); EditorApplication.RequestRepaintAllViews(); }); PopupWindow.Show(rect, this.m_ModifyItemUI); } }
private void ShowCompiledCodeButton(Shader s) { #if UNITY_2020_1_OR_NEWER using (new EditorGUI.DisabledScope(!EditorSettings.cachingShaderPreprocessor)) s_PreprocessOnly = EditorGUILayout.Toggle(Styles.togglePreprocess, s_PreprocessOnly); #endif EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Compiled code", EditorStyles.miniButton); bool hasCode = ShaderUtilEx.HasShaderSnippets(s) || ShaderUtilEx.HasSurfaceShaders(s) || ShaderUtilEx.HasFixedFunctionShaders(s); if (hasCode) { GUIContent showCurrent = Styles.showCurrent; Rect rect = GUILayoutUtility.GetRect(showCurrent, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); Rect position = new Rect(rect.xMax - 16f, rect.y, 16f, rect.height); if (EditorGUIEx.ButtonMouseDown(position, GUIContent.none, FocusType.Passive, GUIStyle.none)) { Rect last = GUILayoutUtilityEx.TopLevel_GetLast(); PopupWindow.Show(last, (PopupWindowContent)Activator.CreateInstance(System.Type.GetType("UnityEditor.ShaderInspectorPlatformsPopup, UnityEditor"), new object[] { s })); GUIUtility.ExitGUI(); } if (GUI.Button(rect, showCurrent, EditorStyles.miniButton)) { #if UNITY_2020_1_OR_NEWER ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0, s_PreprocessOnly); #else ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0); #endif GUIUtility.ExitGUI(); } } else { GUILayout.Button("none (precompiled shader)", GUI.skin.label, new GUILayoutOption[0]); } EditorGUILayout.EndHorizontal(); }
private void PresetDropDown(Rect rect) { if (EditorGUI.DropdownButton(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { if (this.m_Curve != null) { if (this.m_CurvePresets == null) { Debug.LogError("Curve presets error"); } else { this.ValidateCurveLibraryTypeAndScale(); AnimationCurve animationCurve = new AnimationCurve(this.GetNormalizedKeys(this.m_Curve.keys)); animationCurve.postWrapMode = this.m_Curve.postWrapMode; animationCurve.preWrapMode = this.m_Curve.preWrapMode; this.m_CurvePresets.curveToSaveAsPreset = animationCurve; PopupWindow.Show(rect, this.m_CurvePresets); } } } }
public void OnGUI(float x, float y) { using (new EditorGUI.DisabledScope(!ManagedDebugger.isEnabled)) { GUILayout.BeginVertical(); EditorGUILayout.Space(); var codeOptimization = CompilationPipeline.codeOptimization; var debuggerAttached = ManagedDebugger.isAttached; var debuggerContent = GetDebuggerContent(debuggerAttached, codeOptimization); var buttonArea = new Rect(x + k_MarginX, y + k_MarginY, k_Width, k_Height); if (EditorGUI.DropdownButton(buttonArea, debuggerContent, FocusType.Passive, EditorStyles.toolbarDropDown)) { PopupWindow.Show(buttonArea, new ManagedDebuggerWindow(codeOptimization), m_PopupLocation); GUIUtility.ExitGUI(); } EditorGUILayout.Space(); GUILayout.EndVertical(); } }
private void ShowCompiledCodeButton(Shader s) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Compiled code", EditorStyles.miniButton); bool flag = (bool)sutilHasShaderSnippets.Invoke(null, new object[] { s }) || (bool)sutilHasSurfaceShaders.Invoke(null, new object[] { s }); if (flag) { try { GUIContent showCurrent = Styles.showCurrent; Rect rect = GUILayoutUtility.GetRect(showCurrent, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); Rect position = new Rect(rect.xMax - 16f, rect.y, 16f, rect.height); bool mDown = (bool)editorGUIMouseButtonDown.Invoke(null, new object[] { position, GUIContent.none, FocusType.Passive, GUIStyle.none }); if (mDown /*EditorGUI.ButtonMouseDown(position, GUIContent.none, FocusType.Passive, GUIStyle.none)*/) { Rect last = (Rect)guilayoutgroupGetLast.Invoke(guiLayoutUtilityTopLevel.GetValue(null, null), null); //GUILayoutUtility.topLevel.GetLast(); PopupWindow.Show(last, (PopupWindowContent)newSipp.Invoke(null, new object[] { s })); GUIUtility.ExitGUI(); } if (GUI.Button(rect, showCurrent, EditorStyles.miniButton)) { sutilOpenCompiledShader.Invoke(null, new object[] { s, sippCurrentMode.GetValue(null, null), sippCurrentPlatformMask.GetValue(null, null), (int)sippCurrentVariantStripping.GetValue(null, null) == 0 }); //ShaderUtil.OpenCompiledShader( s, sippCurrentMode.GetValue( null, null ), sippCurrentPlatformMask.GetValue( null, null ), (int)sippCurrentVariantStripping.GetValue( null, null ) == 0 ); GUIUtility.ExitGUI(); } } catch { } } else { GUILayout.Button("none (fixed function shader)", GUI.skin.label, new GUILayoutOption[0]); } EditorGUILayout.EndHorizontal(); }
private void DoActiveTargetsGUI() { bool flag = GridPaintingState.scenePaintTarget != null; using (new EditorGUI.DisabledScope(!flag || GridPaintingState.validTargets == null)) { GUILayout.Label(GridPaintPaletteWindow.Styles.activeTargetLabel, new GUILayoutOption[] { GUILayout.Width(90f) }); GUIContent content = GUIContent.Temp((!flag) ? "Nothing" : GridPaintingState.scenePaintTarget.name); if (EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.popup, new GUILayoutOption[] { GUILayout.Width(130f) })) { int selectionIndex = (!flag) ? 0 : Array.IndexOf <GameObject>(GridPaintingState.validTargets, GridPaintingState.scenePaintTarget); GridPaintTargetsDropdown.MenuItemProvider itemProvider = new GridPaintTargetsDropdown.MenuItemProvider(); GridPaintTargetsDropdown windowContent = new GridPaintTargetsDropdown(itemProvider, selectionIndex, null, new Action <int, object>(this.SelectTarget), 130f); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), windowContent); } } }
void CreateNewItemButton(Rect itemRect) { if (m_ModifyItemUI == null) { return; } Rect plusRect = new Rect(itemRect.x + leftMargin, itemRect.y, 15, 15); if (GUI.Button(plusRect, s_Styles.plusButtonText, "OL Plus")) { plusRect.y -= 15f; m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, m_ItemProvider.Create(), delegate(object obj) { ClearCachedWidth(); int newIndex = m_ItemProvider.Add(obj); SelectItem(newIndex); EditorApplication.RequestRepaintAllViews(); // We want to repaint the flexible menu (currently in modifyItemUI) }); PopupWindow.Show(plusRect, m_ModifyItemUI, null, ShowMode.PopupMenuWithKeyboardFocus); } }
private void DoPalettesDropdown() { string name = palette != null ? palette.name : Styles.createNewPalette.text; Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(name), EditorStyles.toolbarDropDown, GUILayout.Width(k_DropdownWidth)); if (GridPalettes.palettes.Count == 0) { if (EditorGUI.DropdownButton(rect, GUIContent.Temp(name), FocusType.Passive, EditorStyles.toolbarDropDown)) { OpenAddPalettePopup(rect); } } else { GUIContent content = GUIContent.Temp(GridPalettes.palettes.Count > 0 && palette != null ? palette.name : Styles.createNewPalette.text); if (EditorGUI.DropdownButton(rect, content, FocusType.Passive, EditorStyles.toolbarPopup)) { var menuData = new GridPalettesDropdown.MenuItemProvider(); m_PaletteDropdown = new GridPalettesDropdown(menuData, GridPalettes.palettes.IndexOf(palette), null, SelectPalette, k_DropdownWidth); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), m_PaletteDropdown); } } }
void PresetDropDown(Rect rect) { if (EditorGUI.DropdownButton(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { if (m_Curve != null) { if (m_CurvePresets == null) { Debug.LogError("Curve presets error"); return; } ValidateCurveLibraryTypeAndScale(); AnimationCurve copy = new AnimationCurve(GetNormalizedKeys(m_Curve.keys)); copy.postWrapMode = m_Curve.postWrapMode; copy.preWrapMode = m_Curve.preWrapMode; m_CurvePresets.curveToSaveAsPreset = copy; PopupWindow.Show(rect, m_CurvePresets); } } }
private void DrawLabelList(bool partiallySelected, float xMax) { GUIStyle style = (!partiallySelected) ? EditorStyles.assetLabel : EditorStyles.assetLabelPartial; Event current = Event.current; foreach (GUIContent current2 in (from i in this.m_AssetLabels.m_ListElements where (!partiallySelected) ? i.selected : i.partiallySelected orderby i.text.ToLower() select i.m_Content).Take(LabelGUI.s_MaxShownLabels)) { Rect rect = GUILayoutUtility.GetRect(current2, style); if (Event.current.type == EventType.Repaint && rect.xMax >= xMax) { break; } GUI.Label(rect, current2, style); if (rect.xMax <= xMax && current.type == EventType.MouseDown && rect.Contains(current.mousePosition) && current.button == 0 && GUI.enabled) { current.Use(); rect.x = xMax; PopupWindow.Show(rect, new PopupList(this.m_AssetLabels, current2.text)); } } }
public void OnGUI(int windowID) { if (!(this.m_LookDevView == null)) { List <CubemapInfo> hdriList = this.m_LookDevView.envLibrary.hdriList; bool flag = 146f * (float)hdriList.Count > this.m_PositionInLookDev.height; if (flag) { this.m_ScrollPosition = EditorGUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]); } else { this.m_ScrollPosition = new Vector2(0f, 0f); } if (hdriList.Count == 1) { Color color = GUI.color; GUI.color = Color.gray; Vector2 vector = GUI.skin.label.CalcSize(LookDevEnvironmentWindow.styles.sDragAndDropHDRIText); Rect position = new Rect(this.m_PositionInLookDev.width * 0.5f - vector.x * 0.5f, this.m_PositionInLookDev.height * 0.5f - vector.y * 0.5f, vector.x, vector.y); GUI.Label(position, LookDevEnvironmentWindow.styles.sDragAndDropHDRIText); GUI.color = color; } for (int i = 0; i < hdriList.Count; i++) { CubemapInfo cubemapInfo = hdriList[i]; ShadowInfo shadowInfo = cubemapInfo.shadowInfo; int intProperty = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Left); int num = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Right); if (this.m_LookDevView.config.lookDevMode == LookDevMode.Single1 || this.m_LookDevView.config.lookDevMode == LookDevMode.Single2) { num = -1; } bool flag2 = i == intProperty || i == num; Color selectionColor = Color.black; Color selectionColor2 = Color.black; GUIStyle style = EditorStyles.miniLabel; if (flag2) { if (i == intProperty) { selectionColor = LookDevView.m_FirstViewGizmoColor; selectionColor2 = LookDevView.m_FirstViewGizmoColor; style = LookDevEnvironmentWindow.styles.sLabelStyleFirstContext; } else if (i == num) { selectionColor = LookDevView.m_SecondViewGizmoColor; selectionColor2 = LookDevView.m_SecondViewGizmoColor; style = LookDevEnvironmentWindow.styles.sLabelStyleSecondContext; } if (intProperty == num) { selectionColor = LookDevView.m_FirstViewGizmoColor; selectionColor2 = LookDevView.m_SecondViewGizmoColor; style = LookDevEnvironmentWindow.styles.sLabelStyleBothContext; } } GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(250f) }); int num2 = hdriList.FindIndex((CubemapInfo x) => x == this.m_SelectedCubemapInfo); if ((this.m_SelectedCubemap != null || this.m_DragBeingPerformed) && this.GetInsertionRect(i).Contains(Event.current.mousePosition) && ((num2 - i != 0 && num2 - i != -1) || num2 == -1)) { GUILayout.Label(GUIContent.none, LookDevEnvironmentWindow.styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayoutUtility.GetRect(250f, 16f); } GUILayout.Label(GUIContent.none, LookDevEnvironmentWindow.styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Width(250f), GUILayout.Height(18f) }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(i.ToString()); stringBuilder.Append(" - "); stringBuilder.Append(cubemapInfo.cubemap.name); GUILayout.Label(stringBuilder.ToString(), style, new GUILayoutOption[] { GUILayout.Height(18f), GUILayout.MaxWidth(175f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button(LookDevEnvironmentWindow.styles.sEnvControlIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0])) { Rect last = GUILayoutUtility.topLevel.GetLast(); PopupWindow.Show(last, new LookDevEnvironmentWindow.EnvSettingsWindow(this.m_LookDevView, cubemapInfo)); GUIUtility.ExitGUI(); } using (new EditorGUI.DisabledScope(cubemapInfo.cubemap == LookDevResources.m_DefaultHDRI)) { if (GUILayout.Button(LookDevEnvironmentWindow.styles.sCloseIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0])) { this.m_LookDevView.envLibrary.RemoveHDRI(cubemapInfo.cubemap); } } GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseDown && lastRect.Contains(Event.current.mousePosition)) { Event.current.Use(); } Rect rect = GUILayoutUtility.GetRect(250f, 125f); rect.width = 253f; float num3 = 24f; float num4 = num3 * 0.5f; float latitude = shadowInfo.latitude; float longitude = shadowInfo.longitude; Vector2 vector2 = this.LatLongToPosition(latitude, longitude + cubemapInfo.angleOffset) * 0.5f + new Vector2(0.5f, 0.5f); Rect position2 = rect; position2.x = position2.x + vector2.x * rect.width - num4; position2.y = position2.y + (1f - vector2.y) * rect.height - num4; position2.width = num3; position2.height = num3; Rect position3 = rect; position3.x = position3.x + vector2.x * rect.width - num4 * 0.5f; position3.y = position3.y + (1f - vector2.y) * rect.height - num4 * 0.5f; position3.width = num3 * 0.5f; position3.height = num3 * 0.5f; Rect rect2; Rect textureRect; this.GetFrameAndShadowTextureRect(rect, out rect2, out textureRect); if (this.m_LookDevView.config.enableShadowCubemap) { EditorGUIUtility.AddCursorRect(position3, MouseCursor.Pan); } if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition)) { if (!Event.current.control && Event.current.button == 0 && this.m_SelectedCubeMapOffsetIndex == -1) { if (this.m_LookDevView.config.enableShadowCubemap && position3.Contains(Event.current.mousePosition)) { this.m_SelectedLightIconIndex = i; this.m_SelectedShadowInfo = shadowInfo; Undo.RecordObject(this.m_LookDevView.envLibrary, "Light Icon selection"); this.m_SelectedShadowInfo.latitude = this.m_SelectedShadowInfo.latitude + 0.0001f; this.m_SelectedShadowInfo.longitude = this.m_SelectedShadowInfo.longitude + 0.0001f; } if (this.m_SelectedShadowInfo == null) { Rect rect3 = rect2; rect3.x += 100f; rect3.y += 4f; rect3.width = 11f; rect3.height = 11f; if (this.m_LookDevView.config.enableShadowCubemap && rect3.Contains(Event.current.mousePosition)) { Undo.RecordObject(this.m_LookDevView.envLibrary, "Update shadow cubemap"); hdriList[i].SetCubemapShadowInfo(hdriList[i]); this.m_LookDevView.envLibrary.dirty = true; } else { if (this.m_LookDevView.config.enableShadowCubemap && textureRect.Contains(Event.current.mousePosition)) { this.m_SelectedShadowCubemapOwnerInfo = hdriList[i]; this.m_SelectedCubemapInfo = this.m_SelectedShadowCubemapOwnerInfo.cubemapShadowInfo; } else { this.m_SelectedCubemapInfo = hdriList[i]; } this.m_SelectedPositionOffset = Event.current.mousePosition - new Vector2(rect.x, rect.y); this.m_RenderOverlayThumbnailOnce = true; } } } else if (Event.current.control && Event.current.button == 0 && this.m_SelectedCubemapInfo == null && this.m_SelectedShadowInfo == null) { this.m_SelectedCubeMapOffsetIndex = i; this.m_SelectedCubeMapOffsetValue = cubemapInfo.angleOffset - this.ComputeAngleOffsetFromMouseCoord(Event.current.mousePosition); } GUIUtility.hotControl = this.m_LookDevView.hotControl; Event.current.Use(); } if (Event.current.GetTypeForControl(this.m_LookDevView.hotControl) == EventType.MouseDrag) { if (this.m_SelectedShadowInfo == shadowInfo && this.m_SelectedLightIconIndex == i) { Vector2 mousePosition = Event.current.mousePosition; mousePosition.x = (mousePosition.x - rect.x) / rect.width * 2f - 1f; mousePosition.y = (1f - (mousePosition.y - rect.y) / rect.height) * 2f - 1f; Vector2 vector3 = LookDevEnvironmentWindow.PositionToLatLong(mousePosition); this.m_SelectedShadowInfo.latitude = vector3.x; this.m_SelectedShadowInfo.longitude = vector3.y - cubemapInfo.angleOffset; this.m_LookDevView.envLibrary.dirty = true; } } if (Event.current.type == EventType.Repaint) { this.DrawLatLongThumbnail(cubemapInfo, cubemapInfo.angleOffset, 1f, 1f, rect); if (this.m_LookDevView.config.enableShadowCubemap) { if (cubemapInfo.cubemapShadowInfo != cubemapInfo || (this.m_HoveringCubeMapIndex == i && this.m_SelectedCubemapInfo != cubemapInfo)) { CubemapInfo infos = cubemapInfo.cubemapShadowInfo; if (this.m_HoveringCubeMapIndex == i && this.m_SelectedCubemapInfo != cubemapInfo) { infos = this.m_SelectedCubemapInfo; } float alpha = 1f; if (this.m_SelectedShadowInfo == shadowInfo) { alpha = 0.1f; } else if (this.m_HoveringCubeMapIndex == i && this.m_SelectedCubemapInfo != cubemapInfo && cubemapInfo.cubemapShadowInfo != this.m_SelectedCubemapInfo) { alpha = 0.5f; } this.DrawLatLongThumbnail(infos, cubemapInfo.angleOffset, 0.3f, alpha, textureRect); GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear); GUI.DrawTexture(rect2, LookDevEnvironmentWindow.styles.sLatlongFrameTexture); GL.sRGBWrite = false; } GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear); GUI.DrawTexture(position2, LookDevEnvironmentWindow.styles.sLightTexture); GL.sRGBWrite = false; } if (flag2) { this.DrawSelectionFeedback(rect, selectionColor, selectionColor2); } } GUILayout.EndVertical(); } GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(250f) }); if ((this.m_SelectedCubemap != null || this.m_DragBeingPerformed) && this.GetInsertionRect(hdriList.Count).Contains(Event.current.mousePosition)) { GUILayout.Label(GUIContent.none, LookDevEnvironmentWindow.styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayoutUtility.GetRect(250f, 16f); GUILayout.Label(GUIContent.none, LookDevEnvironmentWindow.styles.sSeparatorStyle, new GUILayoutOption[0]); } GUILayout.EndVertical(); if (flag) { EditorGUILayout.EndScrollView(); } this.HandleMouseInput(); this.RenderOverlayThumbnailIfNeeded(); if (Event.current.type == EventType.Repaint) { if (this.m_SelectedCubemap != null) { this.m_LookDevView.Repaint(); } } } }
internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder) { PopupWindow.Show(activatorRect, windowContent, locationPriorityOrder, ShowMode.PopupMenu); }
public static void Show(Rect activatorRect, PopupWindowContent windowContent) { PopupWindow.Show(activatorRect, windowContent, null); }
private void DoPrefabButtons() { if (!m_IsPrefabInstanceAnyRoot || m_IsAsset) { return; } using (new EditorGUI.DisabledScope(m_PlayModeObjects)) { EditorGUILayout.BeginHorizontal(Styles.prefabButtonsHorizontalLayout); // Prefab information PrefabAssetType singlePrefabType = PrefabUtility.GetPrefabAssetType(target); PrefabInstanceStatus singleInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(target); GUIContent prefixLabel; if (targets.Length > 1) { prefixLabel = Styles.goTypeLabelMultiple; } else { prefixLabel = Styles.goTypeLabel[(int)singlePrefabType, (int)singleInstanceStatus]; } if (prefixLabel != null) { EditorGUILayout.BeginHorizontal(GUILayout.Width(kIconSize + Styles.tagFieldWidth)); GUILayout.FlexibleSpace(); if (m_IsDisconnected || m_IsMissing) { GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor; GUILayout.Label(prefixLabel, EditorStyles.whiteLabel, GUILayout.ExpandWidth(false)); GUI.contentColor = Color.white; } else { GUILayout.Label(prefixLabel, GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); } if (!m_IsMissing) { using (new EditorGUI.DisabledScope(targets.Length > 1)) { if (singlePrefabType == PrefabAssetType.Model) { // Open Model Prefab if (GUILayout.Button(Styles.openString, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); AssetDatabase.OpenAsset(asset); GUIUtility.ExitGUI(); } } else { // Open non-Model Prefab using (new EditorGUI.DisabledScope(m_ImmutableSourceAsset)) { if (GUILayout.Button(Styles.openString, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(asset), (GameObject)target, StageNavigationManager.Analytics.ChangeType.EnterViaInstanceInspectorOpenButton); GUIUtility.ExitGUI(); } } } } // Select prefab if (GUILayout.Button(Styles.selectString, EditorStyles.miniButtonRight)) { HashSet <GameObject> selectedAssets = new HashSet <GameObject>(); for (int i = 0; i < targets.Length; i++) { GameObject prefabGo = PrefabUtility.GetOriginalSourceOrVariantRoot(targets[i]); // Because of legacy prefab references we have to have this extra step // to make sure we ping the prefab asset correctly. // Reason is that scene files created prior to making prefabs CopyAssets // will reference prefabs as if they are serialized assets. Those references // works fine but we are not able to ping objects loaded directly from the asset // file, so we have to make sure we ping the metadata version of the prefab. var assetPath = AssetDatabase.GetAssetPath(prefabGo); selectedAssets.Add((GameObject)AssetDatabase.LoadMainAssetAtPath(assetPath)); } Selection.objects = selectedAssets.ToArray(); if (Selection.gameObjects.Length == 1) { EditorGUIUtility.PingObject(Selection.activeObject); } } // Should be EditorGUILayout.Space, except it does not have ExpandWidth set to false. // Maybe we can change that? GUILayoutUtility.GetRect(6, 6, GUILayout.ExpandWidth(false)); // Reserve space regardless of whether the button is there or not to avoid jumps in button sizes. Rect rect = GUILayoutUtility.GetRect(Styles.overridesContent, Styles.overridesDropdown); if (m_IsPrefabInstanceOutermostRoot) { if (EditorGUI.DropdownButton(rect, Styles.overridesContent, FocusType.Passive)) { if (targets.Length > 1) { PopupWindow.Show(rect, new PrefabOverridesWindow(targets.Select(e => (GameObject)e).ToArray())); } else { PopupWindow.Show(rect, new PrefabOverridesWindow((GameObject)target)); } GUIUtility.ExitGUI(); } } } EditorGUILayout.EndHorizontal(); } }
void NewElement(Rect buttonRect, ReorderableList list) { buttonRect.x -= 400; buttonRect.y -= 13; PopupWindow.Show(buttonRect, new EnterNamePopup(m_Tags, s => { InternalEditorUtility.AddTag(s); }), null, ShowMode.PopupMenuWithKeyboardFocus); }
void NewElement(Rect buttonRect, ReorderableList list) { buttonRect.x -= 400; buttonRect.y -= 13; PopupWindow.Show(buttonRect, new EnterNamePopup(m_Tags, s => { InternalEditorUtility.AddTag(s); })); }
private void DoDiffScroll(Event current) { float elementHeight = diffElementRenderer.ElementHeight; if (IsGrouping()) { float totalTypesCount = diffWindowStatusList.Select(i => GetMergedStatus(i.State)).Distinct().Count(); float elementsTotalHeight = (diffWindowStatusList.Count(IsVisible) + totalTypesCount) * elementHeight; diffScrollContentRect = new Rect(0, 0, Mathf.Max(DiffRect.width - 16, 420), elementsTotalHeight); } else { diffScrollContentRect = new Rect(0, 0, Mathf.Max(DiffRect.width - 16, 420), diffWindowStatusList.Count(IsVisible) * elementHeight); } diffScroll = GUI.BeginScrollView(DiffRect, diffScroll, diffScrollContentRect); int index = 0; FileStatus?lastFileStatus = null; float infoX = 0; for (int i = 0; i < diffWindowStatusList.Count; i++) { var info = diffWindowStatusList[i]; bool isVisible = IsVisible(info); Rect elementRect; if (IsGrouping()) { FileStatus mergedStatus = GetMergedStatus(info.State); if (!lastFileStatus.HasValue || lastFileStatus != mergedStatus) { elementRect = new Rect(0, infoX, diffScrollContentRect.width + 16, elementHeight); lastFileStatus = mergedStatus; FileStatus newState = lastFileStatus.Value; if (current.type == EventType.Repaint) { styles.diffScrollHeader.Draw(elementRect, GitGUI.GetTempContent(mergedStatus.ToString()), false, false, false, false); GUIStyle.none.Draw(new Rect(elementRect.x + 12, elementRect.y + 14, elementRect.width - 12, elementRect.height - 24), GitGUI.GetTempContent(gitOverlay.GetDiffTypeIcon(info.State, false).image), false, false, false, false); } if (elementRect.Contains(current.mousePosition)) { if (current.type == EventType.ContextClick) { GenericMenu selectAllMenu = new GenericMenu(); elementContextFactory.Build(newState, selectAllMenu, this); selectAllMenu.ShowAsContext(); current.Use(); } else if (current.type == EventType.MouseDown && current.button == 0) { settings.MinimizedFileStatus = settings.MinimizedFileStatus.SetFlags(mergedStatus, !isVisible); if (!isVisible) { ClearSelected(e => e.State == newState); } Repaint(); current.Use(); } } infoX += elementRect.height; } } if (!isVisible) { continue; } elementRect = new Rect(0, infoX, diffScrollContentRect.width + 16, elementHeight); //check visibility if (elementRect.y <= DiffRect.height + diffScroll.y && elementRect.y + elementRect.height >= diffScroll.y) { bool isUpdating = (info.MetaChange.IsFlagSet(MetaChangeEnum.Object) && gitManager.IsFileUpdating(info.LocalPath)) || (info.MetaChange.IsFlagSet(MetaChangeEnum.Meta) && gitManager.IsFileUpdating(GitManager.MetaPathFromAsset(info.LocalPath))) || updatingPaths.Contains(info.LocalPath) || pathsToBeUpdated.Contains(info.LocalPath); bool isStaging = (info.MetaChange.IsFlagSet(MetaChangeEnum.Object) && gitManager.IsFileStaging(info.LocalPath)) || (info.MetaChange.IsFlagSet(MetaChangeEnum.Meta) && gitManager.IsFileStaging(GitManager.MetaPathFromAsset(info.LocalPath))); bool isDirty = (info.MetaChange.IsFlagSet(MetaChangeEnum.Object) && gitManager.IsFileDirty(info.LocalPath)) || (info.MetaChange.IsFlagSet(MetaChangeEnum.Meta) && gitManager.IsFileDirty(GitManager.MetaPathFromAsset(info.LocalPath))); bool selected = IsSelected(info); bool enabled = !isUpdating && !isDirty && !isStaging; diffElementRenderer.DoFileDiff(elementRect, info, enabled, selected, this); DoFileDiffSelection(elementRect, info, index, enabled, selected); } infoX += elementRect.height; index++; } GUI.EndScrollView(); if (DiffRect.Contains(current.mousePosition)) { if (current.type == EventType.ContextClick) { if (gitSettings.UseSimpleContextMenus) { GenericMenuWrapper genericMenuWrapper = new GenericMenuWrapper(new GenericMenu()); elementContextFactory.Build(genericMenuWrapper, this); genericMenuWrapper.GenericMenu.ShowAsContext(); } else { ContextGenericMenuPopup popup = injectionHelper.CreateInstance <ContextGenericMenuPopup>(); elementContextFactory.Build(popup, this); PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero), popup); } current.Use(); } else if (current.type == EventType.KeyUp && current.keyCode == KeyCode.Delete) { foreach (var id in selections) { var entry = diffWindowStatusList.FirstOrDefault(e => SelectionPredicate(id, e)); if (!string.IsNullOrEmpty(entry.LocalPath)) { DeleteAsset(entry.LocalPath); current.Use(); } } } if (current.type == EventType.MouseDrag && current.button == 2) { diffScroll.y -= current.delta.y; Repaint(); } } }
private void DoPrefabButtons(GameObject go) { // @TODO: If/when we support multi-editing of prefab/model instances, // handle it here. Only show prefab bar if all are same type? if (!m_IsPrefabInstanceAnyRoot) { return; } using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode && PrefabStageUtility.GetPrefabStage(go) == null)) { EditorGUILayout.BeginHorizontal(s_Styles.prefabButtonsHorizontalLayout); // Prefab information PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(go); PrefabInstanceStatus instanceStatus = PrefabUtility.GetPrefabInstanceStatus(go); GUIContent prefixLabel; if (targets.Length > 1) { prefixLabel = s_Styles.goTypeLabelMultiple; } else { prefixLabel = s_Styles.goTypeLabel[(int)prefabType, (int)instanceStatus]; } if (prefixLabel != null) { EditorGUILayout.BeginHorizontal(GUILayout.Width(kIconSize + s_Styles.tagFieldWidth)); GUILayout.FlexibleSpace(); if (PrefabUtility.IsDisconnectedFromPrefabAsset(go) || PrefabUtility.IsPrefabAssetMissing(go)) { GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor; GUILayout.Label(prefixLabel, EditorStyles.whiteLabel, GUILayout.ExpandWidth(false)); GUI.contentColor = Color.white; } else { GUILayout.Label(prefixLabel, GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); } if (targets.Length > 1) { GUILayout.Label("Instance Management Disabled", s_Styles.instanceManagementInfo); } else { if (!PrefabUtility.IsPrefabAssetMissing(go)) { if (prefabType == PrefabAssetType.Model) { // Open Model Prefab if (GUILayout.Button("Open", "MiniButtonLeft")) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); AssetDatabase.OpenAsset(asset); GUIUtility.ExitGUI(); } } else { // Open non-Model Prefab using (new EditorGUI.DisabledScope(m_ImmutableSourceAsset)) { if (GUILayout.Button("Open", "MiniButtonLeft")) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(asset), (GameObject)target, StageNavigationManager.Analytics.ChangeType.EnterViaInstanceInspectorOpenButton); GUIUtility.ExitGUI(); } } } // Select prefab if (GUILayout.Button("Select", "MiniButtonRight")) { Selection.activeObject = PrefabUtility.GetOriginalSourceOrVariantRoot(target); // Because of legacy prefab references we have to have this extra step // to make sure we ping the prefab asset correctly. // Reason is that scene files created prior to making prefabs CopyAssets // will reference prefabs as if they are serialized assets. Those references // works fine but we are not able to ping objects loaded directly from the asset // file, so we have to make sure we ping the metadata version of the prefab. var assetPath = AssetDatabase.GetAssetPath(Selection.activeObject); Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(assetPath); EditorGUIUtility.PingObject(Selection.activeObject); } // Should be EditorGUILayout.Space, except it does not have ExpandWidth set to false. // Maybe we can change that? GUILayoutUtility.GetRect(6, 6, GUILayout.ExpandWidth(false)); // Reserve space regardless of whether the button is there or not to avoid jumps in button sizes. Rect rect = GUILayoutUtility.GetRect(s_Styles.overridesContent, s_Styles.overridesDropdown); if (m_IsPrefabInstanceOutermostRoot) { if (EditorGUI.DropdownButton(rect, s_Styles.overridesContent, FocusType.Passive)) { PopupWindow.Show(rect, new PrefabOverridesWindow(go)); GUIUtility.ExitGUI(); } } } } EditorGUILayout.EndHorizontal(); } }
public void OnGUI(int windowID) { if (this.m_LookDevView != null) { List <CubemapInfo> hdriList = this.m_LookDevView.envLibrary.hdriList; bool flag = (146f * hdriList.Count) > this.m_PositionInLookDev.height; if (flag) { this.m_ScrollPosition = EditorGUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]); } else { this.m_ScrollPosition = new Vector2(0f, 0f); } if (hdriList.Count == 1) { Color color = GUI.color; GUI.color = Color.gray; Vector2 vector = GUI.skin.label.CalcSize(styles.sDragAndDropHDRIText); Rect position = new Rect((this.m_PositionInLookDev.width * 0.5f) - (vector.x * 0.5f), (this.m_PositionInLookDev.height * 0.5f) - (vector.y * 0.5f), vector.x, vector.y); GUI.Label(position, styles.sDragAndDropHDRIText); GUI.color = color; } for (int i = 0; i < hdriList.Count; i++) { Rect rect5; Rect rect6; CubemapInfo infos = hdriList[i]; ShadowInfo shadowInfo = infos.shadowInfo; int intProperty = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Left); int num3 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Right); if ((this.m_LookDevView.config.lookDevMode == LookDevMode.Single1) || (this.m_LookDevView.config.lookDevMode == LookDevMode.Single2)) { num3 = -1; } bool flag2 = (i == intProperty) || (i == num3); Color black = Color.black; Color firstViewGizmoColor = Color.black; GUIStyle miniLabel = EditorStyles.miniLabel; if (flag2) { if (i == intProperty) { black = (Color)LookDevView.m_FirstViewGizmoColor; firstViewGizmoColor = (Color)LookDevView.m_FirstViewGizmoColor; miniLabel = styles.sLabelStyleFirstContext; } else if (i == num3) { black = (Color)LookDevView.m_SecondViewGizmoColor; firstViewGizmoColor = (Color)LookDevView.m_SecondViewGizmoColor; miniLabel = styles.sLabelStyleSecondContext; } if (intProperty == num3) { black = (Color)LookDevView.m_FirstViewGizmoColor; firstViewGizmoColor = (Color)LookDevView.m_SecondViewGizmoColor; miniLabel = styles.sLabelStyleBothContext; } } GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(250f) }; GUILayout.BeginVertical(optionArray1); int num4 = hdriList.FindIndex(x => x == this.m_SelectedCubemapInfo); if ((((this.m_SelectedCubemap != null) || this.m_DragBeingPerformed) && this.GetInsertionRect(i).Contains(Event.current.mousePosition)) && ((((num4 - i) != 0) && ((num4 - i) != -1)) || (num4 == -1))) { GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayoutUtility.GetRect((float)250f, (float)16f); } GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(250f), GUILayout.Height(18f) }; GUILayout.BeginHorizontal(optionArray2); StringBuilder builder = new StringBuilder(); builder.Append(i.ToString()); builder.Append(" - "); builder.Append(infos.cubemap.name); GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Height(18f), GUILayout.MaxWidth(175f) }; GUILayout.Label(builder.ToString(), miniLabel, optionArray3); GUILayout.FlexibleSpace(); if (GUILayout.Button(styles.sEnvControlIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0])) { PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), new EnvSettingsWindow(this.m_LookDevView, infos)); GUIUtility.ExitGUI(); } using (new EditorGUI.DisabledScope(infos.cubemap == LookDevResources.m_DefaultHDRI)) { if (GUILayout.Button(styles.sCloseIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0])) { this.m_LookDevView.envLibrary.RemoveHDRI(infos.cubemap); } } GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); if ((Event.current.type == EventType.MouseDown) && lastRect.Contains(Event.current.mousePosition)) { Event.current.Use(); } Rect rect = GUILayoutUtility.GetRect((float)250f, (float)125f); rect.width = 253f; float num5 = 24f; float num6 = num5 * 0.5f; float latitude = shadowInfo.latitude; float longitude = shadowInfo.longitude; Vector2 vector2 = ((Vector2)(this.LatLongToPosition(latitude, longitude + infos.angleOffset) * 0.5f)) + new Vector2(0.5f, 0.5f); Rect rect3 = rect; rect3.x = (rect3.x + (vector2.x * rect.width)) - num6; rect3.y = (rect3.y + ((1f - vector2.y) * rect.height)) - num6; rect3.width = num5; rect3.height = num5; Rect rect4 = rect; rect4.x = (rect4.x + (vector2.x * rect.width)) - (num6 * 0.5f); rect4.y = (rect4.y + ((1f - vector2.y) * rect.height)) - (num6 * 0.5f); rect4.width = num5 * 0.5f; rect4.height = num5 * 0.5f; this.GetFrameAndShadowTextureRect(rect, out rect5, out rect6); if (this.m_LookDevView.config.enableShadowCubemap) { EditorGUIUtility.AddCursorRect(rect4, MouseCursor.Pan); } if ((Event.current.type == EventType.MouseDown) && rect.Contains(Event.current.mousePosition)) { if ((!Event.current.control && (Event.current.button == 0)) && (this.m_SelectedCubeMapOffsetIndex == -1)) { if (this.m_LookDevView.config.enableShadowCubemap && rect4.Contains(Event.current.mousePosition)) { this.m_SelectedLightIconIndex = i; this.m_SelectedShadowInfo = shadowInfo; Undo.RecordObject(this.m_LookDevView.envLibrary, "Light Icon selection"); this.m_SelectedShadowInfo.latitude += 0.0001f; this.m_SelectedShadowInfo.longitude += 0.0001f; } if (this.m_SelectedShadowInfo == null) { Rect rect10 = rect5; rect10.x += 100f; rect10.y += 4f; rect10.width = 11f; rect10.height = 11f; if (this.m_LookDevView.config.enableShadowCubemap && rect10.Contains(Event.current.mousePosition)) { Undo.RecordObject(this.m_LookDevView.envLibrary, "Update shadow cubemap"); hdriList[i].SetCubemapShadowInfo(hdriList[i]); this.m_LookDevView.envLibrary.dirty = true; } else { if (this.m_LookDevView.config.enableShadowCubemap && rect6.Contains(Event.current.mousePosition)) { this.m_SelectedShadowCubemapOwnerInfo = hdriList[i]; this.m_SelectedCubemapInfo = this.m_SelectedShadowCubemapOwnerInfo.cubemapShadowInfo; } else { this.m_SelectedCubemapInfo = hdriList[i]; } this.m_SelectedPositionOffset = Event.current.mousePosition - new Vector2(rect.x, rect.y); this.m_RenderOverlayThumbnailOnce = true; } } } else if ((Event.current.control && (Event.current.button == 0)) && ((this.m_SelectedCubemapInfo == null) && (this.m_SelectedShadowInfo == null))) { this.m_SelectedCubeMapOffsetIndex = i; this.m_SelectedCubeMapOffsetValue = infos.angleOffset - this.ComputeAngleOffsetFromMouseCoord(Event.current.mousePosition); } GUIUtility.hotControl = this.m_LookDevView.hotControl; Event.current.Use(); } if ((Event.current.GetTypeForControl(this.m_LookDevView.hotControl) == EventType.MouseDrag) && ((this.m_SelectedShadowInfo == shadowInfo) && (this.m_SelectedLightIconIndex == i))) { Vector2 mousePosition = Event.current.mousePosition; mousePosition.x = (((mousePosition.x - rect.x) / rect.width) * 2f) - 1f; mousePosition.y = ((1f - ((mousePosition.y - rect.y) / rect.height)) * 2f) - 1f; Vector2 vector4 = PositionToLatLong(mousePosition); this.m_SelectedShadowInfo.latitude = vector4.x; this.m_SelectedShadowInfo.longitude = vector4.y - infos.angleOffset; this.m_LookDevView.envLibrary.dirty = true; } if (Event.current.type == EventType.Repaint) { this.DrawLatLongThumbnail(infos, infos.angleOffset, 1f, 1f, rect); if (this.m_LookDevView.config.enableShadowCubemap) { if ((infos.cubemapShadowInfo != infos) || ((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos))) { CubemapInfo cubemapShadowInfo = infos.cubemapShadowInfo; if ((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos)) { cubemapShadowInfo = this.m_SelectedCubemapInfo; } float alpha = 1f; if (this.m_SelectedShadowInfo == shadowInfo) { alpha = 0.1f; } else if (((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos)) && (infos.cubemapShadowInfo != this.m_SelectedCubemapInfo)) { alpha = 0.5f; } this.DrawLatLongThumbnail(cubemapShadowInfo, infos.angleOffset, 0.3f, alpha, rect6); GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; GUI.DrawTexture(rect5, styles.sLatlongFrameTexture); GL.sRGBWrite = false; } GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; GUI.DrawTexture(rect3, styles.sLightTexture); GL.sRGBWrite = false; } if (flag2) { this.DrawSelectionFeedback(rect, black, firstViewGizmoColor); } } GUILayout.EndVertical(); } GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(250f) }; GUILayout.BeginVertical(options); if (((this.m_SelectedCubemap != null) || this.m_DragBeingPerformed) && this.GetInsertionRect(hdriList.Count).Contains(Event.current.mousePosition)) { GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]); GUILayoutUtility.GetRect((float)250f, (float)16f); GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]); } GUILayout.EndVertical(); if (flag) { EditorGUILayout.EndScrollView(); } this.HandleMouseInput(); this.RenderOverlayThumbnailIfNeeded(); if ((Event.current.type == EventType.Repaint) && (this.m_SelectedCubemap != null)) { this.m_LookDevView.Repaint(); } } }
void DrawPresetSwatchArea() { GUI.Box(new Rect(0, position.height - k_PresetsHeight, position.width, k_PresetsHeight), "", s_Styles.curveSwatchArea); Color curveColor = m_Color; curveColor.a *= 0.6f; float yPos = position.height - k_PresetsHeight + (k_PresetsHeight - k_PresetSwatchHeight) * 0.5f; InitCurvePresets(); var curveLibrary = m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib(); if (curveLibrary != null) { GUIContent guiContent = EditorGUIUtility.TempContent(string.Empty); for (int i = 0; i < curveLibrary.Count(); i++) { Rect swatchRect = new Rect(k_PresetSwatchMargin + (k_PresetSwatchWidth + k_PresetSwatchSeperation) * i, yPos, k_PresetSwatchWidth, k_PresetSwatchHeight); guiContent.tooltip = curveLibrary.GetName(i); if (GUI.Button(swatchRect, guiContent, s_Styles.curveSwatch)) { AnimationCurve max = m_CurveEditor.animationCurves[0].curve; AnimationCurve min = m_CurveEditor.animationCurves.Length > 1 ? m_CurveEditor.animationCurves[1].curve : null; var animCurve = curveLibrary.GetPreset(i) as DoubleCurve; max.keys = CurveEditorWindow.GetDenormalizedKeys(animCurve.maxCurve.keys, m_CurveEditor); max.postWrapMode = animCurve.maxCurve.postWrapMode; max.preWrapMode = animCurve.maxCurve.preWrapMode; if (min != null) { min.keys = CurveEditorWindow.GetDenormalizedKeys(animCurve.minCurve.keys, m_CurveEditor); min.postWrapMode = animCurve.minCurve.postWrapMode; min.preWrapMode = animCurve.minCurve.preWrapMode; } m_CurveEditor.SelectNone(); RefreshShownCurves(); SendEvent("CurveChanged", true); } if (Event.current.type == EventType.Repaint) { curveLibrary.Draw(swatchRect, i); } if (swatchRect.xMax > position.width - 2 * k_PresetSwatchMargin) { break; } } } // Dropdown Rect presetDropDownButtonRect = new Rect(k_PresetSwatchMargin - k_PresetsDropdownButtonSize, yPos + k_PresetSwatchSeperation, k_PresetsDropdownButtonSize, k_PresetsDropdownButtonSize); if (EditorGUI.DropdownButton(presetDropDownButtonRect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { if (m_MaxCurve != null) { AnimationCurve max = m_CurveEditor.animationCurves[0].curve; AnimationCurve maxCopy = new AnimationCurve(CurveEditorWindow.GetNormalizedKeys(max.keys, m_CurveEditor)); maxCopy.postWrapMode = max.postWrapMode; maxCopy.preWrapMode = max.preWrapMode; AnimationCurve minCopy = null; if (m_MinCurve != null) { AnimationCurve min = m_CurveEditor.animationCurves[1].curve; minCopy = new AnimationCurve(CurveEditorWindow.GetNormalizedKeys(min.keys, m_CurveEditor)); minCopy.postWrapMode = min.postWrapMode; minCopy.preWrapMode = min.preWrapMode; } m_CurvePresets.doubleCurveToSave = new DoubleCurve(minCopy, maxCopy, true); PopupWindow.Show(presetDropDownButtonRect, m_CurvePresets); } } }
/// <summary> /// <para>Show a popup with the given PopupWindowContent.</para> /// </summary> /// <param name="activatorRect">The rect of the button that opens the popup.</param> /// <param name="windowContent">The content to show in the popup window.</param> public static void Show(Rect activatorRect, PopupWindowContent windowContent) { PopupWindow.Show(activatorRect, windowContent, (PopupLocationHelper.PopupLocation[])null); }