#↕️┃editor-extensions
1 messages · Page 2 of 1
That is because your scripts are not in an Editor folder
I have a Prefab Base, with BaseComponent.cs attached. I want to also have a Prefab Variant with SubclassComponent.cs attached. Is there a way to do that without breaking the connection? In other words, any way to avoid this outcome on the prefab variant?
You want to replace the BaseComponent with a SubclassComponent? No that is not possible as they would be two different instances
yeah, looks like you're right about that: https://forum.unity.com/threads/prefab-variant-with-derived-class.661873/\
kind of a bummer, since it almost works if you switch to debug view and swap the components.
no idea if right section, but me and my teammates developed this tool for prefab-making of player enemies 2000 BC
question... any way to force point filter (nearest neighbor scaling) to that preview?
its a 16px
so it becomes ugly
Probably gotta pass a material to the method
I do not know in which channel I can ask exactly this question, so I will leave it here...
_ _
Due to the URP (Universal Render Pipeline) package, the window is not cleared at the beginning of the next frame from the previous render.
Full question with description and video of the problem:
https://docs.google.com/document/d/15Xj76NFJL_dKxzCo-UuFrc245kqE7vROYuaa5gVW12I/edit?usp=sharing
Due to the URP (Universal Render Pipeline) package, the window is not cleared at the beginning of the next frame from the previous render. The link to the video demonstrating the problem will be at the end. This is definitely because of the URP, because when I deleted it and build the game, the...
The question with a full description of the problem is very big, so I made a text document in Google Drive.
If I asked a question in the wrong channel, please let me know.
If necessary, I can send my full project via Google Drive. It weighs less than a gigabyte (maybe even less than 500 megabytes).
Check your cameras clear mode
Idk how urp works but in normal unity it's just in the camera inspector
Shieeet , Editor scripting is funnn .. it's like being in WPF all over again
UItk is fun, imgui isn't lol
UITK is fun until you go off the beaten path and then it's like "oh, abstract internal method? fucka-you"
the api keeps getting better ♥️ ... although it still feels like not in production-ready state just yet
wait you can use UITK in UnityEditor scripting ?
I'm using an Editor.OnPreviewGUI to display a model. The docs say the params of OnPreviewGUI are r - the rect for the preview, and background - a background image by way of a GUIStyle.
My problem is that no matter how I pass an image into the background parameter the background remains grey. I've tried creating a 1,1 texture and setting its pixel to a colour, I've tried passing in a texture, I've tried setting each background in onActive, onFocused, onHover, onNormal, normal to no avail.
I've seen other people override the OnPreviewGUI method and create custom previews to do this, but I've also definitely seen just the standard overload work.
I've just come to the realisation that all of the above is true in any SRP. But not using legacy. Works perfectly using legacy.
lol.. where have you been dude! .. yeah, that's the recommended way of making customEditor in 2022 and above bcos uitk will be the default api used for editor tooling, including default inspector
Yeah fr! wow.. the docs on unity kinda doesn't mention much, or I've missed it . EditorScripting was something I never really got totally interested until recently hehe
well shit.. time to porting this newly made tool from today I guess 😣
yeah, it's not worth the time to use imgui for whatever reason... unless you're maintaining old games that tied to certain 3rd party library that can't used with latest Unity version
Tho, others may have their own opinion regarding this
Every now and then I still see job vacancies for making editor tooling with imgui, so that's another reason why you'd still want to use it I guess
Probably because there's a shit load of stuff that is still undocumented, works poorly with UITK, or you literally have to cram custom shit down its throat to get it to work. There's a load of editor controls that still don't exist easily in UITK, and while the IMGUI container allows you to add custom IMGUI stuff it's only just barely functional.
I saw couple of Japanese gamedev job ads for this... and I've no idea why even Japanese still using imgui nowadays
And quick, easy, feature bare tools you need to make in a day are still much quicker with imgui.
Currently my problem with UITK is that the entire editor goes to 1FPS whenever I'm editing a value in the inspector.
It's been at the top of the docs for custom editors and property drawers, even before the editor actually used UITK by default. They had the docs surfacing it to beginners before it was even reasonably workable!
oh god it's been so long since I touched editor UI stuff. Is UITK the one that uses uss/xml?
Yes ("UXML")
pronounced ucksemell
There was something I wanted to make with that actually. Following the manual page on injecting into project settings
hey, hope everyone is doing great, i have to make tools in my editor and i wanted to know what is the depth of this extension, like how far can go in it and make stuff, any references or video tutorial would help thanks a lot
This field has a custom attribute on it. But the OnGUI of that attribute doesn't get called untill I add entries to the list. How can I edit the Rigidbodies field even if the list is empty?
You can't make propertydrawers for arrays
You can make a custom editor for the whole component if that helps
i need to grab an imported gameobject (mesh) and set its import settings though a menu action
what i need speifically is a cast/conversion of the gameobject from asset db to importer type
ModelImporter importer = AssetImporter.GetAtPath(path) as ModelImporter;
@waxen sandal ok, thanks for the answer!
oof! For some reason the docs wasn’t showing it . Thanks!
I’m gonna study it up today. I just read the XML part ah so I did see it somewhere. Nice, I’m used xaml from Maui etc. shouldn’t be too distant
when i do this, after i rename the asset it creates it loses the sprite data for some reason
also happens after entering play mode
why not assign the sprite before you use CreateAsset?
oh yea i guess you can do that
Otherwise you'll have to dirty the asset properly using the instructions pinned to the channel <#↕️┃editor-extensions message>
Hi Team! im working on an Editor script to display positional vectors from structs in a list attached to an object. Im struggling to find how to get the index of the selected element so I can only display the 'highlighted' element
e.g. Element 1 is highlighted right now. I want to get that index.
From what I've read, it doesn't exist - if I want that I need to rebuild the entire inspector element and name the elements in the process, then I can access the assigned names.
it can be done, but I can't recommend you if it's imgui, I've been away from imgui for the longest time now 🙂
But if it's uitk, man, you can just blink your eyes, then poof! .. done..
All jokes aside, in uitk you can use ListView for this, and get the selected element/index via listView.selectedItem or listView.selectedIndex
im using 2020.3 which i think doesnt have uitk? - im making progressing doing the above, creating the list myself with names for the objects - but of a pain.
pretty sure it's available, but you don't have to use uitk, it was just my suggestion.. or just wait until other imgui masters that are knowledgeable answer your question
For IMGUI you have to use ReorderableList, which is a bunch of work, but makes provides the selected index fairly easily.
Ahh yeah, cheers. Ive settled on just having a seperate list drawn afterwords where i can select a named element and have that highlighted. a little messy but saves me rebuilding the serialised list just to be able to have an onselect event
What's the best way of handling user input in the editor?
Where should I save static variables from the editor? Just in a static class doesn't seem to survive me reloading my scene.
Is this a good use for Scriptable Objects? Or something else perhaps
For simple stuff you can use SessionState but if you have a lot or more complex stuff you can use ScriptableSingleton (The docs for both have examples on how to use them)
Sorry if I'm asking this question wrong, but when working on a custom serializer, how do I get more fields to serialize under a list item?
What do you mean?
I'm trying to custom serialize a list of an abstract class
I know I need to use ISerializeCallbackReceiever, and I understand the example they give. I've gotten to be able to make a list of strings of my abstract class name but don't know how to add the classes properties underneath it
[SerializeReference] will serialize polymorphic fields
SerializeReference doesn't seem to completely serialize the list though :/
It just says "Element 0" for example.
That is because it serializes it as a reference, and not a value.
I'm trying to get the whole list editable
By default everything is serialized as a value which means they are automatically assigned a value.
But when serialized by reference, that means that they can references each other along with being null. So they default to being null.
That is why it says "Element 0". It is null
Does that makes sense @subtle axle?
Yeah, but I also can't "Drag and drop" a class to make an instance of it. I have this solved for one of my lists by creating a button and a dropdown to instance one of the classes in a list
But how can I add to the list, and choose which class to add to it so it doesn't do that?
Yeah, that is a limitation. There is no in editor support for assigning the type. You will need to either create a custom property drawer for the base type. Or get one of the several extensions that are on github that automatically add a dropdown field for selecting the type.
I have Odin. Which works great. But I am trying to turn this into an asset so trying to code this bad boy myself.
It seems like you should be able to drag a script from the editor onto the list to do that :/ or something along those lines.
How can I hijack the "+" button to create a property drawer?
Yeah that would makes sense and be nice
'Cant'
I would just create a property drawer for the base abstract class that has a dropdown for selecting the type
So what are my options? Like I said, I've done this for a list that lives on my item, but this other list I'm trying to do it with is a few variables deep LOL
Would that make it so when you add to the list it shows that property drawer?
Once added yeah
Okay so if on "Game Item A" I have a list of "Abstract Class B", and Classes C and D are children of that class, I'd add a property drawer to "Abstract Class B", then when I add a new item to "Game Item A" it'd give the ability to add Classes C or D?
Am I understanding that correctly?
@subtle axle super scuffed semi-pseudo code
[CustomPropertyDrawer(typeof(MyClass))]
class MyClassPropertyDrawer :PropertyDrawer
{
override void OnPropertyGUI(SP property, Rect rect, GUILabel label)
{
// We get a rect for the dropdown field that is a single line height.
Rect dropdownRect = rect;
dropdownRect.height = singleLineHeight;
// Draw a button that looks like a dropdown.
if (EditorGUI.DropdownButton(dropdownRect, "Type"))
{
// Get all the types that derive from the field type of the property.
// This will be "MyClass". Instead of "property.managedReferenceType", you could also do "typeof(MyType)". Might actually be better tbh.
var types = TypeCache.GetDerivedTypes(property.managedReferenceType);
// We create a menu, and add an item for each type we could create.
GenericMenu menu = new GenericMenu();
foreach(var type in types)
{
// NOTE: you will want to do a check to see if the type is not abstract before adding the menu item for it.
// We create a menu itme, and if it is selected we assing the "managedReferenceValue" to a new instance of the type using "Activator.CreateInstance(..)".
menu.AddItem(type.Name, obj => property.managedReferenceValue = Activator.CreateInstance((Type)obj), type);
}
menu.ShowDropdown(dropdownRect);
}
Rect fieldRect = rect;
fieldRect.y += 21;
// Calling PropertyField for the property will (if memory serves) call the base drawer as if it was not drawn with this custom property drawer. This results in the dropdown field and then the property drawing normally below it.
EditorGUI.PropertyField(fieldRect, property);
}
}
But that is basically what you would do
Thanks, I'll have to take a look at that. At first glance that's a bit over my head, but thank you!
It looks like that ovverrides the base PropertyDrawer, is that correct? Is this just adding functionality to it?
It is a custom property drawer for the base class type
Oh, I just TOTALLY missed that top line. Thanks
That is because I TOTALLY just added it 😛
Haha, okay, it's amazing what that one like did to jog my memory. So this is similar to adding a custom inspector window.
Okay so I know you meant it as psuedocode and didn't test. I'm getting errors on the types "SP" and "GUILabel", usually it gives me the ability to add the "Using X", but I'm not getting that this time.
Oh yeah, you are going to get a ton of errors. I used short hand for stuff and don't remember some names exactly.
Nah you're fine I can play around with it
Like "SP" is SerializedProperty
Do you know, is OnPropertyGUI the right method? Can't find the API reference for it
If I could find the method, I could find the type for example
Just type in "override" and hit space and the IDE should come up with a list of methods you can override
it should be something close to that
Create Property GUI? Or OnGUI?
Thank you
What will the singleLineHeight be?
Sorry I'm just kinda going line by line...Appreciate your help on this. What should I reaplce "Type" with?
EditorGUIUtility.singleLineHeight
System.Type
Oh you mean "Type"
That is just what text the dropdown button should display
It can be anything
Thanks so much. The last error I'm getting is when I try to use the dropdown (which works btw to get the right types)
InvalidOperationException: Attempting to set the managed reference value on a SerializedProperty that is set to a 'PPtr<$ActionResponse>'
ActionResponse is the "Myclass"
the error is on that menu.additem line
I think I got that error taken care of. The dropdown works, but it won't actually select anything :/
I have custom inspector and i'm using serializedObject to test for multi-object editing. It works but when I enter playmode and then leave playmode and have a gameobject with my component with the custom inspector (and then try saving) I get this error SerializedObjectNotCreatableException: Object at index 0 is null. I've google and googled and can't find a solution. What I find on google is people saying it's a "2nd" inspector causing it but I have no 2nd one open. Restarting unity doesn't work either.
Can I get the orientation of the preview camera used in Editor.OnInteractivePreviewGUI()? I'd like to be able to use this preview to orient an object and then take a snapshot of it
Hey, any idea why this line "property.managedReferenceValue = Activator.CreateInstance((Type)obj);" in a custom drawer wouldn't actually create a new instance of type obj? There's no error being thrown but when I select anything in the dropdown, nothing happens.
is there ANY way of getting the active path in the Project window?
A place to start. https://forum.unity.com/threads/custom-context-menu-for-project-view.127021/ You probably should be able to pull the selected object's path, at least a relative one
Here I have a custom property drawer. I'm trying to make it so a previously unserializable class can become serializable. The dropdown works, but when I actually choose one of the dropdown items nothing happens. There's no error though.
any ideas how can i add an item in this list with a script ?
tried searching ProjectSettings folder but doesn't seem like the Script Execution Order data is being stored there
i think i found it :
UnityEditor.MonoImporter.SetExecutionOrder( UnityEditor.MonoScript.FromMonoBehaviour(_instance), 0 );
I am reaaaalllly struggling with this :/ Anybody willing to help me out? Been playing around with this for over an hour with no success.
You mean it is not printing out a message?
@gloomy chasm So the dropdown shows all of my ActionResponses. But when I click a dropdown item, nothing (seemingly) happens in the inspector. The debug log shows me that indeed the managedreferencevalue is changing, but in the inspector it still just says "Element x"
In the Debug.Log messages, is the value getting assigned? If so try putting a debug.log in the OnGUI method as well and print the value of the property
Yes, it is! I'll do that and let you know the result.
@gloomy chasm So within that callback function, it's working. Within the OnGUI, it's null.
by working, I mean its set. It's not working, per se
In the callback apply modified properties
Is that a method of the property?
property.serializedObject.ApplyModifiedProperties()
Still null 😦
Where did you put it?
`
void CreateActionResponse(object obj, SerializedProperty property)
{
Debug.Log(property.managedReferenceValue);
Debug.Log("You have selected " + obj);
property.managedReferenceValue = Activator.CreateInstance((Type)obj);
Debug.Log(property.managedReferenceValue);
property.serializedObject.ApplyModifiedProperties();
}
`
Hey I'm sorry
It did overwrite
I think something happened when I saved
Okay, so it is now saving the variable, but nothing is happening within the inspector.
It's definitely doing something now. It added a dropdown arrow to the element, but still doesn't seem to quite be serializing it.
Sorry, I'm really not trying to keep bumping but I want this info to be as up-to-date as possible if people do decide to help. Messing around with [Serializefield] and reference, I got it so it'll change the list name to be the correct actionresponse. My biggest problem is no children properties of that class show up in the inspector.
Can you show a screenshot of what it looks like in the inspector?
Sure!
@gloomy chasm I had it at one point saying the name of the ActionResponse instead of Element but somehow I screwed that up in messing with [SerializeField] and [SerializeReference]
Looks like you need to override the PropertyHeight method
And have it return return EditorGUI.GetPropertyHeight(property) + EditorGUIUtility.singleLineHeight;
Okay! Here, I'm going to DM you some of the other classes at play if that'd be helpful
Override propertyheight in that drawer class?
Yeah
Hm. That definitely adds more space! So thanks for that, but it's still blank :/
if you're drawing a PropertyField, pass true to the includeChildren argument
you will need to do the same for GetPropertyHeight
Why don't I get a slider?
have you tried making it significantly larger?
it works
Sliders fallback to an input field if there's not enough space
Can't really find the perfect channel to ask this question, but I think it is most relevant to this one. Say I'm making an asset for the asset store, should I include preview packages as dependencies? Or should I try to avoid that as much as possible. I'm thinking of using jobs and boost for multithreading, but I am worried people won't want to use the asset because of the dependencies.
Any idea why I can only drag one GUI.Window if I have multiple open? They all have separate IDs...
All I'm doing is calling GUI.DragWindow at the very end off my GUI.Window draw callback
One window has ID 0 and the other one has ID 3852
hey guys, i am making some tools in the editor and i have a dropdown of a Enum in the inspector right now and when the dev selects a enum i want more options to appear in the inspector for further configuration. how can i do that?
Custom editor that checks the value of the property and then draws different fields based on that
How do I make these expandable groups like in the URP render asset?
is it a built in feature or do i have to make it myself?
Foldout?
how do i get these?
oh i thought it was an extension for visual code so i asked here
No. Its just a feature of visual studio (or most other IDE's) known as Intellisense. 👍
It should just work. Yeah. You might need to re-start your Visual Studio not 100% sure tho.
What does SerializedProperty.Update exactly do?
There is such an explanation
Update = set serialized object stream now based on what is in the actual class
ApplyModifiedProperties = take what is in the object stream and put it in the class
But it is pretty unclear to me
Like what is the actual class
and what is the object stream
I have a list inside a struct. Am making a custom property drawer for the struct. How do I find out which exact element of the list was changed, if any?
Why do I get this?
I got it with this code https://pastebin.com/3pzqz6Za
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.
Because you are adding the height to the x position and not the y position 😛
Jez, thanks
Changed it, now the button is still over the component
Override the GetPropertyHeight method in the PropertyDrawer
... like normal...? public override float GetPropertyHeight(..) {.. }
No, it is used by the inspector when drawing the property to know how much space it takes up
Thus the name, Get Property Height
Gets the height of the property
Well, now when I collapse and expand the list the the button adjusts its position only when I hover some other element
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 advice?
(the 2 last ones are with correct placement)
GetPropertyHeight is run first before OnGUI so when GetPropertyHeight is run, the height fields have not be initialized yet.
So what do I do?
Gonna sleep btw
You get the heights in the GetPropertyHeight method instead. Or simply use EditorGUIUtility.singleLineHeight and EditorGUIUtility.standardVerticalSpacing
Seems like you misunderstood me. The bug does not happen when you simply open the Inspector. It happens only when I collapse and expand the list one after the other. I followed your first suggestion but it didn't help.
I followed your first suggestion but it didn't help.
Am already doing it but it didn't change anything
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.
No you're not
Don't just find them, use them
What's happening, it's drawing and calculating height, caching that height
It stops drawing but is still asked for the height, the cache is never updated and thus it uses the height from the last draw
At least, that's what I'm guessing
But it recalculates every time
Every OnGUI it does, but OnGUI isn't called when it's not drawing
So remove that field on your class and make it a local field
Yeah there's no call to GetPropertyHeight for those relative properties here
Now I'm using this code but getting this exception on line with GetPropertyHeight
So method stops and the inspector isn't drawn at all
Now I have this code which works but with bad results
Okay solved it myself
Thank you all
I don't think this belongs here, but is there any Editor extension that adds the capability of the inspector to change tuple and struct values of a MonoBehaviour instance?
If the struct has a [Serializable] attribute it should already be able to be edited in the inspector
Ah, thank you
Hey, small yet substantial question or rather questions:
- Do you know an asset that would allow me to append a build version to my project based of git tags
- If not, do any of you know how to sneak a string or two into build in a way that won't disrupt the project itself?
One approach for the latter is just adding a txt next to the exe (in the post build callback) and working with that, but it feels... ugly
like a command line argument ?
Command line argument? No?
Basically I want to have something like that in my game but nicely automated based of git
you can run unity with command line (ex: "C:\Program Files (x86)\Unity\Editor\Unity.exe" -projectPath "C:\Projects\svn_repos")
Nope, not at all what I need
the version is given by the build property right ?
What build property you have in mind?
Yeah, considered using that as a way to keep the version
But it has the issue of adding changes to git when I build a game
then i'm not sure to understand your purpose ^^
Okay, let's say I have a git like so:
A - B - C - D
and tag v0.3.5 on the commit B
Now, D is two commits ahead, so when I build. I will get a version like:
v0.3.5.2-commithash
```added to the build
Without altering the project settings nor files
I then add a commit E, with a tag v0.4.0 because I've added some feature
Now, when I build I will get a version like
v0.4.0.0
Which I will then be able to get in my code and display in UI
While I editor I can just ask the git for that number, in build I have to somehow inject it in
Altering Application.version will however add a change to git, which I don't want as that will be a tad messy
i get you
Unless I can, I don't know, set the .version and then set it back so it's not visible in the repo?
But that might cause troubles on something like android which requires sematic versioning (I might be wrong on that) so it will be angry that Application.version has letter and stuff
i think you have to create a custom BuildPipeline where you manage to retrieve your git versions, then you are right you could have issue with mobile deployment (i'm not sure but propably). So better to override the Application.version. If this build Buildpipeline is integrated in a CI pipeline, it will be called by CLI or watever. So it will build your project without saving anything, and without changing the source files at the end
Well, but changing .version like that will cause commits on git if I build from editor, which I do
then build with CLI :p
you could have issue with mobile deployment (i'm not sure but propably). So better to override the Application.version
Well, I am more worried that overriding it will cause issues on mobile
But that's another step to my build I need to remember
Application.version is read only...
What?
Ah right, PlayerSettings.bundleVersion
Which apparently unlike the docs say, is not for Android and iOS only
I might try it later
@dreamy lava// Yeah, android allows only numbers and dots in the bundle version
**Conceptual question **: Dropping the txt version of this question around Editor Tools development so you can just expand it in the discord. Didn't want to post the massive text wall.
is it possible to replace the flag name field with a drop down in a custom editor? Ive tried a property drawer but i dont know how i can maintain the rest of the fields intact, and only modify flag name. (i need to get the array for the drop down from flags data)
There are a couple of ways to do that. You could add a component to the GO and treat it as a singleton. Another way is to use the new GlobalObjectID struct to reference the GO when it is created.
You could make it a conditional field that's dependent on the flags data being set. I'd have to look into how to pass the selection's array into it.
The 'correct' way to do this as is, is to simple create the property drawer for the whole class. It is simple (only 4 fields) so it would be trivial to manually recreate.
Also thanks @gloomy chasm, I'll look into this ObjectID struct. The question actually arose because I suppose I was trying to pattern something like a Singleton. Which I'm not against, but personally I'm trying to become less dependent on them to grow my skill set a bit
Something to consider is whether the "Flag Name" would be better as a struct/class which can hold some ID to the name instead of a string so if you change the string name, the Flag Name would also update the visually and also not break.
I get that, however remember a singleton is just a pattern. It has it uses. If you want to there to be only a single instance of something, you probably want a singleton. No sense trying to reinvent the wheel just to avoid a perfectly fine pattern.
Of course there are times where it is better not to use them. Like with anything, moderation is key 🙂
Hahaha indeed. Appreciate the detail/advice bud. Will post a git when I solve this and ping ya if you're interested. Feels like I'm actually on the verge of finally making something remotely useful
Nice! Good luck! 😄
I'm trying to use github for unity https://github.com/github-for-unity/Unity/blob/master/docs/using/getting-started.md
But I'm getting the above error when I try to sign in with your browser
I just want to put the project under source control in git.
Okay big mistake that project is 5 years sitting idle. Ignore me. I'll try to find some guide on how I can add a project to source control.
Don't use that plugin, it hasn't been updated in forever. Just use an external git GUI like Fork, SourceTree, GitKraken, GitHub Desktop, etc
Yes I have a client I'm familiar with I was hoping to have a default gitignore or something.
nice thanks
Hello everybody, is it possible that the Script of a ScriptableSingleton is already an instance of ScriptableSingleton? When i create ScriptableSingleton Object it seems this is another instance of the ScriptableSingleton. I am confused about ScriptableSingleton, getting an Error when clicking on the ScriptableSingleton Object -> ScriptableSingleton already exists. Did you query the singleton in a constructor?
i tried, but i dont know how can i contain the fields like "Element 0" does
smart idea, ty
I got a property drawer that changes in size depending on an enum field. How would I go about setting the property height to the right value?
I got it working but now my input fields are thicc
You just override the float GetPropertyHeight(..) method.
The rect that is given in OnGUI is the full size of the property area.
ok thanks :)
Whats the best way to resize a Texture2D so it fills the entire of a
GUILayout.Box? I know GUI.DrawTexture has a ScaleMode.ScaleToFit property, is there anything similar for GUILayout.Box?
is there any way to get the type T in a custom property drawer for a generic class?
for example
something like this although obviously that doesnt work
or atleast the name of the T generic type
what i want is a field where i can do something like AnyInstanceOf<AttackPattern>
where AttackPattern is an abstract class
but i get a choice to put anything that derives from it in that field
i know how to do that just thought it might be possible with a generic so i dont have to duplicate code since i will use this for a few different things
fieldInfo.GetGenericArguments()[0]
fieldInfo.FieldType.GetGenericArguments()[0] but yeah thats it thanks
i cant seem to be able to access this though
FindPropertyRelative("value") returns null
oh nevermind
forgot SerializeField
well in mycase SerializeReference
ok this is beautiful
made it better with an attribute instead
one thing thats annoying me is that using GUILayoutUtility.LabelWidth makes this 2 pixels too big
Then just move it over by 2 pixels 😛
yea
just find it weird
although i guess its intended that you use a padding of 2 pixels maybe
hi can anyone help me with this editor problem that I am facing, It is really hard for me to explain as well but I will try my best, I have a class "Action" which has different types as well, For example, Action A, Action B, Action C. When a certain action is selected from the enum dropdown it shows the properties of that action in the inspector. for example if Action A is selected, it will show properties relevent to
Action A
And i want a list of actions on a scriptable object lets say i have a list, which has 10 actions on it of different types
Action A, Action B ...... and so on
these can repeat as well there can be 5 action A in one list and 3 action B
and all their specfic properties are visible as well
and these all execute in a sequence but this part i can do i just want to know how do i get a list of Actions and select an action type in inspector and show relevent properties and edit them in editor
sort of like this but the properties draws after a type is selected in the inspector and i can have a list of these and the properties draws in the list too
make it not an enum
but a derived class instead
have class Action
and then ActionA : Action
then have a field of type Action
that can take any of them
and put their respective properties into fhe class definition
👆 also, SerializedReference sounds perfect for this 🙂
wrote a blog post about this, feel free to use the code. I also explain how it works in case you want to modify it a bit
While my problem is not really an "editor-extension" issue, it is quite related to the editor, so I thought maybe you could give me a hand with it. I have this error popping up in the console during development.
The class is really so simple... I have no idea how could it be possible to give any kind of issue...
Show the captain type
It is an ScriptableObject
is there a way to reload all assets for a specific scriptedImporter?
ex: I have a custom ScriptedImporter for "data" files, and I want it to run for all .data files when I click a button in the editor.
i would try to find them with
AssetDatabase.FindAssets
and them one by one run
AssetDatabase.ImportAsset
for each of them
can't search by extensions 😦
I'm trying two options: 1) settings labels on first import so I can use FindAssets. 2) keeping an up-to-date list of those assets in my project settings provider via an AssetsPostProcessor
how can i add a tooltip to a custom variable like in this editor? since this isnt working ofc
I think
EditorGUILayout.FloatField(new GUIContent("Animation Length", "Seconds to finish"), script.GetAnimLength()); should work
EditorGUILayout.PropertyField(vector2) doesn't show up for me in a custom editor
the vector2 is a public property that I get through FindProperty
it also shows up correctly if I enable the base.OnInspectorGUI
EDIT: resolved, I was looking for an inexistent property
I hope this is the correct channel
Hey guys does anyone know how I can color the background so whenever a game runs its red / whatever color in the bg
Edit / Preferences / Colors / Playmode tint
Hey all, I have a pretty specific question about a custom property drawer. Unity's Animation Curve property drawer opens the Curve Editor window when you click on the property drawer, and when you edit the curve within that curve editor window, it updates the serialized AnimationCurve that is being drawn by the property drawer. I am trying to replicate that process. Here's what's done already.
- I made a custom editor window for a class I created.
- I've started writing a custom property drawer for that class. The property drawer, like the AnimationCurve editor, just draws some OpenGL stuff into a rect in the inspector. When the rect is clicked, it opens the Editor Window I created in step 1.
However, because the type sent to the property drawer is serialized, it sends a copy of the data to the window, not a reference, and so editing the type in the window won't be actually edit the actual field on the Monobehavior.
The data being edited in the window is is essentially a List<Keyframe>. How do I set the values of this this from the property drawer as the editor window updates them?
Is there a dirty way to make a table?
In what?
serializedObject.FindProperty("PathTypeSelection").intValue = pathTypeSelection;
serializedObject.ApplyModifiedProperties();
this causes my Inspector to close whenever I change the any property valuepathTypeSelection value
can it not do that
actually it's happening without that FindProperty
OK, I've restarted Unity and it's fixed 
Hello guys, is there a way to separate big numbers with a coma or smth like this ? Maybe with an attribute ?
I think the only way to do that would be to make it a text field
I see, thx for your answer
Best place to put a project-wide and scene-wide settings for my package? It’d be great if I can add custom tab on project settings window 🤔
Ah I found SettingsProvider
Working on an editor and the scroll bar is staying fixed at top. It will not scroll down. This is how it is started off
private void OnGUI()
{
EditorGUILayout.BeginScrollView(scrollPos);
Is there anyway to make this cleaner?
if (genericLabelObjects.Any(x => x.Dirty))
{
using (new EditorGUI.DisabledScope(hasUnsavedChanges))
{
hasUnsavedChanges = true;
}
}
else
{
using (new EditorGUI.DisabledScope(hasUnsavedChanges))
{
hasUnsavedChanges = false;
}
}
Have you removed the controls from those disabled scopes? Because otherwise they don't serve a purpose, surely?
I don't know what you're asking
this is only required if you have a name that conflicts locally (or some other really specific cases)
this was my example of saying window.
I have no idea what you mean by window scopes
Window is a window mate...
Anyways thanks for rubber ducky: hasUnsavedChanges = genericLabelObjects.Any(x => x.Filled);
And your code and question makes no mention of that stuff, I'm just pointing out that the DisabledScope does nothing without editor controls to disable
Yes, I thought that hasUnsavedChanges was disabled by default.
Huh, I've never used that property before
How can I save my package's settings under ProjectSettings folder and access from there in runtime?
So I don't have to worry about user moving the settings around?
Why Unity doesn't support this with simple way? 😅
A config that can resolve to whatever settings file you want?
Question, please tell me there's a better way?:
if (genericLabelObjects[i].type == typeof(uint))
{
int n;
int.TryParse(genericLabelObjects[i].value, out n);
genericLabelObjects[i].value = EditorGUILayout.IntField(new GUIContent(genericLabelObjects[i].key, $"{genericLabelObjects[i].type.Name}"), n).ToString();
Probably just same thing as ScriptableSingleton but something I can access on runtime
I was thinking a config file, that way you can handle any edits with any dir / file watch and just resolve to the new dir.
Watch the Projects settings?
Ah I want it changed from ProjectSettings window
I just want reliable path, don't want to deal with letting user use custom settings path, etc
Thing is ProjectSettings folder won't be accessible in runtime
Question: I'm trying to limit the characters that go into a EditorGUILayout.TextArea this is how I get / set my values currently:
MyValue = EditorGUILayout.TextField(MyValue, ""); What I'm trying to understand is how I can get that textfield OR if I'm just being lazy with the layouts and need to have a better way of getting input. I just need to https://docs.unity3d.com/2018.3/Documentation/ScriptReference/UI.InputField-contentType.html
Hello how I can fix it
Reset your packages.
Hi! I'm working on a custom MenuItem for the Assets/Create context menu. How would I get the name of the file on which the context menu was activated?
I solved it. It's in Selection.activeObject.name
Hello, I have a quick question. II have a List<> of "Tech", the issue is that somehow one of the scriptable objects for "Tech" became corrupted? I think I might've deleted it by accident.
I'm trying to capture any nulls at the start of OnInspector, but it isn't working
public override void OnInspectorGUI()
{
TechTree targetTree = (TechTree)target;
for (int nodeIndex = 0; nodeIndex < targetTree.tree.Count; nodeIndex++)
{
//remove any weird null techs.
if(targetTree.tree[nodeIndex].tech == null)
{
Debug.Log("NULL NODE");
targetTree.tree.Remove(targetTree.tree[nodeIndex]);
break;
}
}
That looks like targetTree.tree is null somewhere
I think I was messing up by trying to filter out the nulls at the editor as opposed to at the actual tech tree class
not 100% on the solution, but I think i'm getting there
My custom inspector called on OnInspectorGUI is updating the hierarchy many times per second. What is the best way for it to only update when the object in the scene updates, or when the inspector updates?
Any ideas why unity would be refusing to link to script files in an 'Editor' folder, while in editor? Assembly-CSharp-Editor.csproj has the files listed, and UNITY_EDITOR appears to be defined... so I'm a bit stumped.
OnInspectorGUI is called 'every' frame
Think of it sort of like a MonoBehaviour's Update method
I've realized I can implement my intended behavior with a simple state machine (like what I'd do with an update loop in a monobehavior)
What would the correct syntax be for a static reference to an activeContext? I can't figure it out in the docs. Ie, Selection.activeContext == [SomeConstant]
== is an equality check, = is a set
I am not trying to set the active context, I'm trying to see if the active context is a specific context
so
if (Selection.activeContext == [SomeConstant]) { }
?
Yes. I don't know how to figure out what should go in [SomeConstant] because I'm confused on what the type for activeContext is
or rather, I know it's type object but I don't know how I define a constant for it correctly
object?
show your Selection class code
if(GUI.changed || Selection.activeContext == [SomeConstant]){
EditorUtility.SetDirty(target);
myScript.GenerateWallFromSpline();
}
selection is a built in unity class
Ok so activeContext is a unity Object. so [SomeConstant] can be anything that derives from UnityEngine.Object
My solution deviated pretty far from the above discussion but figured I'd post incase anyone is searching through the logs later
ToolManager.activeContextType was what I was looking for, rather than the object type
ToolManager.activeContextType == typeof(SplineToolContext)) works perfectly
Other than some other observer, is there any quick way (with the window class) that would update data on window close?
OnDestroy?
That would work, thank you.
Does .Close() destroy the window?
That works prefect, thanks!
Description
Close the editor window.
This will destroy the editor window.```
Sometimes I over think it 😄
Is there any way to fire when a user opens a dropdown?
To fire what
A function.
if its something simple you can detect the click with rect.Contains and event.type mousedown
Is there a way to get the GUID or path to the csharp file that is running the function?
e.g. something like AssetDatabase.GetGUIDForCallingFunction()
wait, just noticed what you posted... normally the control over which calling which is in your hand already, so not quite sure you really want
No, but you can make one. It depends on exactly what you want.
MonoScript scriptAsset = MonoScript.FromScriptableObject(this);
string path = AssetDatabase.GetAssetPath(scriptAsset);
return AssetDatabase.GuidFromAssetPath(path);
If you want it to work with other classes, then you could maybe do something like.
You should be able to do something like
public string GetGUID()
{
return AssetDatabase.GuidFromAssetPath(Getpath());
}
private string GetPath([CallerFilePath] string sourceFilePath = "")
{
// I can't remember exactly what to do here. But basically sourefFilePath will be the file path in relation to the computer c:/something.
// But you want it in relation to the assets folder.
string assetPath = sourceFilePath.Remove(Application.dataPath);
return assetPath;
}
Oh, you want it from the one calling it, well same idea, just use [CallerFilePath] to get the path to the file, then you can do the same thing to get the guide.
Would I need to call Object.Destroy to clean up these MonoScript instances?
I don't think so
Not unless you want to destroy your script asset 😉
Isn't it creating another instance of the script?
Ah, it just gets the script, nevermind.
MonoScript is the script asset. It is the in-engine representation of the .cs file
Thanks!
Though I think using CallerFilePath would work better for you tbh. It is definitely more flexible.
I think I'll have to regardless, since while it is a ScriptableObject I don't have an instance when I need the path
You can create an instance of it and then destroy the instance.
Seems like kind of a hacky workaround 🤷
if its a ScriptableObject why not use Resources.Load?
How would that work, I don't have a path
yes you do, all resources are in a Resources folder
But it's not in the resources folder 😅
why not
Because it's an editor asset
can still be in a Resources folder
I'd rather not create a resource folder just for this. Also makes porting more complicated
I always forget resources are even a thing anymore, since I've used addressables for so long now
Yeah, the Resources folder should generally be avoided when possible
either you work within the Unity ecostructure or you work outside of it, your choice. But if you are going to work outside of it then dont expect Unity to provide support for what you want to do
That could be said of any API that unity has added since their inception, it's just a case of how long it takes and how many people need it
Why? Explain
Addressables replace the need for resources, and are a more comprehensive system
Nonsense
How is that nonsense
Addressables are for when I want to load data external to my project, Resources are when I want data internal to my project
You can do both with addressables
Firstly, it forces anything in that folder to constantly be loaded. This may be fine for one asset, but it can add up.
For editor tooling, depending on the context for the use, it can force the user in to using specific folder structure/organization, having to dive in to 'your' folders to edit something.
^ that's why I don't like them for editor tooling
I don't think I've ever used the resources folder
What? Addressables is for dynamically loading(and unloading) assets at runtime (along with other things)
What even is an asset that is "external" to your project?
@slate cliff What are you doing btw? Is it getting/saving settings for you tool?
omg do you even have any idea what Addressables are?
Pretty much, creating a scriptable object at the path of the csharp file for settings
I settled with just using the unity search functionality to find the script file and caching that. I'll leave it at that for now even if it's not the best solution
Ah, look at the ScriptableSingleton class and the [FilePath] attribute
Ah cool, didn't know about that. Thanks
Yeah, it is super handy! Also works great if you don't use the FilePath attribute and just use it for settings during the editor session.
is there a way to add a context menu item when right-clicking any asset? from my research, it seems like it's restricted to custom monobehaviours
You mean in the project browser?
yeah
Just use [MenuItem]
oh huh, from the examples i saw, i thought that was restricted to methods that were on monobehaviours
thanks!
Just put it on any static method and you can have things show up anywhere.
For example [MenuItem("Assets/My Cool Asset Menu")] will show up in the context menu for assets.
And [MenuItem("GameObject/Oooh, I'm in the hierarchy now!")] shows up in the hierarchy window.
thats awesome, thank you!
Now I've written another small editor extension that I will then forget to ever use 
That's what it is all about! 💯
Hey all, running into an issue where my EditorWindow class is throwing NullReferenceException error
`private void OnGUI()
{
if(GUILayout.Button("Click me ")) {
Debug.Log("the button is clicked");
MyScript.Instance.debugLogs();
}
}`
I am referencing MyScript class by doing:
public static MyScript Instance;
Instance = this;
Any suggestions on how to fix this?
I don't understand the example code on the documentation page. Do you need to import an object named "cube" for it to work? When is this suppoed to trigger?
https://docs.unity3d.com/ScriptReference/AssetImporters.ScriptedImporter.html
extension has to be .cube iirc
Well if you look at the docs for the attribute then it does it is the extension 😛
Hey im really new to editor scripting, and im trying to make my first simple tool (I need it for my own project). So far I was able to resolve any problem on the way, but with this one I cant seem to find anything in docs or forums
void DeleteParam(int index)
{
Undo.IncrementCurrentGroup();
Undo.SetCurrentGroupName("delete parameter");
var groupIndex = Undo.GetCurrentGroup();
var spar = new SerializedObject(serParams[index].objectReferenceValue);
Undo.RecordObject(so.targetObject, "");
((Parameter) spar.targetObject).parent.parameters.Remove((Parameter) spar.targetObject);
Undo.DestroyObjectImmediate(spar.targetObject);
AssetDatabase.SaveAssets();
so.Update();
Undo.RecordObject((Object)this, "");
var parameters = so.FindProperty("parameters");
serParams = new List<SerializedProperty>();
for (int i = 0; i < parameters.arraySize; i++)
{
serParams.Add(parameters.GetArrayElementAtIndex(i));
}
Undo.CollapseUndoOperations(groupIndex);
}
im trying to record an undo group here
and for long time i thought that for some reason everything records correctly, except the DestroyObjectImmediate, wich deletes one nested scriptible object
apperently it records and works just fine, but...
when I do CTRL+Z everything goes back to normal, yet the deleted asset doesnt appear for fiew minutes
yeah after fiew minutes it suddenly appears in project inspector, but I really dont know what is happening throughout those fiew minutes, I even tried to refresh asset database on Undo/Redo event, but it doesnt help
basic question. How can I make my editor script only update when something in the scene or inspector has actually changed, instead of constantly (OnInspectorGUI)
For some reason, OnSceneGUI still updates every frame even if I'm not touching anything
What are you doing/trying to achieve?
How would you go about baking the transform of a gameObject ?
This is my use case, say I've copies of one gameObject then each of the copy would have their own scale... man this is hard to explain in english haha
it's similar like when you're applying the Transform in Blender... so the transform will be normalized to 1
hope that's not confusing
aight, found something https://github.com/mariosubspace/mesh-apply-transform-unity
Quite old, but I can work my way based on that
I have a problem with my custom editor wich I cant resolve by my own
I try to make a SerializedObject with
new SerializedObject(conditions[j].objectReferenceValue)
where conditions is a List of Serialized properties, and for some reason this objectReferenceValue returns null.
This is simplified object inspected
public class SMTransition : ScriptableObject
{
[SerializeField] public List<SMCondition> conditions = new List<SMCondition>();
}
[Serializable]
public class SMCondition
{
}
Ofc List of serialized properties in my editor script is manually populated by iterating through this list property, so I am sure that value it stores must be object reference.
So far only clue I have is that I read somewhere that objectReferenceValue may refer only to objects deriving from basic Unity Object, but if its so I have no idea how to bypass it
objectReferenceValue is only for fields that are of a type that is or inherits from UnityEngine.Object. Like wise, you can only create a SerializedObject for a object that inherits from UnityEngine.Object
ehhh so its true...
SMCondition is a wrapper class to store multiple things in one place, is there any way to achive this inheritance for this class?
What do you mean? serializedProperty.FindRelativeProperty("someValue")?
what do I mean with which part?
conditions[i].FindRelativeProperty("ThatNameOfTheFiledInSMConditionYouWant")
ohhhhh w8... what this method is actually doing? it takes the property deeper from hierarchy?
Yeah, it finds a property relative to the property it is called on
i mean, will it return some property from SMCondition?
Yeah
when i read docs i must have misunderstood word "relative"
that solves everything I guess wow
The reason it is relative is because you can give it a path
property.FindRelativeProperty("myVectorField.x")
Will return the property for the x field in a vector3 (assuming myVectorFIeld is a vector3 field)
Damn... I just realised that one of my editor scripts beeing like 300 lines of code or so, could be actually half as large XD
Well, that isn't the reason it is called "Relative"
yeah but english isnt my native language so I understood it totally wrong, only this one word coused me such a pain lol
One more question if I may.
if SMTransition is my serialized object beeing inspected, will ApplyModifiedProperties() affect this SMCondition fields inside?
Yes
well unfortunately not... when I change property of SMCondtition inside SMTransition editor window, serializedObject of SMTransition doesnt return true with ApplyModifiedProperies :/
but nvm, thats a minor issue
There is a good change you might not be doing something correct then.
is it becouse of
intValue = EditorGUILayout.IntField(serCon.FindPropertyRelative("intValue").intValue);
//and then tryingto apply this value
insted of
intValue = EditorGUILayout.PropertyField(serCon.FindPropertyRelative("intValue"));
That doesn't change anything.
It would need to be this (Though would of course be better to cache the found property)
serCon.FindPropertyRelative("intValue").intValue = EditorGUILayout.IntField(serCon.FindPropertyRelative("intValue").intValue);
well actually it looks like this in my code
intValue = EditorGUILayout.IntField(serCon.FindPropertyRelative("intValue").intValue);
serCon.FindPropertyRelative("intValue").intValue = intValue;
(I know its a mess without caching it but only for now)
So pretty much the same, but im doing it only becouse this applyModifiedProperties doesnt recognise change in this EditorGUILayout.IntField as a property change
intValueProperty = serCon.FindPropertyRelative("intValue");
intValueProperty .intValue = EditorGUILayout.IntField(intValueProperty.intValue);
intValueProperty.serializedObject.ApplyModifiedProperties();
Try that
ahh nvm it works just fine with
intValue = EditorGUILayout.PropertyField(serCon.FindPropertyRelative("intValue"));
thanks rubber duck XD
as I said, minor issue
im trying to make a property drawer for a struct and im wondering what it is I need to be able to make a fields for a list
okay got it
still having some weird issues though
atm im struggling with the property drawer height
For some reason the property drawer height is being rather laggy in being set, i think im updating the hieight in the wrong section
and also if I have a list of them, then only the last one in the list will be updating its value
Override the GetPropertyHeight method
I have
the problem is that it updates very slowly
also that bug where if the property is in a list, then only the bottom element in the list will be updating it
just trying to figure out why is behaving so strangely
and I need to get it working asap
Shoooow coooooode
yea I know that would help a lot 😅
but its all behind NDA
it gets tricky asking for help when the problems are behind an NDA
Hello, I have a script that inherits from Editor for a scriptable object. I have a button already in it and I want to populate a List that's inside the scripable object. Only problem is that I don;t know how to reference the list variable that's in the SO from my editor window
https://docs.unity3d.com/ScriptReference/SerializedObject.html
And if you need more explanation try here
https://help.vertx.xyz/programming/editor-issues/serialisation/serializedobject-how-to
Its me again my lovely fellows!
void DrawTransition(Rect rect, int index, bool isActive, bool isFocused)
{
{...}
using (new GUILayout.AreaScope(new Rect(rect.x, rect.y, rect.width, rect.high),
new GUIContent("Condtiions"), EditorStyles.helpBox))
{
}
}
Inside a ReorderableList item im trying to draw an area scope, but it is not beeing drawn where this item list actually is. Seems like rect.y gives me the very top of an inspector window instead of position relative to this item in a list. For now i have written some absolute values and it works for my screen, but I want to keep it relative to actual list position.
or maybe this rect passed to this methos isnt actually a rect of an item to draw? I feel like im missing something VERY obvious and trivial
You shouldn't use GUILayout stuff inside of the PropertyDrawers or ReorderableList and things like that.
I figured it out, yet I couldnt find any possible way to surround part of this list item with helpBox style
[GameEffect(ID = "spearEffect")]
public class SpearEffect : AbilityEffect
{ //Logic in here }
Does anyone know what I could use to replace my current effect system of typing a string in that corresponds to an attribute? I want to be able to have separate values set in the inspector for different items, but want the logic to remain the same in some cases. I am not using SOs right now since I would rather not have to create a separate file and instead keep it all within the ItemData SO.
Is this maybe what PropertyDrawers are for? If so, I see in the documentation they manually add fields for all the SerializedProperties, but would it be possible instead to loop through them so new effects work without modification?
PropertyDrawers are nice if you just want one large script with most of your data on it. Instead of creating a large hierarchy, you can just create a bunch of structs which you can hide or show on the editor if that's what you want to do.
Unfortunately, it's a pain to edit every time you want to add more to your scripts, since you're not only editing the data script but the PropertyDrawer too.
You can quite easily just loop through all properties in a serializedproperty and draw them excluding ones you want to have custom behaviour for
Or you can just use a propertyattribute on the field you want to draw different
Also, you might be looking for custom editors if you want to change the whole ScriptableObject representation
is there a way to keep a list in memory even when the editor reload?
ex: I have a [InitializeOnLoad] class where I build a list but any time a c# file is modified, that list is cleared.
You gotta serialize it somewhere
EditorPrefs is usually used to save custom editor data to disk (you can first serialize the data to string and then save using EditorPrefs.SetString)
Not for complicated data really
And editorprefs is shared between projects
So you can't use the same extensions in between projects
how to fix this?
@simple cove here is the item editor I have spent a few hours on https://www.youtube.com/watch?v=uQ20vzqKaBQ
I can dodge all the file shenanigans and have it do it for me
that's awesome
that looks fire
Why does unity's inspector not support unsigned integer types? It seems silly to have to apply a Range attribute to every field that is unsigned or to have to check it in OnValidate
Actually they do work, ulong doesn't seem to work though. I can still assign negative values and can't go above max long value. I wonder if this is a bug and if so, if it's fixed in newer Unity versions. The use case for ulong is probably **extremely **low, so probably a non-issue, just something I noticed.
Yeah apparently, they will not fix which is probably understandable.
https://issuetracker.unity3d.com/issues/unsigned-long-ulong-value-input-range-is-identical-to-long-in-inspector
i feel like this should exist.. anyone familiar with an editor extension or tool to view scriptable objects of the same type in spreadsheet format?
i have an CSV importer / exporter but for values like game object references it's a pain to reconnect on csv import
What do you mean?
Like ```
ScriptableObject Instacne | Field 1 | field 2 | field 3
ScriptableObject Instacne other | Field 1 | field 2 | field 3
exactly
i'm currently exporting to CSV files to view in excel, but i have more complex data types than just ints bools and strings, so setting them on import is a pain
was wondering if anyone has see an in-app editor utility that essentially views scriptable objects in a spreadsheet
I don't know of any my self (might find something on the asset store). But it wouldn't be that hard to make tbh
You would use that combined with SerializedObject/SerializedProperty
how do i fix a 2D Box Collider that overlaps another?
how to make a collider that fits a 3d object
Is there a way to make this editor GUI I've programmed show up whenever there is a SerializeField of type List<GameEffect>, instead of needing to make custom editors for everything that uses them?
You can do so for array/list elements but not for the whole list
Even if they are just regular C# classes, not Unity Objects?
Yes
Actually that would probably be enough, what do I use to do that?
Ooh okay I'll look into it
Is there any way to add a find log to the Console?
Search filters out all the other logs. Sometimes it is useful to jump to a certain log and check nearby logs
When writing a custom editor, is there a way to enter some default search text for an object field? E.g., i'd like to default to filtering assets with a certain label
Otherwise it brings up a list of every texture, which is much less helpful!
Is there any callback to see when the inspector changes? I want to inject some extra UI to some internal AssetImporters. I was thinking of using Selection.selectionChanged but there might be a better way
How were you planning on injecting the UI?
Grabbing the UITK inspector window and adding new elements
public static class EditorGUIUtilities
{
// The TypeTool.GetEvent is just a little utility to get reflected stuff easier. Easy to replace with default C# calls.
private static readonly EventInfo _editorTrackerRebuiltInfo = TypeTool.GetEvent<ActiveEditorTracker>("editorTrackerRebuilt");
/// <summary>
/// Called when a property window rebuilds it's UI.
/// </summary>
public static event Action OnEditorTrackerRebuilt
{
add { _editorTrackerRebuiltInfo.AddMethod.Invoke(null, new object[] { value }); }
remove { _editorTrackerRebuiltInfo.RemoveMethod.Invoke(null, new object[] { value }); }
}
}
Then add a callback to the OnEditorTrackerRebuilt that gets all property windows and checks, what their target is (if it is the one you want) and if you have already added your element to them.
Is there any way in odininspector to sort a list of interfaces by the base class instead of just by "User Type"
The Odin discord server would be a better place to ask.
Thanks
Does anyone know why there is a forced recompile and editor window refresh when I enter play mode? It's causing the editor tool I'm making to lose everything done within it. Using UITK, never used to happen with imgui
Yes, there is a domain reload and scene reload (that can be disabled if you know what you're doing and want to manually reset all static variables yourself)
Are the variables in your tool actually set to be serialized in your editor/window?
They are set to be serialized yes. But it's not like they just don't exist anymore, the whole editor window effectively goes blank and is then redrawn
Editors are redrawn in IMGUI too, they're just immediately using values that you've (likely) serialized into the window, editor, or objects
Can you show some code?
Unfortunately not which is frustrating me to no end.
Alright it's entirely possible I'm just being daft. Thanks for your help, I'll come back if I make a breakthrough
Could be that whatever you're serializing is not serializable
Or if you create elements on input field change then that could also be a thing
Definitely not as easy to completely restore state in UITK vs IMGUI
It could also be that UITK is doing something stateful with the editor that you're either not working to be aware of, or is actually flawed. UITK can be a pain in the ass sometimes imo
Don't I know it. The old tool was IMGUI and I think sometimes I should have just rewritten using IMGUI again. I'll go digging, what's another day added to the schedule 🙃
I got ahead of this and everything that is needed already exists in uxml, it's just hidden or shown. (except from bits that only exist in imgui)
Well if you hide/show things in callbacks then you still need to restore that state at start
Oh yeah i know but that's an easier task imo.
Sure, just making sure that it is happening 😛
Iam creating RPG inventory and am at phase of creating items. Scriptable objects by default are ok until you start having lots of items. I have seen odin and seems great, but often i find free tools even better and open source for customization, my question is have you used any odin alternatives? Serialization and attributes
Hello Guys,
I am kind of new to editor scripting in unity. I am trying to make an editor window to import objects and set some values through it. I tried to make Label, texts and all UI related stuff with bunch of tutorials, but i couldn't find a relevant one for importing assets.
Basically," I want to import the objects and load/save it in specified project folder and access its properties through Editor Window."
Any help is Appreciated. Thanks in Advance.
How do I send a list of objects to Selection.activeGameObject ?
I can send it newSelection[0] but I want all objects in the Array
I just figured it out, should have been Selection.objects, not activeGameObject
But I tested and too and it gave the same convert type error
isn't that's what it's doing already ?
not quite sure, but I believe I've done this before.. something like this perhaps?
new Window { window = win, content = new GUIContent(win.titleContent) }
you must populate the active windows first then do something like above...
That class has other useful methods so I would take a look at them as well.
hi. has anyone found a way to discard changes in a scene programmatically?
Have you tried just calling EditorSceneManager.OpenScene on the same scene? I’d check if that reloads a fresh copy
Reloading the scene seems to have worked in Unity 5.5 so it seems promising: https://answers.unity.com/questions/1298210/how-to-revert-scene-to-the-last-saved-state-in-the.html
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
I’d be surprised if this scene handling behaviour changed in the meanwhile tbh. can’t check atm but would be curious to know if you give it a try.
I'm using UIElements.TextField, is there any way to increase the size of the content (the box where you can enter text) in code? Don't really fancy messing with this USS stuff but it seems like I'll have to if I want to use GraphView.
element.style.width = new StyleLength(size);
Thank you!
I'm using that right now. the problem is it won't respect selections and hidden objects
would be cool if they let us just use that discard methd
I tried it with reflection, but doesn't work. seems it needs to be called from a specific context
What do you mean by context? App state, or something more specific?
You can request it via the Unity feature request tool or maybe get an alternative solution from a dev on the forums
Re: selections, can’t you clear them by nulling it out in Selection object? Re hidden objects, are you saying that hidden objects persist past scene reload?
Hello. How do I override the inspector for System.Collections.Generic.List<T: Serializable> ? I have a custom inspector for T which works using [CustomEditor(typeof(Mod))], but it isn't displayed when the type is nested in a List<T>
Custom inspector (first screenshot), List<T> (second screenshot)
I've tried overriding CreateInspectorGUI and OnInspectorGUI but none of them work unfortunately.
I'm guessing I need a custom editor for the class that wraps the List<T> ?
Indeed, this works - disregard my request 🙂 Thanks
Unity Editor's context
like, there are multiple iterations of OnGUI etc
and different phases of executions (OnEnables, Editor Updates, Delayed calls etc.)
so when I call the discardChanges from my code (which uses EditorApplication.delayCall btw) , the array of changed scenes is empty, even though the scene is clearly modified
Hi! I'm writing a custom PropertyDrawer for class Mod that's nested in another class ModsPool that contains a few fields:
public class ModsPool : ScriptableObject
{
public ItemType ValidItemType;
public List<Mod> Prefixes;
public List<Mod> Suffixes;
}
It works fine, except when I add an eighth element, and at this point it seems like I hit a maximum height or something, see the associated screenshot.
Any idea where it might come from? Disclaimer: I'm a bit lost with editor code so... Bear with me 😄
Here is the full code: https://gist.github.com/tbarusseau/5b1dc17da77cac0c4a4fa8e116b07d22
Hey, small question.
Is Physics.Raycast(...) not usable inside a PreviewScene?
ANSWER:
Seemingly, yes it's not, PhysicsScene is what I need to use to make it work, the usual Physics.Raycast was being executed on the MainStage and not my custom one.
https://forum.unity.com/threads/raycast-in-the-prefab-scene.647548/
_
Hey,
I'm developing a UPM package for internal use.
Is there a way to include certain tags/layers/sorting layers in the package, or do I have to write an editor script to create them?
No default way
how do i keep the Sprite field IN the screen
the whole thing
i tried flexible space after it and ExpandWidth true
neither did anything
i dont wanna hard set a width
i dont know if it is a bug but TextMeshPro's right click menu creation is not using ObjectFactory, instead it just Add component via gameobject.AddComponent instead of ObjectFactory.AddComponent
cause im relying on ObjectFactory.componentWasAdded to do component replacing, the way TMP creates its default text/button/label doesnt allow me to do component swap via script
Is there any way to add custom settings to the model import settings inspector?
Not sure where you are talking about, but probably a bug.
Not a good way. Best you can do would be to inject the UIToolkit elements for your settings in to the top or bottom of the inspector. However you would need to save your custom settings else where, which can get a bit messy
Settings could be saved as custom values to the meta file I guess 🤔
But injecting UI elements sound cumbersome anyways 😬
Would be nice to just have custom settings for custom asset postprocessors
I don't think there is a way to do that. I think you could use the importer data?
@thin fossil Some one was just asking how to inject stuff, you can see here what I said.
Thx thats interesting
on the problem of how to use EditorGUILayout to draw a serialized reference
How do I clamp the value in inspector?
script.radius = EditorGUILayout.FloatField("Radius", script.radius);
script.radius = Mathf.Clamp(EditorGUILayout.FloatField("Radius", script.radius), 0, 10);
But it would be good to look in to SerializedObject and SerializedProperty as that is the much better and recommended way to modify values in the editor.
They ensure changes will be saved, support undo/redo, and support prefab overrides.
thank you, is this what you're thinking?
MyObject obj = ScriptableObject.CreateInstance<MyObject>();
SerializedObject serializedObject = new UnityEditor.SerializedObject(obj);
SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("myInt");
Yeah something like that
Hello I have editor window which uses importpackages inside but problem happens when unity starts doing this then any other import package will be canceled because editor reloaded window
Its any fix for that?
like if its possible to cancel auto import or stop editor importing anything while in this process
Is it possible to draw a single mesh inside of a custom editor window? I'd like to write a custom collision editor tool for a UGC game to replace the current (extremely cumbersome to use) system that involves futzing around with the scene view camera and a massive ton of generated collision handles
is there any API call to get absolute mouse button state in editor? Or do I really need to keep track myself using the GUI events (as I suspect)?
How can i make a list of dropdown menus?
what i want to use it for is to be able to have a scriptable object with a list i can make bigger and the content is dropdown menus that has options from a list of strings
so i can make sure that i only select existing things and dont miss spell the name
i found this on how to make a list but it doesnt seem to quite work with swapping it out with a list of stringshttps://answers.unity.com/questions/1214828/editorguilayout-list-field.html
i got the list to work, then i might figure out the rest
i found this which is probably what im looking for https://answers.unity.com/questions/458987/dropdownlist-with-string-array-in-editor-inspector.html
Yes. You can do 3D rendering to a RenderTexture completely in code, no scene or camera.
I don't have a tutorial handy, but the gist is to create a RenderTexture and use the Graphics and GL static classes to set that as the active render target and submit a draw mesh call.
For more complex rendering, it's recommended (and sometimes required) to use a CommandBuffer
Once you have the rendered texture, you can draw it in the editor window as you would any other texture
so ive got it working, though is there a way to make it look a bit more like a list? right now im pretty much just using loops to draw the popout fields. is that maybe what the rect fields are for? making things look pretty?
I'm able to create a Render Texture with a solid Cyan background and draw it to the UI, and it's working. But I can't seem to get my mesh to render with Graphics.DrawMesh()
One thing I forgot to mention, first you need to set up the "camera", which is a projection matrix
Ah. I want to use an orthographic "camera" because this is a 2.5D game and I don't need to view the mesh in 3D
Also I read that Graphics.DrawMesh doesn't render immediately when you call it...
Okay, for that you use Matrix4x4.Ortho method to create the orthographic projection matrix
Oh yeah, you could be using Graphics.DrawMeshNow
Not exactly. It doesn't look like there's an overload for passing materials and submesh indices
You can material.SetPass to set the current material, which subsequent draw calls will use
And it looks like the "materialIndex" actually means submesh, since it's described as: "Subset of the mesh to draw."
Alternatively, you can use CommandBuffer, which has a more straight-forward DrawMesh function
The difference is, you create a CommandBuffer object, add all the commands into it by calling its functions and then call Graphics.ExecuteCommandBuffer.
man I'm getting flashbacks to when I tried to write my own engine
Here's a full pseudo-code example:
var renderTexture = new RenderTexture(...);
var cmd = new CommandBuffer();
cmd.SetRenderTarget(renderTexture);
// Setup the "camera"
var camViewMatrix = Matrix4x4.TRS(cameraPosition, cameraRotation, Vector3.one).inverse;
var camProjectionMatrix = Matrix4x4.Ortho(-5, 5, -5, 5, 0, 100);
// The projection matrix needs to be converted for the GPU
camProjectionMatrix = Graphics.GetGPUProjectionMatrix(camProjectionMatrix, true);
cmd.SetViewProjectionMatrices(camViewMatrix, camProjectionMatrix);
// Now we can finally draw the mesh
cmd.DrawMesh(mesh, Matrix4x4.TRS(meshPosition, meshRotation, meshScale), material, submeshIndex);
// And execute.
Graphics.ExecuteCommandBuffer(cmd);
For performance, the render texture and command buffer should be pooled. There's a built-in pool for RenderTextures through either RenderTexture.GetTemporary/ReleaseTemporary or CommandBuffer.GetTemporaryRT/ReleaseTemporaryRT. The CommandBuffer you can just cache and reuse, using Clear() to reset it.
Right! I HAVE a donut prop rendering!
But it's solid gray
The mesh SHOULD be red and white though
@short tiger Any reason why it would be solid gray? It's like the material isn't actually being used
Could I have potentially missed something?
private void RebuildCommandBuffer()
{
if (previewCommandBuffer == null)
{
previewCommandBuffer = new CommandBuffer();
}
previewCommandBuffer.Clear();
previewCommandBuffer.SetRenderTarget(meshRenderTexture);
previewCommandBuffer.ClearRenderTarget(true, true, previewBackgroundColor);
float aspect = (float) meshRenderTexture.width / (float) meshRenderTexture.height;
float halfHeight = 5;
float halfWidth = halfHeight * aspect;
Matrix4x4 view = Matrix4x4.TRS(camPosition, Quaternion.Euler(camEulerAngles), camScale).inverse;
Matrix4x4 camProj = Matrix4x4.Ortho(-halfWidth, halfWidth, -halfHeight, halfHeight, 0, 100);
camProj = GL.GetGPUProjectionMatrix(camProj, true);
previewCommandBuffer.SetViewProjectionMatrices(view, camProj);
Matrix4x4 matrix = Matrix4x4.TRS(meshPosition, Quaternion.Euler(eulerAngles), scale);
for (var i = 0; i < propMesh.subMeshCount; i++)
{
previewCommandBuffer.DrawMesh(propMesh, matrix, propMaterials[i], i);
}
}
If you're using a lit shader, it'll be dark since there's no lighting
How do I solve that without switching to an unlit shader for all of the materials?
You can try to simulate lighting, at least a basic directional light. The actual code will differ depending on what render pipeline you're using. If you're using built-in, you'll find all the shader variables related to lighting on this page:
https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
You can set them with CommandBuffer.SetGlobal{Vector/Float}
(We are)
Then _LightColor0 and _WorldSpaceLightPos0 should be all you need to set, with color and direction respectively.
maybe also need to enable the DIRECTIONAL shader keyword with CommandBuffer.EnableShaderKeyword, if your shaders expect that keyword.
What do I set the direction to? I'm too dumb to comprehend Vector4 for anything other than colors lol
If you set it to (0, -1, 0, 0), the light will be directly above, pointing down (negative Y). The w component is expected to be 0 when it's a direction instead of a position, but I'm not sure it actually matters.
So it's just a (world space Vector3 direction, 0)
The mesh is still solid gray
I may just need to take a screenshot of the editor and break my NDA, I'm really confused
No worries, I'm imagining a solid gray mesh in my mind's eye
Does it look normal if you use an unlit shader?
I'm afraid to change the material to find out. I don't want to wipe out any properties that are set on it currently since I'm not an artist.
But I guess I can always git reset
Is it easier to swap the material instead of the shader?
Neither is actually possible
The material itself is read-only, and the mesh filter I'm reading from is imported from an asset
Can I ask if the shader is the Standard shader or something custom?
Yes, it is the Standard shader
Alright, I'm setting up a quick test project to see if I run into the same problem
I'll take a screenshot of what I'm actually seeing just to be sure
The cyan background is intended, to depict a "sky"
It's like it's the same shade of gray as the background of the editor window, which is weird.
Oh that might mean the shader is writing 0 to alpha and the texture is drawn as transparent
If you're using GUI.DrawTexture, there is a alphaBlend parameter that should be set to false
Btw, it looks like you have to specify the shaderPass in DrawMesh, otherwise it will try to draw all passes, which causes weird issues. Pass 0 in the Standard shader is the base pass
Setting alphaBlend made the mesh look black
Setting shaderPass to 0 makes it invisible
Yeah, I'm still struggling to get lighting to work
In general, it's recommend to use Graphics.DrawMesh to fully support lighting, but that requires a scene
There's definitely some combination of properties and keywords that will get lighting to work, but it might not be worth it.
You might want to look into editor preview scenes, to manage a scene from editor code and render from that
But I'm going to keep trying anyway because I want to figure it out. I'll let you know if I do.
I honestly just want to see the mesh in color, without lighting
I don't need lighting for the collision editor tool
I just need to see where the mesh is
And draw collision representations over top of it that an artist can drag to move and resize
Yeah, but Standard can't render as unlit, it always needs some lighting. I'm trying to get basic, uniform ambient lighting working.
Agggh shaders
I mean, if you know that all these meshes are going to be using the Standard shader, you don't have to use their actual materials
You can just substitute it with your own simpler unlit shader
Get the main texture from the imported material and set it on your unlit material
I wonder if using editor preview scenes would be better, I mean it would be nice to use Unity's default collider editor UIs instead of trying to develop my own. Especially for polygon colliders which will be needed for more complex meshes
I don't think a preview scene will make drawing editor handles any easier. It's still like a regular scene, not like the scene view.
The only problem with using the default Scene View for this tool is the camera. Forcing it to a certain position so you don't have to futz with it manually, things like that. And then the Inspector starts to become limiting too because I effectively have to write an entire state machine into a custom inspector just to get this all working the way I want it to, and manage colliders on a temporary object in the scene, just a massive mess
But there is the stage API, which is what the prefab editor uses. That might be closer to what you want.
Only if it can be used inside of a custom window.
Then no
I don't know how difficult it is to draw editor handles in editor windows. Never tried that, only used them in the SceneView.
@agile badger I managed to get lighting working
What'd you do?
Here I'm basically simulating a light probe. Here's the whole code:
https://gist.github.com/PeturDarriPeturs/62401793d3d69f1eae29823ae57a3090
There's a lot of code just for converting the SphericalHarmonicsL2 type (which is how light probes are encoded in Unity) to the shader properties, which I've stolen borrowed from Keijiro
Complicated math I don't understand
But the actual probe creation is as simple as can be:
var probe = new SphericalHarmonicsL2();
probe.AddAmbientLight(ambientColor);
probe.AddDirectionalLight(lightDirection.normalized, lightColor, 1);
You could also just use PreviewRenderUtility
here's an example of that that I've done in the past https://github.com/vertxxyz/NTexturePreview/blob/master/Editor/N3DTexturePreview.cs#L236
Though, it's pretty undocumented and I'm unsure how flexible it is
Good call. Definitely less hacky than this and easier to manage for more complicated scenes. Still, there's something compelling about forgoing the whole scene and GameObject API to render something, especially when it's just a single mesh.
Yeah it is very undocumented but you can find some good resources online for it. And it is very flexible as it basically gives you full access to the preview scene and everything, that is unless you want transparent backgrounds, then you are out of luck.
Pretty neat!
This method appears not to exist @short tiger
previewCommandBuffer.SetKeyword(material, new LocalKeyword(material.shader, "LIGHTPROBE_SH"), true);
I'm using 2020.3.4f1
Yeah, it should be simpler in that case, just previewCommandBuffer.EnableKeyword("LIGHTPROBE_SH")
I'm very closely zoomed in... And you can see it's TRYING
It's REALLY TRYING
I can make out the red and white stripes of the floatie prop
You can see the sections if you notice the red pixels and the white ones
But as you can see... it's not quite... right
Still pretty black. Not sure why.
Are you still not specifying the shader pass?
I think this is another pass drawing on top, mostly obscuring the first correctly lit pass
Nah, I am specifying the pass
I actually think it's my render texture format
Since I created it with new RenderTexture(width, height, 0); where 0 is the depth
Mm, I think 8 is minimum to get proper depth writing/testing
Documentation says this though
(0, 16, 24 and 32 are supported)
been wracking my brain and I'm sure someone else has done this, but I want a null entry in the inspector to show a red label and make the label of every parent property up to the parent red as well
like so
was thinking originally of using an attribute to achieve this which works fine on the level of the property itself but doesn't play ball when going back up the stack
Is it the same editor drawing the whole stack of properties?
I was then thinking of going from the root itself but wasn't sure if using a default EditorGUILayout.propertyField would respect child properties custom property drawers
it's not the same type
it's all under one component
but each of the properties are varying classes that form the whole
like this
Assuming this is drawn with EditorGUI/Layout, as opposed to UI Toolkit, the only way to achieve this is to check for the null property in the parent drawers.
You can't retroactively change what has already been drawn in immediate GUI
was thinking it would have to come from the root editor drawer
It should be doable, but the SerializedProperty iterator is a bit of a pain to use
yeah
wasn't looking forward to recursively searching down the stack
would have to check if it is currently being drawn etc to save on wasted cycles
but still have to go down the stack to find all the null references :/
OKAY. I GOT IT TO WORK. Note to self. Camera must not be at the same Z coordinate as the object
Because then it'll near-clip
Also, don't forget you can enable anti aliasing on the render texture in its constructor. It looks pretty bad without it.
Or make the render texture higher resolution than the drawing rect to super sample it.
I'm just making the rt match the size of the available space in the window - the width of inspectors
Bu the end of this it's gonna feel like an entire external program inside of the Unity Editor lol
Agggh so turns out @short tiger that, although I CAN get the mesh to draw
I can't actually draw collider previews 😛
Can't draw circles, capsules or polygons
At least...not without a terrifying amount of DIY rendering code
Aggh so I can use Handles inside a render texture and that works great except for the fact that the matrix is all smashed
Does anybody know if there is a way to get the highlighted string in a TextMeshPro text field in the inspector? I am trying to find an answer it the documentation and have had a look at some TMPScripts that looked promising but I found nothing in this regard.
Ugh, I forgot what it's called
Effectively the sample there but it's quite undocumented
Thank you, I will give that a thorough look!
I came across this and it looked promising, but maybe it's because my lack of practice in working with Editor things that I couldn't get it to work: https://answers.unity.com/questions/275973/find-cursor-position-in-a-textarea.html
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
Yeah it's pretty much the same thing that I linked
I also wonder if things have changed with UIToolkit
IIRC they haven't when I looked a year back or so
But they might
I was also still on 2019 with shitty uitk 😛
Hrm, UIToolkit might be a lead, too 🤔
I haven't looked at that at all
Well, it has something for selecting strings in a TextField, but it doesn't look like it offers the other way around 🤔
Could check the source and see if there's some reflection way
UIElement's TextField has a textSelection object that provides a bunch of detail
You should check what you're actually dealing with though! Use the UIElements inspector to see whether it's even UIToolkit
Thank you, will do :) I feel like I'm stepping out of my current skill-level with this idea I had, so maybe I'll just need a bit more time to understand and learn before I can tackle this specific thing 
Reflections are definitely something I'm not prepared to tackle yet, I'd say 😉
All my friends tell me they are the path to the dark side 😅
Also to be honest while I haven't been participating in this channel much, us editor people are the best of them 😛
❤️
I'd guess you are very patient for sure :D Not only struglling with writing code for own programs, but also fighting with the code of assets or Unity itself to get stuff to work takes a special kind of dedication 😁
I'm making my own gizmo rendering and nothing has ever been this painful
Ha, I've tried that before
I always knew I would port my debugging thing from using a jabillion Debug/Gizmos.DrawLine to something more sensible
but I expected the hard part to be the rendering and not just routing gizmo calls correctly
Hmmmm you might have given me an idea though. Let's see how this rabbit hole will turn out.
I would advise downloading and using the Unity C# source (pinned to this channel), if you ever think you're close to something or want to check if something does what you expect it might, it's always a great resource
If a quick google fails me usually I will just search the source for some of the terms
wow, that's quite a resource. Thank you for pointing that out, it's been a while since I have used the pinned messages anywhere 
Anyone know a way to build a custom selectable list of items inside an Editor Window? Something like the Scene Hierarchy but as a list instead of a tree.
TreeView?
I need to do this with GUILayout/EditorGUILayout ideally
Nope
Is there then a way to get the remaining space while in a GUILayout.BeginArea()/GUILayout.EndArea() block?
What is lifecycle of PropertyDrawer? What can I cache on the instance and what I should not?
If I have multiple property of same type, will same PropertyDrawer be reused for them?
Generally yes
You can disable caching but it's been iffy when I tried it before but that might be on me
What header?
Why not just draw a button with a position, why do guilayout?
GUI.Button?
Again what header?
If you insist on guilayout then use a horizontallayoutgroup or use positions for both
Or use an expander
Eeeexpaaaaandeeeeer
not sure if this is the right channel to ask about this but, how would i hide variables when the bool is false? ive looked online and ive not found anything talking about doing it in scriptable objects
Use a custom editor
just had a try with that and im getting the error "'Object' does not contain a definition for 'HasChoice'" and for the other variables
not target do myBehaivour.
hey there, does anyone have experience with scene dependencies?
When running my scene on mobile instead of desktop I delete a number of assets as well as prefabs from serialized fields in my managers. Yet, even when the scene is basically empty, when I use Select Dependencies it still shows all the assets that were previously linked in the manager. How can I get rid of these conections?
EDIT: It seems the reason is that some of my objects are connected to prefabs, when I unpack the objects with the now empty connections, the dependencies are gone
Am I not disposing of something properly here, or is Unity just being arsey again?
Impossible to say without seeing some code I think
The problem is I don't know where it's coming from, it seemingly just happens sometimes.
Ah, it's the gameobject inspector. Then I'd imagine it's not your fault
🙃 okay, thanks. It's annoying as well because I can't reliably reproduce it enough for a bug report either
is there a way to add/remove a define constrain for an assembly definition file with editor script? I can't find a way, do I have to regenerate the whole file?
Is it possible to get old projects using these files
So I'm working on a custom editor tool for modifying my own terrains via tiles/grids and I'm trying to overwrite the Unity events that interface with the scene view when I'm painting or using my tool. I'm currently doing Event.Use on EventType.MouseDrag EventType.MouseDown and EventType.MouseMove and it's working to stop the actual object selection and scene camera rotation but I can still see this box selection behavior. Any ideas how to correctly set this up?
int id = GUIUtility.GetControlID(FocusType.Passive);
HandleUtility.AddDefaultControl(id);
No clue what those files are from or what they contain so really can't say. But in general, no. Unless you have the .cs files and .png files etc. that are used in the project, there is no magical way to get them back.
Thank you!!! Was struggling to find an answer to this
what is it that decides the window name for EditorWindows?
EditorWindow.Title
ah, thanks
that seems to be deprecated, but i tried this and its still called "MyWindow"
[MenuItem("Multi Scene Workflow/Scene Manager")]
static void Init()
{
// Get existing open window or if none, make a new one:
SceneManager window = (SceneManager)EditorWindow.GetWindow(typeof(SceneManager));
window.titleContent = new GUIContent("Scene Manager", "Loads, Unloads, and Saves Scene Collections");
window.Show();
}
What's your class called?
wait hold on ive accidentally made two classes the same name so its creating an error
Yeah I feel like there's something else going on
either in your code or the layout engine is messed up and you should reset it
there we go. it was the class name conflict so it didnt update 
what do i use to save settings for the editor?
i want to save an array of paths so its easier available and i dont need to keep it in a scriptable object or something
as this is only for loading scenes with a window
Is any body know how to create editor window aside from another one ,like this ?
In your window or application wide?
you could use EditorPrefs, or with UIToolkit use ViewData
Please explain
I usually just save a json in the ProjectSettings folder
ive ended up just making a method that gets all the paths when i need them. as i only need them when i press the load button
I am creating a custom window editor in unity, and I can't get multiple taps to load side by side when i click on the menu item
[MenuItem ("GameObject/My Editor")]
public static void ShowWindow() {
var w = GetWindow<MainWindow>();
var tap = GetWindow<MainSidebar>("sidebar", typeof(MainWindow));
}
this is what i do
this is what i see
this is what i want
this typeof(MainWindow) is desiredDockNextTo so you are getting what you asked for
There's a few way to save data in editor with different use cases:
EditorPrefs, good for 1 or 2 values that are fine to be shared between projects
ScriptableSingleton, the best way for more complex serializable data
UITK ViewData/Serialized Fields on the editor window, good for temporary data in editor windows that needs to survive domain reload (does not persist if you completely close the window)
SessionState, as the name says, persists during the whole session of Unity and is deleted on close
but what i want is creating MainSidebar beside MainWindow
I know what you want, but that is not what you have programmed
yes,but i don't know how to create window that i want...
it's simple.
- dont pass a desiredDockNextTo parameter
- get the Rect from MainWindow
- use that Rect to calculate the position of MainSidebar
is this works on editor window?
Try it and find out

anyone know what's a safe way to get a unique id for Progress.Report(), apparently it needs to be an int
using it in an editor window if that helps
nvm, found it, your suposed to call Progress.Start first,t hat returns the id 🙂
So I'm working on an editor tool for painting custom meshes and I'd like to use a hotkey to toggle the feature on and off. Problem is it's an Editor Window so I'm using a delegate for OnSceneGUI to check for input. Whenever I toggle the hotkey on it works but gives me this error in the console Getting control 0's position in a group with only 0 controls when doing Repaint
I suppose this is because the OnSceneGUI events are happening between the Layout and Repaint stages, but I'm not sure how else to check for input within the editor.
Hello! im trying to install unisense, however my unity is being stubburn.its a git plugin, and even on the offical unisense github page it says to install it through a link using "install git plugin with url" heres a photo of what my unity tells me! (one moment unity is booting up)
Call this after your button logic https://docs.unity3d.com/ScriptReference/GUIUtility.ExitGUI.html
here is the unisense github page! https://github.com/nullkal/UniSense
Read the whole error
What's in the whole error?
error adding package
It only says that when you click it in the console window and look at the whole thing?
oh shit
i feel really slow rn
but like why do i need git installed on my pc...
shouldnt it just install thru unity?
i feel really really slow rn
Unity doesn't have a built in git
Doesn't seem to be working. I think because it's exiting the GUI for the scene view, not the editor window. I'm showing all my controls in an editor window but I want to be able to hotkey them from the scene view.
Could put it in OnGUI but then I could only read the inputs when the active window is the editor window and I want to be able to turn the feature on and off from the scene view.
You should probably be using a ShortcutAttribute with the context set to the SceneView if you're using your own shortcut. I presume it would then be called at a nicer time
And then the shortcut would also be rebindable
Yeah that sounds better indeed. Any pointers on how to set that up?
I guess one hack would be to make a private bool in the entire class and just toggle it and exit the GUI with OnGUI when it's true and set it back to false
finally, it works. thank you vertx
I don't really know where to ask this question, but if anyone has some experience with Perforce:
Is it possible to automatically checkout files that you want to change?
The issue is GUI changing between Layout and Repaint, ExitGUI just throws an exception that causes IMGUI to rerun.
So the answer is either to change your data outside of a IMGUI update, or to ExitGUI if a change is happening
I was hoping that ShortcutAttribute would be the former, and involve no work, while getting the benefits of a configurable setup