void OnGUI() { if (GUI.Button(new Rect(10.0f, 10.0f, 100.0f, 30.0f), "Send Event")) { EditorWindow win = GetWindow <receiveEvent>(); win.SendEvent(EditorGUIUtility.CommandEvent("Paste")); } EditorGUI.DrawRect(new Rect(10, 10, 160, 60), new Color(0.5f, 0.5f, 0.85f)); EditorGUI.DrawRect(new Rect(20, 20, 140, 40), new Color(0.9f, 0.9f, 0.9f)); EditorGUIUtility.AddCursorRect(new Rect(20, 20, 140, 40), MouseCursor.Zoom); //ObjectPickerを開く if (GUILayout.Button("ShowObjectPicker")) { int controlID = EditorGUIUtility.GetControlID(FocusType.Passive); //CameraのコンポーネントをタッチしているGameObjectを選択する EditorGUIUtility.ShowObjectPicker <Camera> (null, true, "", controlID); } string commandName = Event.current.commandName; if (commandName == "ObjectSelectorUpdated") { currentObject = EditorGUIUtility.GetObjectPickerObject(); //ObjectPickerを開いている間はEditorWindowの再描画が行われないのでRepaintを呼びだす Repaint(); } else if (commandName == "ObjectSelectorClosed") { selectedObject = EditorGUIUtility.GetObjectPickerObject(); } EditorGUILayout.ObjectField(currentObject, typeof(Object), true); EditorGUILayout.ObjectField(selectedObject, typeof(Object), true); }
public static string TextAreaForDocBrowser(Rect position, string text, GUIStyle style) { int id = EditorGUIUtility.GetControlID("TextAreaWithTabHandling".GetHashCode(), FocusType.Keyboard, position); var editor = EditorGUI.s_RecycledEditor; var evt = Event.current; if (editor.IsEditingControl(id) && evt.type == EventType.KeyDown) { if (evt.character == '\t') { editor.Insert('\t'); evt.Use(); GUI.changed = true; text = editor.text; } if (evt.character == '\n') { editor.Insert('\n'); evt.Use(); GUI.changed = true; text = editor.text; } } bool dummy; text = EditorGUI.DoTextField(editor, id, EditorGUI.IndentedRect(position), text, style, null, out dummy, false, true, false); return(text); }
private static void OnScene(SceneView sceneview) { var currentEvent = Event.current; if (currentEvent.GetTypeForControl(EditorGUIUtility.GetControlID(FocusType.Passive)) == EventType.keyDown) { if (currentEvent.keyCode == KeyCode.Space) { if (ShowContextMenu()) { currentEvent.Use(); } } } GameObject[] gameObjects = FindObjectsOfType <GameObject>(); foreach (GameObject go in gameObjects) { if (PrefabUtility.GetPrefabType(go) == PrefabType.Prefab) { continue; } foreach (MonoBehaviour mb in go.GetComponents <MonoBehaviour>()) { ISceneGUI sceneGui = mb as ISceneGUI; if (sceneGui != null) { sceneGui.OnSceneGUI(); } } } }
public static int ToggleButton(Rect position, int current, int flag, GUIContent[] iconsOn, GUIContent[] iconsOff, GUIStyle style) { if (iconsOn == null) { return(current); } var enabled = (current & flag) == flag; var toggleID = EditorGUIUtility.GetControlID(kToggleButtonHashCode, FocusType.Keyboard, position); EditorGUI.BeginChangeCheck(); GUI.Toggle(position, toggleID, false, enabled ? iconsOn[0] : iconsOff[0], style); if (EditorGUI.EndChangeCheck()) //if (GUI.Button(position, toggleID, enabled ? iconsOn[0] : iconsOff[0], style)) { if (!enabled) { current |= flag; } else { current &= ~flag; } } return(current); }
//[MenuItem("UnityHelpers/Create Asset 2")] //public static void CreateAsset2() //{ // CreateAsset<LevelsData>(); //} void OnGUI() { if (!isOpen) { int controlID = EditorGUIUtility.GetControlID(FocusType.Passive); EditorGUIUtility.ShowObjectPicker <MonoScript>(null, false, "", controlID); isOpen = true; } if (Event.current.commandName == "ObjectSelectorClosed") { var script = (MonoScript)EditorGUIUtility.GetObjectPickerObject(); if (script != null) { var path = AssetDatabase.GetAssetOrScenePath(script); var classname = Path.GetFileNameWithoutExtension(path); var type = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(x => x.GetTypes()) .FirstOrDefault(x => x.Name == classname); if (type == null) { Debug.LogError("Could not find type with class name: " + classname); } else { CreateAsset(type); } Close(); } } }
//create icon button void IconButton(int i) { //set icon button texture if (inventory[i].Icon != null) { curTexture = inventory[i].Icon.texture; } else { curTexture = null; } //if clicking button, bring up object picker to select sprite if (GUILayout.Button(curTexture, GUILayout.Width(SPRITE_BUTTON_SIZE), GUILayout.Height(SPRITE_BUTTON_SIZE))) { int controllerID = EditorGUIUtility.GetControlID(FocusType.Passive); EditorGUIUtility.ShowObjectPicker <Sprite>(null, true, null, controllerID); curIndex = i; } //update icon button image string commandName = Event.current.commandName; if (commandName == "ObjectSelectorUpdated") { if (curIndex != -1) { inventory[curIndex].Icon = EditorGUIUtility.GetObjectPickerObject() as Sprite; } Repaint(); } }
public static void OnSceneViewGUI(SceneView sv) { Event e = Event.current; if (e == null) { return; } int controlId = EditorGUIUtility.GetControlID(FocusType.Passive, sv.position); if (e.type == EventType.DragUpdated) { Object[] draggedObjects = DragAndDrop.objectReferences; if (draggedObjects.Length == 1 && draggedObjects[0] is GTerrainData) { DragAndDrop.AcceptDrag(); DragAndDrop.visualMode = DragAndDropVisualMode.Generic; DragAndDrop.activeControlID = controlId; e.Use(); } } else if (e.type == EventType.DragPerform) { Object[] draggedObjects = DragAndDrop.objectReferences; if (draggedObjects.Length == 1 && draggedObjects[0] is GTerrainData) { GTerrainData data = draggedObjects[0] as GTerrainData; GCommon.CreateTerrain(data); e.Use(); } } }
private void Draw() { var path = _cp.GetPath(); for (int i = 0; i < path.Count; ++i) { var p = path[i]; Handles.color = i == selectId ? Handles.selectedColor : Color.red; var id = EditorGUIUtility.GetControlID(FocusType.Passive); var oldp = _cp.transform.TransformPoint(p); var size = HandleUtility.GetHandleSize(oldp) * .05f; var np = Handles.FreeMoveHandle(id, oldp, Quaternion.identity, size, Vector3.zero, Handles.DotHandleCap); if (id == EditorGUIUtility.hotControl) { selectId = i; } if (oldp != np) { Undo.RecordObject(_cp, "move point"); _cp.SetPoint(i, np); } if (_cp.ShowSequence) { Handles.Label(np, i.ToString()); } } Repaint(); }
private void Load() { int controlID = EditorGUIUtility.GetControlID(FocusType.Passive); isPicking = true; EditorGUIUtility.ShowObjectPicker <LevelRegion>(null, false, "", controlID); }
private void DoTextAligmentControl(Rect position, SerializedProperty alignment) { GUIContent alingmentContent = new GUIContent("Alignment"); #if UNITY_5_3 int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, EditorGUIUtility.native, position); #else int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, FocusType.Passive, position); #endif EditorGUIUtility.SetIconSize(new Vector2(15, 15)); EditorGUI.BeginProperty(position, alingmentContent, alignment); { Rect controlArea = EditorGUI.PrefixLabel(position, id, alingmentContent); float width = kAlignmentButtonWidth * 3; float spacing = Mathf.Clamp(controlArea.width - width * 2, 2, 10); Rect horizontalAligment = new Rect(controlArea.x, controlArea.y, width, controlArea.height); Rect verticalAligment = new Rect(horizontalAligment.xMax + spacing, controlArea.y, width, controlArea.height); DoHorizontalAligmentControl(horizontalAligment, alignment); DoVerticalAligmentControl(verticalAligment, alignment); } EditorGUI.EndProperty(); EditorGUIUtility.SetIconSize(Vector2.zero); }
// Opens the object selection window when the "Load existing Gesture" is pressed. private void ShowPicker(BKI_UIType uiType) { lastSelected = uiType; pickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100; string buttonText = ""; if (uiType == BKI_UIType.right) { buttonText = "rhGes_"; } if (uiType == BKI_UIType.left) { buttonText = "lhGes_"; } if (uiType == BKI_UIType.combi) { buttonText = "combiGes_"; EditorGUIUtility.ShowObjectPicker <BKI_CombiGestureClass>(null, false, buttonText, pickerWindow); } else { EditorGUIUtility.ShowObjectPicker <BKI_SingleGestureClass>(null, false, buttonText, pickerWindow); } }
public override void OnGUI() { var positionId = EditorGUIUtility.GetControlID(kCenterGizmoHash, FocusType.Passive); var radiusId = EditorGUIUtility.GetControlID(kRadiusGizmoHash, FocusType.Passive); var position = GetValue(kExposureGizmoPosition); var radius = GetValue(kExposureGizmoRadius); var cameraPosition = GetValue(kCameraPosition); var zoom = GetValue(kZoom); var actualPosition = position * zoom + cameraPosition; var actualRadius = radius * zoom; Handles.color = Handles.xAxisColor; actualPosition = EditorGUIX.PositionHandle2D(positionId, actualPosition, Styles.kPositionSize); Handles.color = Handles.yAxisColor; actualRadius = EditorGUIX.RadiusHandle2D(radiusId, actualPosition, actualRadius); var newPosition = (actualPosition - cameraPosition) / zoom; var newRadius = actualRadius / zoom; if ((position - newPosition).sqrMagnitude > Styles.kPositionThreshold || Mathf.Abs(newRadius - radius) > Styles.kRadiusThreshold) { SetValue(kExposureGizmoPosition, newPosition); SetValue(kExposureGizmoRadius, newRadius); ExecuteCommand(kCmdProcessFromColorCorrection); } }
/// <summary> /// 画每个list里面的元素组件UI /// </summary> /// <param name="rect"></param> /// <param name="index"></param> /// <param name="selected"></param> /// <param name="focused"></param> private void DrawElement(Rect rect, int index, bool selected, bool focused) { if (index >= this.m_listObjs.Count) { return; } var controllId = EditorGUIUtility.GetControlID(-1, FocusType.Passive); var previoursObject = this.m_listObjs[index]; Object changedObject = EditorGUI.ObjectField(rect, previoursObject, typeof(Object), false) as Object; if (previoursObject != changedObject) { if (previoursObject != null) { this.m_actionChangeListItem?.Invoke(previoursObject); } this.m_listObjs[index] = changedObject;//改变list的里面item } if (GUIUtility.keyboardControl == controllId && selected == false) { //在list列表中选择该item this.m_packableList.index = index; } }
Rect InfoField(Rect itemPosition, EmptyFunctionInfo info, GUIStyle style) { GUI.SetNextControlName(info.assetPath); var controlID = EditorGUIUtility.GetControlID(FocusType.Passive); var e = Event.current; switch (e.GetTypeForControl(controlID)) { case EventType.Repaint: style.Draw(itemPosition, false, false, _selected == info, false); EditorGUI.LabelField(itemPosition, string.Format("{0} ({1} {2}行目)", info.assetPath, info.funcName, info.lineNumber)); break; case EventType.MouseDown: if (e.button == 0 && itemPosition.Contains(e.mousePosition)) { if (e.clickCount == 1) { SelectInfo(info); e.Use(); } else if (e.clickCount == 2) { AssetDatabase.OpenAsset(GetScript(_selected), _selected.lineNumber); e.Use(); } } break; } return(itemPosition); }
public static bool ButtonLogic(Rect rect) { int buttonGuid = EditorGUIUtility.GetControlID(FocusType.Passive); bool result = false; switch (Event.current.type) { case EventType.MouseDown: if (rect.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = buttonGuid; Event.current.Use(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == buttonGuid) { if (rect.Contains(Event.current.mousePosition)) { result = true; Event.current.Use(); } GUIUtility.hotControl = 0; } break; } return(result); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { EditorGUI.BeginProperty(position, label, prop); position = EditorGUI.PrefixLabel(position, EditorGUIUtility.GetControlID(FocusType.Passive), label); int originalIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; System.Enum propEnum = GetReflectedFieldRecursively <System.Enum>(prop); if (propEnum == null) { return; } EditorGUI.BeginChangeCheck(); propEnum = EditorGUI.EnumMaskField(position, propEnum); if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(prop.serializedObject.targetObjects, "Inspector"); SetReflectedFieldRecursively(prop, propEnum); EditorUtility.SetDirty(prop.serializedObject.targetObject); } EditorGUI.indentLevel = originalIndentLevel; EditorGUI.EndProperty(); }
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) { Rect position = rect; foreach (SerializedProperty a in prop) { var height = Mathf.Max(LineHeight, EditorGUI.GetPropertyHeight(a)); position.height = height; if(a.name == "Decision") { EditorGUI.PropertyField(position, a, new GUIContent(a.name)); position.y += height; var @object = a.objectReferenceValue; AIDecision @typedObject = @object as AIDecision; if (@typedObject != null && !string.IsNullOrEmpty(@typedObject.Label)) { EditorGUI.LabelField(position, "Label", @typedObject.Label); position.y += height; } else { EditorGUIUtility.GetControlID(FocusType.Passive); } } else { EditorGUI.PropertyField(position, a, new GUIContent(a.name)); position.y += height; } } }
private static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style) { int hashCode = "AlignToggle".GetHashCode(); int id = EditorGUIUtility.GetControlID(hashCode, FocusType.Passive, position); Event evt = Event.current; // Toggle selected toggle on space or return key if (EditorGUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)) { value = !value; evt.Use(); GUI.changed = true; } if (evt.type == EventType.KeyDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { GUIUtility.keyboardControl = id; EditorGUIUtility.editingTextField = false; HandleUtility.Repaint(); } bool returnValue = GUI.Toggle(position, id, value, content, style); return(returnValue); }
public static bool NoField(string label, bool value) { GUIStyle style = new GUIStyle(EditorStyles.toolbarButton); if (value) { style.normal.textColor = Color.black; GUI.color = new Color(0.7f, 0.7f, 1); } else { style.normal.textColor = new Color(0, 0, 0, 0.5f); GUI.color = new Color(1, 1, 1, 0.5f); } EditorGUILayout.LabelField(label, style, GUILayout.Width(20)); GUI.color = Color.white; Rect rect = GUILayoutUtility.GetLastRect(); int ControlID = EditorGUIUtility.GetControlID(FocusType.Keyboard); switch (Event.current.GetTypeForControl(ControlID)) { case EventType.MouseDown: if (rect.Contains(Event.current.mousePosition)) { value = !value; Event.current.Use(); } break; } return(value); }
public void DrawGPUInstancerPrototypeAddButton() { Rect prototypeRect = GUILayoutUtility.GetRect(PROTOTYPE_RECT_SIZE, PROTOTYPE_RECT_SIZE, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); Rect iconRect = new Rect(prototypeRect.position + PROTOTYPE_RECT_PADDING_VECTOR, PROTOTYPE_RECT_SIZE_VECTOR); iconRect.height -= 22; GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.add, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, iconRect, () => { _pickerOverride = null; pickerControlID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100; ShowObjectPicker(); }, true, true, (o) => { AddPickerObject(o); }); iconRect.y += iconRect.height; iconRect.height = 22; GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.addMulti, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, iconRect, () => { GPUInstancerMultiAddWindow.ShowWindow(GUIUtility.GUIToScreenPoint(iconRect.position), this); }, true, true, (o) => { AddPickerObject(o); }); }
void DrawPackableElement(Rect rect, int index, bool selected, bool focused) { var property = m_Packables.GetArrayElementAtIndex(index); var controlID = EditorGUIUtility.GetControlID(s_Styles.packableElementHash, FocusType.Passive); var previousObject = property.objectReferenceValue; EditorGUI.BeginChangeCheck(); var changedObject = EditorGUI.DoObjectField(rect, rect, controlID, previousObject, typeof(Object), null, ValidateObjectForPackableFieldAssignment, false); if (EditorGUI.EndChangeCheck()) { // Always call Remove() on the previous object if we swapping the object field item. // This ensure the Sprites was pack in this atlas will be refreshed of it unbound. if (previousObject != null) { spriteAtlas.Remove(new Object[] { previousObject }); } property.objectReferenceValue = changedObject; } if (GUIUtility.keyboardControl == controlID && !selected) { m_PackableList.index = index; } }
void SkinInit() { if (m_Style == null) { GUIStyle foldOut = "IN Foldout"; m_Style = new GUIStyle(foldOut); m_Style.stretchWidth = false; m_Style.richText = false; m_Style.border = new RectOffset(-800, -10, 0, -10); m_Style.padding = new RectOffset(11, 16, 2, 2); m_Style.fixedWidth = 0; m_Style.alignment = TextAnchor.MiddleCenter; m_Style.clipping = TextClipping.Clip; m_Style.normal.background = foldOut.onFocused.background; m_Style.normal.scaledBackgrounds = foldOut.onFocused.scaledBackgrounds; m_Style.normal.textColor = foldOut.normal.textColor; m_Style.onNormal.background = m_Style.normal.background; m_Style.onNormal.scaledBackgrounds = m_Style.normal.scaledBackgrounds; m_Style.onNormal.textColor = m_Style.normal.textColor; m_Style.onActive.background = m_Style.normal.background; m_Style.onActive.scaledBackgrounds = m_Style.normal.scaledBackgrounds; m_Style.onActive.textColor = m_Style.normal.textColor; m_Style.active.background = m_Style.normal.background; m_Style.active.scaledBackgrounds = m_Style.normal.scaledBackgrounds; m_Style.active.textColor = m_Style.normal.textColor; m_Style.onFocused.background = m_Style.normal.background; m_Style.onFocused.scaledBackgrounds = m_Style.normal.scaledBackgrounds; m_Style.onFocused.textColor = m_Style.normal.textColor; m_Style.focused.background = m_Style.normal.background; m_Style.focused.scaledBackgrounds = m_Style.normal.scaledBackgrounds; m_Style.focused.textColor = m_Style.normal.textColor; m_WarningIcon = EditorGUIUtility.TrIconContent("console.warnicon.sml", "Duplicate label name found or label hash value clash. Please use a different name"); m_SpriteCategoryRenameID = EditorGUIUtility.GetControlID("SpriteCategoryRenameControlId".GetHashCode(), FocusType.Passive); } }
/// <summary> /// 选择物体 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T PickObj <T>(T scrCurrent, string info) where T : Component { T effectGO = null; if (GUILayout.Button(info)) { //create a window picker control ID var currentPickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive); //use the ID you just created EditorGUIUtility.ShowObjectPicker <GameObject>(scrCurrent == null ? null : scrCurrent.gameObject, true, "", currentPickerWindow); } if (Event.current.commandName == "ObjectSelectorClosed") { var objSelected = EditorGUIUtility.GetObjectPickerObject(); if (objSelected != null) { effectGO = (objSelected as GameObject).GetComponent <T>(); // Debug.Log("object selected"); } } return(effectGO); }
public virtual void OnHeaderGUI() { string title = target.name; if (renaming != 0 && Selection.Contains(target)) { int controlID = EditorGUIUtility.GetControlID(FocusType.Keyboard) + 1; if (renaming == 1) { EditorGUIUtility.keyboardControl = controlID; EditorGUIUtility.editingTextField = true; renaming = 2; } target.name = EditorGUILayout.TextField(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); if (!EditorGUIUtility.editingTextField) { Rename(target.name); renaming = 0; } } else { GUILayout.Space(2); GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); } }
public override void OnGUI() { var resizeHandleId = EditorGUIUtility.GetControlID(kResizeHandle, FocusType.Passive); GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal(GUILayout.Width(m_SpliterPosition)); m_InspectorToolbar.OnGUI(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); m_CanvasToolbar.OnGUI(); GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(m_SpliterPosition)); m_Inspector.OnGUI(); GUILayout.EndVertical(); m_SpliterPosition = EditorGUIXLayout.HorizontalHandle(resizeHandleId, m_SpliterPosition, kMinSplitterPosition, kMaxSplitterPosition); m_Canvas.OnGUI(); GUILayout.EndHorizontal(); var progressRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GetValue(kLoadingShow)) { EditorGUI.ProgressBar(progressRect, GetValue(kLoadingProgress), GetValue(kLoadingContent)); } else { EditorGUI.ProgressBar(progressRect, 0, string.Empty); } }
// Drop area for compatible Races private void CompatibleRacesDropArea(Rect dropArea, List <string> compatibleRaces) { Event evt = Event.current; //make the box clickable so that the user can select raceData assets from the asset selection window if (evt.type == EventType.MouseUp) { if (dropArea.Contains(evt.mousePosition)) { compatibleRacePickerID = EditorGUIUtility.GetControlID(new GUIContent("crfObjectPicker"), FocusType.Passive); EditorGUIUtility.ShowObjectPicker <RaceData>(null, false, "", compatibleRacePickerID); Event.current.Use(); //stops the Mismatched LayoutGroup errors return; } } if (evt.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == compatibleRacePickerID) { RaceData tempRaceDataAsset = EditorGUIUtility.GetObjectPickerObject() as RaceData; if (tempRaceDataAsset) { AddRaceDataAsset(tempRaceDataAsset, compatibleRaces); } Event.current.Use(); //stops the Mismatched LayoutGroup errors return; } if (evt.type == EventType.DragUpdated) { if (dropArea.Contains(evt.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; } } if (evt.type == EventType.DragPerform) { if (dropArea.Contains(evt.mousePosition)) { DragAndDrop.AcceptDrag(); UnityEngine.Object[] draggedObjects = DragAndDrop.objectReferences as UnityEngine.Object[]; for (int i = 0; i < draggedObjects.Length; i++) { if (draggedObjects[i]) { RaceData tempRaceDataAsset = draggedObjects[i] as RaceData; if (tempRaceDataAsset) { AddRaceDataAsset(tempRaceDataAsset, compatibleRaces); continue; } var path = AssetDatabase.GetAssetPath(draggedObjects[i]); if (System.IO.Directory.Exists(path)) { RecursiveScanFoldersForAssets(path, compatibleRaces); } } } } } }
/// <summary> /// Shows the picker window. /// </summary> /// <param name="state">State.</param> /// <param name="filter">Filter.</param> private void ShowPicker <T>(PickerState state, string filter) where T : UnityEngine.Object { pickerState = state; // Create a window picker control ID currentPickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive); // Use the ID you just created EditorGUIUtility.ShowObjectPicker <T>(null, false, filter, currentPickerWindow); }
void OnEnable() { _property = this.serializedObject.FindProperty(PropertyName); _reorderableList = this.CreateReorderableList(_property); _lastElementControlID = EditorGUIUtility.GetControlID(FocusType.Passive); EditorBuildSettings.sceneListChanged += this.Repaint; }
void DisplayQualities() { for (int cnt = 0; cnt < QualDB.Count; cnt++) { //display enty number GUILayout.Label("Entry number " + cnt); //display Name in list GUILayout.Label("Quality Name: "); QualDB.Get(cnt).QName = GUILayout.TextArea(QualDB.Get(cnt).QName); //Display icons in list GUILayout.Label("Quality Icon: "); if (QualDB.Get(cnt).QIcon) { selectedTexture = QualDB.Get(cnt).QIcon.texture; } else { selectedTexture = null; } if (GUILayout.Button(selectedTexture, GUILayout.Width(SPRITE_BTN_SIZE), GUILayout.Height(SPRITE_BTN_SIZE))) { int controlerID = EditorGUIUtility.GetControlID(FocusType.Passive); EditorGUIUtility.ShowObjectPicker <Sprite> (null, true, null, controlerID); selectedIndex = cnt; } string commanName = Event.current.commandName; if (commanName == "ObjectSelectorUpdated") { if (selectedIndex == -1) { return; } QualDB.Get(selectedIndex).QIcon = (Sprite)EditorGUIUtility.GetObjectPickerObject(); selectedIndex = -1; Repaint(); } //Delete Button if (GUILayout.Button("DELETE")) { QualDB.RemoveAt(cnt); } } }
private void RenderDetails() { var ctrlId = EditorGUIUtility.GetControlID(FocusType.Passive); Rect rect = GUILayoutUtility.GetLastRect(); rect.y = rect.height + rect.y - 1; rect.height = 3; EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeVertical); var e = Event.current; switch (e.type) { case EventType.MouseDown: if (EditorGUIUtility.hotControl == 0 && rect.Contains(e.mousePosition)) { EditorGUIUtility.hotControl = ctrlId; } break; case EventType.MouseDrag: if (EditorGUIUtility.hotControl == ctrlId) { horizontalSplitBarPosition -= e.delta.y; if (horizontalSplitBarPosition < 20) { horizontalSplitBarPosition = 20; } Repaint(); } break; case EventType.MouseUp: if (EditorGUIUtility.hotControl == ctrlId) { EditorGUIUtility.hotControl = 0; } break; } testInfoScroll = EditorGUILayout.BeginScrollView(testInfoScroll, GUILayout.MinHeight(horizontalSplitBarPosition)); var message = ""; if (selectedLine != null) { message = GetResultText(selectedLine); } EditorGUILayout.TextArea(message, Styles.info); EditorGUILayout.EndScrollView(); }