#↕️┃editor-extensions
1 messages · Page 34 of 1
Yes, for those things it has almost the same things as the gizmos
but it misses some things that are not available so if you really need gizmos you can create a monobehaviour in the scene in OnEnable and in onDestroy of your window you can delete the object
SphereHandleCap, CircleHandleCap, DrawWireDisc etc.
do they have capsules? or is that something I'm gonna have to make myself
Use the docs/google mate
But no i havent seen a capsule function
Two spherehandlecaps + one cylinderhandlecap should do it though
Idk if you mean 3D or 2D capsule though
why does it look so different in the builder vs in the actual window?
In the bottom left "Library" panel, select the icons with the 3 vertical dots at the top right of the panel and select the "Editor Extension" menu item. Then go to the top right of the central viewport/canvas of the UIBuilder and select the theme dropdown and select "Active Editor Theme"
The reason it is different is the UIBuilder is using the runtime/in-game uss styling. Not the editor styling
ah perfect, thank you
this is done exactly what i needed
no more guessing lol
Hahaha
im getting started with it rn, its a lot at once but I think i'll pick it up pretty quickly
its mostly just object fields that i plan to mess with currently.
object fields and inspector elements
nothing too fancy
ah the object field didnt show up in the old mode, now im in editor mode this looks a lot easier
i was gonna be really annoyed that I would have to manually insert property fields and stuff with code somehow inbetween the UXML stuff, but this avoids all that
Yeah that that is annoying to do. Though not too hard.
How can I make something happen when a value changes? You said it was an event or something right?
If you want to bind the value of the field to a vale on your data object (component, editor window, or scriptable object), you can set the binding path to be the SerializedProperty path.
If you just want to do something when the value changes, you just regiter a change event in C#
objField.RegisterValueChangeEvent(evt => {
// Do something here. You can make it a method instead of a lambda if you want.
});
much appreciated. i assume objField is gotten from something similar like this?
Yuuup exactly like that
Was about to say haha. Basically that is just fancy way of looping through every element recursively to find one that is of type VisualElement and with .name set to "MainElement"
(I think it does caching and stuff so it is faster than doing a recursive loop yourself though. Could be wrong)
And that Q method is just a wrapper around a larger .Query() API that you can use if you need more specific/advanced searching. Like excluding (I think) and checking for specific decedents chains.
awesome stuff. looking forward to tinkering more with this later. probably a stretch, but is it possible to get a view of a prefab inside the editor window, and draw the handles and gizmos and stuff?
Of course! But... its a pain :/
You would want to use a class called a PreviewRenderUtility and call it's render methods inside of a IMGUIContainer `VisualElement.
I doubt it's worth it, then
it would make more sense to just use the prefab window
Probably, you can have custom edit contexts and also custom stages, so it is pretty flexible at least
there's a way to check if you're a prefab context I swear?
an API I forgot about
appreciate you 😌
making some progress, but i feel like a long list like this could do with better formatting. Is there a way for me to achieve something like that?
private void ActiveMoveValueChanged(ChangeEvent<string> evt)
{
if (moveDictionary.TryGetValue(evt.newValue, out Move move))
{
Debug.Log("Move changed to " + move.Name);
activeMove = move;
UpdateActiveMoveWindow();
SerializedObject serializedObject = new SerializedObject(activeMove);
MoveDataField.Bind(serializedObject);
Debug.Log("Bound to " + serializedObject.targetObject.name);
}
}
I've bound to a serialised object, yet i dont see anything in the window. what am i doing wrong?
Did you the the binding path of the MoveDataField?
i havent touched the binding path 😅 where do i edit that?
and what do i change it to
You set the bindingPath on the element to be the path of the serialized field you want to bind to. So if your BrawlerMoveset class has a field like [SerializeField] private string _myName; you se the binding path to "_myName"
thanks! can i bind to multiple fields at once, or must that be done manually 😭
The fields searches 'up' to the first parent/ancestor that is bound. So you can .Bind(serialiedObject) on the root element and all descendants that have a bindingPath set will try to bind to the serialized object
I see.
public class Move : AssetObject
{
// ONE FIELD FOR THIS STUFF
[Header("Basic Information")]
public string MoveName => "metarig_" + Name;
public int stateID;
public FP RecoveryFramesFP => (FP._1 / (FP)60) * RecoveryFrames;
public FP LandingFramesFP => (FP._1 / (FP)60) * LandingFrames;
public string Name;
public QBoolean isAttack;
public QBoolean moveIsGrab;
public MoveDirection MoveDirection;
public ButtonState moveButton;
public int RecoveryFrames = 6;
public int LandingFrames = 10;
[Header("Misc. Information")]
public QBoolean dontChargeUlt;
public QBoolean followAttackerVelocity;
public QBoolean dontHitStop;
public QBoolean persistent;
public int persistentTimerLength;
public bool recoveryMove;
public bool dontInterruptOnLand;
public int invulnFrames;
public int intangFrames;
[Header("Sound Information")]
public AudioClip[] moveHitClips;
public AudioClip[] moveSwingClips;
// END FIELD
[Header("Frame Data")]
public List<FrameData> FrameData;
// ONE FIELD FOR A SINGULAR FRAME DATA INSTANCE WITH AN INDEX
[Header("Misc Information")]
public FP chargeCost;
}
Essentially, What I wanna do here is make 2 fields, as the comments show
What do you mean by a 'field'?
like 2 bits that display the information im talking about beneath these dropdowns
You just add a element for each serialized field and set the binding path. You can just add a PropertyField for each instead of having to use the specific type per field. Like a TextField for a string and a EnumDropdown for ButtonState, etc.
So I can't avoid having to do one for each field, I see 😭
Nope, unless you want to group them all inside of a class instead.
It isn't too bad, just takes like 2 minutes
hm, I could do that but that would mean refactoring a shit ton of other code, so no thanks
what about for the list of FrameDatas? can I display a singular FrameData object without much problem using data bindings and an index?
Yup, just data bind a ListView and it will use the property drawer for the FrameData and automatically populate it.
awesome 😄 to confirm, this is for a single FrameData? I don't want all of them. I want to use the slider in the above image to choose which one
Ah then you will have to do that manually, but it isn't too bad.
Just whenever the slider value changes, you do
var newIndex = evt.newValue;
frameDataPropertyField.bindingPath = $"FrameData.Array.data[{newIndex}]";
That should rebinding it. And just have frameDataPropertyField be a PropertyField
If you don't like using strings like that you can also doframeDataPropertyField.BindProperty(serializedObject.FindProperty("FrameData").GetArrayElementAt(newIndex));
awesome man, thanks so much for your time ☺️ made big strides today and I should be done by tommorow.
another thing, I have a big drop-down which kinda sucks, so I was thinking of making a bunch of buttons manually via code which does something I have planned. can you store data in buttons? like a string or something
or I guess when I create the buttons I can just assign the callbacks in the for each loop
You're quite welcome! 😄
Is it just to select a value?
how can I just flush out all the buttons in a visual element? I've been using them as divs of sorts, if that's a good idea or not
yeah essentially
You probably want to use a Radio button then
Flush out the buttons?
like delete all the buttons in a visual element
element.Clear()
and that clears any children of the element?
Radio button stuff. Also, cool info about making editors https://www.foundations.unity.com/components/radio-button
Yup, just liek element.Add(e) will add an element. It is just like a list in that regard
sick, really appreciate your help 😁
should be done by tomorrow with this
Nice!
are there any extensions to allow you to run a serverbuild in the inspector? so i can see the loaded objects etc
Hey, is there any way to change the external script editor via code? I'm using cursor but want to debug in rider, so I created a button in the editor to open rider for debugging, but it doesn't attach the unity project because it's not set as external editor in the preferences...
Hey, just wanted to ask btw, in regards to these things, will that work for a list object?
cus I see you're using Array in that binding path
What do you mean?
for the bindings, you wrote FrameData.Array, but it is a List<FrameData> object. will they work the same?
Ahh, serialized arrays have an additional structure. Which if memory serves is basically:
"FraneData"
- "arraySize"
- "Array"
- "data"
- [0]: FrameData
- [1]: FrameData
The GetArrayElementAtIndex method along with the arraySize property abstracts this away. But when accessing an item via string path, you have to include this internal structure in the path
Also, lists and arrays are both just serialized as arrays, since there is no difference in their data (a list is just a fancy wrapper around an array after all)
I see. thank you for this clarification! didn't really help myself by naming the field and the datatype the same 😅
What do you mean? Ahh you mean it is confusing?
yeah, I was considering naming the lost FrameDatas but that felt wrong lol
or maybe making the datatype FrameDatum
but that doesn't really work either
I'll just stick with this
I think it is fine in this case, it is pretty common to have the type and property name the same
Hi everyone, I'm trying to create a custom inspector for a script using UI Toolkit and I have a foldout that displays some extra information to users. The problem I'm having is that I want this foldout to keep its state (either open or closed) when clicking other objects or entering playmode, but no matter what I do, it keeps resetting state. I've tried using a static variable and it works fine when clicking on other objects, but as soon as I enter playmode, because there's a domain reload, the variable resets state again.
Is there a way to save the state when entering playmode? I thought about using PlayerPrefs but sounds like overkill for something so small...
Like, Unity keeps the state of a list foldout between Edit mode and Play mode, but how do they do it?
You want SessionState
Similar API to EditorPrefs or PlayerPrefs but only keeps the data while the editor is open.
Ooh, never heard of that before! I'll look into it, thanks!
Presumably nodeMap.gizmoColor; is beige. Have you debugged it? Like logged the color?
It's not beige. gizmoColor is very explicitly green, i don't know what makes it change sometimes into a transparentish beige
Have you debug.logged it in this function?
Hey
Do u know why my android build support is taking years when it says “validating”
Why are you directly pinging me and posting in a completely off topic channel
Bc there’s nobody else I could find in the server
Should I debug.log the Handles.color or gizmoColor?
Read the rules #📖┃code-of-conduct
Theoretically they should both be the same but I don't know
Then where do I go?
Turns out whenever the sphere is clicked, it immediately becomes gizmoColor, but sometimes, when hovering the mouse near it, it just becomes that weird beige color. I just want it to always be gizmoColor, so I got no idea what's going on
The beige color I assume is the default hover/highlight color. Like if you hover over a transform gizmo you see it light up. It only happens 'sometimes' because it has to wait for a repaint event iirc (or maybe layout event?).
You can look at the source code for more insight on how it is implement, it is relatively straight forward.
I wanted to add a scroll view to my editor window, but only vertically. But no matter what I try Unity keeps adding a horizontal one too even if there is more than enough horizontal space it still adds one for a few px of scrolling. (if the window is a bit smaller it cuts off half even though it fits fine in the window without a scroll view)
I only want it to scroll vertically and horizontal should behave like without a scroll view. Is that possible?
I also tried
GUILayout.BeginVertical(GUILayout.Width(width));
but if it just gets ignored unless I make it bigger than Unity already made the contnet
I have these buttons with flex grow 1. How can I make it so there are max 5 Buttons before an overflow?
i dont seem to see a grid option
scroll view will be the size of whatever it contains so you have to control the width of the stuff within yourself to not be larger than the viewport.
Sometimes this involves changing width to 0 and using flexable width only.
I would set the width to be 20% and then set the layout direction to wrap. (I don't remember the actual name of the property atm sorry)
I think that would do it at least
But yeah, a grid isn't exactly supported. There is a multi column tree view, which is basically a table. With rows and columns but I think that is overkill for what you need.
This is eventually what I came up with. thanks previous css knowledge 😅 i didnt realise that uss was literally just css
its annoying for buttons with longer names
maybe i'll make it 3 per instead
Yeah uss is just amore limited subset of css! 😄
okay, i've got a good start here, but with these serialised objects, it doesnt appear to draw the custom property drawers. How can I do that?
this is what theyre meant to look like
interestingly enough, the drawer appears to be rendering with the Charge Cost, but not for the Self Launch Angle, both of which use the same type
every time the domain reloads different things get serialised 😭
okay now they're all here??? wtf
and now theyre all gone again
im so damn confused
it appears to be very temperamental. How can I sort this out?
That is indeed weird. Maybe the height for the drawer is incorrect?
Would that make it fallback like that?
I'll check, but I haven't hard coded any heights
as you can see, in the start, it renders properly. when I go to a new one which hasnt been rendered yet, it appears to not render properly.
Oh, I didn't know this was with UI Toolkit. With the old GUI editor, you usually have to calculate the height . . .
left it for tonight but there must be a way to like, force it to render the IMGUI container?
Hey everyone, after 3 days of fighting with this and ChatGPT I need help. I have a custom editor that I have watered down to next to nothing and Unity keeps clipping content that is in a negative position. I have seen many other editors that have pan and zoom functionality render stuff outside of the default viewport but I cannot get this to work for the life of me. Any guidance please? NOTE The editor script is too long for discord so I attached it as a .cs file
What does it look like and what do you expect it to look like?
These are the 2 nodes, both are partially drawn due to being out of the initial windows size:
The one on the right is just barely clipping whereas the one on the is almost fully clipped. When you pan with the middle mouse button, they also don't appear
I'm missing something small, I know it. I just cannot figure it out
Hmm, what if you just remove the panning code?
This line GUI.matrix = Matrix4x4.TRS(panOffset, Quaternion.identity, Vector3.one) * GUI.matrix;
Here is the source code of a IMGUI based node graph editor, you can look to see how it handles the zooming and panning by poking around a bit https://github.com/Siccity/xNode/blob/master/Scripts/Editor/NodeEditorGUI.cs#L47
Thanks I'll give it a go, the panning and zooming seem to work as expected. That line is definitely the source of the problem I just don't know how to fix it. I'll take a look through your reference, thank you
There's almost no reason to be doing this with IMGUI
UIToolkit makes this simple, and there are even open source graph frameworks to build on
for me personally i can see how much faster IMGUI is compared to UIToolkit , especially when im running on battery mode , a simple task like resizing the editor window in 2018 and unity-6 can be been comapred to playing a game at 60 fps vs 15 fps
Performance in dynamic situations isn't generally where a stateful solution like UITK shines. Compare the idle performance and you'll probably see the opposite.
But note that it's mostly irrelevant when talking about developing a graph solution (i.e. what's being commented on), where UITK has tools to modify transforms without remeshing, and it's as simple as adding one line of code to get pretty robust pan and zoom behaviour.
hey guys, doesn't anyone understand why rendering custom property drawers is so temperamental here?
Should probably provide some code
I'm using quantum, which is all compiled in a DLL. maybe i'll ask them too
No idea what a quantum is
I would like to make a custom editor similar to the ShaderGraph's: designers can create and and connect blocks which are read as data by a separate program. Does anyone know of a tutorial that tackles this, or even what it's called in Unity jargon? I've tried looking it up myself, but haven't had any success as of yet
It is a Node Graph. Unity has one called GraphView.
Is there a way to name these better? essentially what I want to do is force open the fold out via code. Is this possible?
Appear to have fixed this. The way I fixed it was just by clearing and creating a new property field each time
FrameDataElement.Clear();
var frameProp = currentSerialisedMove.FindProperty("FrameData").GetArrayElementAtIndex(CurrentFrame);
PropertyField propertyField = new PropertyField();
propertyField.BindProperty(frameProp);
FrameDataElement.Add(propertyField);
Foldout frameDataFoldout = propertyField.Q<Foldout>();
frameDataFoldout.value = true;
confused as to why this Foldout grab isnt working.
there is a foldout there, being the "Element 0" thing.
maybe the foldout isnt there at the time of adding?
The actual binding only happens every 100ms, so it doesn't exist yet
yeah i thought it was something like that. shame
Easiest way is do use the schedualer, something like propertyField.schedule.Execute(() => ... ).AfterDelay(100);
(I don't remember the method name, could be StartAfter, StartDelay, After,Delay or something like that)
I'll try that. Thanks! I'm just glad i got the main bit fixed with the FrameData stuff lmao
There is also a SerializedPropertyBind event, but I don't remember if that is public in Unity 6 or not. I remember making a wrapper for it via reflection a while back
This seems to work
btw, with scrollTo, it scrolls the bottom of the page to the element right?
Actually... if that foldout is automatically created by the PropertyField, you can just do frameProp.isExpanded = true
Followed by applying the modified properties
I'm not sure the exact scroll behavior. I think it just scrolls so that the element is fully in the viewport.
this is much much better! it avoids that weird little bit where the the prop is not expanded. Someone mentioned in the unity discussions board expanding the prop by default but didnt say how they did it...
scroll behaviour appears to be a bit broken in some bits though. could that be to do with the order of actions?
Yeah probably because when you tell it to scroll, the property hasn't been populated yet. You can also just et the numeric scroll value I think.
But what you can do is something like use the scheduler and run it every frame until the children change or soemthing like that
Where can I have a look at this scheduler API?
Awesome, thank you 😄 almost done with this, and the next step is to draw some handles. Which event function should I use to deal with handles?
Like scene view handles?
yah
i wanna draw some circles and squares and stuff
If it is an Editor and you only want them visible when object is selected, you can use the OnSceneGUI method in Editor. If you want them visible even when not selected, you would use the SceneView.duringSceneGUI event and subscribe to it.
If you want to manipulate the handles, you probably want to look in to Tools and EditorToolContext
if you're talking about the class, it is an editorwindow. I tried OnSceneGUI, but nothing shows up
im not gonna bother with that, its just gonna draw data from the moveset editor
For Editor window you use the SceneView event
Just subscribe in OnEnable and unsub in OnDisable
okay cool, i've got that now 😄
btw, in regards to this scheduler thing, does that run synchronously? so if i have a schedule Until() condition, the rest of the code wont work until thats finished?
like this, and then after that, scroll to?
it is async
ah damn
is there a way to change the color of a sliderl ike this?
i cant seem to find any se3ttings in the UI builder
the bar (tracker) or the circle (dragger)? You need to query and find the visual element within the slider. By default, the name of the bar is "unity-tracker" and the name of the circle is "unity-dragger" . . .
In UIToolkit, is there anyway to have the same label width as a PropertyField would give.
Nvm, found it. Really unintuitive. (BaseField<float>.alignedFieldUssClassName)
Any of you folks using localization in your projects? If so, which did you go with? It seems like the big two are i2 and unity
I used i2 at first then unity's til now.
Do you have any opinions on i2 now that you've left it behind?
It was really a long time ago so I'm a bit foggy about it. It served my needs at the time. But I don't remember it had anything remotely close to smart strings of Unity's Loc. Truthfully at that time I didn't know I need something like smart strings, so this doesn't count I guess?
However the reason I left it behind was less about its functionality and more about the legality of project sharing.
I have to strip down most of proprietary assets, tools and libraries for this purpose.
So the less of proprietary 3rd party assets, the less of my worriness.
Cheers mate, makes sense. Thanks!
is there a way to force someone into a layout when you open your special editor window?
can odin inspector support 2d arrays of int, gameobject, etc?
is there a way to create a class for this to copy and paste in code?
like how you can create buttons
and stuff
Yeah-ish, you can save as a new uxml file. And either load and instantiate it in the code, or create a new VisualElemetn.... that loads and instantiates it in code, but as a wrapper.
Or just manually create the hierarchy in code
I followed a tutorial, and i made a backing code
You can just use uss, along with adding to the class list like: element.AddToClassList("my-button--selected);
cus I think the active color is like blue or something
And in uss you do
.my-button--selected {
background-color: red`
}
ah right
easy enough, thanks 😅
is there a unity preset colour for like button selected?
You can use the 'active' color by doing
background-color: var(--unity-colors-button-background-pressed);
border-color: var(--unity-colors-button-border-pressed);
much appreciated 😊
You're welcome 😄
you've helped me out through a lot of my UI builder journey lmao, I really do appreciate your assistance 😀
There are many lists of all the icon names
the github 404s
but I'll have a look thank you
how can I make it so these items dont shrink?
oaky, it seems chaning this fixes it? strange
flex-shrink: 0
yeah, i turned that on but it didnt work by itself. I had to do the align self thing too
Huh odd, sometimes on somer versions it does do a thing where it sort of adds a default style but doesn't show it. Still odd that the fixed it though.
yeah frankly i dont wanna mess with it any further LOL
lest it go back to squished
haha
If you had to do align-self, then possibly they overlapped each other . . .
are there any extensions to allow for visual folders in hierarchy
Instead of using empty gameobject as a parent are there extensions that allow me to sort stuff into visual folders for organization
Yeah a bunch. You can just google something like Unity hierarchy github and see a lot on github for free. Or type hierarchy in to the search of the Unity asset store and find a bunch of free and paid ones as well.
❤️
@gloomy chasm excuse the ping, just wanted to show you what I was able to cook up with some of your help 😄
very pleased with this, should speed up the workflow immensely
Nice! Congratulations!
Btw you can add context menu items like this if you want to move those copy-paste buttons
element.AddManipulator(new ContextualMenuManipulator((evt) =>
{
evt.menu.AppendAction("Log Something", action => Debug.Log("Something"));
}));
I was kinda sick of those haha 😅 I was looking for something like this but couldnt find it anywhere. Would I append this to a button or what?
where does the manipulator happen
also another question, is there a way to make it so if i drag my mouse along these buttons, they do their click event?
in that gif im holding the mouse button down btw
You can't with buttons because it 'eats' the event. However, all a button is is this:
element.RegisterCallback<PointerDownEvent>(evt => { Do think here });
element.AddToClassList(Button.ussClassName);` // Just adds button styling to the element.
So if on your parent, you register events to down and up pointer events, you can get the index or whatever of the down and then of the up and select all between them. And/or use the enter/leave events and check if the pointer is pressed and if so add to the selection.
There however, is no good way to show mixed fields. Like wen you select multiple GameObjects and editing the position in one changes all of them.
oh no I only want it to show the latest one that I'm dragging over
I don't want to show all of them
also in regards to the manipulator thing, how can I make that show up? it says add manipulator, but I'm not sure how it would show up
Oh, then you can just register Down, Move, and Up events to the parent, of those buttons, and when the mouse moves while the pointer is pressed change the selection to the one under the mouse.
What do you mean 'show up'?
intellisense, auto suggestion box in the IDE I guess
he couldn't find this method element.AddManipulator
i suppose im confused to how a contextual menu manipulator works. Is it like this when you click something? (chrome example)
do i have to do some positional math to figure out which one is under the mouse or is that sorted for me?
Yeah it opens a menu at the mouse's position when you right-click
I think there is a method on Element for getting the element at a position. If not, you have to loop through the child elements and use a method to check if they contain a point
wdym by point here?
also, can I open a contextual menu with a left click? similar to a dropdown?
if (element.ContainsPoint(mousePosition))
oh right
Yeah, you just have to do it yourself. There is GenericMenu and DropDownMenu (or something like that). Which both contain a menu.Show type of method
Okay I'll try these out. Thank you!
Hi everyone, I wanna see if you guys can help me. I'm creating a custom tool and I want to create a txt inside the Resources folder when the user presses a button and automatically load this file as a TextAsset after creation.
I'm using File.WriteAllText() to create the text file and then I call AssetDatabase.Refresh() to import the text as a TextAsset, and then I have a script that inherits from AssetPostprocessor in order to detect if the file was imported. The problem I'm facing is that if I try to call Resources.Load() inside the AssetPostprocessor, it returns an empty array. But if I call it manually after like, a second, it correctly loads the file.
My question is: is there a way to know when a file was fully imported by Unity? Since apparently I can't use AssetPostprocessor for that...
If this is editor code then why bother using Resources?
Because later on, the same file will be loaded in-game through Resources
Right, but editor code can differ.
I dont know how to know when importing is done but you can check https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorApplication-isUpdating.html
Can also use https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorApplication-delayCall.html or an editor coroutine or async to wait a bit for it to be ready
Yeah, I just tried waiting a single frame using an async method and apparently it works. Thanks
That is because you are not meant to call Resources inside of it. You should be using AssetDatabase methods. That 1 frame delay and using the Resources API like that can cause issues in the future.
Hum... Ok. I was trying to use the same logic for both editor code and gameplay code instead of duplicating it, that's why I was using Resources
Yeah, a lot of time you can't/shouldn't unfortunately.
Ok, I have another question: with UI Toolkit, I'm creating a small popup with a TextField inside by calling PopupWindow.Show(), but for some reason my TextField doesn't gain focus until I either click on it or press Tab. I've tried calling myTextField.Focus() inside the OnOpen method of the Popup, but nothing happens. I've also tried changing the TextField TabIndex value to something bigger than zero but again, nothing changed. Do anyone know how to automatically give focus to a field inside a PopupWindowContent?
Ah, well, again, seems like the solution was to wait a single frame
Waiting a frame for stuff always felt kinda hacky
That is because Unity doesn't add the elements fully when first opened. At least not in the place that OnOpen is called. I think you can listen to the AttachToPanel event and focus in there.
Ah, I see, registering to the AttchToPanelEventworks as well, and it looks a lot nicer than waiting a frame. Thanks!
Is there a convenient way of resizing AssetPreview.GetAssetPreview()? I need to check a couple of textures, which I do with this method, but the textures are too big for my taste:
void DrawTextureArea(string label, ref Vector2 scrollPosition, Texture2D[] textures)
{
GUILayout.Label(label);
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(128));
using (new GUILayout.HorizontalScope())
{
for (int i = 0; i < textures.Length; i++)
{
Texture2D texture = AssetPreview.GetAssetPreview(textures[i]);
GUILayout.Label(texture);
}
}
EditorGUILayout.EndScrollView();
}
you can provide a width and height when drawing the label
why is my gameobject not appearing in the play scene?
also i have another issue when i create a new project and runs it it gives me compiler errors despite having no scripts and only gets fixed when i restart the editor
hello everyone my player is stucking on the platform like this anyone have any idea how to solve it?
Hi everyone, I keep getting this error. I think its tied to the [RequireComponent] attribute which i have on some of my components. But no idea what is actually causing it.
Anyone have an idea what this error means?
Try #💻┃unity-talk . This channel is for discussing the creation of editor tools, like editor windows, property drawers, and attributes . . .
Is there a way to determine when a checkbox in the inspector is checked?
Like I have a MonoBehavior component and in it I have:
public bool MyBool;
When it is clicked in the inspector, I'd like to execute code while in the editor. Specifically, I'd like to hide the game object it is clicked on.
The thing is that this bool also controls if I want to have this object active when the game starts.
So I was wondering is it possible to make a grid view for an custom editor window like how it is done for the Tile Palette Editor Window? If anyone has any suggestions that would be appreciated.
OnValidate() will be called for monobehaviours in editor when they have serialized stuff changed. If you want to update other things in the scene make sure to set them as dirty with EditorUtility
Thanks. How to set the eye in the editor? The one that hides the object.
So when the checkbox is pressed, I'd like to change the visibility in the editor.
tbh I have no idea if that is controllable from c#
Basically, I have this:
void Awake() {
if(Application.isEditor)
gameObject.SetActive(ShouldBeVisibleInEditor);
else
gameObject.SetActive(Application.isMobilePlatform);
}
And so far I made it to be active in the editor in the game mode only when the checkbox is clicked.
But when I disable this checkbox, it's still visible in the Editor mode. To hide it in the editor mode I still need to click the eye icon.
Disabling the gameObject should make it not show in the editor anymore, no?
Depends, you using UITK or IMGUI?
UITK is what I normally use.
The problem with that is that it won't be active any more: when I deploy and it runs on a mobile phone it won't get enabled when the game starts.
Unchecking this Should Be Visible In Editor checkbox should make it not show in the editor anymore. But then when I deploy and it runs on a phone, the user should still see it no matter what.
Depends on how big the grid is, could just do a bunch of elements with border styling. Or could use the vector painting API to draw the lines and then use maths to figure out what cell the pointer is in when it clicks.
So just manually click the eye icon? It seems like all you are doing is making a wrapper around clicking the eye icon.
Isn't there away to display a grid like how Unity does it with the Tile Palette though? I mean I could just use a bunch of Visual Elements and that would work. But I thought there would be another way. 🤔
All that is is using Gl.DrawLine(..) 9most likely) to draw a bunch of lines in a grid. No built-in thing as far as I know.
Could check the source code to be sure.
Yes. I just don't want to click more than I have to. The thing is that if there are many things like that, then I have to do a lot of additional work.
How to get an instance of it? Hide requires an instance.
Oh I guess SceneVisibilityManager.instance.Hide(gameObject, true);
Ah ok yeah I think I will just create a grid class using UITK since I would need that for some other editor tooling I'm working on anyway.
I was just hoping someone knew of another simpler way to do it 😅
Ahh, sadly not. Though it really isn't too bad to make a simple one.
void OnValidate() {
if(!ShouldBeVisibleInEditor)
SceneVisibilityManager.instance.Hide(gameObject, true);
else
SceneVisibilityManager.instance.Show(gameObject, true);
}
Yay
It also works in the deployment?
no, its in the editor namespace
it will not exist in builds and will cause a compile error
Oh, so I have to add the preprocessor directive. Good to know.
Wait, how do I then hide and show the objects in deployment without deactivating them? No generic way?
nope, you will have to enable/disable renderers and other things
Hi everyone, I've got another question: I have a button that, on click, shows a list of options using GenericDropdownMenu. Then, when I click one of the options of the GenericDropdownMenu, I'm showing a popup using PopupWindow.Show(). The problem I'm having is that when the Popup opens, the GenericDropdownMenu is still active and I can still interact with it. The weird thing is that this only seems to happen when I call PopupWindow.Show(). If I do anything else, like logging some text, the GenericDropdownMenu disappears as expected.
If I click "Option 1", the popup appears but the GenericDropdownMenu is still there. If I click "Option 2", I'm logging a text to the console and the GenericDropdownMenu disappears as expected
Not the solution I wanted, but using UnityEditor.GenericMenu instead of UnityEngine.UIElements.GenericDropdownMenu seems to work as expected.
Did you try closing the dropdown menu when an option is selected?
How? The GenericDropdownMenu class doesn't have a "Close" method or similar.
What is your callback logic for when the button is clicked? Does anything stop or consume the event?
Not really? Here's a slightly modified version:
var optionsButton = parent.Q<Button>("options-button");
var menu = new GenericDropdownMenu();
menu.AddItem("Option 1", false, () => PopupWindow.Show(optionsButton.worldBound, new MyCustomPopup()));
menu.AddItem("Option 2", false, () => Debug.Log("Test"));
optionsButton.clicked += () =>
{
menu.DropDown(optionsButton.worldBound, optionsButton);
};
So I just remembered Unity has an experimental GraphView class that you can use to create exactly what I wanted 😅
It just took me a while to figure out how to set it up since there is not much documentation on it.
is UniTask the best coroutine alternative or should i use something else
Unity has an Editor Coroutines package you can use. I know nothing about UniTask so I can't really say if I recommend it or not.
ty
I like Unitask. It's a bit more complicated to use than simple coroutines, but you also have more control on how your async Methods are terminated
After being forced to write a coroutine solution for MonoGame when I was messing around with that a few months ago I just added a event system to tell when a coroutine ended. You could probably do the same with Unity.
You can also use C#'s Task system and async/await.
But replaced with Awaitable or UniTask
What do you mean?
instead of using System.Task we should use Awaitable or UniTask as the task type
Ahh, generally yeah, but it's not too big of a deal for use in the editor.
UniTask offers support for a "frame yield" even in editor so its a good replacement for coroutines
Not saying UniTask ain't handy. Just that for doing async programming in the editor it isn't needed. As it can be a rather 'large' dependency for otherwise small tasks.
At least from my understanding of things. I admittedly don't do a lot of async work in the editor.
I dont really either but I use UniTask and async code everywhere in runtime code so its nice to have it usable in editor too if required (e.g. load lots of data for some editor window but not freeze the main thread)
I'm seeing here that SearchWindow and ISearchWindowProvider are still experimental in Unity 6. Do anyone know if there's a non-experimental alternative to a searchable popup list?
Hello, how do you all handle mono behaviours used for authoring? I've been using #if UNITY_EDITOR, however this results in my build logs being spammed of missing mono scripts or serialization layout being changed. Is it possible to somehow remove such scripts from Game Objects during build?
An example of such script:
#if UNITY_EDITOR == false
...usings
internal sealed class AssetRoot : MonoBehaviour
{
private void Awake()
{
Destroy(this);
}
}
#else
...usings
[SelectionBase]
internal sealed class AssetRoot : MonoBehaviour
{
private readonly HashSet<string> invalidTransformCache = new();
[FoldoutGroup("Filtering")]
[Required]
[SerializeField]
private List<Transform> ignorePositions = new();
[FoldoutGroup("Filtering")]
[Required]
[SerializeField]
private List<Transform> ignoreRotations = new();
...a bunch of Editor specific stuff
}
#endif
Logs:
04-23 12:02:39.418 23410 23520 E Unity : A scripted object (probably AssetRoot?) has a different serialization layout when loading. (Read 32 bytes but expected 40 bytes)
04-23 12:02:39.418 23410 23520 E Unity : Did you #if UNITY_EDITOR a section of your serialized properties in any of your scripts?
editor monobehaviours shouldn't really exist
What would be the alternative? I use some plugins which do this and also need to serialize some fields for Editor tooling to store data during authoring
you'd probably have to store that information yourself
Could you elaborate on this 🤔
Hey all,
How can I toggle OnSceneGUI visibility ?
If you have control over the implementation, you can do this:
var sceneView = UnityEditor.SceneView.lastActiveSceneView;
if (sceneView && sceneView.drawGizmos)
{
}
You use #if UNITY_EDITOR around the content of the MonoBehavior, not the whole class.
Same warnings happen - serialization layout issues
Ahh yeah you gotta exclude the serialized fields as well. But actually I just remembered you can use hide flags instead
I think if you add the DontSaveInBuild flag it should be all good and you can enclose the whole thing in a #if UNITY_EDITOR https://docs.unity3d.com/6000.0/Documentation/ScriptReference/HideFlags.DontSaveInBuild.html
I had thought about this, however the issue I'm experiencing is on components which are added on objects that should be included in build. Hide flags affect the whole game object :/
As far as I know, the DontIncludeInBuild HideFlags are per-component
I could be misremembering though of course.
Hmm, I'll do some testing to double check, currently stuck on some other issues... Last time I've used it I think it affected the whole game object, thanks for the tip!
Anyone know why unity cloud projects aren’t showing up in the hub? Or at least the one I’m looking for, it shows up on my windows computers but not on Mac. Some show up but not the one I’m looking for.
Had some time to test this out, it seems that it yeets the GameObject, dropped these two components on a GameObject and the ExtraScript doesn't log anything in build:
public class AuthoringScript : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField]
private HideFlags flags = HideFlags.DontSaveInBuild;
private void OnValidate()
{
gameObject.hideFlags = flags;
}
#endif
private void Awake()
{
Debug.Log("I shouldn't be here");
}
}
public class ExtraScript : MonoBehaviour
{
private void Awake()
{
Debug.Log("I should still print stuff");
}
}
these dont even work properly in prefabs so they really half assed them
i swear even in addressable scenes they dont work
Is there any way to set a particular scene as the default in the editor when a project is first opened?
I am submitting a Unity project as a take home task and whenever I download my project repo on a separate machine and open the project from Unity hub, it seems to open a default untitled scene instead of my scene
My scene still exists, but the user has to manually navigate to the scene's location and open it.
I have ensured that my scene is the only one in the project and is the first and only scene in the Build data scene list
I am using the standard unity .gitignore template so im not sure if it might have something to do with that
The opened scene is stored in preferences. Don't remember if it is is local to the project or globabl to the computer.
You can write a script using [InitializeOnLoad] to load the scene on first load if the current scene is not persistent/an asset
ah i see
Sorry, I left and wasn't able to get back to you on this. I'm glad you found a result. For me, using an EditorWindow instead of a PopupWindow fixed it . . .
No prob. I've created a forum post about this and they've request me to create a Bug report. Apparently this is indeed a bug. I'm using the GenericMenu class instead of the GenericDropdownMenu for now.
Oh, nice. That's pretty sweet . . .
how can I prevent a foldout closing when I press the left key?
Is there a way to check if a folder in the projects window is empty and/or expanded/collapsed?
so i have an attribute public string title {get; private set;}, where PropertyFields dont work well with attributes defined like this so i have to do it manually. so i have this to get the FieldInfo:
private string _getBackingFieldName(string propertyName)
{
return string.Format("<{0}>k__BackingField", propertyName);
}
private FieldInfo _getBackingField(object obj, string propertyName)
{
return obj.GetType().GetField(_getBackingFieldName(propertyName), BindingFlags.Instance | BindingFlags.NonPublic);
}
I can edit it and all just fine. but its not being correctly saved. when i simply do:
string previousTitle = TitleField.GetValue(script) as string;
string newTitle = EditorGUILayout.TextField("Title", previousTitle);
if (previousTitle != newTitle)
{
TitleField.SetValue(script, newTitle);
EditorUtility.SetDirty(script);
}
whenever i close and open the project, the edits are gone.
how do i fix this so that the edit is actually written correctly to the asset? (this is a scriptable object)
~~wait, i could maybe work around this by using internal instead of private and do script.title = newTitle right? or does using the namespace then give access to it as well?~~~nvm, the editor has an editor assembly so that dont work
I asssume by 'attribute' you mean a memeber of a object and not a [Attribute]. If so, you need to add the [field: SerializeField] attribute to the auto property.
yes i do 
After you add the attribute you can access it via SerializedProperty like normal
ah really its that small thing again
it was just missing field:
Yeah, it is because unity only serializes fields, not properties. field: tells the attribute to apply to the backing field and not the property.
how do i use PackageInfo.FindForAssetPath() ??? i have tried all i can think of that should work for getting my package info both when its imported and in my dev environment. all just returning null.
ive tried
Packages/com.name.package with and without a /, and with /package.json.
same with Assets/packageLocation
i thought maybe it only finds installed packages but i cant even get it to work when it is 
i cant even check what it does cuz its an external call so the c# reference is no help here
idk if this is how you should do it. i guess i could load the .json itself but it seems like this should be the intended way to do it
Shouldn't you be using https://docs.unity3d.com/6000.0/Documentation/ScriptReference/PackageManager.PackageInfo.FindForPackageName.html and what is your "dev environment"?
This is unity 6000 though, this package supports older versions
And that the development environment is just the unity project im using to make the package. Im saying that because there will be a difference in file location. Where im developing it, the package won't be installed as a package as its already in the project
You can edit a package when it's inside Packages/ so you don't have to make things work differently while editing it
And that function has existed for a bit
You can also just search all entries for a match and get it this way
I feel like thats a little overkill when i know where the package is going to be at all times tho
Thought i couldn't manually make folders in there? Though i guess i never tried
Ok holdon let me double check. Im pretty sure find by for name was not available in this version
You can put the whole package in that folder: e.g. Packages/mycoolpackage
And it will work and be editable in editor
Ah, well now i just feel dumb. But thats good to know
You may be right actually, I just did Find() on all of em to find mine
(can check with the little dropdown)
Yeah im on 21
i cant find a proper channel for the editor itself so i think this is close enough,why is the camera clipping so early? it wasnt like this before,i could zoom all the way into the monitor of that pc but now the camera clips everything and its getting hard to work with
Through asset database or?
Or you mean going through all the package folders to check for yours?
thats a setting on your camera called clipping planes
nvm i fixed it,turns out i can just press f on an object and it focuses there and the clipping fixes itself
This gets them all so you can just search for yours via name.
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/PackageManager.PackageInfo.GetAllRegisteredPackages.html
welp, i suppose i will have to filter thought unnecessary data unless i make a json solution myself in that case
you sure? unity doesnt allow me to create folders in the Packages folder. or do you mean to make a folder called Packages within Assets?
unity isn't the police
Project root/Packages
Where the manifest.json lives.
This works as I use it for a package myself
make it in file explorer
Yep do it outside of unity
ohno, its super inconvenient to make it from the package folder. every time i export it as a unity package i gotta move the entire thing, unless i only use github
I clone my package repo in there and commit it as is
I don't have it inside a unity project in the repo
what i mean is when you export a unity package it only allows you to select files thats within the scope of Assets/. Even the asset store validator does that. only time its not inconvenient is if i dont export unity packages, and host it on github as is
No this is all for a package via the package manager
.unitypackage files you can do whatever cus they are not special
then how would you export while it is in the package folder? both exporting a unity package and uploading directly to the asset store requires the files to be in the asset folder
I didnt realise this was for the asset store. you will have to do it the shit old way then 🤷♂️
a package is not the same as a "unity package of files"
i have no idea if the asset store supports upm packages yet
it is only code and assembly files with the required demo, but it should function the same as any other package installed through git
I created a window with a MultiColumnLisView. How do I save the column widths when they are changed? Currently whenever the window is rebuilt, the column widths are reset (which are tiny).
Serialize an array to the window, it's a scriptable object
I want to make something like this but for a scriptable object inspector does anyone know how and preferably a dropdown add button for an array style
it has to be nested in other stuff like this for now i was using dictionaries
each effect has there own properties that can be edited
That's an AdvancedDropdown
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/IMGUI.Controls.AdvancedDropdown.html
and you can customize the add button for a list via ListView.onAdd in UITK
there's no easy way to modify it without manually drawing the list sadly
could you provide an example im kinda confused still
and im also too broke for odin inspector
Sadly no, it's very complicated. Maybe there's some packages out there that do it
kk
When do I serialize that array? I'm not seeing an onColumnWidthChanged event.
OnDisable
this unity package i got for serialized dictionarys does this can i have help making a custom serialized dict instead?
https://streamable.com/31yjre
nvm
i managed to do it without custom inspector somehow
Hey, I am trying to make a new shortcut that would create a script, I just can't figure out how to tie it to a specific context :/
I want this to only be registered in the Project view, not Scene view etc.
Here's the code I have so far:
public class EditorShortcuts : MonoBehaviour
{
[Shortcut("NewNnScript", KeyCode.S, ShortcutModifiers.Control | ShortcutModifiers.Alt)]
private static void NewScript() =>
ProjectWindowUtil.CreateScriptAssetFromTemplateFile("Assets/NnUtils/Scripts/Editor/NnScriptTemplate.txt", "NnScript.cs");
}
Please @ me and thanks in advance!
The sample there seems to match what you want, except you need to change the focusedWindow
Ah, so you would have to make a custom context implementation, I see.
How come unity doesn't have these for built in windows, such as Scene, Project etc.?
No idea, maybe they do, I just learned about this API 😛
Is it possible to check if game is about to quit when inside the Editor? I'm doing some logic inside OnDestroy to cleanup and need to exclude some paths during editor game shutdown
I've tried hooking into UnityEditor.EditorApplication.playModeStateChanged, but it doesn't seem to fire before OnDestroy 🤔
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorApplication-quitting.html set some global value in this
Will check this out tomorrow, thanks!
Mhm, this does not fit my use case - this checks if the Editor is quitting, not if the game inside the editor is quitting
Ah I misread
UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode seems to work
There is also this which unifies a number of events https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorApplication-playModeStateChanged.html
See this @gloomy chasm
Oh, should of read the convo more, my bad!
I Wrote the drawers script but still doesn't work and I'm not sure how to use it, anyone knows why please ?
https://paste.mod.gg/rqzqrqzkrnye/0
https://paste.mod.gg/rqzqrqzkrnye/1
https://paste.mod.gg/rqzqrqzkrnye/2
time = new List<string>?
yeah tried with strings to fill it with those 24 hours but didn't work 😬
The only thing that can be null on line 20 is that collection
So if it's not that, then your linenumbers are probably wrong and anyone through chat will just be guessing
that error usually means you are trying to attach a non-MonoBehaviour to a gameObject, usually when you change a script from MonoBehaviour to something else while it is still attached somewhere.'
And you shouldn't need both Visual Element and onGUI. At the very least I would combine them into one class or it might cause some problems.
2022 and later can show either one so yea you dont have to make a version for both gui systems
is there a fast way to see if it's attached to an gameObject and what gameObject ?
to be honest I have no clue what I'm doing 🥲
maybe they show up as a warning
maybe search for it in the hierarchy (and projects) folder "SO_DailyTasks"
the warning in the middle might be on to something
you either have two script named SO_DailyTasks or one and it is not derived from ScriptableObject
Yes this one
uff.
Usually you have a script named:
MyClass
and the drawer script (which has to be inside a folder named "Editor") is called:
MyClassDrawer
You are kinda mixing both into a single script, that doesn't work
There are a couple tutorials on drawers and editors, or you could look up how Unity handles it, here is the script for a VerticalLayoutGroup (this is an editor though and not a drawer)
https://paste.mod.gg/obnisnqfjgwe/0
A tool for sharing your source code with the world!
I followed the tutorial on the official Unity API and they showed multiple script 😬
like do I really need to use drawers for what I want (aka a simple 24 hours timer drop down list) that's a TimeSpan ?
perhaps a property attribute on say a long so you can select a time span but serialize it in MS
https://docs.unity3d.com/ScriptReference/PropertyAttribute.html
Or a drawer for your own class
Unity can't show TimeSpan in the inspector, that might be one of the reasons why your script doesn't work. You could just use something like
[Range(0, 24)][SerializeField] float startTime;
[Range(0, 24)][SerializeField] float endTime;
private void OnValidate()
{
if (endTime < startTime)
{ endTime = startTime; }
}```
or at the very least you have to display the start and endTime as float and then convert it to TimeSpan once the game starts
you can store the time as milliseconds or seconds or even minutes as int or long but dont use float
can be whatever tbh but your problem is the drawer gui i guess
I need to have those displayed in the inspector in this format 06:00
same on the UI in game
and also it will be used inside SO because each prison will have different timings for the tasks
someone sugested drawers but I forgot to solve which problem x)
Custom drawer is to show the GUI controls you want. It will let you display a list of times but you can save the time as some number so its serializable.
So you will draw a popup: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorGUILayout.Popup.html or similar
Should I start from scratch and could you help me do it step by step please ? 🙂
ill give a general overview of how it would work:
- const for time interval such as 1h
- make list of strings for options that start at interval and go up x amount (01:00, 02:00 ect)
- look at variable to figure out what string should be "selected" rn (e.g.
5meaning 5 hours so string at index 4) - convert new selected option index to new selected time e.g. 6
- write to
intorlong
the serialized var could be int hours; for example
the whole idea is taking some variable and mapping to and from your custom gui options
But here the time span is saved as TimeSpan type
but that isnt serializable by unity so it can be stored as a number
I don't understand how to do that 🤔
then i cant help you 😆
a time span object represents some amount of time, NUMBERS CAN TOO
I did this first is it good or I'm already in the wrong ?
im not going to check things like a teacher
then I'm doomed 😦
I have an object with 2 fields. I have subscribed to RegisterValueChangeCallback on my first field, when I edit it I also edit the other value through SerializedProperty and finally ApplyModifiedProperties. Both are currently drawn using UITK PropertyField. For some reason the other field doesn't seem to update though, do I need to force UITK to redraw it somehow? This is in a PropertyDrawe
If I close and open the window the value is was clearly properly serialized correctly
I've worked around it by manually unbinding and then rebinding the property. Feels a bit hack-ish so if someone has a better idea that would be great
No idea really without seeing the code.
anybody know why I can't change anything in the first list and I can't expand/collapse the items in the second list. It's an editor window
public class SettingsWindow : EditorWindow
{
[MenuItem("Tools/AdvancedScriptTemplates/Settings")]
public static void ShowWindow()
{
GetWindow(typeof(SettingsWindow));
}
private void OnGUI()
{
UnityEditor.Editor m_MyScriptableObjectEditor = UnityEditor.Editor.CreateEditor(TemplateSettings.instance);
m_MyScriptableObjectEditor.OnInspectorGUI();
}
private void OnDestroy()
{
TemplateSettings.instance.Save();
}
}
Probably because the editor is recreated every frame
ah ok that fixed it
has anyone run into the issue when unity remote 5 wont show the Mobile keyboard with textmeshpro input field
im using FieldInfo a couple of places in my editors, but for some reason one of them are resetting back to the previous value after ive changed the field value when i call serializedObject.ApplyModifiedProperties();, why does that happen? instead should i only call this once im changing serialized properties and not when im changing fields as those are not serialized properties?
hmm, when i dont call it, something breaks so im not too sure
I'd need to see your code to make sense of this
How are you using FieldInfo? What exactly is "resetting"?
holdon if im gonna show code i gotta get a new things
but essentially, im doing a few things to figure out which index i want from a list, then im storing that index. the index is being set through FieldInfo as its public get; private set; but the list of items are not using FIeldInfo, those are using serialized properties. its the list that is being changed which should then set the index for the FieldInfo
so because im using both, i have to call ´serializedObject.ApplyModifiedProperties();´ to allow the list elements to update properly, but then the FieldInfo is reverted back to what it was before the serialized properties where changed
This is part of the code i have in OnInspectorGUI
if(_Scenes.serializedObject.hasModifiedProperties)
{
Undo.RegisterCompleteObjectUndo(target, "MultiSeneTools: Scene Collection Active Scene Index = " + ActiveIndexField.GetValue(script));
updateActiveSceneIndex();
}
serializedObject.ApplyModifiedProperties();
The ActiveIndexField correctly set during updateActiveASceneIndex() to what it should, but once again as it reaches the apply method, its back to what it was before the method ran
if you want to see the entire logic for that i can post that as well
Not an expert when it comes to this but try calling SetDirty and/or serializedObject.Update before applying
but im calling ActiveIndexField.SetValue(script, index); where im setting the new value
ill try that first then
ok im getting somehwere so i might be able to figure someting out
thanky
nice, fixed it! added an serializedObject.Update() after changing the fieldinfo, then im applying the modified properties after ive changed them, instead of doing both after both 
The reason is because ApplyModifiedProperties() changes all the properties in the target object to match the serialized. So it will overwrite any changes made to the target object. While Update() changes all of the properties in the serialized object to match the target.
You can think of ApplyModifiedProperties() as sending the data from the serialized to the target object.
And Update() as sending the data from the target to the serialized.
ok so this is the last bug i cant figure out. ive been trying for several hours trying several things and googling, which i found that this might be a unity bug so idk. but ill ask anyway.
I have a strange issue with opening editor windows automatically with the ´[InitializeOnLoadMethod]´ attribute, where it shouldnt open multiple windows but somehow it opens some kind of invisible windows that are bugged, but show up on the taskbar.
this is simplified for the example but i have this code:
[InitializeOnLoadMethod]
static void Startup()
{
CheckUpdates(); // checks if an update has been detected, if it has opens the setup window
}
where CheckUpdates() is calling SetupWizard.MenuEntryCall(); where its needed.
ive tried storing the wizard instance in my config scriptable object and not opening one when the config has an open wizard, so that so when the project reloads the instance isnt lost, but this had no effect as far as i can tell. and its still opening blank windows
MenuEntryCall isnt doing anything other than just opening the window with setting some default values for where its on the screen
This is the important part of the code 😛
But a work around is probably to just do the check in EditorApplication.delayCall += () => CheckUpdates();
this is all
[MenuItem("Tools/Multi Scene Tools Lite/Setup", false, 1)]
public static void MenuEntryCall()
{
MultiSceneToolsSetup_Wizard _Wizard = (MultiSceneToolsSetup_Wizard)GetWindow(typeof(MultiSceneToolsSetup_Wizard));
Wizard.titleContent = new GUIContent("Multi Scene Tools Setup", "Creates or updates the config");
_Wizard.position = new Rect(Screen.currentResolution.width/3, Screen.currentResolution.height/4, _Wizard.position.width, _Wizard.position.height);
_Wizard.minSize = new Vector2(684, 520);
_Wizard.Show();
}
Is GetWindow the EditorWindow.GetWindow method?
yep
That calls Show already
isee, i originally didnt have that there but i added it as i was hoping the hidden windows would then be forced to show themsevles but ofc it didnt do anything
-# im currently testing this to see if its still happening btw
You can do this:
var wizard = Resources.FindObjectsOfType<MultiSceneToolsSetup_Wizard >().FirstOrDefault();
if (wizard == null)
wizard = CreateInstance<MultiSceneToolsSetup_Wizard >();
// Set properties on 'wizard'...
wizard.Show();
Looking at what I did in the past, I did do the delay call to open it. Also when testing I would reset the layout of Unity so those bugged windows are closed.
ah, i didnt even think of trying to open a different layout, ive been reopening the project each time 
ok nice, this seems to have done the trick. thanky!
gonna have a look at this as well just to make sure nothign bad is happening
Yeah I have had to do it a lot when I add a custom popup window because when you open a window with ShowPopup, there is no way to close to besides that or find all of them with Resources.FindObjectsOfType haha
OK I'm at a loss
I created a Custom GridBrush and a GridBrushEditor. Almost everything works except the fact that in the Tile Palette window the grid brush will draw itself when you click on a random position in the Tile Palette Window. Is that by design or am I missing something.
I thought the override for drawing in the inspector would fix that but it doesn't help at all.
anyone know why the animation rigging package gizmos won't get disabled when i toggle the gizmo's visibility ?
How can I get the GUID of an Scene?
Did you try AssetDatabase.AssetPathToGUID?
Oh, I didn't. I'll try that, thanks
they are a component, not really the same
you gotta disable the bone renderer
I wasnt talking about the bone renderer
Iwas talking about the constraint targets
ahh mb, i dont know much about disabling those gizmos
Where can I find this "right-click" option in source code?
Do you mean "Copy Property Path" or do you mean the menu that opens up?
This is the menu that gets opened https://docs.unity3d.com/6000.1/Documentation/ScriptReference/EditorApplication-contextualPropertyMenu.html
Thx! That was it (Copy & Paste are custom)
I'm using a material property block to assign properties to the shader being used for this tilemap. When the object is dirty, and the scene gets saved, these properties are reset. Is there a method or event or something i can hook onto to reapply my material property block when the object gets saved?
currently i refresh the material property block on Awake(), OnValidate(), and OnBecameVisible(), but none of those occur when the object is saved.
Are you not able to use EditorGUILayout.Foldout inside OnInspectorGUI? the internet is fraught with people saying it doesnt work in various scenarios, but there is never really any answer.
I am storing the state of the foldout in the MB it acts as the inspector for to mitigate any problem of the state being broken during drawing, but it just never seems to register a click on the label, even with the toggle on label set to true, i.e:
myExternalVisibleState = EditorGUILayout.Foldout(myExternalVisibleState, ShowImplementations, "The label to be shown", true);
(Oh I am also using Unity 2022.3, I was using 2021 but thought maybe it was something that regressed between versions so bumped up one to check if that fixed it, it didnt 😦 )
Editorguilayout doesn't work in property drawers
SerializedProperties have an isExpanded field which you can use for your foldout
Can you point me to an example?
I have tried searching for what you mean, cant find anything, also I use EditorGuiLayout stuff quite a bit in the inspector and the rest of it seems fine, the confusing thing is there are lots of posts of people saying it should work in the inspectors fine as its just another editor thing
they don't work in drawers
Is there any alternative that does the same thing? I cant really use an attribute as I am having to loop over properties within objects and spit them out into their own bits of the UI
its fine, it does work, but for some reason it wasnt treating the data as a reference so was constantly just overwritting the value, wrapped it in a class to ensure it is correctly using the reference and works as intended now
Can you provuide more code?
Sure
oh sorry its not letting me share, let me chop it up a bit
[CustomEditor(typeof(ObservableGroupViewer))]
public class ObservableGroupViewerInspector : global::UnityEditor.Editor
{
public class VisibilityState
{
public bool ShowGroup { get; set; }
}
public Dictionary<LookupGroup, VisibilityState> VisibleStates = new();
public override void OnInspectorGUI()
{
var observableGroupViewer = (ObservableGroupViewer)target;
if(observableGroupViewer == null) { return; }
var observableGroupManager = observableGroupViewer.ObservableGroupManager;
EditorGUIHelper.WithLabel("Active Groups");
foreach (var observableGroup in observableGroupManager.ObservableGroups.OrderByDescending(x => x.Count))
{
if (!VisibleStates.ContainsKey(observableGroup.Group))
{ VisibleStates.Add(observableGroup.Group, new VisibilityState()); }
var visibleState = VisibleStates[observableGroup.Group];
EditorGUI.indentLevel++;
visibleState.ShowGroup = EditorGUILayout.Foldout(visibleState.ShowGroup, label, true);
EditorGUI.indentLevel--;
if (!visibleState.ShowGroup) { return; }
GroupUIAspect.DrawGroupUI(componentTypeLookup, observableGroup.Group);
}
}
}
Thats a slightly chopped up and bolted together version, but that works, it doesnt retain through reselection but thats what I wanted, if I wanted it to persist I could just move the data tracking the visible states into the MonoBehavior its sourcing data from.
Right
GUILayout does work in Editor derived classes but not in PropertyDrawers
Generally, it's recommended to use SerializedObject/Property to access fields though, there's more info #↕️┃editor-extensions message
Does anyone know of a good free dungeon generation tool I can use in my Lethal Company inspired game? I found these demos which look like exactly what I want. 2d demo, 3d demo 2. These are demos from an existing Godot plugin.
You probably want to learn how to make one instead. Each games usually have their own set of rules
Lethal Company uses the paid asset DunGen, for reference
Uh oh
Looks like your ListView is not populating the data correctly 🤔
Have you set the ItemSource to the correct object?
Yeah im pretty sure but I've scrapped the editor for my project for now in favor of json (at least for now).
Are there any edge cases for script extending from Editor such that OnEnable() isn't called? Furthermore, what's the best way to clean up materials and other unity objects when the editor object is deselected? How much can I rely on OnDisable() being called, or should I consider alternatives?
Should be reliable afaik
Is it possible to bind using UI Builder before unity 6?
Editor SerializedProeprty binding yes, but not the runtime binding.
thanks! I'll probably try updating to unity 6 and if I have too many issues I'll use the serializedproperties.
If you are doing stuff with data in the editor, you should always be using SerializedProperties, otherwise things won't get saved properly or support undo/redo or prefab overrides
Oh so the runtime binding is only for non-inspector UI? Gotcha
Hi! I am making some scriptable object assets with a custom editor. Now and then when updating the assets via user interaction i get this error. Do you know a way of finding where this error occurs?
Anyone have any good extensions for cinema creation?
Cinemachine...?
And Timeline?
any extensions to help me bulk sort a messy project cause like got 2 separate projects that need to be organized and merged into one and both exceed 17GB
In the CreatePropertyGUI() of the PropertyDrawer class, is there any way to get the label text passed by the second argument of the PropertyField constructor? Or do I have no other way than to use OnGUI()?
Probably this https://docs.unity3d.com/6000.0/Documentation/ScriptReference/ObjectNames.NicifyVariableName.html specifically but there's a bunch of goodies there
IIRC properties also have a displayName
Thank you for replying:)
In my project, the PropertyDrawer of the parent element passes a runtime-generated name to the child element through the second argument of the PropertyField constructor.
In the CreatePropertyGUI(), property.displayName only gives the display style name string of the original variable name. Instead, I want to get the passed name.
You're probably looking for PropertyDrawer.preferredLabel
Oh! It worked!
Thank you so much:)
public StatsData virusData = default;
public List<StatsData> enemyStats = default;
``` This is in a custom EditorWindow.
The first line is assignable in the Inspector, the second line isn't. StatsData is a ScriptableObject.
What is the reason for that and is there a workaround other than creating a new SO that has a List<StatsData>?
How do I align my elements in inspector within a custom PropertyDrawer? As im digging in it seems like only visual elements deriving from BaseField<T> can inherit this functionality of auto-alignment with other fields in inspector, but is there any other way to get it to work?
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
VisualElement root = new VisualElement() { tooltip = property.tooltip, style = { flexDirection = FlexDirection.Row } };
Label fieldLabel = new Label(property.displayName);
fieldLabel.AddToClassList(PropertyField.labelUssClassName);
VisualElement inputField = new VisualElement() { style = { flexDirection = FlexDirection.Row } };
inputField.AddToClassList(PropertyField.inputUssClassName);
root.Add(fieldLabel);
root.Add(inputField);
Rebuild(inputField, property);
root.TrackPropertyValue(property, prop => Rebuild(inputField, prop));
return root;
}
This is a simple case, label and some visual element to serve as an input
May I ask how you know this? Has the dev released a statement saying this?
Either way I'm swaying towards buying DenGen anyway.
Can someone spot my error or misunderstanding? Both fields are assigned in Inspector and this code works if the editor is playing, but not when stopped
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
public class EditorHelper : MonoBehaviour
{
private static SceneHelper sceneHelper;
[MenuItem("Scenes/Open Menu Scene", false, 0)]
private static void OpenMenuScene()
{
FindSceneHelper();
if (EditorApplication.isPlaying)
{
SceneManager.LoadScene(sceneHelper.mainMenuScene.Name);
}
else
{
EditorSceneManager.OpenScene(sceneHelper.mainMenuScene.Name);
}
}
[MenuItem("Scenes/Open Gameplay Scene", false, 1)]
private static void OpenGameplayScene()
{
FindSceneHelper();
if (EditorApplication.isPlaying)
{
SceneManager.LoadScene(sceneHelper.mainGameplayScene.Name);
}
else
{
EditorSceneManager.OpenScene(sceneHelper.mainGameplayScene.Name);
}
}
private static void FindSceneHelper()
{
if (sceneHelper != null)
return;
Debug.Log($"Finding Helpers...");
SceneHelper[] sceneHelpers = FindObjectsOfType(typeof(SceneHelper)) as SceneHelper[];
if (sceneHelpers is { Length: > 0 })
{
sceneHelper = sceneHelpers[0];
Debug.Log($"Found {sceneHelpers[0].gameObject.name} {sceneHelper == null}");
if (sceneHelper)
{
Debug.Log($"{sceneHelper.mainMenuScene.Name}, {sceneHelper.mainGameplayScene.Name}");
}
if (sceneHelpers is { Length: > 1 })
{
Debug.LogError("There is more than one SceneHelper object in the scene!");
}
}
}
}
Ignore this, solved my issue
I’ve talked to the dev and have done a lot of modding stuff
Hi. I'm making a custom importer AssetPostprocessor. Specifically OnPostprocessGameObjectWithUserProperties and OnPostprocessModel
So these processes all models. Fbx, and .blend
Is there a way to mark certain assets to use this custom importer or not?
Do i perhaps, like, gotta name the asset with a "_Level" suffix, then the custom importer i just check for this suffix to run it? I imagine this is simple and would work, but is there a more correct way to mark it?
Heey, I'm working on making some editors utilizing PreviewRenderUtility along Handles drawing & interactivity, and the general execution flow goes like:
- PRU.BeginPreview
- PRU.EndAndDrawPreview
- Handles.SetCamera(PRU.Camera)
- Draw Handles
Im experiencing some weird issues with how the handles are drawn, and it seems to only happen in docked mode for the preview window. Handles shift around based on camera positioning, and the rect its drawn in appears shifted down from the actual preview rect. However, these issues are fully resolved in floating window mode, the handles there work perfectly as expected. Does anyone have any experience with drawing handles in preview windows and know how to get around this? Moving handle drawing between begin/end preview doesnt help, tried making sure the FOV is constant, setting the camera pixel rect to the preview rect, etc...
Some forum posts i looked at but none of them seemed to resolve anything for me. Click interaction works perfectly fine btw.
https://discussions.unity.com/t/previewrenderutility-and-handles/783621
https://discussions.unity.com/t/writing-an-editor-window-that-mimics-the-scene-view/728634/35
Not sure if this the right place to ask, but how do I move these things? I draw them with EditorGUILayout. The problem is that toggle checkmark is drawing over the label, so I want to add some offset between. I tried margin/padding in the GUIStyle, but it didn't work
draw your own prefix label and toggle to make the label wider
how do I do that
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("FooBar", GUILayout.Width(50f));
EditorGUILayout.Toggle(false);
EditorGUILayout.EndHorizontal();
something like this (written from memory so may have mistakes)
The idea is to give the label a fixed width that better suits what you desire.
I'll try it
gui layout options are used to specify these settings: https://docs.unity3d.com/ScriptReference/GUILayoutOption.html
yeah I know what it is
nothing changed
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Always Draw Prefab Name", new GUIStyle()
{
fixedWidth = 200
});
_alwaysDrawPrefabName = EditorGUILayout.Toggle("", _alwaysDrawPrefabName);
EditorGUILayout.EndHorizontal();
do what i did and you ommit the arg for a label when you dont need it... like in my example 😐
basically all of those control gui layout functions have an overload without a label arg
PrefixLabel asks for GUIStyle, not GUILayoutOption
perhaps Label is better suited here than PrefixLabel
now it looks good, thank you🙏
It seems that EditorGUI.FloatField doesn't allow you to drag to edit floats.
I tried using EditorGUILayout.FloatField which does allow dragable edit, but it broke the rest of my property drawer.
Is there a way to add that functionality to regular EditorGUI.FloatField?
I'm using
Undo.RecordObjects(scriptObjects.ToArray(), "Namespace Fix");
```The problem is this doesn't show up in the undo history.
I use FileReadAllText() and File.WriteAllText() to make changes to the scripts.
I assume the editor doesn't detect the changes and I have to tell it manually that they have changed but I don't know how.
as long as you record objects before making changes it should work
when i add a custom attribute to my script (if that script happens to be open) the formatting/styling is whacked
but if i add a script w/ the custom attribute already in there and compiled i guess.. it works fine..
it isn't until i cycle back to have it selected does it look correct..
i can share more or the scripts if need be.. but i think theres just something im missing (or forgetting to do)
how can i go about having it style/ or redraw or w/e it needs to do when adding to a component already in the inspector
Can you show the code that handles drawing the button? Too many things it could be to realy make a guess without it.
nvm, i figured it out.. I was initializing the styles in the wrong spot
while i was writing it logically i thought (we'll if theres no buttons, then theres no header either.. so theres really nothing to style.. so makes sense to have my InitializeStyle() method at the top of the DrawSeperated() method..
Hi guys. I'm usingii OnPostprocessGameObjectWithUserProperties, and added component SpriteRenderer, and do Resources.Load SpriteAtlas and use GetSprite
Deblog says it can find the sprite no problem (the sprite name has a (Clone) suffix), but when i see in inspector, no sprite assigned. What's going on?
Hey guys, I'm trying to make an editor button that when I click calls an event
How do you guys go about auto saving ScriptableSingleton in a non sucky way?
Currently without needing to save, I can just do:
private void Toggle(ref bool value, string title)
{
value = GUILayout.Toggle(value, title);
}
Toggle(ref SomeScriptableSingleton.instance.SomeBoolField, "...");
But if I want toggling the field to cause the singleton to save, I don't see a clean way of doing it without a bunch of boilerplate code.
Unity doesn't support accessing methods or events via serialized property (since they are not serialized). If it is a UnityEvent you can get the value and then on that value you can invoke it.
I just save it in the setter of the property 🤷♂️
Can't do the ref setting like that any more. But really, it is best not to use public fields anyway.
I think saving on OnDisable is also a decent enough compromise.
But I'm running into an entirely different problem, that the saved data just doesn't seem to load at all. Not even the example code copied straight from https://docs.unity3d.com/6000.0/Documentation/ScriptReference/ScriptableSingleton_1.html. I can see that the save is created, but on next editor session it just doesn't seem to load from the save.
Can you find the actual file and see it has the saved data?
Yep, the file does get created and the data seems fine.
That should be okay I think? It is serializing the object using the normal Unity serializer so it should be okay. But I'm not sure if it might set some other data before the call that might mess it up.
Did you copy the code literally 1 - 1 including the Menu items for savin and loading?
Yep, exactly one to one.
Did you try it as a new file?
I didn't, but I guess might as well.
Oh, does the file name have to match the class name or something?
No it shouldn't any more. But Unity might have that file in a weird state for some reason
Might just to make sure, have the file name be the same
After a bit of trial and error, the issue seems to be that it doesn't work if the scriptable singleton class is nested inside another class.
When nested, the serialized m_Script is empty while m_EditorClassIdentifier is non empty, so it seems to me that there is specific code meant to handle this case but it doesn't actually work?
You still need one Object per class, and I'd expect nesting to break it
MonoScript relies on tying the script to its file, and that's what m_Script is
(Apologies if assetdatabase problems don't go here)
Right now im working on an sdk for my game and im trying to make a pallet system,
When i create a pallet in prefab mode on the object using the button i made, it creates it but it does not drop the object in the scriptable object...
But when i use the prefab in the project window it seems to drop it there?
my script
i maybe doing something wrong with getassetpath or loadassetpath but im not so clear on it
Does anyone know where GLTFast is now in the package manager? (in 6000.1.5f1), i can't seem to find it....
Heya! how do i keep state in an EditorWindow beyond a code reload? Its making development extremely annoying to have to refill all information into a window
my current setup consists of having a handler object that the window communicates with
basically a front/backend infrastructure where the EditorWindow is responsible for displaying things and the handler is responsible for doing the heavy lifting
however the handler object becomes null after every code reload
easiest way to replicate my setup
[Serializable]
public class Handler : UnityEngine.Object {
int data;
}
public class Window : EditorWindow {
[SerializeReference] Handler h;
void OnEnable() {
if(!h) {
h = new();
Debug.Log("this should only run once");
}
}
}
"this should only run once" is printed every time the code reloads
if i simply do
public class Window : EditorWindow {
int data;
void OnEnable() {
if(data == 0) {
data = 5;
Debug.Log("this should only run once");
}
}
}
``` it works
you could store the data in a ScriptableObject or ScriptableSingleton
It should be throwing an exception because you are inherit from UnityEngine.Object That isn't allowed...
well it wasnt ^^`
Also the field is never serialized since it isn't public or has [SerializeField].
As long as the window is open it will serialize all serializable fields. Meaning they will persist between domain reloads.
So no need for the Handler at all.
Also, [SerializeReference] does nothing on fields of a type that inherit from UnityEngine.Object. They are made for POCOs
Same with [Serializable]
got it
Unity doesnt recognize .Ink when building the projects
But my dialogue works
Idk if this is the right place to ask about ink but how would i fix that?
Assembly reference crap just floods my whole project with errors
Hello!
I have these Sprite Renderers (in a 3D game) that the default preview is always rotated to the other way
Is there a way to default the rotation on the PREVIEW to face a certain angle? (I tried having the prefab be rotated but it doesn't do anything)
(the hierarchy of the prefab is literally that single SR, and I think that if I add a parent it should be solved but it would just add unnecessary GOs to the hierarchy)
I'm making a list of items which can be dragged from the inspector into the scene. i want these items to be in capsule shaped boxes, so i modified the GUI.skin.label style and set the background to a generated capsule texture, however this texture doesn't look how its supposed to in the inspector. you can compare the capsule shaped one (which is just the texture put on a material and rendered on a quad) and the misshapen one which is rendered in the inspector through this script:
https://pastebin.com/qaAQZaEC
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
any one knows what is TextureID in Profiler ?
i tried logging all textures ID's in the project , but none of them seem to match
var id = (int) tex.GetNativeTexturePtr();
var instance_id = tex.GetInstanceID();
Finally figured it out, turns out changing the border of the style messed things up
Is there a way to check if there is at least one dirty asset in the AssetDatabase?
bump that thread , maybe the devs will add it
so i decided to scan the entire DB ... but still no luck , here is the code i used :
public void ScanAllTextures()
{
var EVERYTHING = AssetDatabase.GetAllAssetPaths();
foreach( var x in EVERYTHING )
{
var GUID = AssetDatabase.GUIDFromAssetPath(x);
var TYPE = AssetDatabase.GetMainAssetTypeFromGUID(GUID);
if( TYPE == typeof(Texture2D) )
{
var tex = AssetDatabase.LoadAssetAtPath<Texture2D>(x);
var id = tex.GetNativeTexturePtr();
Debug.Log( $"GUID:{GUID} TexID:{id} PATH:{x}");
tex = null;
EditorUtility.UnloadUnusedAssetsImmediate();
}
}
}
how would I spawn a new gameobject not as a clone, but as an actual prefab? Correctly linked and all that?
when I Instantiate() they are grey and not counted as prefab instances like if I dragged one into the scene
I think this might be it?
Is there a recomended way to draw a solid tri in scene? I know you can draw meshes but between handles and gizmos i cant find anything that does it on a tri by tri basis
ive seen some suggestions of using the GL commands directly but i've had trouble getting those working nicely
(i'd use a mesh but im doing some dynamic adjustments to the info in a way where ideally i wouldn't wanna constantly build a new mesh)
GL is the way I would do it https://docs.unity3d.com/6000.0/Documentation/ScriptReference/GL.Vertex.html
What issues do you have with GL?
Just like, wasn't working aha. Didn't dive too deep into it though, figured i'd ask here incase there was something simpler i missed
I assume it's related to using it in a 3d context as the example code linked by mechwarrior is seemingly partial and my interpreted guess at how to use the matrix referenced in that page was wrong
I couldn't find a fully fledged example online
GL is inherently 3D. And just for reference, all examples you will find on the Unity Docs are complete samples that can be copy-pasted in to a project and work.
Also, here is another example with different matrix usage.https://docs.unity3d.com/6000.0/Documentation/ScriptReference/GL.html
Feel free to share some code if you are still having issues!
Is there a way to display an indeterminate progress bar that blocks the editor from being interacted with?
OnPostRender does not work if you use URP or HDRP, need to use one of the events in RenderPipelineManager instead
@queen wharf
If the server let me i’d be posting that reaction gif from The Wire rn, thank you
It doesnt block input, I can still click around the editor when it is up
... you shouldn't be able to... it is what is used when scripts reload, assets import, etc.
Can you share your the usage of it?
Yeah give me a bit
Also worth noting that you can set the progress to -1 for an unlimited/infinite bar
private static void ShowIndeterminateProgress(string title)
{
EditorUtility.DisplayProgressBar(
title,
"Please wait...",
-1
);
}
private static void StopIndeterminateProgress()
{
EditorUtility.ClearProgressBar();
}
private static async Task BuildTask(Builder builder, BuildOptions buildOptions, string outputLocation)
{
ShowIndeterminateProgress("Running Pre Build");
try
{
await builder.PreBuildAsync();
}
finally
{
StopIndeterminateProgress();
}
}
Didn't know about the -1, thanks for that!
I can definitely click on things while mine is up.
This looks just like how I use it. This is bugging me, I know I ran in to the exact same issue before but I can't for the life of me remember what I did to fix it...
I looked at my usage and it is the same. Weird...
Yeah definitely is weird. It is running in an EditorApplication.delayCall callback so maybe that has something to do with it
Seems it used to block, but now it doesn't
Does something like this look right? Or do i need to actually use the cameras or something.
Ideally i want to draw triangles in the scene, during play mode
public class GLTest : MonoBehaviour
{
// Draws a triangle that covers the middle of the screen
public Material mat;
private void Awake()
{
RenderPipelineManager.endFrameRendering += PostRender;
}
void PostRender(ScriptableRenderContext con, Camera[] _)
{
if (!mat)
{
Debug.LogError("Please Assign a material on the inspector");
return;
}
GL.PushMatrix();
mat.SetPass(0);
GL.LoadOrtho();
GL.Begin(GL.TRIANGLES);
GL.Vertex3(0, 0, 0);
GL.Vertex3(1, 1, 0);
GL.Vertex3(0, 1, 0);
GL.End();
GL.PopMatrix();
}
}
So far this isn't drawing a tri at 0,0,0 but not sure if i need to use any of the like setmatrix functions or color functions etc.
is there anything here that would cause my pc memory to explode and crash my game?
there's an attribute somewhere that tells unity what name to use when serializing something in a list if it cant find a name-esque string inside it, anyone recall what that is?
eg. so i can give these an explicit name
its too early in the morning i was about to post a cute cat gif in response before realising what discord im in.
will have to see if it actually does what i want but that is what i was recalling i think ty
i think thats what i was thinking of so it might just not exist lol
i thought it was that because of the applyToCollection prop but i didn't see it was inherited lol
found these 2 forums
https://discussions.unity.com/t/how-to-change-the-name-of-list-elements-in-the-inspector/650614
https://discussions.unity.com/t/i-cannot-rename-list-element-names-in-the-inspector/830675
so yeah seems like you'd just have to do a custom property drawer
or i suppose use SerializedDictionary<string, T> lol
refreshing myself abit on propertydrawers,
i'm drawing two serializedproperties here via PropertyField with a different rect each (rn one is just 20 y more than the first). visually looks how i want but the mouseover controls seem to overlap/be shared between both bools here. Just curious what aspect of a custom propertydrawer actually decides the control space of a field since it seems to be seperate from the visual rect?
I can post code if needed but I know i'm doing a couple things wrong rn, just curious whats in charge of that
Resolved I am dumb dumb and used a silly rect value for the height
As far as I know, it uses the first serialized string of the given serialized object.
Given an ScriptableObject how can I get the path where it's stored? AssetDatabase.GetAssetPath doesn't work when the object is "inlined" into an scene or prefab
If its an asset reference it should work 🤔
If it is 'inlined' then it is not an asset. And it is generally a bad idea to try to 'inline' objects in a scene from experience. Unity doesn't like saving them.
I have a set of scripts (extensions, attributes, editor windows) that I use all the time now, and I use some of them for a framework/plugin that I’m preparing to sell on the asset store. Ideally I’d like to also offer the whole set as a separate asset but also include just the ones in use in the first framework as a part of that first package. Is there any friction then if someone purchases both? I will test by making the two separate packages and see what happens when I import them together, but was curious if anyone had experience with this. Like I imagine if you have a free vs premium version of a code asset you’d have come across this before.
I’m guessing if you just target the same directories and use the same name for the asmdef then the user can just add and replace smoothly but would like to hear from experience
Oh
The asset store has ways of doing upgraded version of assets and stuff. But yeah, if the paths are the same and the meta files are the same. Then it will see them as files that already exist and skip adding them. Another option is packaging them as packages (like Package Manager package) and then they will just be dependencies and it should work fine.
Alright cool. Thanks for the insight
When I use Handles.Label how can i know when it's been hovered over? googling online mentions controlids a couple times but i dont understand it
it all happens right away as you call it
it's immediate mode gui
fair, how can i know if it's been hovered over 😛
Could you define hovered?
eg. whatever makes it start using the hovered part of the guistyle
(my mouse is over that)
Hm, I'm not sure you can extract information as such
🥺
brutal
i can't find a way to calculate the used rect of it in the context of the 3d space either so i can do comparable rect checking afaik
maybe you can do with just separate button?
wym?
would need to be on button hover not click but maybe
worried if theres overhead on that at scale tho
You are already in a territory where it's not supposed to scale tbf
might be hitting 100-10,000 range practical min max with these
probably more on upper
just annoying that clearly the info is somewhere cuz it changes style usage
since it's IMGUI I have a feeling all it does is this somewhere in call chain:
Color drawColor = isHovered : style.onHover : style.normal;
and whether it's hovered or not is resolved right away here
:/
you mean HandleUtility.WorldPointToSizedRect?
I did see that but I don't know how I could determine the rect
what do you mean? it determines the rect
From the description it seems like that's for 2d labels at a 3d point, where as my label is a 3d label at a 3d point, no?
there are not 3d labels 🤔
this is kinda what Label deos: cs public static void Label (Vector3 position, GUIContent content, GUIStyle style) { Vector3 val = HandleUtility.WorldToGUIPointWithDepth (position); if (!(val.z < 0f)) { BeginGUI (); GUI.Label (HandleUtility.WorldPointToSizedRect (position, content, style), content, style); EndGUI (); } }
3d might not be the best wording, i mean that the label is manipulated by the handle matrices' rotation and position from the camera and stuff
i see
This ended up working, many thanks
I assume this takes the camera rotation aspect into consideration right? My points are static so was curious if i could cache the results
Feel like i cant
world to screen transformation is dependent on the current camera transform so no
Hey guys!
For the past fiew months I've been working on some ScriptableObject oriented reactive framework with full tooling and stuff (if you are familiar with it, its basically like "Scriptable Objects Architecture Pattern (SOAP)" package, but imo way more advanced and flexible). Im slowly coming to release-ready state and before I publish it on Asset Store I would like to let some people mess with it a bit for the purpose of beta-tests. To be clear a fully commercial game is being developed on the first draft of this tool, so it is not a complete shot in a dark, but version I want to publish has been rewritten from scratch, so it would be nice to test it separately.
Ofc it will be a paid asset so im more than happy to share a license after publishing to anyone that wants to contribute, so if you are intrested feel free to DM me.
Some technical info to be aware of:
version: Unity 6
scripting backend: works on both, yet it is to be tested to what extend IL2CPP handles it due to some reflection based solutions and runtime code emiting
documentation: package includes a sample project (1 for now) and built in manual, but full documentation with API and stuff is WIP
support: I would not recommend making a game with beta version I would provide, as there will most likely be breaking updates by the time of release
I'm not the biggest fan of SOAP (sorry 😅), though I've never used it for more than 2 days... doesn't it have an issue that suddenly you have over 9000 SOs that you need to PERFECTLY configure in order for things to work well, and if you don't - it may take you days to understand why? (That's a genuine question, it's how it always felt to me.)
With that said though, I'm always curious to see different approaches to things, so I'm curious what makes your framework more advanced and how it works in general. Do you have some basic summary and/or examples?
I mean, yeah, if you think about it that way you remove code dependency by treating data and events as assets, effectively transforming the code referencing spaghetti problem into asset management hell XD Whatever floats your boat in that case I guess, personally I prefer latter one.
In terms of features of my framework, overall its more composition oriented then SOAP thanks to utilisation of recently added support for generic [SerializeReference] (little thinks like instead of ScriptableVariables having an option of being clamped or something, you can define as many as you wish your own validators/modifiers), less manual work with defining concrete types for generic ScriptableObject types thanks to static analysis and editor-side code-gen pass, and many more, but the core and a single feature that gave birth to an idea of making this framework in a first place is polymorphism.
To understand the issue: we had values as SO's with typical event "onValueChanged", but it was pain in the *** to keep signature of every handler fitting the event it was observing, even tho in most cases argument wasnt even used, so I made a system in which every reactive piece of data derived from type representing a parametrless event and then rest is a history...
We ended up with a system that allowed us to observe every value in multiple different ways letting us choose if we want to handle it with no param, with new value, or new and old value. If some system expects a reference to a parametrless event we can pass a value to it as it will be treated as one that triggers whenever value changes. Seems silly but it really allows for very flexible approach to designing in-game systems.
Also if you dont like the idea of storing values and events as assets, I exposed full API to create your own types that benefit from this polimorphic observer approach and dont necessarily derive from ScriptableObject. Everything lives in interfaces and static extensions layer.
Thanks for the answer! Good job making it more flexible and convenient. Asset management hell is still not my thing but perhaps next game jam I do (if I remember and you're still looking for someone to play with it or it's released), I could give this approach another shot. 🙂
(And generic serialized reference is indeed awesome! 🤩)
Great! Feel free to DM me if you want to try it then, I have ready PATs to hand for downloading via UPM
Given the path to an scene (or the scene object, I don't care), how can I get a list of all inlined assets? i.e: for example if someone created an scriptable object but instead of storing it in a different file they stored it inside the scene itself. AssetDatabase.LoadAllAssetsAtPath doesn't work.
I could use Resources.FindObjectsOfTypeAll, but I don't know how can I filter the elements to I only have the ones of the specified scene.
If you use Resources.FindObjectsOfTypeAll and you filter out specific type that you desire maybe comparing path to your scene with AssetDatabase.GetAssetOrScenePath will help you filter the inlined assets in that specific scene.
That only return assets that you can see in the project view, but inlined assets in an scene aren't show in the project view
Then those aren't sub assets but are serialized in the scene itself
Oh, well, I still need to get them haha
I don't know how that works for scriptable objects but may not be doable easily
It doesn't work because their path is an empty string
oh
Well that may be overdoing it but I remember some utility class has option to find all dependencies for an object, so if any dependency within a scene that is of type ScriptableObject exists without a path it needs to be serialised in a scene, maybe that will do it
That may still only be for assets
It gets direct dependencies and can also get indirects:
https://docs.unity3d.com/ScriptReference/AssetDatabase.GetDependencies.html#:~:text=Note%3A GetDependencies() gets the,not Assets on your disk.
Possibly, it's just a blind guess from me
Ok so most likely solution is to still use Reaources.FindObjectsOfTypeAll and filter by type as well as by !EditorUtility.IsPersistant && !AssetDatabase.Contains, that will yield only assets serialised in scene, and after that I'm afraid the only solution to determine in which scene exactly it is serialised is to iterate through serialised objects of the scene to find any property referencing it, or read directly from a file to find in which scene file this instance id is present. It would be much simpler to just ensure only one scene is loaded though, then there is no problem with that
Sometimes this is the way to go. I wrote something to find what unity events referenced an object (e.g. called a function on this game object/component) and had to do Find and reflection to do it
Would be nice if we could examine a scene asset externally as im sure its done in native code
Or don't 'inline' assets in a scene in the first place 😉
Yea its not wise but may be a lib/package so they want to account for this
hi
I try to work with the GraphView and i have a problem.
I want to know when the user add a remove an edge between nodes.
It look like graphViewChanged must do that work, with the parameter GraphViewChange.edgesToCreate but this callback is not call when and edge is added or removed.
Is there an other way to have the information when an edge change ?
Innovative freshman: I wonder if I can somehow do XYZ
Senior dev: ...just don't
XD
Thanks
Hey guys for the tool I'm making I need to make assembly definitions, and it mostly works, but not entirely? The problem I'm facing is that there seems to be issues referencing these assembly definitions I've made with GUIDs. For example, Rider will say that it doesn't exist, and sometimes unity will pop up saying there's duplicate references.
This is what I'm putting into the file:
private const string k_ASSEMBLY_EDITOR_ONLY = @"
""includePlatforms"": [
""Editor""
],";
private string AssemblyContents =>
$@"{{
""name"": ""{_assemblyName}"",
""rootNamespace"": ""{_rootNamespace}"",
""allowUnsafeCode"": false,
""overrideReferences"": false,
""autoReferenced"": {(_autoReferenced ? "true" : "false")},
$EDITOR_ONLY_MARKER$
""noEngineReferences"": false
}}";
```(`$EDITOR_ONLY_MARKER$` gets replaced with `k_ASSEMBLY_EDITOR_ONLY` if it's editor only, or the entire line deleted if not.)
I then import everything using:
```cs
UnityEditor.PackageManager.Client.Resolve();
AssetDatabase.ImportAsset($"Packages/{formattedName}", ImportAssetOptions.ImportRecursive);
AssetDatabase.Refresh();
```but I'm not sure if AssetDatabase methods works in the Packages folder. The GUI references problem can be fixed if I right-click on the assembly file and re-import it. How do I correctly import the assembly definition if it's in the packagees folder??
Hello, I've been using for a long time the Unity Graph View package, and there's one single thing that I can't figure out how to fix. Is there any way (with specific GraphView methods or general UI Elements configuration) to set the anchors of all visual Elements to be at the center? They all have their anchors at the top left corner, which brings issues when trying to ensure that everything follows the mouse
I'm trying to set a specific icon for every ScriptableObject instance of a certain type. I've made an Editor for that type and use EditorGUIUtility.SetIconForObject in OnEnable which seems to work as icon in the inspector and as preview in the Project window, but the Project window icon is the standard ScriptableObject icon unless I manually reimport that asset. Does anybody know how to fix this? Overriding RenderStaticPreview was unsuccessful 🙂
Image attached to show what I mean with preview vs. icon in the Project window. The icon is the ScriptableObject icon. And of course the preview goes away entirely if you use the slider in the Project window and then the custom icon is nowhere to be seen.
you have to set icon for script meta that defines this type
not for the object itself
cool icon btw 😄
So I've got a custom property drawer. This property drawer has extra functionality where a it needs to have ApplyModifiedProperties called or the inspector won't update. Normally its fine.
However, ApplyModifiedProperties does not trigger a repaint the very first time its called after a domain reload. I've tried MarkAsDirty and Update, neither help. Any help please?
per the documentation, GetType gets the exact runtime type of an object: https://learn.microsoft.com/en-us/dotnet/api/system.object.gettype?view=net-9.0&redirectedfrom=MSDN#System_Object_GetType
Yet in my custom editor for MonoBehaviours, when I call GetType(), it returns MonoBehaviour.
what?
Show some code
at least invite me to dinner first...
Could do without the unnecessary ping and comment thanks
I'm having issues with updating an existing Mesh asset. I have a script that creates a mesh based on terrain. It works fine if it's creating the asset for the first time, but if I change the number of vertices and then update the existing asset, it doesn't actually write out the new vertices.
This results in only part of the terrain being covered by the mesh.
public static void UpdateOrCreateAsset<T>(T obj, string path) where T : UnityEngine.Object
{
var output = AssetDatabase.LoadAssetAtPath<T>(path);
if (output)
{
string oldName = output.name;
EditorUtility.CopySerialized(obj, output);
output.name = oldName;
AssetDatabase.SaveAssets();
}
else
{
AssetDatabase.CreateAsset(obj, path);
}
}
this is how I'm updating the existing mesh asset
The weird thing is that the triangles do update
The example above had its resolution reduced from 512x512 to 256x256. Since the vertices didn't update, only 1/4th of the terrain is covered by the triangles
The mesh creation isn't that exciting
result.SetVertices(vertices);
result.SetTriangles(triangles, 0);
that's how I actually set the vertices and triangles
https://paste.myst.rs/clamnqca
here's the mesh script
a powerful website for storing and sharing text and code snippets. completely free and open source.
I presume I'm doing something wrong here, or maybe forgetting to flush or save something on the mesh?
I sculpted the terrain and ran the script, and the vertices didn't change at all
I tried using Mesh.vertices instead of Mesh.SetVertices and got the same result
interestingly, if I ask for the max/min X and Z values of the vertices of output after copying the serialized data, they're consistent with the values from obj
...both before and after copying
This would make sense if the resulting mesh had too many vertices, and if I were only updating some of them
If I sculpt the terrain, the min/max Y values change correctly on output after copying
Uh oh
Restarting the editor fixes it
reimporting the asset doesn't do anything
so, in short: if I change the vertices of an existing mesh asset, Unity ignores these changes until I restart the editor
I heard you need to CLear the old mesh before you CopySerialized
bingo
that's annoying!
if (output)
{
if (output is Mesh mesh)
mesh.Clear();
string oldName = output.name;
EditorUtility.CopySerialized(obj, output);
output.name = oldName;
AssetDatabase.SaveAssets();
}
else
{
AssetDatabase.CreateAsset(obj, path);
}
hello what are the dots icon called? the icon i have selected in the screenshot is called sv_label_0 but im not sure about the name for the dots
From some utils I use but these are all the values and their associated names
internal static class MonoScriptIconExtensions {
public static void SetIcon(GameObject gObj, MonoScriptLabelIcon icon) {
Texture2D iconAsTexture = EditorGUIUtility.IconContent($"sv_label_{(int)icon}").image as Texture2D;
SetIcon(gObj, iconAsTexture);
}
public static void SetIcon(GameObject gObj, MonoScriptIcon icon) {
Texture2D iconAsTexture = EditorGUIUtility.IconContent($"sv_icon_dot{(int)icon}_pix16_gizmo").image as Texture2D;
SetIcon(gObj, iconAsTexture);
}
private static void SetIcon(GameObject gObj, Texture2D texture) {
EditorGUIUtility.SetIconForObject(gObj, texture);
}
}
internal enum MonoScriptLabelIcon {
Gray = 0,
Blue,
Teal,
Green,
Yellow,
Orange,
Red,
Magenta
}
internal enum MonoScriptIcon {
CircleGray = 0,
CircleBlue,
CircleTeal,
CircleGreen,
CircleYellow,
CircleOrange,
CircleRed,
CircleMagenta,
DiamondGray,
DiamondBlue,
DiamondTeal,
DiamondGreen,
DiamondYellow,
DiamondOrange,
DiamondRed,
DiamondMagenta
}
($"sv_icon_dot{(int)icon}_pix16_gizmo") that is what i was looking for. thanks a lot ❤️
anyone knows how to quickly create a Settings popup on the target Object ? similar to how you can right click on a gameobject / component and a new floating window will appear. - something like EditorUtility.PopUpSettings( target_object )
nvm i figured it out :
static System.Reflection.MethodInfo mOpenPropertyEditor;
public static void OpenPropertyEditor( UnityEngine.Object obj ) {
if( mOpenPropertyEditor != null ) {
mOpenPropertyEditor.Invoke( null, new object[] { obj, true } );
return;
}
mOpenPropertyEditor = typeof(EditorWindow).Assembly
.GetType("UnityEditor.PropertyEditor")
.GetMethod("OpenPropertyEditor",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic,
null, new System.Type[] { typeof(UnityEngine.Object) , typeof(bool) }, null);
if( mOpenPropertyEditor != null ) OpenPropertyEditor( obj );
}
Is there a way to get the width of the red line?
Is there a reason why?
nvm I figured something out
EditorGUIUtility.labelWidth
Not even sure if they're using IMGUI
I was just trying to make a custom drawer, but my Label wasn't the same length as the default Labels. I was using a "normal" Label instead of EditorGUI.PrefixLabel() and now it fits nicely
ah sorry figured it out. Im not sure why, but it had something to do with the type being in a different editor-only assembly. It started working when I moved the files to be in the proper assemblies.
Do you guys think that you should use the VR package for unity(openXR) or just create your own scripts for tracking/inputs? Navigating and reading the openXR package contents is confusing as hell
#🥽┃virtual-reality or #🤯┃augmented-reality would be the correct channel. This one is for discussion around creating custom editor windows and inspectors and such.
thanks
Not sure if this is the best place to ask, but I've had such a hard time finding a visual list of built in icons to make my editor windows. While I finally did find a library on github, is there any documented reasons as to why unity doesn't have a library already? And don't get me started on their doc website. The majority doesn't have an image of what the icon, window, etc.
Also yes. I'm a terribly new newb
I tend to use this package to see all the built-in icons.
https://github.com/ErnSur/unity-editor-icons
Why doesn't have this built-in? Because it isn't a supported workflow. It isn't not supported, it just isn't actively intended either.
This site can help with general editor tools development and styling
https://www.foundations.unity.com/
Dude, this is so helpful! Thank you! For the links and info!
#📱┃mobile is probably what you want. This channel is for discussion around creating custom editor windows, inspectors, and that sort of thing. You can look at the description of a channel if you are not sure what it is about! 🙂
You're very welcome! 😄
Anybody know why my Vector2 is wrapping over two lines when I show it in my custom property drawer like so:
EditorGUI.PropertyField(position, property);
Image 1 is what it looks like when it has enough space, Image 2 is what happens when the horizontal space gets too small. This doesn't happen without my CustomDrawer.
thks
that's helpful, but I'm not sure how to use that that to fix my problem. Is there a way to "check" how much height a propertyField will need? Right now GetPropertyHeight() always returns 18. I guess I could check if my property is Vector3, Vector2, etc. and if it's not wide mode I increase it to 36.
or is it possible to retrieve the custom drawer and then read the PropertyHeight from there?
I want to run a script on project load and then never have it active again, but I am not sure if an attribute or something as I tried InitializeOnLoad but happens every time script updated
You can maybe use EditorPrefs and set a bool or something there to mark it as executed (and check that bool each time before you execute stuff)
Oh... or create a file marker... I don't remember if there's anything like EditorPrefs that's per project 🤔 (Of course you can always create a file with whatever data)
You create a ScriptableSingleton that is saved to disk, and just set a bool in it once it runs.
You wouldn't want to use EditorPrefs in this case since those are 'global' to the users computer, not per-project.
yeah, that's why I wrote he other line, I guess I should've explained more 😄 👍
ok, odd there is not an event for like when a project has loaded. I really just want to trigger the C# project to open at start but if it repeats it takes focus off Unity!!
Is it just once for that editor session or you only want it to run once ever?
No there is not a specific event, but it should not be an issue
[InitializeOnLoad]
class MyStartupEvent
{
static MyStartupEvent()
{
// If it has already run, in this project, we stop and don't do anything.
if (MySingleton.Instance.HasRun)
return;
// Register that the startup event has now run one time.
MySingleton.Instance.HasRun = true;
// Your code here...
}
}
You can look at the docs for how to do the ScriptableSingleton, they have a great example
Or if it's just for this instance/session of the editor, use SessionState
but if a scriptable singleton is it not left in that state for next time you open the project?
It is if it is saved to disk. The docs have a good example of this as well 🙂
yeah SessionState does seem a way to keep it in 1 class...
SessionState is reset when Unity closes, meaning it dos not keep its state between sessions
yep i wanted that - now it loads C# project once on each Unity open
How do I make my property drawer for my attribute work when in a nested field like how the range attribute does? OnGUI is not even called when it's a nested field.
Wdym
this method does not run:
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (attribute is ShowIfAttribute showIfAttribute && showIfAttribute.EvaluateCondition(property))
{
EditorGUI.PropertyField(position, property, label, property.isExpanded);
}
}
Under this condition:
[Serializable]
public class Foo
{
// attribute applied to this field does not have OnGUI called for its property drawer
public int a;
}
public class Bar : MonoBehaviour
{
public Foo test;
}
I don't see your attribute there at all?
I didn't think that my example with my comment that I wrote inside of discord would need to show the attribute being applied
imagine it is there
What about the rest of your property drawer?
Hi, i want to ask whether anyone know how to hide the size element (number on the right) on the element that unity draws by default when putting a list in PropertyField(), currently using IMGUI to make my first editor extension and id like to somehow disable that part of the editor
You can't with IMGUI when using a ProeprtyField. If you really wanted to, you could draw a rect over it that is the same color of the background. And Use() any pointer events. But you could still tab to it. Doesn't really seem like it is worth the effort to me
You could also use a ReorderableList instead of PropertyField, but you would have to setup a good chunk of the logic yourself
I see, thanks for the help, i think i will look back on this issue later and finish making it work for now while ignoring the array size.
my property drawer is only OnGUI and GetHeight. GetHeight is called. Not OnGUI.
How can I include offline documentation in .html format in my package so UPM can register it?
Manual states that you can either include documentationURL in package.json to point to a webside or put offline documentation with this folder structure:
└── Documentation~
└── <package-name>.md
but documentationUrl doesnt seem to work with path to .html file relative to a package (at least as far as I tested) and including it in Documentation~ folder also doesnt work as it is not a markdown.
I have my full documentation configured to be generated in html format and I want to ship it with the package, but UPM seems a bit stubborn about it.
Maybe ShowIfAttribute is not derived from PropertyAttribute? IIRC there is a special attribute type you have to derive from if you want to use custom property drawers for attributes
I assume you expanded foo in foldout, child properties code is not run if foldout is not expanded.
Yea its expanded and ShotIfAttribute does extend ProperyAttribute and the height method is properly called just not the OnGUI method
That's interesting, it should definitely work by default.
Maybe there is some custom editor code somewhere that hooked over drawing Foo, and is doing some simulation of default Unity editor behavior? You can check the stack trace of who is calling into GetPropertyHeight
I'm trying to create a prefab variant from a blend file in editor code. It works, but it puts an instance into the current scene. I tried creating a preview scene and passing that to InstantiatePrefab but it still adds it to the current scene.
Can you share some code?
Typical. I edit the code to get a sample ready, and suddenly it works
You're welcome? 😛
Yo, anyone who uses VS Code with Git. Can ya'll tell me why I'm getting this error? For some reason, when I try to commit, it's taking all of my computer's files even though. I'm using a specific folder for my app
You probably need a .gitignore: https://github.com/github/gitignore/blob/main/Unity.gitignore
Yup, figured out the issue. Thanks
Anyone know how the heck to add settings to the build profile section?
Are they not just scriptable objects?
can unitask work on update/fixedupdate/lateupdate ?
i know it can work on void start
You don't mean in Edit mode, right? 😅 If so, then yes, it has a... something... it's in the docs though 😅
await UniTask.Yield(PlayerLoopTiming.FixedUpdate)
yea all of the delay functions they provide can change the timing mode.
Outside of play mode it will use EditorApplication update
Anyone here with knowledge about Handles, EditorWindow and color?
am having a problem with drawing, in the code I use the same Color for the DrawAAConvexPolygon() and DrawSolidArc(), yet they differ in color.
Handles.color = new Color(color.r, color.g, color.b, color.a * color.a); // even without the a times a it bugs
Handles.DrawSolidArc(pointA, Vector3.forward, startDir, 180, radius);
Handles.DrawSolidArc(pointB, Vector3.forward, -startDir, 180, radius);
Handles.color = new Color(color.r, color.g, color.b, color.a);
Handles.DrawAAConvexPolygon(
new Vector3(pointA.x, pointA.y, 0) + startDir * radius,
new Vector3(pointA.x, pointA.y, 0) + startDirR * radius,
new Vector3(pointB.x, pointB.y, 0) + startDirR * radius,
new Vector3(pointB.x, pointB.y, 0) + startDir * radius
);
Well for one you're giving different alphas
yeah, but even when i use the normal, it also has differant colors
I'm not sure what I'm supposed to be looking at in the screenshot
sorry, the cap at the end should be supposed to be the same color as the rest of the body
should a pill shape same color and outline that has its alpha set to 1
this is whitout the different alphas,
you want something like this?
Oh nice thank you, have already fixed the problem. How did you do it?
for this i just made a visual element with border radii
and drew an outline around it
you kinda inspired me. i gotta make a thing for this contract soon so i think i'm gonna make an editor tool for it as a personal package as a bonus
inspector radar charts for configuration
They are but they are sealed.
i did the thing guys. took me all day but aint she purdy
has configurable named attributes, independent min/max range values, and you can edit the underlying data with the graph itself
Greetings!
I am trying to create a quick inline-editor for scriptable objects using ui-toolkit and i have encountered a scenario where this inline-editor would recursively draw itself to oblivion, causing the engine to stall.
Is there any good way to make it not redraw itself should it encounter a self-reference?
Maybe a hashset could work here
I have tried something similar, but the issue is:
Due to the nature of ui toolkit having to create things once, whenever the user assigns a scriptable object that self references itself, it would somehow need to check and update the hashset and conversly create an object field, not a property field.
The InspectElement component doesnt have this check and i am not sure how to create a custom one that updates itself during the runtime
Im developing a custom package and there is one thing I cant seem to grasp...
- If package wants to load some assets that come with it, it can use a virtual path "Packages/<package-name>/path"
- In order for this to work package needs to be registered by UPM and cant be inside Assets folder
- As I develop the package I need to have access to this functionality, so I store it somewhere else on disk and import it with UPM
- But now I cant upload it to a pending page on asset store nor I can export it to a .unitypackage, as its not in Assets folder.
I feel like there is some crucial step in this process that im missing....
My package uses virtual paths to access relative assets so I cant develop it directly in Assets folder, but it needs to be in Assets folder for it to be exported/uploaded.
How do other developers handle this process?
In order for this to work package needs to be registered by UPM and cant be inside Assets folder
You can just put the package in the packages folder in your project. It is called a local package 🙂
The package manager will automatically notice it
Yeah I bet there is number of options where I can put it, the point is that it cant be in Assets, yet it needs to be in Assets :/
unless you mean putting it in Assets/Packages?
The newest version of the asset publisher tool supports packages.
Nope I mean you literally put it in Packages as if it were Assets. So your package path would be something like YourProject/Packages/com.your.package
oh rly? Thats an info giving some hope!
although it should be communicated more clearly then, because for me it states that is must be in Assets foldet and my package is in MyPtoject/LocalPackages/com.me.package with a relative path given in manifest.json for UPM
To embed a new package, create your new package content inside a folder under the Packages folder. For more information, follow the instructions for creating your own custom package.
There it is! I knew there is a simple widely known step that I missed somehow! XD Now I know, thanks a lot!
You're welcome haha. Once you move it there, you can just use the Asset Store Publisher Tools to upload it as a package, so when it is installed it will be as a embed package.
I scanned through this part of docs briefly, I guess I ignored that part as my package does not have dependencies so it must not be info for me XD
Haha
it send me through a deep rabbit hole of understanding the difference between .unitypackage and an actual "Package" (which apparently is not the same) and finding some concept of "Hybrid Pacakge" or something... story concludes that Asset Store Uploader hides this functionality as experimental feature you need to activate with a define symbol ehhhh
a .unitypackage is just a .zip file basically that Unity has built in support for extracting and putting the assets in the project.
A UPM Package is structure for handling collections of assets and scripts that can have versions and dependencies.
A 'hybrid package' is just a UPM Package that has been put in a .unitypackage so when the .unitypackage is added to the project, the UPM Package is embeded inside of the Packages folder instead of being added to the Assets folder
How can I open a specific folder in the project window? All I found was theres the ping object method which can highlight an object, but I want it to enter the specific folder
Only way is via reflection iirc
yeap, for some odd reason project window is internal :/