public void OnEnable() { var rootElement = GetRootElement(); var path = EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath; var styleSheet = EditorGUIUtility.LoadRequired(path) as StyleSheet; rootElement.styleSheets.Add(styleSheet); var collectionWasNull = Collection == null; if (Collection == null) { Collection = new PackageCollection(); } if (SearchFilter == null) { SearchFilter = new PackageSearchFilter(); } if (SelectionManager == null) { SelectionManager = new SelectionManager(); } var windowResource = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(TemplatePath); if (windowResource != null) { root = windowResource.CloneTree(); rootElement.Add(root); root.StretchToParentSize(); Cache = new VisualElementCache(root); SelectionManager.SetCollection(Collection); Collection.OnFilterChanged += filter => SetupSelection(); Collection.SetFilter(PackageManagerPrefs.LastUsedPackageFilter); if (!collectionWasNull) { Collection.UpdatePackageCollection(true); } SetupPackageDetails(); SetupPackageList(); SetupSearchToolbar(); SetupToolbar(); SetupStatusbar(); SetupCollection(); SetupSelection(); // Disable filter while fetching first results if (!Collection.LatestListPackages.Any()) { PackageManagerToolbar.SetEnabled(false); } Collection.FetchListOfflineCache(!Collection.listOperationOfflineOngoing); Collection.FetchListCache(!Collection.listOperationOngoing); Collection.FetchSearchCache(!Collection.searchOperationOngoing); Collection.TriggerPackagesChanged(); } }
private static Texture2D LoadRequiredIcon(string name) { Texture2D texture2D = EditorGUIUtility.Load("Icons/" + name) as Texture2D; return((!(texture2D != null)) ? (EditorGUIUtility.LoadRequired("Builtin Skins/Icons/" + name) as Texture2D) : texture2D); }
public static StyleSheet GetStyleSheet() { var path = EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath; return(EditorGUIUtility.LoadRequired(path) as StyleSheet); }
public MaterialGraphPreviewGenerator() { m_Scene = EditorSceneManager.NewPreviewScene(); var camGO = EditorUtility.CreateGameObjectWithHideFlags("Preview Scene Camera", HideFlags.HideAndDontSave, typeof(Camera)); SceneManager.MoveGameObjectToScene(camGO, m_Scene); m_Camera = camGO.GetComponent <Camera>(); EditorUtility.SetCameraAnimateMaterials(m_Camera, true); m_Camera.cameraType = CameraType.Preview; m_Camera.enabled = false; m_Camera.clearFlags = CameraClearFlags.Depth; m_Camera.fieldOfView = 15; m_Camera.farClipPlane = 10.0f; m_Camera.nearClipPlane = 2.0f; m_Camera.backgroundColor = new Color(49.0f / 255.0f, 49.0f / 255.0f, 49.0f / 255.0f, 1.0f); // Explicitly use forward rendering for all previews // (deferred fails when generating some static previews at editor launch; and we never want // vertex lit previews if that is chosen in the player settings) m_Camera.renderingPath = RenderingPath.Forward; m_Camera.useOcclusionCulling = false; m_Camera.scene = m_Scene; var l0 = CreateLight(); SceneManager.MoveGameObjectToScene(l0, m_Scene); //previewScene.AddGameObject(l0); Light0 = l0.GetComponent <Light>(); var l1 = CreateLight(); SceneManager.MoveGameObjectToScene(l1, m_Scene); //previewScene.AddGameObject(l1); Light1 = l1.GetComponent <Light>(); Light0.color = new Color(0.769f, 0.769f, 0.769f, 1); // SceneView.kSceneViewFrontLight Light1.transform.rotation = Quaternion.Euler(340, 218, 177); Light1.color = new Color(.4f, .4f, .45f, 0f) * .7f; m_CheckerboardMaterial = new Material(Shader.Find("Hidden/Checkerboard")); m_CheckerboardMaterial.shader.hideFlags = HideFlags.HideAndDontSave; m_CheckerboardMaterial.hideFlags = HideFlags.HideAndDontSave; if (s_Meshes[0] == null) { var handleGo = (GameObject)EditorGUIUtility.LoadRequired("Previews/PreviewMaterials.fbx"); // @TODO: temp workaround to make it not render in the scene handleGo.SetActive(false); foreach (Transform t in handleGo.transform) { var meshFilter = t.GetComponent <MeshFilter>(); switch (t.name) { case "sphere": s_Meshes[0] = meshFilter.sharedMesh; break; case "cube": s_Meshes[1] = meshFilter.sharedMesh; break; case "cylinder": s_Meshes[2] = meshFilter.sharedMesh; break; case "torus": s_Meshes[3] = meshFilter.sharedMesh; break; default: Debug.LogWarning("Something is wrong, weird object found: " + t.name); break; } } s_MeshIcons[0] = EditorGUIUtility.IconContent("PreMatSphere"); s_MeshIcons[1] = EditorGUIUtility.IconContent("PreMatCube"); s_MeshIcons[2] = EditorGUIUtility.IconContent("PreMatCylinder"); s_MeshIcons[3] = EditorGUIUtility.IconContent("PreMatTorus"); s_MeshIcons[4] = EditorGUIUtility.IconContent("PreMatQuad"); s_LightIcons[0] = EditorGUIUtility.IconContent("PreMatLight0"); s_LightIcons[1] = EditorGUIUtility.IconContent("PreMatLight1"); s_TimeIcons[0] = EditorGUIUtility.IconContent("PlayButton"); s_TimeIcons[1] = EditorGUIUtility.IconContent("PauseButton"); Mesh quadMesh = Resources.GetBuiltinResource(typeof(Mesh), "Quad.fbx") as Mesh; s_Meshes[4] = quadMesh; } }
static FxStyles() { tickStyleRight = new GUIStyle("Label") { alignment = TextAnchor.MiddleRight, fontSize = 9 }; tickStyleLeft = new GUIStyle("Label") { alignment = TextAnchor.MiddleLeft, fontSize = 9 }; tickStyleCenter = new GUIStyle("Label") { alignment = TextAnchor.MiddleCenter, fontSize = 9 }; preSlider = new GUIStyle("PreSlider"); preSliderThumb = new GUIStyle("PreSliderThumb"); preButton = new GUIStyle("PreButton"); preDropdown = new GUIStyle("preDropdown"); preLabel = new GUIStyle("ShurikenLabel"); hueCenterCursor = new GUIStyle("ColorPicker2DThumb") { normal = { background = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/DarkSkin/Images/ShurikenPlus.png") }, fixedWidth = 6, fixedHeight = 6 }; hueRangeCursor = new GUIStyle(hueCenterCursor) { normal = { background = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/DarkSkin/Images/CircularToggle_ON.png") } }; wheelThumb = new GUIStyle("ColorPicker2DThumb"); centeredBoldLabel = new GUIStyle(GUI.skin.GetStyle("Label")) { alignment = TextAnchor.UpperCenter, fontStyle = FontStyle.Bold }; centeredMiniLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel) { alignment = TextAnchor.UpperCenter }; wheelThumbSize = new Vector2( !Mathf.Approximately(wheelThumb.fixedWidth, 0f) ? wheelThumb.fixedWidth : wheelThumb.padding.horizontal, !Mathf.Approximately(wheelThumb.fixedHeight, 0f) ? wheelThumb.fixedHeight : wheelThumb.padding.vertical ); header = new GUIStyle("ShurikenModuleTitle") { font = (new GUIStyle("Label")).font, border = new RectOffset(15, 7, 4, 4), fixedHeight = 22, contentOffset = new Vector2(20f, -2f) }; headerCheckbox = new GUIStyle("ShurikenCheckMark"); headerFoldout = new GUIStyle("Foldout"); playIcon = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/DarkSkin/Images/IN foldout act.png"); checkerIcon = (Texture2D)EditorGUIUtility.LoadRequired("Icons/CheckerFloor.png"); if (EditorGUIUtility.isProSkin) { paneOptionsIcon = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/DarkSkin/Images/pane options.png"); } else { paneOptionsIcon = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/LightSkin/Images/pane options.png"); } }
public ParadeMonitor() { m_ComputeShader = (ComputeShader)EditorGUIUtility.LoadRequired("Post FX/Monitors/WaveformCompute.compute"); }
public VectorscopeMonitor() { m_ComputeShader = (ComputeShader)EditorGUIUtility.LoadRequired("Post FX/Monitors/VectorscopeCompute.compute"); }
public override Texture LoadImage() { return((Texture)EditorGUIUtility.LoadRequired("skew_help.png")); }
void DrawRoot(Root root) { if (root != null) { { root.rect.x += 3; var rect = root.rect; rect.x += rect.width; rect.width = 96; if (GUI.Button(rect, "Add Event")) { ShowRootContextMenu(); } rect.x += rect.width + 16; rect.width = 24; var explorer = EditorGUIUtility.LoadRequired("React/explorer.png") as Texture2D; var oldShowExplorer = reactor.showExplorer; reactor.showExplorer = GUI.Toggle(rect, reactor.showExplorer, explorer, "button"); if (reactor.showExplorer != oldShowExplorer) { if (reactor.showExplorer) { if (paletteWindow == null) { paletteWindow = ScriptableObject.CreateInstance <ReactExplorerWindow>(); } paletteWindow.target = this; var wrect = new Rect(0, 0, 384, 512); wrect.x = EditorPrefs.GetFloat("React.Search.x", 50); wrect.y = EditorPrefs.GetFloat("React.Search.y", 50); paletteWindow.position = wrect; paletteWindow.ShowUtility(); } else { if (paletteWindow != null) { paletteWindow.CloseAndSaveState(); paletteWindow = null; } } } rect.x += rect.width + 8; var maximise = EditorGUIUtility.LoadRequired("React/maximise.png") as Texture2D; var minimise = EditorGUIUtility.LoadRequired("React/minimise.png") as Texture2D; if (GUI.Button(rect, reactor.goLarge ? minimise : maximise)) { reactor.goLarge = !reactor.goLarge; if (reactor.goLarge) { var w = EditorWindow.GetWindow <ReactEditorWindow>(); w.Show(); } else { Selection.activeGameObject = reactor.gameObject; } } root.rect.xMax = rect.xMax; } } }
public void OnGUI() { if (target == null) { return; } reactor = target as Reactor; root = reactor.Root; if (root == null) { return; } if (reactor.hotNode == root) { if (root.ChildCount > 0) { reactor.hotNode = root.Children[0]; } else { reactor.hotNode = null; } } root.Reactor = reactor; if (lastHotNode != reactor.hotNode) { lastHotNode = reactor.hotNode; if (paletteWindow != null) { paletteWindow.Update(); } if (searchWindow != null) { searchWindow.Update(); } } position = GUILayoutUtility.GetRect(Mathf.Min(EditorGUIUtility.currentViewWidth - 64, viewRect.width), viewRect.height); mousePosition = Event.current.mousePosition; PreProcessGraph(root, root); root.OnValidate(); if (style == null) { style = new GUIStyle(GUI.skin.box); style.normal.background = EditorGUIUtility.LoadRequired("React/decorator.psd") as Texture2D; style.border = new RectOffset(16, 16, 16, 16); style.overflow = new RectOffset(6, 6, 6, 6); } if (Event.current.type == EventType.Repaint) { if (schedule != null) { schedule(); schedule = null; } } dropZones.Clear(); OnValidateGUIState(); ProcessGUIEvents(); viewRect = position; cursor = new Rect(0, position.y + 15, 1, ROWHEIGHT); EditorGUI.BeginChangeCheck(); if (focusFirstControl) { GUI.FocusControl("FirstFocus"); } Draw(root, null); if (EditorGUI.EndChangeCheck() && target != null) { EditorUtility.SetDirty(target); } OnGUIHasBeenDrawn(); }
internal static void Initlize() { if (!IsValidRepo) { return; } gitCredentials = EditorGUIUtility.Load("UniGit/Git-Credentials.asset") as GitCredentials; gitSettings = EditorGUIUtility.LoadRequired("UniGit/Git-Settings.asset") as GitSettings; if (gitSettings == null) { gitSettings = ScriptableObject.CreateInstance <GitSettings>(); AssetDatabase.CreateAsset(gitSettings, "Assets/Editor Default Resources/UniGit/Git-Settings.asset"); AssetDatabase.SaveAssets(); } repository = new Repository(RepoPath); Update(); if (IconStyle == null) { IconStyle = new GUIStyle { imagePosition = ImagePosition.ImageOnly, alignment = TextAnchor.LowerLeft, padding = new RectOffset(2, 2, 2, 2) }; } if (icons == null) { icons = new Icons() { validIcon = EditorGUIUtility.IconContent("UniGit/success"), validIconSmall = EditorGUIUtility.IconContent("UniGit/success_small"), modifiedIcon = EditorGUIUtility.IconContent("UniGit/error"), modifiedIconSmall = EditorGUIUtility.IconContent("UniGit/error_small"), addedIcon = EditorGUIUtility.IconContent("UniGit/add"), addedIconSmall = EditorGUIUtility.IconContent("UniGit/add_small"), untrackedIcon = EditorGUIUtility.IconContent("UniGit/info"), untrackedIconSmall = EditorGUIUtility.IconContent("UniGit/info_small"), ignoredIcon = EditorGUIUtility.IconContent("UniGit/minus"), ignoredIconSmall = EditorGUIUtility.IconContent("UniGit/minus_small"), conflictIcon = EditorGUIUtility.IconContent("UniGit/warning"), conflictIconSmall = EditorGUIUtility.IconContent("UniGit/warning_small"), deletedIcon = EditorGUIUtility.IconContent("UniGit/deleted"), deletedIconSmall = EditorGUIUtility.IconContent("UniGit/deleted_small"), renamedIcon = EditorGUIUtility.IconContent("UniGit/renamed"), renamedIconSmall = EditorGUIUtility.IconContent("UniGit/renamed_small") }; } EditorApplication.projectWindowItemOnGUI += CustomIcons; GitLfsManager.Load(); GitHookManager.Load(); GitExternalManager.Load(); GitCredentialsManager.Load(); needsFetch = true; EditorApplication.update += OnEditorUpdate; }
public static Font GetFont() { return((Font)EditorGUIUtility.LoadRequired(UnityEditor.Experimental.EditorResources.fontsPath + "consola.ttf")); }
public static Font GetFont() { return((Font)EditorGUIUtility.LoadRequired("Packages/com.unity.mobile.android-logcat/Editor/Resources/consola.ttf")); }
public override void OnInteractivePreviewGUI(Rect r, GUIStyle background) { if (m_VisualEffectGO == null) { OnEnable(); } bool isRepaint = (Event.current.type == EventType.Repaint); m_Angles = VFXPreviewGUI.Drag2D(m_Angles, r); Renderer renderer = m_VisualEffectGO.GetComponent <Renderer>(); if (renderer == null) { return; } if (renderer.bounds.size != Vector3.zero) { m_CurrentBounds = renderer.bounds; //make sure that none of the bounds values are 0 if (m_CurrentBounds.size.x == 0) { Vector3 size = m_CurrentBounds.size; size.x = (m_CurrentBounds.size.y + m_CurrentBounds.size.z) * 0.1f; m_CurrentBounds.size = size; } if (m_CurrentBounds.size.y == 0) { Vector3 size = m_CurrentBounds.size; size.y = (m_CurrentBounds.size.x + m_CurrentBounds.size.z) * 0.1f; m_CurrentBounds.size = size; } if (m_CurrentBounds.size.z == 0) { Vector3 size = m_CurrentBounds.size; size.z = (m_CurrentBounds.size.x + m_CurrentBounds.size.y) * 0.1f; m_CurrentBounds.size = size; } } if (m_FrameCount == kSafeFrame) // wait to frame before asking the renderer bounds as it is a computed value. { float maxBounds = Mathf.Sqrt(m_CurrentBounds.size.x * m_CurrentBounds.size.x + m_CurrentBounds.size.y * m_CurrentBounds.size.y + m_CurrentBounds.size.z * m_CurrentBounds.size.z); m_Distance = Mathf.Max(0.01f, maxBounds * 1.25f); ComputeFarNear(); } else { ComputeFarNear(); } m_FrameCount++; if (Event.current.isScrollWheel) { m_Distance *= 1 + (Event.current.delta.y * .015f); } if (m_Mat == null) { m_Mat = (Material)EditorGUIUtility.LoadRequired("SceneView/HandleLines.mat"); } if (isRepaint) { m_PreviewUtility.BeginPreview(r, background); Quaternion rot = Quaternion.Euler(0, m_Angles.x, 0) * Quaternion.Euler(m_Angles.y, 0, 0); m_PreviewUtility.camera.transform.position = m_CurrentBounds.center + rot * new Vector3(0, 0, -m_Distance); m_PreviewUtility.camera.transform.localRotation = rot; m_PreviewUtility.DrawMesh(s_CubeWireFrame, Matrix4x4.TRS(m_CurrentBounds.center, Quaternion.identity, m_CurrentBounds.size), m_Mat, 0); m_PreviewUtility.Render(true); m_PreviewUtility.EndAndDrawPreview(r); // Ask for repaint so the effect is animated. Repaint(); } }
//public HierarchyElementData(string assetfilePath, bool isFolder) //{ // //if (BundleDataManager.Instance.GetInspectorElement()) // //ElementData = BundleDataManager.Instance.CreateInspectorElement(ref assetfilePath, IsFolder); //} static HierarchyElementData() { directoryIcon = (Texture)EditorGUIUtility.LoadRequired("folder.jpg"); }
private void InitPreview() { if (m_Loaded) { return; } m_Loaded = true; if (m_PreviewUtility == null) { m_PreviewUtility = new PreviewRenderUtility(true); #if UNITY_2017_1_OR_NEWER m_PreviewUtility.cameraFieldOfView = 30f; #else m_PreviewUtility.m_CameraFieldOfView = 30f; #endif GetPreviewCamera().cullingMask = 1 << PreviewCullingLayer; #if UNITY_5_6_OR_NEWER GetPreviewCamera().allowHDR = false; GetPreviewCamera().allowMSAA = false; #endif CreatePreviewInstances(); } if (m_FloorPlane == null) { m_FloorPlane = (Resources.GetBuiltinResource(typeof(Mesh), "New-Plane.fbx") as Mesh); } if (m_FloorTexture == null) { m_FloorTexture = (Texture2D)EditorGUIUtility.Load("Avatar/Textures/AvatarFloor.png"); } if (m_FloorMaterial == null) { Shader shader = EditorGUIUtility.LoadRequired("Previews/PreviewPlaneWithShadow.shader") as Shader; m_FloorMaterial = new Material(shader); m_FloorMaterial.mainTexture = m_FloorTexture; m_FloorMaterial.mainTextureScale = Vector2.one * 5f * 4f; m_FloorMaterial.SetVector("_Alphas", new Vector4(0.5f, 0.3f, 0f, 0f)); m_FloorMaterial.hideFlags = HideFlags.HideAndDontSave; } if (m_ReferenceInstance == null) { GameObject original = (GameObject)EditorGUIUtility.Load("Avatar/dial_flat.prefab"); m_ReferenceInstance = (GameObject)UnityEngine.Object.Instantiate(original, Vector3.zero, Quaternion.identity); InitInstantiatedPreviewRecursive(m_ReferenceInstance); AddSingleGO(m_ReferenceInstance); } if (m_DirectionInstance == null) { GameObject original2 = (GameObject)EditorGUIUtility.Load("Avatar/arrow.fbx"); m_DirectionInstance = (GameObject)UnityEngine.Object.Instantiate(original2, Vector3.zero, Quaternion.identity); InitInstantiatedPreviewRecursive(m_DirectionInstance); AddSingleGO(m_DirectionInstance); } if (m_PivotInstance == null) { GameObject original3 = (GameObject)EditorGUIUtility.Load("Avatar/root.fbx"); m_PivotInstance = (GameObject)UnityEngine.Object.Instantiate(original3, Vector3.zero, Quaternion.identity); InitInstantiatedPreviewRecursive(m_PivotInstance); AddSingleGO(m_PivotInstance); } if (m_RootInstance == null) { GameObject original4 = (GameObject)EditorGUIUtility.Load("Avatar/root.fbx"); m_RootInstance = (GameObject)UnityEngine.Object.Instantiate(original4, Vector3.zero, Quaternion.identity); InitInstantiatedPreviewRecursive(m_RootInstance); AddSingleGO(m_RootInstance); } m_ShowReference = EditorPrefs.GetBool("AvatarpreviewShowReference", true); SetPreviewCharacterEnabled(false, false); }
public void ObjectIconDropDown(Rect position, SerializedProperty iconProperty) { const float kDropDownArrowMargin = 2; const float kDropDownArrowWidth = 12; const float kDropDownArrowHeight = 12; if (s_IconTextureInactive == null) { s_IconTextureInactive = (Material)EditorGUIUtility.LoadRequired("Inspectors/InactiveGUI.mat"); } if (s_IconButtonStyle == null) { s_IconButtonStyle = new GUIStyle("IconButton") { fixedWidth = 0, fixedHeight = 0 } } ; void SelectIcon(UnityEngine.Object obj, bool isCanceled) { if (!isCanceled) { iconProperty.objectReferenceValue = obj; iconProperty.serializedObject.ApplyModifiedProperties(); SearchService.RefreshWindows(); } } if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive, s_IconButtonStyle)) { SearchQuery.ShowQueryIconPicker(SelectIcon); GUIUtility.ExitGUI(); } if (Event.current.type == EventType.Repaint) { var contentPosition = position; contentPosition.xMin += kDropDownArrowMargin; contentPosition.xMax -= kDropDownArrowMargin + kDropDownArrowWidth / 2; contentPosition.yMin += kDropDownArrowMargin; contentPosition.yMax -= kDropDownArrowMargin + kDropDownArrowWidth / 2; Rect arrowRect = new Rect( contentPosition.x + contentPosition.width - kDropDownArrowWidth / 2, contentPosition.y + contentPosition.height - kDropDownArrowHeight / 2, kDropDownArrowWidth, kDropDownArrowHeight); Texture2D icon = null; if (!iconProperty.hasMultipleDifferentValues) { icon = iconProperty.objectReferenceValue as Texture2D ?? AssetPreview.GetMiniThumbnail(targets[0]); } if (icon == null) { icon = Icons.favorite; } Vector2 iconSize = contentPosition.size; if (icon) { iconSize.x = Mathf.Min(icon.width, iconSize.x); iconSize.y = Mathf.Min(icon.height, iconSize.y); } Rect iconRect = new Rect( contentPosition.x + contentPosition.width / 2 - iconSize.x / 2, contentPosition.y + contentPosition.height / 2 - iconSize.y / 2, iconSize.x, iconSize.y); GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit); if (s_IconDropDown == null) { s_IconDropDown = EditorGUIUtility.IconContent("Icon Dropdown"); } GUIStyle.none.Draw(arrowRect, s_IconDropDown, false, false, false, false); } } void AddProvider(ReorderableList list) { var menu = new GenericMenu(); var disabledProviders = GetDisabledProviders().ToList(); for (var i = 0; i < disabledProviders.Count; ++i) { var provider = disabledProviders[i]; menu.AddItem(new GUIContent(provider.name), false, AddProvider, provider); if (!provider.isExplicitProvider && i + 1 < disabledProviders.Count && disabledProviders[i + 1].isExplicitProvider) { menu.AddSeparator(string.Empty); } } menu.ShowAsContext(); } void AddProvider(object providerObj) { if (providerObj is SearchProvider provider && !m_EnabledProviderIds.Contains(provider.id)) { m_EnabledProviderIds.Add(provider.id); UpdateEnabledProviders(); } } void RemoveProvider(ReorderableList list) { var index = list.index; if (index != -1 && index < m_EnabledProviderIds.Count) { var toRemove = SearchService.GetProvider(m_EnabledProviderIds[index]); if (toRemove == null) { return; } m_EnabledProviderIds.Remove(toRemove.id); UpdateEnabledProviders(); if (index >= list.count) { list.index = list.count - 1; } } } void UpdateEnabledProviders() { m_ProvidersProperty.arraySize = m_EnabledProviderIds.Count; for (var i = 0; i < m_EnabledProviderIds.Count; ++i) { m_ProvidersProperty.GetArrayElementAtIndex(i).stringValue = m_EnabledProviderIds[i]; } serializedObject.ApplyModifiedProperties(); SetupContext(); } void DrawProviderElement(Rect rect, int index, bool selected, bool focused) { if (index >= 0 && index < m_EnabledProviderIds.Count) { GUI.Label(rect, SearchService.GetProvider(m_EnabledProviderIds[index])?.name ?? "<unknown>"); } } void CheckContext() { if (m_SearchContext.searchText != m_TextProperty.stringValue) { SetupContext(); } } }
private void DrawSelectableObjects() { List <UnityEngine.Object> selectableObjects = this.m_Root == null?this.m_SelectableObjects.Keys.ToList() : this.m_SelectableObjects[this.m_Root]; this.m_ScrollPosition = EditorGUILayout.BeginScrollView(this.m_ScrollPosition); foreach (UnityEngine.Object obj in selectableObjects) { if (!SearchMatch(obj)) { continue; } Color backgroundColor = GUI.backgroundColor; Color textColor = ObjectPickerWindow.m_Styles.elementButton.normal.textColor; int padding = ObjectPickerWindow.m_Styles.elementButton.padding.left; GUIContent label = new GUIContent(obj.name); Rect rect = GUILayoutUtility.GetRect(label, ObjectPickerWindow.m_Styles.elementButton, GUILayout.Height(20f)); GUI.backgroundColor = (rect.Contains(Event.current.mousePosition) ? GUI.backgroundColor : new Color(0, 0, 0, 0.0f)); ObjectPickerWindow.m_Styles.elementButton.normal.textColor = (rect.Contains(Event.current.mousePosition) ? Color.white : textColor); Texture2D icon = EditorGUIUtility.LoadRequired("d_ScriptableObject Icon") as Texture2D; IconAttribute iconAttribute = obj.GetType().GetCustomAttribute <IconAttribute>(); if (iconAttribute != null) { if (iconAttribute.type != null) { icon = AssetPreview.GetMiniTypeThumbnail(iconAttribute.type); } else { icon = Resources.Load <Texture2D>(iconAttribute.path); } } ObjectPickerWindow.m_Styles.elementButton.padding.left = (icon != null ? 22 : padding); if (GUI.Button(rect, label, ObjectPickerWindow.m_Styles.elementButton)) { if (this.m_Root != null && this.m_SelectableObjects[this.m_Root].Count > 0) { onSelectCallback?.Invoke(obj); Close(); } this.m_Root = obj; if (!this.m_SelectChildren) { onSelectCallback?.Invoke(this.m_Root); Close(); } } GUI.backgroundColor = backgroundColor; ObjectPickerWindow.m_Styles.elementButton.normal.textColor = textColor; ObjectPickerWindow.m_Styles.elementButton.padding.left = padding; if (icon != null) { GUI.Label(new Rect(rect.x, rect.y, 20f, 20f), icon); } } if (this.m_Root == null) { if (this.m_AcceptNull) { GUIContent nullContent = new GUIContent("Null"); Rect rect2 = GUILayoutUtility.GetRect(nullContent, ObjectPickerWindow.m_Styles.elementButton, GUILayout.Height(20f)); GUI.backgroundColor = (rect2.Contains(Event.current.mousePosition) ? GUI.backgroundColor : new Color(0, 0, 0, 0.0f)); if (GUI.Button(rect2, nullContent, ObjectPickerWindow.m_Styles.elementButton)) { onSelectCallback?.Invoke(null); Close(); } GUI.Label(new Rect(rect2.x, rect2.y, 20f, 20f), EditorGUIUtility.LoadRequired("d_ScriptableObject On Icon") as Texture2D); } GUIContent createContent = new GUIContent("Create New " + this.m_Type.Name); Rect rect1 = GUILayoutUtility.GetRect(createContent, ObjectPickerWindow.m_Styles.elementButton, GUILayout.Height(20f)); GUI.backgroundColor = (rect1.Contains(Event.current.mousePosition) ? GUI.backgroundColor : new Color(0, 0, 0, 0.0f)); if (GUI.Button(rect1, createContent, ObjectPickerWindow.m_Styles.elementButton)) { onCreateCallback?.Invoke(); Close(); } GUI.Label(new Rect(rect1.x, rect1.y, 20f, 20f), EditorGUIUtility.LoadRequired("d_ScriptableObject On Icon") as Texture2D); } EditorGUILayout.EndScrollView(); }
private static Texture2D LoadRequiredIcon(string name) { Texture2D texture2D = EditorGUIUtility.Load(string.Concat("Icons/", name)) as Texture2D; return(texture2D == null ? EditorGUIUtility.LoadRequired(string.Concat("Builtin Skins/Icons/", name)) as Texture2D : texture2D); }
public override Texture LoadImage() { return((Texture)EditorGUIUtility.LoadRequired("MegaFiers\\bend_help.png")); }
public override void OnInspectorGUI() { Map m = (Map)target; showDimensions = EditorGUILayout.Foldout(showDimensions, "Map Dimensions"); if (showDimensions) { // EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); GUILayout.Label("Width", GUILayout.Width(78)); float nextXSz = EditorGUILayout.FloatField(m.size.x, GUILayout.Width(32)); GUILayout.Label("Height", GUILayout.Width(78)); float nextYSz = EditorGUILayout.FloatField(m.size.y, GUILayout.Width(32)); Vector2 nextSz = new Vector2(nextXSz, nextYSz); if (nextSz != m.size) { RegisterUndo("Map Size Change"); m.size = nextSz; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Side Length", GUILayout.Width(78)); float nextLength = EditorGUILayout.FloatField(m.sideLength, GUILayout.Width(32)); if (nextLength != m.sideLength) { RegisterUndo("Map Side Length Change"); m.sideLength = nextLength; } GUILayout.Label("Tile Height", GUILayout.Width(78)); float nextHeight = EditorGUILayout.FloatField(m.tileHeight, GUILayout.Width(32)); if (nextHeight != m.tileHeight) { RegisterUndo("Map Side Height Change"); m.tileHeight = nextHeight; } GUILayout.EndHorizontal(); // EditorGUI.indentLevel--; } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); GUILayout.Label("Edit Z", GUILayout.Width(78)); int nextZ = EditorGUILayout.IntSlider(editZ, 0, 20); if (nextZ != editZ) { // RegisterUndo(target, "Map Height Selection"); editZ = nextZ; } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUIContent[] toolbarOptions = new GUIContent[3]; toolbarOptions[(int)EditMode.AddRemove] = new GUIContent("Add/Remove"); toolbarOptions[(int)EditMode.Reshape] = new GUIContent("Reshape"); toolbarOptions[(int)EditMode.Paint] = new GUIContent("Paint"); EditMode nextMode = (EditMode)GUILayout.Toolbar((int)editMode, toolbarOptions); EditorGUILayout.EndHorizontal(); if (nextMode != editMode) { editMode = nextMode; editModeChanged = true; } if (editMode == EditMode.AddRemove || editMode == EditMode.Reshape) { //show inset/offset settings for current stamp GUILayout.BeginHorizontal(); GUILayout.Label("Invisible", GUILayout.Width(78)); makeInvisibleTiles = EditorGUILayout.Toggle(makeInvisibleTiles); GUILayout.EndHorizontal(); GUILayout.Label("Side Insets"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("-X", GUILayout.Width(32)); sideInsets[(int)Neighbors.FrontLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackRightIdx]); GUILayout.Label("+X", GUILayout.Width(32)); sideInsets[(int)Neighbors.BackRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontLeftIdx]); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("-Y", GUILayout.Width(32)); sideInsets[(int)Neighbors.FrontRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackLeftIdx]); GUILayout.Label("+Y", GUILayout.Width(32)); sideInsets[(int)Neighbors.BackLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontRightIdx]); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("-Z", GUILayout.Width(32)); sideInsets[(int)Neighbors.BottomIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BottomIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.TopIdx]); GUILayout.Label("+Z", GUILayout.Width(32)); sideInsets[(int)Neighbors.TopIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.TopIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BottomIdx]); EditorGUILayout.EndHorizontal(); // GUILayout.Label("Corner Insets (not yet implemented)"); // EditorGUILayout.BeginHorizontal(); // GUILayout.Label(" 0", GUILayout.Width(32)); // cornerInsets[(int)Corners.Front] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Front], GUILayout.Width(32)), 0, 1.0f); // GUILayout.Label("+X", GUILayout.Width(32)); // cornerInsets[(int)Corners.Right] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Right], GUILayout.Width(32)), 0, 1.0f); // EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); // GUILayout.Label("+Y", GUILayout.Width(32)); // cornerInsets[(int)Corners.Left ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Left ], GUILayout.Width(32)), 0, 1.0f); // GUILayout.Label("+XY", GUILayout.Width(32)); // cornerInsets[(int)Corners.Back ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Back ], GUILayout.Width(32)), 0, 1.0f); // EditorGUILayout.EndHorizontal(); } else if (editMode == EditMode.Paint) { EditorGUILayout.Separator(); specScrollPos = EditorGUILayout.BeginScrollView(specScrollPos, true, false, GUILayout.Height(80)); EditorGUILayout.BeginHorizontal(GUILayout.Height(64)); //show list of texture specs controls //a texture spec is a rectangular Texture2D with some metadata //only for now, there's no metadata. //this metadata gets stored in the map object, which composes the //textures into an atlas. uvs are mapped from this atlas. //changes to the texture spec list force recreation of the mesh. //texture spec info for each face is stored as part of the MapTile class. Texture2D[] textures = new Texture2D[m.TileSpecCount + 1]; if (specPlaceholderTexture == null) { specPlaceholderTexture = EditorGUIUtility.LoadRequired("SpecPlaceholder.png") as Texture2D; } for (int i = 0; i < m.TileSpecCount; i++) { Texture2D specTex = m.TileSpecAt(i).texture; if (specTex != null) { textures[i] = specTex; } else { textures[i] = specPlaceholderTexture; } } textures[m.TileSpecCount] = specPlaceholderTexture; var names = new Dictionary <string, int>(); for (int i = 0; i < textures.Length; i++) { Texture2D tex = textures[i]; GUIUpdateTexture(tex, i, names); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); string n = GUI.GetNameOfFocusedControl(); if (names.ContainsKey(n)) { if (names[n] < m.TileSpecCount) { specSelectedSpec = names[n]; } } EditorGUI.indentLevel++; //now, show the parameters for this spec bool oldEnabled = GUI.enabled; GUI.enabled = specSelectedSpec < m.TileSpecCount; if (GUILayout.Button("Delete Tile")) { RegisterUndo("Delete Tile Spec"); m.RemoveTileSpecAt(specSelectedSpec); while (specSelectedSpec >= m.TileSpecCount) { specSelectedSpec--; if (specSelectedSpec < 0) { specSelectedSpec = 0; break; } } } GUI.enabled = oldEnabled; EditorGUI.indentLevel--; EditorGUILayout.Separator(); } if (GUI.changed) { EditorUtility.SetDirty(target); } }