#↕️┃editor-extensions

1 messages · Page 71 of 1

gloomy chasm
#

What I really want is the component drawers.

#

OH F me!

#

Your 100% right and I am just stupid. I had it in my head that CanEditMultipleObjects was for components (I was thinking of CanHaveMultiple). I am real sorry, and thank you.

trim tendon
#

I'm modifying Texture2Ds data via an AssetPostprocessor. These Texture2Ds are all stored within a SpriteAtlas. How can I ensure the SpriteAtlas is updated and repacked after I modify the data?

onyx harness
#

You use your eyes

trim tendon
#

@onyx harness No, seriously. I want this to be automatic.

onyx harness
#

I would say look for the code executed when you press the update button

sinful pulsar
#

hello. ive been having some trouble with visual studio code, the intellisense doesnt show up. i have the c# extension in VSC, and VSC is set as my external script editor. any idea what i can do?

#

also, im not sure if this is the right place to ask, so i apologise if ive made a mistake

waxen sandal
sinful pulsar
#

yes

waxen sandal
#

No clue then

chilly stone
#

Hey, is there a way to add a button to all inspector windows? For example, right next to "Add Component" button?

short tiger
#

@chilly stone I would say the first step is finding where Unity is drawing that Add Component button

#

Looks like it's being drawn with UI Elements in the latest Unity versions

chilly stone
#

Hmm is it? In 2020.1.4f1 it's inside IMGUI container
It's really hard to find any info on such narrow topic. I guess I'll look into source code of some packages that modify an inspector...

waxen sandal
#

You just get the root element

#

Then find hte IMGUI container it's drawing in

#

And add an element next to it

chilly stone
#

@waxen sandal how would I get that root element, from what kind of script?

waxen sandal
#

Find the editor window with Resources.FindObjectsOfTypeAll

chilly stone
#

Oh it works that way

#

So do I just do that in a class that doesn't extend anything similar to EditorWindow?

waxen sandal
#

Depends

#

You might have to do it in some event since it might recreate that button every time your selection changes

chilly stone
#

Yeah that's what I'm trying to fugure out

waxen sandal
#

I'd just try a few things

#

InitializeOnLoad

#

Selection.SelectionChanged

#

etc.

onyx harness
#

Override Editor for GameObject, draw a button at the top of the Inspector

chilly stone
#

@onyx harness yeah that works too, but can I modify or remove certain elements in inspector?

onyx harness
#

Define elements

chilly stone
#

Buttons, checkboxes, text fields

onyx harness
#

If elements are drawn using IMGUI, you are doomed

#

If it is using UI Toolkit, then you can manually scan and remove them.
This path is much more likely to raise issues

chilly stone
#

I mean, Unity doesn't use UI Elements for default inspectors yet, so no

#

Inspector stuff is inside IMGUI containers. Let's say, I want to modify how inspector header looks, how do I access it?

onyx harness
#

You trick it

#

Going through UI Toolkit, find the header, draw over it

chilly stone
#

Oh so I cant actually remove it from hierarchy and have to draw over it?

#

Interesting

onyx harness
#

Oh you can remove it

#

I tend to keep them, in case they are "needed"

chilly stone
#

Oh neat stuff

onyx harness
#

In this GIF you can see I can rename Component

#

I draw over it

chilly stone
#

A little intimidating compared to simple inspectors I'm making :)

#

Are you using purely IMGUI?

onyx harness
#

A mix

chilly stone
#

Oh, I would also like to ask is it sane to make property drawers using UI Elements?

onyx harness
#

I never used them this way, but it is the future of it

chilly stone
#

Yeah, I hate to extend UnityEditor.Editor for each inspector that has UIE drawers in order for them to be visible...
When will they make inspecotrs to use UIE by default...

#

It's always on their roadmap but never gets finished

onyx harness
#

This means rewrite the whole Editor world

#

Not gonna be done in one year

leaden lodge
#

hey all I'm using UI Elements and trying to get a value from a Toggle. I've noticed there's no "onChange" event so what's the proper way to do this?

split bridge
#

most of the UI Toolkit elements have RegisterValueChangedCallback e.g. Foldout does - I assume Toggle has one too @leaden lodge

leaden lodge
#

I see it, I'll try it in a bit

#

thanks @split bridge

gloomy chasm
#

@chilly stone Oh I was just messing with the inspector stuff most of this weekend. If you got any questions you can feel free to @ me. Opening the UIElements Debugger for the inspector will show you what you have to work with. It is actually quite a bit.

chilly stone
#

Sure, for now I have no questions :)

whole steppe
#

How do I set up C++ in Microsoft Visual studio

civic river
whole steppe
#

Not C. C++

#

But are you saying just search it up?

chilly stone
#

@gloomy chasm hey, so how can I get a whole hierarchy of inspector window?
This is how I'm getting an actual window:
var inspector = Resources.FindObjectsOfTypeAll<EditorWindow>().FirstOrDefault(w => w.GetType().Name == "InspectorWindow");
But inspector.rootVisualElement doesn't conatin any children or parents. Can I somehow load them in or am I doing it wrong?

gloomy chasm
#

@chilly stone When are you getting the inspector window? It may not be loaded yet. I had to put the call inside of a method called from EditorApplication.delayCall

split bridge
#

Also if you're trying to find UI Toolkit elements in Unity editor windows, a lot of them don't have any as they're still mostly imgui

gloomy chasm
#

That is true for most, but the Inspector actually ahs quite a few. Each component header, body, and footer is it's own element.

icy falcon
#

Anyone know of extensions that allow me to change my formatting?
I want this

Function() {
  if () {
  }
}

Instead of this

Function()
{
  if ()
  {
  }
}
onyx harness
#

@icy falcon

icy falcon
#

oh ok ty

#

I looked in formatting > general but didn't notice new lines

glacial onyx
#

Hiho! I made a simple Editor Script that resets object position, but now I want to add an Undo step to it.
I've tried this:

                go.transform.position = Vector3.zero;``` 
but it doesnt seem to work. What am I doing wrong?
gloomy chasm
#

I think you need to use Undo.RegisterCompleObjectUndo instead.

#

I have never actually used RecordObject my self or seen it used while looking the Unity's source on Github.

#

Idk what it does tbh 😛

uneven arrow
#

Have you tried Undo.RecordObject(go.transform, ... instead?

glacial onyx
#

going to try both right now 😮

#

well, @uneven arrow said what i already have, and @gloomy chasm doesn't seem to work either.
There are some steps we are probably missing

uneven arrow
#

Idk why, but I have this working w/o problems. It's in Editor script though, executed from OnInspectorGUI — in case it's any relevant

gloomy chasm
#

Yeah, @glacial onyx where is his being run from?

glacial onyx
#

It runs while using the unity editor. No playmode or anything

#

sec, ill share the code

#

its just a command, doesn't say anything about OnInspectorGUI

#

file is in Editor folder

gloomy chasm
#

Have you tried recording the transform instead of the whole GameObject?

#

Also, unrelated to your problem, but I would recommend using undo groups

uneven arrow
#

Just tested a MenuItem command — doesn't work either.

#

So I'm guessing it only works within one of the Editor callbacks

glacial onyx
#

@gloomy chasm that worked! Crazy simple solution >.< gosh, i'm so dumb.
It works now, thank you! 🙏

   go.transform.localPosition = Vector3.zero;```
onyx harness
#

".transform"...

#

@glacial onyx told you that

uneven arrow
#

Have you tried Undo.RecordObject(go.transform, ... instead?
@uneven arrow Lol

#

Now I have to figure why my stuff doesn't work 😬

glacial onyx
#

ah, i didn't read it through, im sorry @uneven arrow >.<

#

i read it, but i didnt SEE it, you know

onyx harness
#

Be careful please when people send help, sometime we crush our brain to understand while we obviously already gave the solution.

#

It's a non-sense

glacial onyx
#

Indeed. Imma read and compare more thoroughly

uneven arrow
#

I've been struggling with this too. The way I understood it was: RecordObject only understands direct modifications of object's properties, not its subtree. Also, the object has to be serializable (and probably a subclass of Component too)

onyx harness
#

It's because Object are treated differently.

#

As reference, not plain object

#

This subtlety makes the whole thing

uneven arrow
#

Still depends on how they actually implemented the RecordObject, but yeah 👍

onyx harness
#

Not even.
It is how the whole serializer works.

#

Otherwise, if you record a GameObject, that obviously has a Transform, which also links to its GameObject.
Infinite loop.

gloomy chasm
glacial onyx
#

So best way is to record a GameObjects properties, whatever they may be, yes?

#

@gloomy chasm pretty interesting. Imma be sure to use much more of these for sure. This is incredibly useful

onyx harness
#

if you record the GameObject, it is because you plan on modifiying one of its direct properties.

#

Name, flag, static, layout, etc.

uneven arrow
#

Otherwise, if you record a GameObject, that obviously has a Transform, which also links to its GameObject.
Infinite loop.
@onyx harness Don't want to make an offtopic out of it, but it's definitely possible to finitely traverse the graphs with loops simply by remembering which nodes you've already traversed 😉

onyx harness
#

I know I know it's possible, but it doesn't work like that in Unity

#

They recently implemented new attributes like [SerializeReference] to implement this behaviour.

#

But this is very recent.

gloomy chasm
#

(And it is amazing)

onyx harness
#

And we've been fighting hard to have it.

#

Not me directly, but I had a discussion with Superpig on Slack (The main dev of the Unity serializer)

#

He said "performance reason"

#

Look at it now, they implemented it

glacial onyx
#

Well, just ran into an issue with this. How about resetting an Active Element. I deactivate it, but cant undo to reactivate ^^'

onyx harness
#

Strange, should work.

glacial onyx
#

Sec, Imma think a bit more about this

#

Well, ignore what I said, it works. I was making unnecessary comparisons

normal leaf
#

Hello everyone

#

cannot see this object in my editor

#

fixed

tough cairn
#

trying to use GUILayout in PropertyDrawer but it gives me group id 1 error

onyx harness
#

First rule of PD, don't use GUILayout

tough cairn
#

is the 2nd rule have something to do about the 1st rule ?

#

swapped to using rect's but not all the elements are appearing behind the normal UI lol

#
Rect buttonRect = new Rect(
  position.x,
  position.y + ((1 + buttonHeight) * (( i + 1 ) - 1)),
  position.width,
  buttonHeight - 1 );
#

oh nvm had a wrong return value in GetPropertyHeight

quaint zephyr
#

Custom Inspector. I typically used EditorGUILayout no issues. But in this particular situation, I have a Horizontal Group where I used EditorGUILayout.ObjectField, but I want to follow up with a couple GUI.Buttons. The buttons were a sinch to make because of EditorGUILayout.GetControlRect().
However, the problem now is how do I get EditorGUILayout's control rect "back on track" now that GUI class drew over it? Is there a way to "set" the ControlRect in the EditorGUILayout?

whole steppe
#

Has anyone worked with EditorUtility.DispalyProgressBar and EditorApplication.update before?

#

I'm currently having an issue where I've subscribed to the EditorApplication.update event, and I'm calling EditorUtility.DisplayProgressBar inside the function, but it's not displaying

onyx harness
#

@quaint zephyr GUILayout.Space

sage sedge
#

Hello. How can i cast this so it works? thank you i have never had experience with custom editors before.

visual stag
#

an object field takes one object

#

you have an array

sage sedge
#

How do i solve

#

ive tried numerious combinations, but obviously i dont understand what im doing

sage sedge
#

Anyone?

visual stag
#

if you want to display an array you should probably use PropertyField (SerializedObject, SerializedProperty, etc)

tough cairn
#
void OnSceneGUI()
{
    using( new GUILayout.VerticalScope( GUI.skin.window ) )
    {
        using( new GUILayout.HorizontalScope() )
        {
            GUILayout.Label("Hi");
        }
    }
}
#

i want to create something like this , i know its possible i have done it in the past

#

ok found it

#

it needs to be wrapped in Handles GUI

#

Handles.BeginGUI(); :: Handles.EndGUI();

tough cairn
tulip plank
#

Is there a way to add custom menu items to the existing Animator context menu(s)?

wispy delta
#

@tulip plank [MenuItem ("CONTEXT/Animator/Your function")]

#

example of adding a function to the Transform context menu to randomly rotate it

[MenuItem ("CONTEXT/Transform/Randomize Yaw")]
private static void RandomYaw (MenuCommand command)
{
    if (command.context is Transform transform)
    {
        Vector3 v = transform.localEulerAngles;
        v.y = (v.y + Random.value * 360f) % 360f;
        Undo.RecordObject(transform, "Randomize Yaw");
        transform.localEulerAngles = v;
    }
}
tulip plank
#

Innnteresting, I will check this out, thank you very much!

wispy delta
#

this is super nitpicky but...

I'm working on a foldout scope so i can define a scope and any gui within it will only be drawn if the foldout is expanded

usage looks like this

using (var foldout = new FoldoutHeaderScope(resolutionPerMeter, "Texture Settings"))
{
    if (foldout.expanded)
    {
        // Draw properties here
        EditorGUILayout.PropertyField(resolutionPerMeter);
        EditorGUILayout.IntPopup(maxResolution, MaxSizeContents, MaxSizeValues);
        EditorGUILayout.PropertyField(compress);
        EditorGUILayout.PropertyField(storeExtraInfo);
        EditorGUILayout.PropertyField(padding);
    }
}

checking if (foldout.expanded) is a lil redundant since it's implied that the gui within the scope shouldn't draw if the foldout isn't expanded. not really a big deal, but is it possible to disable gui drawing until the scope is disposed automatically if the foldout isn't expanded? would be cool to just plop gui code within the scope and not have it draw/not drawn automagically based on the state of the foldout

#

fuck wrong gif

onyx harness
#

I would say yes, I think it is doable, but the trick is tricky

#

@wispy delta use clip

wispy delta
#

goootcha. i haven't used clipping before so correct me if i'm wrong, but would the idea be to BeginClip with a rect flush to the bottom of the foldout header with a height of 0 if the foldout is not expanded?

wispy delta
#

making a clip scope correctly hides the gui, but the layout is still affected @onyx harness
do you know if there's a way to avoid that? also if you think this is a dumb thing to do lemme know haha, it's not a big deal if i have to do a single bool check lol

onyx harness
#

Maybe use Area

#

@wispy delta

#

Or the other trick would be to use GUILayout.Space with a negative value, to negate the height used by your drawings

wispy delta
#

oh damn that's genius haha
looks like Area works tho! thanks 💙

quaint zephyr
#

@onyx harness Thanks

#

So I have done quite some coding on editor extensions, particularly, when editor loads it downloads data I have online for debugging feedback files that are submitted by users from their apps. It's all working fine. But now the issue is when it came time to build, I am getting a bunch of errors because quite a few of my scripts are UnityEditor based and use attributes and EditorApplication events and such like.

#

Some of these scripts I don't even need in production, but I do use in development

#

How can I EXCLUDE these scripts from build?

#

I know how to exclude parts of scripts using #if UNITY_EDITOR directives.

#

But would I just slap #if UNITY_EDITOR around the entire class? Or is there a more simpler/cleaner/conventional approach to this?

onyx harness
#

@onyx harness Thanks
@quaint zephyr Huh? What have I done?

#

Editor scripts are not embedded in the build.

#

Even better, anything inside folders Editor are not embedded

quaint zephyr
#

@onyx harness it was for my last question yesterday.

#

Yeah that's what I thought too, but turns out I had asmdef for that group of scripts and in there it had iOS ticked instead of just Editor by itself. 🙂

whole steppe
#

Does anyone know how to create one of the new "Busy" progress bars in 2020.1? I need to run a blocking operation on my scene to process a bunch of data but at the moment all I can manage to do is a background task

visual stag
#

There's also a cancellable version. You just call the Display repeatedly with a new progress value.

blissful burrow
#

hms, is there a way to detect when a prefab has been edited, from the perspective of the instances?

#

I currently have an issue where I want all my instances to update cached non-serialized stuff when you edit their corresponding prefab

#

there is a callback in prefab stage when you leave edit mode there, so I could scan the scene for instances of the edited prefab and update them, but, this feels like it might be really costly and wasteful, and it also doesn't cover the case where you edit the prefabs through the inspector

onyx harness
#

Perhaps EditorUtility.IsDirty

#

But this works for one Object

wicked elm
#

Hello anyone here can help me ?

#

but does not work.

Error i get:

FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

ReplaceMaterials.ReplaceSelected (UnityEngine.Material material, UnityEngine.Material replaceMaterial, System.Boolean recursive) (at Assets/Editor/ReplaceMaterials.cs:54)

ReplaceMaterials.OnGUI () (at Assets/Editor/ReplaceMaterials.cs:23)

#

Any ideas ? Please if anyone understand this - it s a big help, i have 0 Plan here.

onyx harness
#

You have null mesh renderers

wicked elm
#

so Script need to have a Mesh Renderer ?

onyx harness
#

Oh sorry, your exception is not even NullException

#

The stack trace does not even follow the script lines

wicked elm
#

i am Sorry, but: i happy if you can help. Because: i do nothing understand from this script.

== 0.

if (brainhavefailed== True)
{
thePersonAsksistostupidforthis = true;
}

onyx harness
#

You can give it a try to NG Asset Finder Free on the Asset Store

wicked elm
#

so i never write Editorscripts or somethign big.
i do not understand the codeLines he use.

but a Script like this, will be a so much big help in my project ...

#

NG Asset Finder ?

wicked elm
#

oh boy :(
Thank you for the Asset, but this makes a Script of ~ 100 Lines
to a Handbook of 49 pagves, eaven to understand what this assetfinder do.

#

not so really useful, because: Nobody knows if he find anything at the end

#

hm, no i am sorry, will not help, because: does work with gameobjects if i umderstand right ?

onyx harness
#

You did not read well then

wicked elm
#

yeah, i understand what it does, but not how it can help me.

if i have a Reference in Scene hmmm. Moment, Did it work with materials to or only gameobjects ?

onyx harness
#

It works with any Object against any Object

wicked elm
#

no i am sorry, this is not useful.

1 GameObject have 4 - 6 Materials
1 prefab, having 700 GameObjects using this 6 Materials.

so i need to replace the Materials, not the Gameobjects.
( i hope you understand what my problem is )

onyx harness
#

And it looks through the Project, or the entire scene

wicked elm
#

yeah i see 🙂 it s not that bad, but not useful in my situation

onyx harness
wicked elm
#

but, hm, maybe ... one moment

onyx harness
#

This picture alone does what you said

#

But you preferred to read fast and skip 90% of the information

wicked elm
#

one moment.

#

yes, because you have a Documentation, for all aassets, i just look for the "Finder"

onyx harness
#

And the link points directly to the right documentation

wicked elm
#

yeah, give me a second, i want to try something.

onyx harness
#

If you feel it is too big, I can't do much for you unfortunately

wicked elm
#

one moment, i need more references in my scene 😄

#

just give me a second.

#

(y)

#

👍

onyx harness
#

It worked for you?

wicked elm
#

worked a little other than expetet, but it works this way 🙂

onyx harness
#

This tool allows you to replace or find any Object. You provide one, I do the search.

wicked elm
#

the First ( i have not done until this moment ) is to replace all Materials i have . because my Blender model have different names here or there

But this i need to do 1st Time > after this it should work in minutes not in horus i need today

onyx harness
#

Replacement is pretty quick

wicked elm
#

i see 😄

#

works really nice

onyx harness
#

You see, no stress here, stay relax and calmly read the advices/tips you are given in this channel, we are here to help

wicked elm
#

hm not that bad idea: i think i put this in my favorites, not this month ( out of money for this month ) but ... 😄

#

can be a nice idea

onyx harness
#

Try NG Tools Free

#

It gives you a taste of the power under

#

And there is several free tools in there

wicked elm
#

i got Assetfinder this time, i do have a look in the other next time 🙂

#

i see, you have a lot online there

#

oh , moment i write you private

onyx harness
#

Just to cover all the tools, taken one by one, it is not that big

leaden lodge
#

weird question, is it possible to change the setting for which input system the current project is using from script? I'd like to make the current project use the new Unity input system in an editor script

severe python
#

Is there a way to make custom project templates for the Unity Hub?

waxen sandal
#

I don't think there's official support

#

But iirc they're just zipped in some dir

severe python
#

a project template is exactly what I need

#

not even zips

#

just directories

leaden lodge
#

before I continue down this rabbit hole of reflecting into internal functions is there some official Unity-supported way of changing the new input system settings in editor script?

#

I found two settings inside of ProjectSettings called enableNativePlatformBackendsForNewInputSystem and disableOldInputManagerSupport and I am currently looking at reflecting into internal functions to change them

#

this is strictly an editor script so it's not happening at runtime

waxen sandal
#

Tbh, I'd just look at the settings window

leaden lodge
#

hm

#

does the window need to be opened?

waxen sandal
#

I mean the source

#

Then just call the same method

leaden lodge
#

oh I am looking at the source for the window

#

it's changing a serialized field which uh

#

doesn't exist

waxen sandal
#

Sure it does

#

It might just be native

#

And not on the C# side

leaden lodge
#

this.m_EnableInputSystem = this.FindPropertyAssert("enableNativePlatformBackendsForNewInputSystem");

waxen sandal
#

Fonts have a bunch of those things as well

leaden lodge
#

yeah that's what I suspect too

#

and that's the current route I'm going down, just trying to access their internal functions to modify this

#

I just didn't want to continue down this path if there was some easier way to do it

waxen sandal
#

I don't remember the exact way to get the ProjectSettings SerializedObject

#

But once you get that it should be easy

#

@onyx harness probably remembers

leaden lodge
#

typeof(PlayerSettings).GetField("_serializedObject", BindingFlags.Static | BindingFlags.NonPublic);?

#

seems to work

#

oh hm it's null when I try to get a value

#

ok I found the GetSerializedObject method and it grabbed something let's see how it goes

leaden lodge
#

yeah seems to work

#

thanks @waxen sandal

wispy delta
#

Is there a way to know if an Editor is expanded? I'm embedding some component editors within another component's editor instead of having them drawn in the inspector and need to create foldouts. SerializedProperty.isExpanded is handy for storing (and remembering) if a property is expanded or not, but I can't find an equivalent for an Editor

strong phoenix
#

hi want to ask

#

how to get sprite can search through editor?

#

want to create something similar like this

#

but in UnityEditor + has a preview of the image

onyx harness
#

@onyx harness probably remembers
@waxen sandal you just need to load the settings directly from ProjectSettings/ with AssetDatabase

#

Is there a way to know if an Editor is expanded? I'm embedding some component editors within another component's editor instead of having them drawn in the inspector and need to create foldouts. SerializedProperty.isExpanded is handy for storing (and remembering) if a property is expanded or not, but I can't find an equivalent for an Editor
@wispy delta it exists, but it's quite stuck into Inspector code

wispy delta
#

I figured. I was spelunking around the decompiled editor code but couldn't find it anywhere!

onyx harness
#

but in UnityEditor + has a preview of the image
@strong phoenix your gif is already in Unity Editor and it shows a thumbnail of every sprites. I don't get it

#

I figured. I was spelunking around the decompiled editor code but couldn't find it anywhere!
@wispy delta I'm not home, can't look, but I'll give a glance tomorrow

wispy delta
#

Would be so rad if unity let you store your own custom serialized data on a serialized object for stuff like this
so.AddProperty("expanded", false)
Would be so helpful

strong phoenix
#

@strong phoenix your gif is already in Unity Editor and it shows a thumbnail of every sprites. I don't get it
@onyx harness oh sorry, iin EditorWindow

#

not in inspector

#

and i want have a preview image of it, how do i do that(?)

#

if i can say, want hav sumthin like this in my EditorWindow

onyx harness
#

Would be so rad if unity let you store your own custom serialized data on a serialized object for stuff like this
so.AddProperty("expanded", false)
Would be so helpful
@wispy delta well it already exists, just need to find it

wispy delta
#

Oh neat! Good to know

onyx harness
#

if i can say, want hav sumthin like this in my EditorWindow
@strong phoenix your Object field? Set a big height. I don't remember the minimum.
But the preview automatically shows up if the height is enough.
Perhaps 140F.

#

Or more like 100 maybe

#

Just give it a try

chilly stone
#

So I'm trying to make a scene profile editor. Basically, it's an editor for scriptable object that contains a list of scenes which you can load for quick testing. I implemented a reorderable list using UI Elements. Each element in a list has PropertyField that holds an individual SceneReference, which is drawn by IMGUI drawer. It looks like this:

#

And it works 100%, scenes get added and removed, but I get those errors every time I remove an entry from a list (by pressing minus button)

#
tough cairn
#

what's the name of the node graph api ?

sleek robin
#

Hey,So for some reason when I was invited to a team,I can't see it in unity hub,and I can see another team. I tried logging in again,but I still can't see it
I am not sure where to put this

chilly stone
tough cairn
#

i need to make a shortcut for this sucker

onyx harness
#

@tough cairn UnityEditor.InspectorWindow.isLocked

tough cairn
#

im guessing its for the current focus one ?

onyx harness
#

Yes

tough cairn
#

ty ty

onyx harness
#

This is not static

tough cairn
#

yea im looking at it rn

#

https://github.com/Unity-Technologies/UnityCsReference/blob/61f92bd79ae862c4465d35270f9d1d57befd1761/Editor/Mono/Inspector/InspectorWindow.cs#L29

onyx harness
#

Just use m_AllInspectors and the job is done

tough cairn
#

i see - GetAllInspectorWindows()

#

looks like a job for reflections

onyx harness
#

Basically the same

tough cairn
#

true true

onyx harness
#

Or you can directly use ActiveEditorTracker.sharedTracker.isLocked

#

This one is for the current one

tough cairn
#

isn't not internal ?

onyx harness
#

This one is public

tough cairn
#

oo

#

ill try this one 1st

onyx harness
#

Inspector uses this one.

tough cairn
#

not all have a lock

#

but all implement this class , right ?

onyx harness
#

Sorry I didnt understand

#

Who is all?

tough cairn
#

Hirarchy , Project , Inspector have the lock

#

scene, Console don't

onyx harness
#

Lock is specifically Inspector

tough cairn
#

i see 3 locks on that img

onyx harness
#

This little portion of the window is drawn by:
void ShowButton(Rect r)

tough cairn
#

the hamburger menu is urs ?

onyx harness
#

As you can see, i used it to draw a book and a button

#

Yes

tough cairn
#

neat

onyx harness
#

ShowButton works like OnGUI with a Rect

tough cairn
#

for any Window class ?

onyx harness
#

Any, just respect the definition

#

Like Update, OnGUI, Awake, etc.
ShowButton works the same

tough cairn
#

i see

#

handy

#

🤔 i need a cheat sheet of those lil things no one actually speaks about

onyx harness
#

I will do one "soon"

tough cairn
#

hhh

#

include "AddItemsToMenu"

#

👍

onyx harness
#

I will do much more

#

What you see, is Unity Editor in HTML 🙂

#

I am willing to make an interactive tutorial on a website

tough cairn
#

i do enjoy using immediate mode UI - its relatively clean and quick for simple tasks

onyx harness
#

Where you just need to hover an area to receive an explanation

tough cairn
#

but that's on a whole another level beyond me

#

sounds awesome

onyx harness
#

There is a shitton of hidden spot/gem, editor people don't even imagine

tough cairn
#

"Hand" - did u replace the icon with text ?

#

or just the GUIContent ?

onyx harness
#

It purely a prototype

#

It's a website

#

Not a software

tough cairn
#

oooo

#

i see

#

do u need all the lil icons ?

vapid scarab
tough cairn
#

its a single file xD

onyx harness
#

Looks nice

#

i have many scripts already to display icons

#

but can you export them to a file?

tough cairn
#

i think i had something like that added there

onyx harness
#

how would i display a field like this in a custom EditorWindow?
@vapid scarab I guess it is an ObjectField?

tough cairn
#

without the actual export

#

it scans it somehow

onyx harness
#

Because Unity textures are read-only

vapid scarab
#

hmm, maybe my usage was wrong, i tried that, didnt display. ill try again

tough cairn
#

the scans don't include all the icons

#

i found a list of extra icons that are missing and added them manually

#

ah ok :: Resources.FindObjectsOfTypeAll<Texture2D>()

tough cairn
#

@onyx harness any way to draw on top of the inspector ?

onyx harness
tough cairn
#

yea lol - that's too OP

onyx harness
#

This is not an easy task

#

You can inject yourself using UI Toolkit

tough cairn
#

ok nvm then , its not something i rly need

#

looks good tho

onyx harness
#

Thanks

lone turtle
#

So.. i recently downloaded the headless builder, its editor extensions were part of the editor.. Then some else crashed Unity and its mention isn't there anymore

#

can't figure out how to gets its menu back..

#

i try to reimport the packae and it won't let me select the areas where the scripts, fonts, and so on are

#

deleted it completely and re-added it... it must of made changes that weren't saved before my unity editor crashed

shrewd remnant
#

i am calling GUILayout.Window in top of every element still its showing under them how can i fix it

onyx harness
#

What is GUILayout.Window?

waxen sandal
#

It's order dependant

#

If you want to draw it on top it need to be the last one you draw iirc

tough cairn
#

how to stretch graph view to parent size ?

tough cairn
#

is there a way to create UIElements without xml and uss ?

#

ah nvm i see there is a IMGUISupport

glacial onyx
#

Hiho!
How do I detect if mouse is inside the game window tab in an editor script?

gloomy chasm
#

That should do @glacial onyx

glacial onyx
#

@gloomy chasm imma check it out, thank you again! 🙏

#

@gloomy chasm doesn't exactly tells me if im in game window, but i manage to get its reference with 'getInstanceID()' which is pretty nice. Thank you!

gloomy chasm
#

@glacial onyx Haha, well I mean I think they only way to get more direct was if there was something called like IsMouseInGameWindow but that would be honestly pretty useless most of the time. You can do a check if the window is the game window and you will have what you are looking for 🙂

whole steppe
#

Hello friends,
is it possible to change the font size in the tabs ?

#

i mean the tab title "Main" "Interactable" etc.

onyx harness
#

Change the button style

#

GUI.skin.button

#

@whole steppe

whole steppe
#

let me see.

tough cairn
#

how to flex items on the vertical axis ?

#

my toolbar is appearing under the body element

#

am i doing something wrong ?

tough cairn
#

ok nvm i figured it out -> removed Body.StretchToParentSize();

civic river
#

Hello peoples, I'm wondering if this is a bug or I'm not understand something about UI elements. I have two elements that both have a links field.

[SerializeField]
public List<NodeLink> links = new List<NodeLink>();

The UI elements debugger clearly shows them as different elements, but when I expand or contract the list for one element in does so for ALL elements with the links field.

waxen sandal
#

Sounds like a binding problem

tough cairn
#

can something like this be done : cs var vsa = new VisualTreeAsset { text = "<UXML ... " };

chilly stone
#

@tough cairn why are you looking for ways to couple everything together? That defeats the purpose

#

UI Elements was designed in a way to separate concerns and make your tool development easier. Don't make it hard for yourself, it takes couple of hours to learn uxml and uss syntax grumpy_cat
Don't like it? Use IMGUI

tough cairn
#

k

#

i do

#

i use both now

chilly stone
#

We're kinda forced to use IMGUI for property drawers currently

tough cairn
#

i think immediate mode is superior, change my mind

chilly stone
tough cairn
#

( not IMGUI vs UIElements )

chilly stone
#

What makes immediate mode superior to UIE?

tough cairn
#

immediate mode as in a design paradigm , i come from sass less html angular vue ect ... learning imgui just makes so much sense

#

speed

chilly stone
#

UIE is event-driven, IMGUI is update-driven, but one makes more sense and afaik is performant (UIE)

tough cairn
#

what u see is what u get

#

sure , we are talking about specific api's , im talking about a design paradigm , imgui could be optimized but unlikely will , i understand that

chilly stone
#

If you're used to IMGUI and don't want to learn new paradigm (although I wouldn't call using events and queries a paradigm) - completely understandable, by all means use it, untill it's deprecated.

tough cairn
#

ehmmm

#

read above

#

immediate mode as in a design paradigm , i come from sass less html angular vue ect ... learning imgui just makes so much sense

chilly stone
#

So? What's forcing you to switch to UIE then?

tough cairn
#

playing around with graphView

chilly stone
#

Ah that

tough cairn
#

nothing is forcing me 🙂

chilly stone
#

I'm just saying, if you're switching to a new stuff, do it the way it's designed. It's the same as trying to go agains a component system in unity (not talking about ECS)

tough cairn
#

i didn't go too deep into UIE but i already see some pitfalls were imgui would suit me better

#

in terms of convenience and speed

chilly stone
#

You mean speed of development?

tough cairn
#

ye

#

do u always load stuff in UIE in absolute paths ?

#

like AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/U...

chilly stone
#

As I always call my uxml and uss by the name of editor class, it works

tough cairn
#

nice

#

ill bookmark that

chilly stone
#

You're welcome :p

tough cairn
#

👍

onyx harness
#

Did you ping me?

tough cairn
#

hi ye

#

nvm

onyx harness
#

What's going on?

tough cairn
#

👋 hi hi

#

was looking for this : UXML could be easily replaced with C#

#

( link above )

onyx harness
#

Hi!🐥

#

I like this way cuz it prevents from adding more files to the project

tough cairn
#

that's what i was thinking as well

onyx harness
#

In a plugin (as DLL) point of view, it makes sense

chilly stone
#

Do you imply that more files = bad?

onyx harness
#

Nope, just as a publisher

chilly stone
#

I can't see a point of being afraid to make 2 more files per editor, doesn't seem like an issue 🤷‍♂️

tough cairn
#

time

chilly stone
#

Compile-time?

onyx harness
#

I dont like to bloat the folders of my users.

tough cairn
#

human valuable seconds lol

onyx harness
#

The less the better

#

I just provide one single DLL per tool, thats perfect

chilly stone
#

There's an option to create them at the same time, if you're concerned about that. They even get filled in properly

onyx harness
#

Could you elaborate, what same time?

chilly stone
#

I mean when you want to create an editor, there's Create->UI Toolkit->Editor Window
It creates all 3 files filled in with basic code

#

That was response to Wad1m complaining about how long it takes to setup UIE editor :p

onyx harness
#

It is not the steps of creating them that annoys me

#

Oh ok

tough cairn
#

what do u get in the end ?

chilly stone
#

wdym?

tough cairn
#

asset file

#

as a combination from the 3 ?

chilly stone
#

You get .cs, .uxml, .uss with the same name

#

If you choose all

tough cairn
#

oh its a template generator

#

that wasn't the point lol

#

miliko wanted to reduce the file count

#

hence the in line uxml & uss

onyx harness
#

Not giving access to direct source prevents the users from altering them easily.

tough cairn
#

also its better to avoid assets clutter - like when u have bunch of small textures for an editor - it will appear in ur project as well

onyx harness
#

But for my development, yes I would gladly use 3 files. And then convert them to C# at the very end.

chilly stone
#

I agree, but saying in general that when you have a lot of files - your code is imperformant or bad - is a stupid statement 🤷‍♂️

onyx harness
#

I never said that and never will

chilly stone
#

Mikilo has solid reasons to have it that way

#

I'm replying to Wad1m, sorry

onyx harness
#

Compilation speaking, thousands of files do impact

#

Thx to AsmDef, the problem is reduced

tough cairn
#

didn't say its imperformant

#

didn't say its bad

#

its just different

chilly stone
#

You said "it's better"

tough cairn
#

quicker 🙂

chilly stone
#

Yes

#

Quicker is the word

chilly stone
#

That's not surprising, of course you can do anything as complex in IMGUI

tough cairn
#

¯_(ツ)_/¯

onyx harness
#

IMGUI is cool for quick development

#

But for complex stuff, you need a good understanding of it to go deeper

tough cairn
#

yea the deeper u go the more hax there will be

onyx harness
#

Or you might lose on the performance side.

#

At the moment the user feels it, you lose

errant mirage
#

Is there a way to have custom themes on the editor?

onyx harness
#

Yes

#

GUI.skin

errant mirage
#

Thanks :)

onyx harness
#

EditorStyles?

#

I dont remember member exactly

tough cairn
#

EditorStyles is build in

errant mirage
#

I'll check it out

onyx harness
#

But Unity Editor has few sets of styles that you can modify

errant mirage
#

Ah ok

onyx harness
#

To come back to IMGUI, the memory may also be a concern, it can generate a lot of garbage

#

But since we are on a standalone Windows or Mac, 99% of publishers or coders wont bother themself

tough cairn
#

true that

#

its my fav design paradigm for UI tho

#

🙂

onyx harness
#

I'll give it credits, speed dev, IMGUI is very good

chilly stone
tough cairn
#

ye ik

onyx harness
#

But feature like Z-index or culling, this is shit

tough cairn
#

i just hide all and replace when needed

onyx harness
#

UIE can do whatever IMGUI does

#

We just need to relearn it

tough cairn
#

UIE seems to be very optimized with the graphView

#

anyhow im off

#

👋 by

chilly stone
#

bye

#

@onyx harness you need to start a youtube channel if you don't have one Happying
There's not enough stuff on the net about editor tooling in-depth

onyx harness
#

I'm preparing an interactive tutorial about Unity Editor scripting 🙂

#

It's pure HTML

chilly stone
#

That's great, hit me up when it's available

onyx harness
#

and of course, still a prototype

short tiger
#

@onyx harness Are you recreating Unity's UI in HTML?

severe python
#

immediate mode is a bad paradigm, change my mind (don't bother)

onyx harness
#

@short tiger Yep

#

This is purely for visual, so I can integrate tutorials in any spot

short tiger
#

Wouldn't it be possible to draw tutorials on-top of Unity's actual UI?

#

Presumably, someone who is interested in learning about Unity editor scripting already has Unity

onyx harness
#

Have you ever touchedUnity's tutorials?

#

@short tiger

short tiger
#

No

#

But if they're bad, can't you do them better?

onyx harness
#

There are pros and cons to do tutorials on Unity or on a website

#

Unity:

  • You need to install and run Unity.
  • You need to install the tutorial (From asset store, or Package Manager, or git, whatever).
  • Harder to maintain. (Unity releases a version every week...)
  • Harder to write the integrated tutorial.
  • Feeling is better, since you execute directly in Unity.

Website:

  • No install at all.
  • Might be difficult to maintain.
  • Tutorial can be added very easily.
  • Developing the whole Unity Editor in HTML can take quite some time. (But I already achieved the fundamental)
#

@short tiger

errant mirage
#

So this tutorial is aimed at absolute beginners?

onyx harness
#

You will need C#

errant mirage
#

Or would it be more open source so anyone can contribute to make tutorials.

onyx harness
#

But I will try to explain the very basics, and it will go deeper for those advanced

errant mirage
#

Ah I see.

onyx harness
#

The system I am writing not suppose to be open source.
Cause it takes time to make a system with people, users, rights, etc.

errant mirage
#

Ok

onyx harness
#

There is no participation

#

Except perhaps comments

#

I am using WordPress

errant mirage
#

But wouldn't it make more sense to only have beginner tutorials on the website UI?

onyx harness
#

How would you define beginner level?

#

I am planning to make it visually understandable ! 😄

errant mirage
#

Hmmm. A simple platformer like the one in Brackeys How to make a Video Game in Unity Series.

onyx harness
#

You will see the Unity Editor, and I will spot Question Marks at some place, and by hovering these spots, I will display explanation of how to access this spot by code.
Then if you click on it, I will detail the integration

#

Oh sorry, it does not plan to teach gameplay

#

It's purely for Editor stuff

errant mirage
#

Ohh got it now.

#

So basically the UI and how it works.

onyx harness
#

Yes.

#

Editor, PropertyDrawer, EditorWindow.
All the interesting API, hidden API.
Internal stuff.
Serialization.

#

Because too much people in here come and ask "hey how do you add a menu item here?", "How to do like the lock button in the Inspector?"

#

With my tutorial, I'll put them before your eyes

errant mirage
#

Haha idk what half of that stuff means but nice

onyx harness
#

You're a good target then 🙂

errant mirage
#

Hehe I'll definitely check it out once it's done

tough cairn
#

that's cool

#

drag and drop uxml layouts

burnt dove
#

How can I execute a code after Unity extensions get initialized?

tough cairn
#
AfterSceneLoad    After Scene is loaded.
BeforeSceneLoad    Before Scene is loaded.
AfterAssembliesLoaded    Callback when all assemblies are loaded and preloaded assets are initialized.
BeforeSplashScreen    Immediately before the splash screen is shown.
SubsystemRegistration    Callback used for registration of subsystems
#

not sure if that's what u mean by extension init

#

there is also [InitializeOnLoad]

burnt dove
#

I'm using DidReloadScripts to execute some stuff which uses reflection every time the user recompile or load its scripts. The problem is that when you launch Unity editor this method is called before unity extensions get initialized

#

And so I get Unity extensions are not yet initialized, so we cannot say if the 'C:/Program Files/Unity/Hub/Editor/2019.2.17f1/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll' is compatible with platform Win64

#

So, I would like to wait until Unity extensions are initialized before execute my code

tough cairn
#

maybe try AfterAssembliesLoaded

burnt dove
#

Ok

tough cairn
burnt dove
#

I'll check that, thanks

chilly stone
#

@onyx harness have you by any chance worked with SerializeReference attribute?

onyx harness
#

@chilly stone Not yet no, unfortunately

#

I only start using new features, when I drop the support of the last version of Unity not supporting it.

#

Since I support 2018 LTS, it doesnt have it I think

tough cairn
#

quick question : anyone knows how to open file like form console ? ( hyperlink to VS )

onyx harness
#

Open file from console?

tough cairn
#

emm blue links

onyx harness
#

Unity Console?

tough cairn
#

i want to make links like that

onyx harness
#

Application.OpenURL ?

tough cairn
#

like when u have an error u can click the blue hyperlinks

#

and it will open VS

onyx harness
#

Oh, make URL clickable in text

tough cairn
#

and focus the line of code

#

hm ?

onyx harness
#

Which feature are you talking about

#

Make blue link or jump to line?

tough cairn
#

make blue link that will open VS and jump to line

#

make URL clickable in text -- > any tips on that ?

onyx harness
#

You need to look into the code, I forgot the name of the API used

tough cairn
#

ah

#
textWithHyperlinks.Append(lines[i].Substring(0, filePathIndex));
textWithHyperlinks.Append("<a href=\"" + filePath + "\"" + " line=\"" + lineString + "\">");
textWithHyperlinks.Append(filePath + ":" + lineString);
textWithHyperlinks.Append("</a>)\n");
#

that's how unity does it

#

i get it

#

" make URL clickable in text "

#

thanks

chilly stone
#

@onyx harness oh ok, I was gonna ask what issues I might encounter, it seems like a powerful thing
I'm currently trying to implement UI animation system, this attribute allowed me to serialize my IAnimation interface and I made a popup where you can choose from a list of animations + it draws default inspector for the one you choose

#

Have you worked on something similar, what can you suggest? How would you do it without SerializeReference?

onyx harness
#

@chilly stone Oh that's a big question.
It is definitely a big feature.

#

Not that easy to use, as I saw many people asking questions/complaining
about it.

#

But people who don't know how to use something easily complain...

#

Your system seems to work good already.

#

Without SerializeRef?
Keep a ref to the animation. (Like any normal Object field)
Apply an PropertyAttribute.
Draw the adequate PropertyDrawer of the animation.

#

It's like embedding an Object Editor. Actually what provides Odin.

chilly stone
#

Doesn't look good right now, there are other limitations and bugs...
With each new problem I'm thinking to actually buy Odin, which will solve most of them

whole steppe
#

what is the best extension?

onyx harness
#

NG Tools obviously 😉

whole steppe
#

how to install

#

that?

chilly stone
#

You're in the wrong chat

onyx harness
#

I have no idea

whole steppe
#

not chat

#

i want to install NG Tools

chilly stone
#

Mikilo was joking LUL

whole steppe
#

um

#

i find it

#

and i downloaded it

waxen sandal
#

That's not it

chilly stone
#

This chat is for Unity editor scripting

#

Ask anywhere else

onyx harness
#

Mikilo was joking :LUL:
@chilly stone Not even ! Adam

waxen sandal
#

Just biased

onyx harness
#

Just biased
@waxen sandal Not even ! XD

whole steppe
#

Mik you said i have to change the tabcontrol to , no idea how to do that GUI.skin.button

chilly stone
#

@whole steppe when you draw tab buttons and want to change font size for example, you should apply a modified default style. Copy the default style like this: var style = new GUIStyle(GUI.skin.button);
Change a font size, and then pass it to the DrawButton constructor

whole steppe
#

Thanks i will try.

chilly stone
#

If you change GUI.skin.button directly it will apply that to every button in inspector, which you don't want I assume

whole steppe
#

i just want to change the Toolbar , yes

chilly stone
#

I never worked with toolbars sorry, Mikilo might give a better advice

onyx harness
#

@whole steppe what do you use to draw the tabs?

severe python
#

how do you do background tasks?

#

with like the background task progress bar

#

like the lightmapper does

onyx harness
visual stag
#

That's not a background progress bar is it?

onyx harness
#

Oh crap you're right 🔥

#

You pointed the API recently

chilly stone
#

Is it possible to draw a rect with rounded corners in IMGUI?

onyx harness
#

For Unity 2020 or newer:
UnityEditor.Progress

rough raven
#

hi there, I have a script and I'm trying to do AssetDatabase.CreateFolder(..., ...), then later trying to verify if it exists with AssetDatabase.IsValidFolder(), but because Unity doesn't "see" the folder until my script finishes running, I always get false there

#

I've tried with Refresh and SaveAssets just after creating, but that changes nothing

#

what am I missing there?

onyx harness
#

It returns a GUID

#

Enough to confirm the creation

#

What do you need more?

rough raven
#

I don't want to carry the GUID all the way to the other part of the code, basically

#

I'd like to be able to confirm if it exists without it

#

can I force a sync refresh or similar to achieve that?

onyx harness
#

Can't tell, if Refresh or SaveAssets aren't enough, maybe delay the execution of the code of one frame might do it

rough raven
#

hmm, yeah, maybe, although that's not a super nice solution, but oh well

#

thanks!

whole steppe
#

Mik i am using this to draw the tabcontrol
currentTab = GUI.Toolbar(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), currentTab, new string[] { "Main", "Interactable", "Options", "Prop", "Audio" });

onyx harness
#

@whole steppe The styles used are "left", "mid", "right".

whole steppe
#

Just need the font slighty smaller

onyx harness
#

sorry, default are buttonleft buttonmid buttonright

#

You need to reduce those styles

whole steppe
#

i have no clue how.

onyx harness
#

Try GUI.skin.FindStyle("buttonmid") and such

severe python
#

@onyx harness thank you

#

your gist up there just cores itself out if you're in 2020.x yeah?

snow plank
#

How do I change that thats linke the under photo that I send after this

waxen sandal
#

What

onyx harness
#

your gist up there just cores itself out if you're in 2020.x yeah?
@severe python Yes. The new UnityEditor.Progress API is way too different from the old system. I didn't want to bother my self reimplement stuff

snow plank
#

@waxen sandal wym

onyx harness
#

More like, what do YOU mean

snow plank
#

@onyx harness arent the pictures clear

waxen sandal
#

No

snow plank
#

@waxen sandal idk how I should expain that more exactly

waxen sandal
#

Click on the color and change the alpha in the color picker

snow plank
#

@waxen sandal i didnt know where I should ask

#

Click on the color and change the alpha in the color picker
@waxen sandal and where is that

waxen sandal
#

Where is what

snow plank
#

@waxen sandal The Alpha u said

chilly stone
#

@onyx harness I'm completely confused how drawers work.
I have a drawer with a simple popup. It seems like there's separate drawer instance created for each popup item. Here's how I checked this:

private bool _value = false;

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
  if (_value == false)
  {
      Debug.Log("value is false");
      _value = true;
  }
  // popup code
}

I assumed this is gonna be called once, but I was wrong.
This is called when I:

  1. Open inspector with the drawer
  2. Choose first popup item
  3. Choose second popup item and so on for each item...
    Why does the drawer recompiles so many times when it should do that once?
onyx harness
#

@chilly stone Who told you that PropertyDrawer is unique and reuse?

chilly stone
#

@onyx harness I know that it's not unique, but it should be created once for each visible property, and for me it's doing that multiple times

#

I should also note that this happens only for PropertyDrawers that apply to attributes

onyx harness
#

Hum... perhaps a change in a custom class serializes it and triggers a reset

chilly stone
#

@onyx harness no way around it? How can I carry previously picked popup index?

onyx harness
#

You would like to know the previously picked? Hum...

chilly stone
#

Which is not very efficient. I want to set objectReferenceValue only when it's different from the previous

waxen sandal
#

That doesn't look very inefficient

#

You can do change checks

chilly stone
#

How?

#

You mean BeginChangeCheck?

waxen sandal
#

Ye

chilly stone
#

Never had to use it before

onyx harness
#

I'm still wondering why the previous index...

#

I guess Navi guessed it right

chilly stone
onyx harness
#

urgh

#

I find the scope of ChangedCheck so ugly

chilly stone
#

What's the difference visually except using and brackets?

#

I like to see indentations where they make sense

onyx harness
#

I'm not against indentation and brakets

chilly stone
#

For me Begins and Ends are ugly :p

onyx harness
#

but this compare to this:

BeginCheck()
GUI()
if (EndCheck())
    DoSomething()
#

I find the latter much better

chilly stone
#

I don't see how it's better, in a big file you can't quickly find where the block is ending 🤷‍♂️

onyx harness
#

I never use Begin/End on big block, never

chilly stone
#

Oh? Ok

#

Then yeah, I see your point

waxen sandal
#

I only do if I have to fix someone else their code

chilly stone
#

Still the main advantage of using scopes is that you can return; at any point without things breaking

waxen sandal
#

Your change check will

onyx harness
#

The weird feeling about the change check scope, is you have to execute the change within the scope

waxen sandal
#

^

onyx harness
#

It doesn't make much sense

chilly stone
#

It's always done at the end anyway 🤷‍♂️

onyx harness
#

Yes, I give you this point, return is automatically handled

#

The best would be to provide a callback directly to the scope

#

Easy to implement

chilly stone
#

Scope can't exist outside of using, as it's destroyed

onyx harness
#

Stays fine to read

#

Efficient, i would bet not that much, but it needs some bench to confirm

chilly stone
#

I don't think scopes or begin-ends would be your bottleneck :p

onyx harness
#

Scope will call the callback on leaving if a change is detected

#

I am more afraid of garbage in this case

#

but I'm not even sure why I am afraid

chilly stone
#

Dunno about garbage

onyx harness
#

A callback will just be a simple delegate

chilly stone
#

Is there a profiler for editor?

onyx harness
#

Yes

#

The Profiler

chilly stone
#

Oh I only used it for checking game performance

waxen sandal
#

Scope makes a new instance

chilly stone
#

Yeah and disposes it

waxen sandal
#

Callback might need to capture a closure and allocate a new class

chilly stone
#

So there should be garbage I suppose

onyx harness
#

Yeah, if closure it is

#

If you provide a membered method

#

There is no closure

waxen sandal
#

Not as efficient as the current implementation though 😛

chilly stone
onyx harness
#

The other problem is storing the delegate inside the scope.
Delegate assignation generates garbage

#

And since IMGUI can have a lot of calls, this trick loses its beauty

chilly stone
#

You need to do some benchmarks :p

onyx harness
#

I don't have time for that 🙂

#

I prefer to continue my tutorial system

rare surge
#

Guys do you know how to make collapse (not foldout) the unity event field? I saw an image somewhere but cannot find it anymore. If you see my image the red line was the button to collapse. I don't want to use foldout if it is not possible with it.

waxen sandal
#

Maybe that's an odin thing?

#

I haven't seen it before

rare surge
#

No but I just remembered Event Trigger has same button there. I just need to make same way and code myself the show / hide behaviour. But it looks like a label with a button?

split bridge
#

@rare surge I did something like this with Odin but can’t remember details - this was the overload I used though: https://twitter.com/timboc_/status/984542933348179968?s=21

Always worth spending a little time on your tools. @TeamSirenix Bringing joy to my #unitydev existence - keep up the awesome work! (CustomDrawer<T> : OdinValueDrawer<T> where T : UnityEvent) #reducingmentaloverhead #thelittlethings #unitytips

#

Unsure if there’s an easier way to do it these days

violet agate
#

Does anyone know how to make it so a window immediately sets one the fields drawn within as the GUI focus?

#

Nevermind, done.

rare surge
onyx harness
#

Never look for complicated things

#

If it is, there might be a problem

frank cloud
#

anyone know if Unity has a built in function to highlight a game object in the scene view? Use case is to hover over a game object and make sure the user knows which one will be picked

visual stag
#

You could figure out how the selection highlight is called, though I don't know if it's at all accessible

frank cloud
#

yea, I figured I could do it by hand by just iterating through all renderers/drawing an outline object...was hoping Unity had something 😦

#

cool plugin tho @visual stag 👍

viral dune
#

Hi, can anybody explain how to draw animationcurve field with no stretching on both of its axis ?

#

this

#

looks very similar, but the Y axis is so far apart

#

how can i turn of the auto stretching of the axis ?

waxen sandal
#

Anyone has an idea on how to copy files with their internal references copied as well?

#

Or am I just stuck having to go through everything using SerializedProperties?

onyx harness
#

@waxen sandal when you copy an asset, it comes with its references already, so I don't get your question

waxen sandal
#

I mean if you copy multiple assets that have references between those assets, currently they point to the source asset rather than the copied asset

grand crest
#

Nvm message disappeared

viral dune
#

how do i make EditorGUILayout.CurveField non editable ?

onyx harness
#

GUI.enabled

viral dune
#

is that going to disable all gui ?

#

how do i turn off only the curvefield ?

onyx harness
#
GUI.enabled = false;
GUI()
GUI.enabled = true;
#

Or use the scope equivalent

viral dune
#

umm, i still don;t get it

onyx harness
#

Replace GUI() with your curve field

viral dune
#

oh, okay, let me try realquick

#
EditorGUILayout.CurveField(thisClass.expCurve,Color.green, new Rect(0,0, 100, 8000000) , GUILayout.Height(385));
#

there's no .Enabled

onyx harness
#

enable?

viral dune
#

nope

#

there's only onenable

onyx harness
#

No no

#

Read the code provided above

viral dune
#

ah

onyx harness
#

There is really no trap

viral dune
#

got it, let me try again

onyx harness
#

You just copy and paste and replace GUI() with your code

viral dune
#
                GUI.enabled = false;
                EditorGUILayout.CurveField(thisClass.expCurve,Color.green, new Rect(0,0, 100, 8000000) , GUILayout.Height(385));
                GUI.enabled = true;
#

so like this right ?

#

awesome, it worked, thanks for your help

onyx harness
#

@viral dune The best practice here is using a scope:
using (new EditorGUI.DisabledScope(true))

viral dune
#

how do i use that ?

onyx harness
#
using (new EditorGUI.DisabledScope(true))
{
    GUI();
}
viral dune
#

ah, thanks!

#

you saved me a ton of time, thanks!

onyx harness
#

My pleasure

rare surge
#

Why this propertydrawer

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
    EditorGUI.PropertyField(position, property, label);
}

Is not working for UnityEvents? Is there other tricks to make it?

onyx harness
#

Can you show me the top of your file containing the PropertyDrawer?

rare surge
#

This is the full code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;


namespace Maz.Unity.EventFramework
{

    [CustomPropertyDrawer(typeof(CollapseAttribute))]
    public class UnityEventCollapseProperty : PropertyDrawer
    {
        GUIContent m_IconToolbarMinus = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus"));
        GUIContent m_IconToolbarPlus = new GUIContent(EditorGUIUtility.IconContent("Toolbar Plus"));

        

        public override float GetPropertyHeight(SerializedProperty property,
                                                GUIContent label)
        {
            return EditorGUI.GetPropertyHeight(property, label, true);
        }

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.PropertyField(position, property, label);
    }

        
    }
}
chilly stone
#

Don't you need to put it inside EditorGUI.PropertyScope?

rare surge
#

Where I need to put that? I made other property drawer as well but the propertyfield was enough

chilly stone
#
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
  using (new EditorGUI.PropertyScope(position, label, property))
  {
    EditorGUI.PropertyField(position, property, label);
  }
}
onyx harness
#

I guess Collapse is applied your field "GameEvent"

rare surge
#

Thanks, didn't work :D
If I am using Editor script with custom inspector there it works just with EditorGUILayout.PropertyField(property); But I thought better to use propertydrawer since I use in different scripts.

@onyx harness yes

onyx harness
#

And you are right. Dump Editor and use PropertyDrawer instead.

#

PropertyField has a mecanism to prevent redrawing itself.

#

Let me explain

rare surge
onyx harness
#

Is this from Odin?

rare surge
#

No

#

Made by myself but with looking into the Even Trigger script. They just put a button over the unity event. I just reworked it little bit.

onyx harness
#

Well, UnityEvent has a built-in PropertyDrawer (PD) which draws GUI like in the gif above.
If you mark a field of type UnityEvent, you bypass the PD and use your custom implementation.
Inside your PD, when you use PropertyField, it will lookup for the proper PD.
But since the PD will be itself, it will infinite cycle.
The fallback is to draw "natively".

rare surge
#

Better to visualize with that. This was made with editor script but yea propertydrawer would be better to be more flexible ^^

#

ohh ok

onyx harness
#

In my entire career of tools maker, I almost never used Editor

#

Neither PropertyScope.

#

I guess it has a purpose, but I've never had an issue without

chilly stone
#

Oh, interesting

rare surge
#

So if I understand correclty so I actually would need to recreate unityevents pd?

onyx harness
#

Kinda yes

rare surge
#

damn 😄

onyx harness
#

Or generate yourself the built-in PD for UnityEvent

#

And draw using it

chilly stone
#

@rare surge a little off topic, what are you using to record those gifs?

onyx harness
#

ScreenToGif or such I guess

rare surge
#

ShareX @chilly stone

chilly stone
#

Oh cool, I should get one :p

rare surge
#

my biggest lifesaver tool

#

Has everything what I need. Many apis included like imgur to upload after the capture

chilly stone
#

Can it record in mp4?

rare surge
#

Yes

chilly stone
#

Great

rare surge
#

But for tutorials or similar things I wouldn't use it. Better to use obs there. I use it just to make quick recordings and upload to show quickly something.

#

Or generate yourself the built-in PD for UnityEvent
@onyx harness What exactly do you mean with generating? It sounds like extracting the code or generating the code.

chilly stone
#

I don't think you should neccesserily regenerate default PD, since you defined a PD for attribute, not for every unity event, right?
I was able to achieve similar by finding actual SerializedProperty for UnityEvent field and simply drawing a field: EditorGUILayout.PropertyField(property);

onyx harness
#

Allocate the PD

#

The property itself is the UnityEvent

chilly stone
#

It doesn't matter - there is recursion happening, so you will have to find the SerializeProperty on a current drawer that is untouched yet, and draw it.
I did this in my SerializeReference drawer and it works fine

onyx harness
#

If you want a tip to start looking, the majority of the PropertyDrawer world is in ScriptAttributeUtility

#

No recursion will happen if you get the built-in PropertyDrawer

#

SerializedProperty and PropertyDrawer are 2 different worlds

#

Related at some point, but 2 different worlds

#

And by talking about SerializeReference, you were drawing it using its SerializeProperty (SP) and it draws the correct GUI, right?

chilly stone
#

So I draw background, label, etc, and then the property field itself

onyx harness
#

This is what I thought, and now can confirm, SerializeReference is not related to his problem

chilly stone
#

Hmm, I can try to make the same for a regular field 🤷‍♂️

onyx harness
#

Regular field or not

#

Using a custom PD is not related to the serialization

#

And you are working on a top object (your interface), not the direct UnityEvent

chilly stone
#

I'll try this for UnityEvent and get back to you 😉

onyx harness
#

You are getting confused with the word "serialize" 🙂

chilly stone
onyx harness
#

Yeah this is where I pointed out earlier

severe python
#

can you make Gizmos' occluded ?

#

for example, I want this white overlay to be hidden by the tree standins

restive ember
#

Hi i have problem

Debug.Log(object.activeSelf);
object.gameObject.SetActive(true);
Debug.Log(object.acitveSelf);```
Return me
False
False

```cs
Debug.Log(object.activeInHierarchy);
object.gameObject.SetActive(true);
Debug.Log(object.activeInHierarchy);```
Return me
False
True

But in both case object is still inactive in Hierarchy in editor, and in Game
Even i tried
```cs
Debug.Log(object.activeInHierarchy);
object.gameObject.SetActive(true);
Debug.Break();
Debug.Log(object.activeInHierarchy);```
And this was still inactive
wispy delta
#

I'm manually drawing an ObjectField and calling Undo.RecordObject so I can use a property, but the change isn't serializing. The field changes in the inspector (in normal and debug mode) and undoing/redoing works, but the change is lost whenever the assembly reloads. Any idea why?

The property:

[SerializeField]
private PortalConfiguration configuration;
public PortalConfiguration Configuration
{
    get => configuration;
    set
    {
        configuration = value;
    }
}

The GUI:

Portal portal = target as Portal;
...
// Draw Configuration
using (var check = new EditorGUI.ChangeCheckScope())
{
    PortalConfiguration newConfig = (PortalConfiguration)EditorGUILayout.ObjectField
    (
        "Configuration", 
        portal.Configuration, 
        typeof(PortalConfiguration), 
        true
    );
    if (check.changed)
    {
        Undo.RecordObject(portal, "Changed configuration");
        portal.Configuration = newConfig;
    }
}
#

From what I understand, you can tell the change isn't serializing correctly because if you change the object reference with my custom gui and then switch the inspector to debug mode the field isn't bold and doesn't have the blue override indicator after changing.

#

But if you switch to debug mode before changing the object reference, the gui gets boldened and has the blue override indicator and the change persists entering/exiting playmode

#

tldr: using EditorGUILayout.ObjectField in conjunction with a c# property and Undo.RecordObject does not properly serialize the change

onyx harness
#

for example, I want this white overlay to be hidden by the tree standins
@severe python isn't gizmos drawn after?

wispy delta
#

Damn looks like I needed to also call PrefabUtility.RecordPrefabInstancePropertyModifications after making the change 😒

#

i guess that's what i get for making a deal with the devil and not using serialized properties

onyx harness
#

@restive ember it can be many reasons, not the right reminder, maybe another script

#

And your 2 examples make perfect sense, we just lack of information about them

#

@wispy delta Good job finding it

barren moat
#

Has anyone here had issues with the editor not compiling code after file changes? I know it's not quite the right topic, but I suspect it could be the result of an editor extension.

restive ember
#

@onyx harness theres no another object or script like this, also its work good at second and any next call function
Theres something strang for me

steady crest
#

@severe python you probably forgot to z-test before rendering the Gizmos

waxen sandal
#

Does that work for gizmos?

steady crest
#

god damnit, I think I got stuff confused

#

well, he could use handles instead of gizmos 🙃

waxen sandal
#

Yes

#

It might work for gizmos, wouldn't surprise me if gizmos used handles internally

vernal belfry
#

Not sure if this is the right place to ask but do you people use any good Logging asset ? something thast makes easier the task to debug errors on remote devices. Im using my own system but Im afraid we will need something better

onyx harness
#

Unity has built-in login with their console

#

What else do you need?

vernal belfry
#

well, when the game is running on other devices, somethinng that can store logs, and in case of need be able to check them somehow

#

right now im using Unity reports

#

so when i detect an error i send myself the last 500 unity built-in logs

#

but i was wondering if there was a more elaborated asset

#

and I have doubts like, for this ones to work currently im using debug.log, but i dont know if i should do that on release

#

i should simply store the lines of log somewhere i guess and not use the console

#

but then, should i also keep them on a file?

onyx harness
#

Oh for production

vernal belfry
#

and be able to get them in case of a crash?

#

yes

#

for production

#

we are close to release

#

and i would like to have as much control as i can

onyx harness
#

you can store them in PlayerPrefs

vernal belfry
#

of remote crashes

#

in playerPrefs? thats interesting

#

its a common practice?

onyx harness
#

It's a simple way to store data

#

Logs among others

#

Usually people use it to store game data

vernal belfry
#

yeah i know, i was thinking to keep a text file updated but playerprefs might be faster

onyx harness
#

But at the end of the day, it can be anything

vernal belfry
#

yeah im using it for settinngs

onyx harness
#

Maybe dont store 1GB of logs in there

vernal belfry
#

hehe no

#

also i could make sort of flag i can activate remotely to get that playerPrefs log list

#

thats what i was wondering if possible

#

imagine a device in ..... mexico... crashes

#

and you dont know why

#

no exceptions

#

no errors

#

how do you get the log info

onyx harness
#

Either you send to your servers massively

#

Or you might need a system to handpick a device

vernal belfry
#

maybe i could prompt the user to push some button and send logs

#

but what if the problem doesnt allow him to start the game 😅 shit

onyx harness
#

There might be services out there providing this kind of thing

vernal belfry
#

yeah thats why im asking here if someone knows

#

maybe not the right room

split bridge
#

Anyone know of a faster way to check a prefab for the presence of components other than PrefabUtility.LoadPrefabContents(); PrefabUtility.UnloadPrefabContents(); (takes ~0.5s for a prefab with a single object) - wondering if it's faster to parse the asset as text

onyx harness
#

AssetDatabase.LoadAsset works?

split bridge
#

huh, it does? Hadn't thought to try that thanks.. will give it a go.

#

about 1000x faster 😅 - thanks! pays to ask

onyx harness
#

Be careful there is no caveat

#

LoadPrefabContents must have a purpose, i don't know what

split bridge
#

I think it loads the prefab in editor - scene isolation and all that gubbins - totally unneeded in my case

rare surge
#

@onyx harness yeah you're right, I can't get it to draw default inspector for UnityEvent
But I found some useful resources: https://gist.github.com/AngryAnt/b5995c9b2cf2a0979758ad17f6a59ef0
@chilly stone @onyx harness thanks The link was really good help. If I use this UnityEventCollapseProperty : UnityEventDrawer so the base.OnGUI(position, property, label); will show the default unity event drawer. Since my collapse function just draws a + or - over the field its done. No more code needed. The only last fix I need to do is I used GUILayout before with BeginHorizontal() in the Editor script. It is moved to bottom. Like in the gif base.OnGUI(position, property, label);

if (show)
{
    base.OnGUI(position, property, label);
}
else
{
    GUILayout.BeginHorizontal(style);
    GUILayout.Label(ReflectionHelper.GenerateGenericTypesAsString(property), GUILayout.ExpandWidth(true));
    GUILayout.EndHorizontal();
}
#

Oh the gif is bugged. It shows very dark field at the top. But its only in the gif lol. Compressing failed 😄

onyx harness
#

Is that code in the PropertyDrawer?

#

Just say yes

#

I know the answer already

rare surge
#

There is more code but its other things like checks if it is generic type or not or creating style

#

xD

onyx harness
#

Do not use [Editor]GUILayout in PD

#

It doesn't work in there like that

rare surge
#

But it works. I just forgot to add public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
I do this with it:

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
    if(show)
    {
        return EditorGUI.GetPropertyHeight(property, label, true) + 20f;
    } else {
        return 0f;
    }        
}

Finally goal reached.

onyx harness
#

I know "it is working"

#

But it's just an illusion

#

Unfortunately, you will think it is working and keep using it in PD

#

And one day, you'll come in here "hey what's happening with my code that I have been warned I should not do"