#↕️┃editor-extensions

1 messages · Page 13 of 1

peak bloom
#

oh apparently if using ProjectFolder it's not relative path? it creates new folder in my document folder out of nowhere

#

there found outside my project folder for some reason

gloomy chasm
peak bloom
#

proly the ProjectSettings one , but ProjectFolder creates it outside my project file

#

man, unity is on crack

#

🤣

#

WAIT WAIT WAIT.. NO

gloomy chasm
peak bloom
#

it creates new folder in my root project folder

#

so yeah still in project folder.. and relative path.. ahaha me on crack once again

#

YOU're correct Mr.MechWarrior!

gloomy chasm
#

OOh right, sorry about that. I just always put ProjectSettings/ in the file path xD

peak bloom
#

it's in my root project folder, yeah , due at 1st I thought it was the ussual Asset folder if I picked ProjectFolder

#

so it created new folder (that I was assuming in my Asset folder) in my root project folder instead

#

lmao

#

you're correct

gloomy chasm
#

Ahh, nope. Also if you think about, not even AssetDatabase is relative to the assets folder

#

You always start a path with Assets/

peak bloom
#

yes, I did not put that Asset/ path due to my false assumption 😅

#

hhahaha

#

nice dude, thanks a ton once again 👍

#

it is solved!

azure coral
#

I just wanted to check in and ask if anyone had any insight to this question I asked over the weekend.

rain beacon
#
    [CustomEditor(typeof(ConversionConfig))]
    public class ConversionConfigInspector : Editor
    {
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            
            EditorGUILayout.HelpBox("This is helpbox", MessageType.Warning);
        }
    }

okay, so this draws the warning at the bottom of the inspector. It's totally expected, because I first call base and then do my thing.
the question is - how do I "interfere" with base implementation? I want to draw warning after/before some specific field / header
obvious solution is to just manually draw everything and throw away base.OnInspectorGUI() call completely, but it just feels extraordinary dumb and requires me to rewrite my inspector script each time I add or remove a property
is there a better way?
I couldn't achieve helpboxes with attributes either

#

would be nice to have a simple attribute [HelpBox("message", messagetype)] which would just simply draw a helpbox, but I don't see a way, since PropertyDrawer doesn't have HelpBox methodkekwait

#

wait I'm dumb, it's extremely simple

#

I just call EditorGUILayout.HelpBox() from the OnGUI 😆
nvm

dull mango
#

how can i render Inspector Some Part of code?
such as i want render part "Fire Setting" from code line 8 --> 13
and render part "Recoil Setting" from code line 14 --> XXX

peak bloom
#

EditorPrefs is the easiest here, it's the same workflow as PlayerPrefs

#

the rest, you can try to google it for more elaborate answers or once you hit a brick wall using them you can post it here

dull mango
#

oh that is nice ideas
thanks👍

peak bloom
#

oh wait.. I misunderstood

#

I thought it was about saving states 😅

#

@dull mango you'd have to make a custom inspector for it

dull mango
#

yes i want custom inspector

peak bloom
#

It's for UIToolkit, you can use UIBuilder for dragNdrop workflow even for custom editor or pure code

dull mango
#

oh sad haha

peak bloom
#

you can show/hide whatever serialized properties on your custom editor, the same logic as you would in c# but with slight different concept

#

the linked page should get you going

shell beacon
#

Guys, I have a question..
I tried to copy GUI.skin.button style without passing it to the constructor, but now it looks like it won't listen to mouse event.. I don't want to use it because looks like we can't get rid of the bg texture of it.. do I have to trigger a repaint manually by checking where the mouse is?

waxen sandal
#

wat?

#

show code

shell beacon
#

I have this.. I want to imitate a button (imagine all the states are there for now lol)

#

I don't wanna copy the button style like new GUIStyle(GUI.skin.button)

#

And I'm using the style like so
EditorGUI.DropdownButton(midRect, s_operatorContent, FocusType.Keyboard, OperatorPopUpStyle)

waxen sandal
#

Why don't you want to copy

#

also does it work if you copy

#

Can you show the code surrounding EditorGUI.DropdownButton

shell beacon
#

It does work but only like in the following picture.. and it looks like a regular button.
If I uncomment the bottom part it doesn't repaint and also doesn't look right..

#

It looks like that

#

Basically I want a flat button style lol...

waxen sandal
#

Can you eliminate which part of those custom settings don't work?

#

Also why are you using a dropdown button and not a normal button?

shell beacon
#

I tried GUI.Button() too, it behave the same

shell beacon
#

The hover state looks good

#

Maybe I'll try EditorStyles skins..?

#

Nope..

shell beacon
#

If I change the background of the normal state of GUI.skin.button, I lose all mouse event repaints... for everything that uses it

shell beacon
waxen sandal
#

Try setting the background to editorguiutility.whitetexture and using the background color instead to ting it

shell beacon
waxen sandal
#

Oh I thought there was a background color field

#

I guess there's GUI.BackgroundColor

shell beacon
#

Alright I tried that.. same behavior 😔

#

This works basically.. but I am trying to avoid lines 74-75

#

I guess I'll have to use something like that.. maybe I'll wrap it in my own "editor helper static function"

#

Thanks @waxen sandal for the help! ❤️

gloomy chasm
# shell beacon Thanks <@171650322551275520> for the help! ❤️

If I understand you correctly, it is the hover state that is not changing, right? If so, fun fact, the built in styles (like button) are treated special by unity internally, so they will repaint and handle mouse hover, but copies and other styles will not. I haven't found any way around this. And the code that does this is in C++ I think, so... yeah...
I recommend looking in to UIToolkit, this sort of thing is much easier with it. 🙂

peak bloom
#

100% agreed.. customEditor with UIToolkit is like waaayy too easy, no lie 😄

shell beacon
still swallow
#

Hello there, I'm a bit unsure where exactly to search for this: I'm trying to duplicate an animator controller and change some animations inside of a blend tree. Here are some pictures and my current code. Can someone help me get on the right track? Thanks.

private void GenerateAnimatorController(GameMode mode)
    {
        string newPath = $"Assets/Resources/Animation Controllers/{characterName}_{mode}.controller";
        AnimatorController template = (AnimatorController)AssetDatabase.LoadAssetAtPath("Assets/Resources/Animation Controllers/Template.controller", typeof(AnimatorController));
        
        AssetDatabase.CopyAsset("Assets/Resources/Animation Controllers/Template.controller", newPath);
        AnimatorController newAnim = (AnimatorController)AssetDatabase.LoadAssetAtPath(newPath, typeof(AnimatorController));

        // Idle
        newAnim.layers[0].stateMachine.states[0].state.motion = idleUp;
        newAnim.layers[0].stateMachine.states[1].state.motion = idleRight;
        newAnim.layers[0].stateMachine.states[2].state.motion = idleDown;
        newAnim.layers[0].stateMachine.states[3].state.motion = idleLeft;
    }
#

A picture of the base layer, in case that's of any help.

still swallow
#

Here's my new code. Am I doing stuff the way it should be done? Or is this code stinky?

private void GenerateAnimatorController(GameMode mode)
    {
        string newPath = $"Assets/Resources/Animation Controllers/{characterName}_{mode}.controller";
        
        AssetDatabase.CopyAsset("Assets/Resources/Animation Controllers/Template.controller", newPath);
        AnimatorController newAnim = (AnimatorController)AssetDatabase.LoadAssetAtPath(newPath, typeof(AnimatorController));

        // Idle
        BlendTree idle = FindBlendTree(newAnim, "Idle");
        RemoveBlendtreeChildren(idle);
        idle.AddChild(idleUp);
        idle.AddChild(idleRight);
        idle.AddChild(idleDown);
        idle.AddChild(idleLeft);

        // Run
        BlendTree run = FindBlendTree(newAnim, "Run");
        RemoveBlendtreeChildren(run);
        run.AddChild(runUp);
        run.AddChild(runRight);
        run.AddChild(runDown);
        run.AddChild(runLeft);

        if (mode == GameMode.HideNSeek) return;

        // Attack
        BlendTree attack = FindBlendTree(newAnim, "Attack");
        RemoveBlendtreeChildren(attack);
        attack.AddChild(attackUp);
        attack.AddChild(attackRight);
        attack.AddChild(attackDown);
        attack.AddChild(attackLeft);
    }

    private BlendTree FindBlendTree(AnimatorController controller, string name)
    {
        foreach(var layer in controller.layers)
            foreach(var state in layer.stateMachine.states)
            {
                var blendTree = state.state.motion as BlendTree;
                if (blendTree != null && blendTree.name == name) return blendTree;
            }

        return null;
    }

    private void RemoveBlendtreeChildren(BlendTree tree)
    {
        for (int i = tree.children.Length; i >= 0; i--)
            tree.RemoveChild(i);
    }
}
dull mango
#

How can i custom gui on right click at properties in inspector?

alpine bolt
visual stag
alpine bolt
peak bloom
#

@gloomy chasm is ObjectChangeKind.DestroyGameObjectHierarchy can't detect objects destroyed via DestroyImmediate?

#

If I removed from right click->delete in the hierarchy it works perfectly, but won't work with destroyImmediate

#

or should I just use OnHierarchyChange?

#

I wish NOT to use OnHierarchyChanged tho, but if there's no other choice then.. eh

peak bloom
#

I swear to god.. that thing won't work

gloomy chasm
#

ObjectChangeEvents only works with things that register undo

peak bloom
#

wait, so you suggest that it's working with DestroyImmediate or nah? sorry english isn't my 1st language 😅

whole steppe
#

how can one change the opened folder in the project window?
I'd like to programmatically navigate the user to a given asset in the project (interface)...

gloomy chasm
whole steppe
# gloomy chasm I am trying to remember, I think something like `EditorUtility.Ping(object)`

I also thought of this, but I think it only pings the object to the user, and doesn't actually change the current opened folder for the user...
or at least that's what I thought...

and yeah! you almost got it! it's more like: EditorGUIUtility.PingObject()

I actually didn't just want to ping an asset, I wanted to know what's under the hood that makes the project window navigate, so I could replicate that action for things like:
step back | step forward, type of thing...

arigatto! ❤️‍🔥

quasi depot
#

is there a way to draw gizmos for a gameobject that allows the gameobject to be selected when its clicked?

whole steppe
quasi depot
#

no, I have made it so the gizmos for my objects are always drawn, Im making a node-like system and for easy editing I would like to be able to select my node gameobjects through their gizmos

whole steppe
#

does that mean you'd like to be ablet to obtain a node's GameObject when you select a node's gizmos?

#

@quasi depot

quasi depot
#

sure

whole steppe
atomic sable
#

anyone know what GUIStyle this button is or what I could do to easily remake it?

quasi depot
#

monobehaviour

atomic sable
#

the GUIStyle for that button is called monobehaviour?

quasi depot
#

no I was responding to Ophura

atomic sable
#

oh

atomic sable
#

also, why does this not give me the blue button for selected?

        normal = GUI.skin.button;

        selected = normal;
        selected.normal = normal.active;
gloomy chasm
whole steppe
# quasi depot monobehaviour

this might be super wacky, however I think it answers your question...
yes, there is a way or 2 that I can think of, but they are mostly likely not the best suit for a reason or another!

you could make a CustomEditor for your MonoBehaviour (node),
then in the OnEnable method, get the GameObject of the currently clicked on node gizmos, like so:

private void OnEnable()
{
    var go = ((CustomNode)target).gameObject;
}```if you do choose this way (which isn't necessarily recommended)
remember to have those too:```cs
override public void OnInspectorGUI() => base.OnInspectorGUI();
override protected void OnHeaderGUI() => base.OnHeaderGUI();```
peak bloom
#

@gloomy chasm just found out about this api Undo.DestroyObjectImmediate

#

so for example, if I removed a component it will fully restore it as well?

#

by fully I mean, the index or order of the component in the gameObejct it's attached to

whole steppe
#

hey, I wondered if you might know something alike for mouse input instead?

specifically for the 4th and 5th buttons...

whole steppe
#

never-mind, just realized that Mouse.current work in the Editor too!

peak bloom
peak bloom
whole steppe
peak bloom
#

well, lots of mouse/pointer events in there.. also depends on what you're doing due to they require it to be VisualElement or it's derivatives (GraphElement)

#

you can register callback to your heart content in uitk

whole steppe
peak bloom
#

tried it, it records index too, yeah 👍

waxen sandal
#

But I vaguely remember there being another way too but I forgot

peak bloom
#

how would you have access to the buffer?

#

is that even posibble?

#

I mean I can do bunch of validation in my api if I can do that.. and would be very neat

whole steppe
waxen sandal
#

Native input handlers is not a good idea

#

MenuItem is nice nowadays since you can change the shortcuts in the shortcut manager

gloomy chasm
waxen sandal
#

But it used to be fixed

whole steppe
waxen sandal
#

Oh right

#

The one I linked should work then

whole steppe
waxen sandal
#

🤔

#

Ok there's one more hack that I know of

#

It's using onSceneGUI

#

It works as long as the scene view is visible

#

And returns mouse coordinates outside the window (but iirc relative to the scene view)

#

Or at least, that's how it worked many years ago

whole steppe
#

I'd still really hope seeing it working in that format though!

it's better than what I currently have, a combo of Mouse.current (which works in Editor 😳) along with EditorApplication.update
I'm trying to make it as performant as possible...

peak bloom
#

I'm using EditorApplication.quitting, it's nice and dandy so far, but there's a problem, when the Unity editor crashed, it won't invoke it

#

are there any way get around this?

waxen sandal
#

The definition of crashing is that it's unexpected and thus it can't invoke quitting

peak bloom
#

yeah, that sucks 😭

glad pivot
#

so i have a scriptable object i want to apply two labels to and i want to create it with through [CreateAssetMenu(menuName = "MyScrObj/Type A")] so i would use AssetDatabase.SetLabels(), but it warns me about doing it in it's constructor and rather do it in OnEnabled. Wouldnt that be called every time it recompiles that way? I only want it to happen when its created. I want to avoid it doing stuff when it recompiles to keep the editor fast

gloomy chasm
#

I recommend the first option though

glad pivot
#

so then i would rather have a method that creates and saves the asset and have that be called in the asset menu?

gloomy chasm
#

Yeah

glad pivot
#

gotcha

gloomy chasm
gloomy chasm
glad pivot
#

ok so this just popped into my brain. Is there a way to tell unity to stop compiling if there is a specific asset missing if it is needed for a plugin or something like that?

gloomy chasm
glad pivot
#

what about builds? same thing there as well?

gloomy chasm
glad pivot
#

tho probably not something super useful as im sure if the plugin needs to check that its already badly designed but just a thought

gloomy chasm
#

But really, you should have it should solve itself at runtime normally if an asset is missing or something.

hollow bluff
#

Is there a way to make a custom property drawer show up in an object that doesn't have a custom editor?

gloomy chasm
hollow bluff
gloomy chasm
hollow bluff
regal jasper
#

Awake isn't called when (re)loading

gloomy chasm
# hollow bluff Ok. I have seen that, but I really wanted to work with the drawer in UI Toolkit,...

Ooh, oaky. So you are wanting to use UIToolkit, but I assume you are on 2020 or 2021? Then, you are correct that the only option is to use a custom editor, or use IMGUI instead of UIToolkit for the property drawer.
If doing a custom editor, you can make a default editor that acts as a fallback for all monobehaviours and ScriptableObjects. You would have to iterate over every SerializedProperty and add a PropertyField for them. You might be able to get away with only iterating over the top level properties I think. Anyway, depends on how much work you want to do for it. You can google the specifics if you want to do the default custom editor like I mentioned

gloomy chasm
regal jasper
gloomy chasm
regal jasper
# gloomy chasm What are you referring to?

About Awake, it is only called as result of a CreateInstance method, if the asset already exists in the project only OnEnable will be called (as result of loading it)

gloomy chasm
regal jasper
gloomy chasm
hollow bluff
gloomy chasm
# hollow bluff I'm on 2023.1 ; does that change anything?

Yeah, that means the property drawer using UIToolkit should work just fine on default drawers. If it isn't feel free to share the PropertyDrawer code, the code for the class/struct it is for, and a snippet of the class where it is used. And I would be happy to take a peek at it and see what's up 🙂

hollow bluff
# gloomy chasm Yeah, that means the property drawer using UIToolkit should work just fine on de...

Ok. Here's what I'm using (for the drawer class):

[CustomPropertyDrawer(typeof(Skill.EffectField))]
public class EffectField_PropertyDrawer : PropertyDrawer
{
    public VisualTreeAsset m_DrawerXML;
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        var container = new VisualElement();

        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Scripts/Editor/EffectField_PropertyDrawer.uxml");
        visualTree.CloneTree(container);

        return container;
    }
}
gloomy chasm
hollow bluff
#

This is what it looks like (type is the name of the variable the the drawer would refer to).

gloomy chasm
#

It should be working just fine.

hollow bluff
gloomy chasm
# hollow bluff The editor isn't custom there.

Hmm, only thing I can think of is to make a really simple setup and see if that works. A custom class with like, a single float field, and then a new monobehaviour with only that class as a field. And then a simple property draw for the custom class that just shows a label or something.

#

Sorry I'm not really able to give much more advice or insight on what the issue is

hollow bluff
hollow bluff
hollow bluff
gloomy chasm
hollow bluff
gloomy chasm
#

Oh really? Odd

peak bloom
#

@gloomy chasm do you know how to SendEvent to IMGuiContainer?

#

So I'm wanting to trigger the ColorPicker which is a imgui method in ColorField from uitk

#

turns out uitk's ColorField element is basically a IMGuiContainer wrapper for Imgui's ColorField

#

sorry if it sounded too confusing 😂..

gloomy chasm
peak bloom
gloomy chasm
peak bloom
#

reflection work, but I prefer not to do that if I can kekwait

peak bloom
#

they just won't work with ImguiContainer

#

I've no clue why they wrapped UItk's colorfield with Imgui one.,.. kinda stupid tbh

gloomy chasm
#

I think it was only in older versions. In newer versions it is its own thing

peak bloom
#

2022.2.x.. too?

peak bloom
gloomy chasm
#

No, in 2022 it should be fully UITK...

peak bloom
#

it is IMGuiContainer, I swear to god 😭

gloomy chasm
#

Well, uh... reflection! 😓

peak bloom
#

yes it works, without a doubt, but as we both know it's not future proof blushie

gloomy chasm
#

Nah, it is pretty solid like 80% of the time. Like the color picker API is probably not going to be touched anytime soon

peak bloom
#

SaveAssets seem to save all dirtied assets which can be problematic to other external libs in a project

gloomy chasm
peak bloom
#

OH! haha..

#

lemme check

gloomy chasm
#

That was sarcasm, there isn't a way to save just one, sorry.

peak bloom
#

lmao, yeah I thought I was, "proly I was blind when I opened the doc multiple times already " 😂

peak bloom
gloomy chasm
#

What is your use-case for saving an asset?

peak bloom
#

it's graphs data basically

#

pretty huge too

#

so every little thing changed in the graph will always saving it to asset

gloomy chasm
#

There is no need to do anything, as long as it is dirty, it will be saved by Unity automatically

peak bloom
#

there's the case of when I did schedule.execute it skip to the next node

#

so related to that too

gloomy chasm
peak bloom
# gloomy chasm What do you mean?

so I have a dialogSystem, so when I hit play (in playmode), the graph will open, it will follow/sync-up with the progression of the playing dialog but. there's a special node that I need to get it's resolved-style while the game is running so I need to schedule it, so it won't throw NaN value, only once i a blue moon tho it would skip

gloomy chasm
peak bloom
#

nda'd so I can't unforutnately

gloomy chasm
#

Ahh good old NDAs.

#

What type of execution are you doing?

#

Could do like a really short delay or something. Or could try using GeometryChanged maybe depending on what the style is

peak bloom
gloomy chasm
#

Then something in your code is real funky 😛

peak bloom
#

it's not my code 😅 it's the same dude who made this humongous thing without binding properties we spoke the other day, you know the undo/redo thing 😂

#

he resigned and somehow I'm handling this mess

gloomy chasm
#

Oof

#

You could try, abstracting the code that runs in the execute method and removing specific things, and share that?

peak bloom
#

duplicate apis all over the place 😂

peak bloom
gloomy chasm
peak bloom
#

aight, that's all for now.. thanks, dude! you're awesome as always 👍

gloomy chasm
#

You're welcome! 😄

peak bloom
#

and sorry for always pinging you 😂

gloomy chasm
#

Lol, all good

whole steppe
gloomy chasm
whole steppe
#

I had a stupid idea, nvm xdd

glad pivot
#

im making a setup scriptable wizard for my plugin and i want to render a texture in the window. How can i make sure it always renders the correct texture? as the texture will be located in a different file once the plugin is installed. in my development project i have the entire plugin in its own folder in the assets folder, but when its installed it will be in the plugins folder

shell beacon
glad pivot
#

i didnt know that worked for plugins cool_think if it does that makes it pretty simple

shell beacon
#

Or you can get the path to your script's cs file and from there it'll be lot more easy..

#

Let me fish a method for you lol...

#

static string GetFilePath([System.Runtime.CompilerServices.CallerFilePath] string callerFilePath = null) => callerFilePath;

#

Usage within a method:
string pathToThisScriptFile = GetFilePath(); // don't pass in parameters to GetFilePath()

#

You're right, don't use resource folder......

gloomy chasm
#

Just to add on to what Roy said. You can then get the your plugin's folder from that, and easily load your texture or other plugin assets.

#

And yeah, it is better to avoid using the Resources folder.

#

You end up with really ugly paths too Assets/YourCompany/YourPlugin/Editor/Resources/YourCompany/YourPlugin/YourTexture.png

shell beacon
glad pivot
#

when i make my own gui for a scriptable wizard, to do that i use OnGUI, but doing that removes the create button. so that doesnt seem to be the intended way to use make the gui, how am i supposed to it instead?

gloomy chasm
glad pivot
#

defining OnGUI removes any of the existing ofc which also removes the button in the corner

#

there doesnt seem to be a way to override it and use base.OnGui()

gloomy chasm
glad pivot
#

its a scriptablewizard, its inheriting from editorwindow. its in the engine by default

gloomy chasm
glad pivot
#

oh, isee that makes more sense

glad pivot
#

is there a way i can run a method once a package has been added to the project? i were using InitializeOnLoad but that proved to be causing issues

#

or even when an update is installed

glad pivot
#

now im getting an error when i open the setup window after detecting an update or the installation of my package. so apparently EditorStyles.centeredGreyMiniLabel is creating a null reference exception. i assume it has something to do with when i open the window automatically. as it only happens when its opened with a method added to Events.registeredPackages. any idea what is wrong here?

i guess this isnt really an editor extention question, though there isnt really much of a place to ask questions about packages shruggie

glad pivot
#

i found a solution to the issue. i just moved the code to a different part of the script and it works every time

glad pivot
gloomy chasm
glad pivot
#

could it be something weird with how im adding the package when im testing it?

#

as im adding it from disk, so if its technically being called from there then it could make sense?

#

yeah, it does in fact seem to be returning the path from my development project isntead of the project its installed in

shell beacon
#

IDK about how you adding the package.. but as @gloomy chasm mentioned this method will give you the caller path
If you have duplicates of this script, then you need to make sure the one you need is executing.
You can also create a script (a helper script maybe) just for that in the root of your directory, where you keep the assembly definition file
And within the script expose that method

#

Obviously you'll have to manipulate the given path for your needs

glad pivot
gloomy chasm
shell beacon
#

It is being compiled into a DLL btw?

glad pivot
glad pivot
shell beacon
#

I think the packages is outside of the project, and in the project you only keep them as dependencies (someone correct me 🙂 )

gloomy chasm
# glad pivot but why is it not even returning a path within the project the package is instal...

Try this. Put this in your package.
YourProject/Packages/YourPackage/Editor/TestScript.cs

public static TestScript {
   public static void Test([System.Runtime.CompilerServices.CallerFilePath] path) { Debug.Log($"FilePath: {path}"); }
}

And this in your other project. Run the MenuItem and tell us what it logs please.
OtherProject/Assets/Editor/TestMenuScript.cs

public static TestMenuScript {
    [MenuItem("Test/Run Test")]
    public static void Test() { TestScript.Test(); }
}
glad pivot
# gloomy chasm Try this. Put this in your package. `YourProject/Packages/YourPackage/Editor/Tes...

ok so if i put this in my package:

public static class TestScript {

    [MenuItem("Test/Run Test package")]
    public static void runTest() => Test();

    public static void Test([System.Runtime.CompilerServices.CallerFilePath] string path = null) { Debug.Log($"FilePath: {path}"); }
}

and this within the other project:

public static class TestMenuScript {
    [MenuItem("Test/Run Test")]
    public static void Test() { TestScript.Test(); }
}

then when i use the menu item from the package Run Test package when its installed in the other project, it returns the file path of the project the package is developed in even though its triggered from the other project.
But the menu item from TestMenuScript returns the correct path from that project.

gloomy chasm
glad pivot
#

ok so it should work if i dont have the package locally from another project then right? as then its not being called from there anymore?

gloomy chasm
#

No, it only matters where you call it from. It doesn't matter if a package is local or not.

glad pivot
#

then what happens if its installed from a git link?

#

would it just throw an exception?

gloomy chasm
#

No, let me try to explain it more

#

It does not matter where the method is that has the CallerFilePath attribute

#

The only thing that matters, is where you call it from.

#

You can think of it as passing a reference to the class

You can sort of think of it like doing this. (This is not valid code, but I hope illustrates what it is doing)

public static class TestMenuScript {
    [MenuItem("Test/Run Test")]
    public static void Test() { TestScript.Test(typeof(TestMenuScript).GetFilePath()); }
}
glad pivot
#

yeah tho i wanted it to be called from a script inside the package go get the package location. so if its isntalled from a git link, the location its called from should be from within the same project right?

gloomy chasm
#

If you call it from within a package, then the path will be within the package

glad pivot
shadow minnow
#

is there a way i can stretch the image of a GUILayout.Label

#
GUILayout.Label(m_PaletteTex, GUILayout.Width(m_PaletteTex.width * 4), GUILayout.Height(m_PaletteTex.height * 4));
waxen sandal
#

GUI.DrawTexture is the right way iirc

shadow minnow
#

what about only displaying a slice of an image?

#

Im making an environment palette editor, the preview image i have here is a texture that contains all of the palettes in sequence, each being a 1px tall horizontal slice; could i display a texture of only the specific slice that is selected?

hollow bluff
#

Is there a way to make property drawers use conditional logic?

waxen sandal
#

In what way

hollow bluff
# waxen sandal In what way

Something like if (exampleBool == true) popup.Add()(new PropertyField(property.FindPropertyRelative(exampleEnum), "Example Enum");

waxen sandal
#

Yeah? Why wouldn't you be able to

#

Are you running into some issue trying tod o that?

hollow bluff
waxen sandal
#

Use serialized properties

#

Just like you're doing for the propertyfield

hollow bluff
waxen sandal
#

property.FindPropertyRelative(exampleBool).boolValue

hollow bluff
peak bloom
#

is Application.logMessageReceived called even when unity crashed?

#

it is not.. F this...

gloomy chasm
peak bloom
#

also AppDomain.FirstChanceException is native call so nothing on Unity side can affect it

#

very unfortunate

gloomy chasm
#

Looks like it is a Mono issue

peak bloom
#

their fork of mono to be exact

gloomy chasm
#

What is it that you are trying to do when Unity crashes?

peak bloom
#

lmao, yeah that's still unfortunate

peak bloom
#

all editor configs are in there

gloomy chasm
peak bloom
#

so the system was made to wait for other changes to meet certain requirements first

#

the buulk save them all

gloomy chasm
peak bloom
#

this wasn't mine originally

#

and I'm not going to re-implement this from scratch.. it's massive

#

wai a sec.. dont type yet

#

So we have this internal tests for editor crashes, which we should pass, before we consider that the tool is done

#

aight thats it 😂

#

the system gets f'd during this test badlly

gloomy chasm
peak bloom
#

unfortunantely, they tested it when all fields were filled and they crashed it. I failed that part.. also I know what you mean

gloomy chasm
#

Something breaking when Unity crashes is a symptom of a problem. Not the problem. The best I can say is to either save them after each value is set, or change something else, whatever it is that is breaking. But trying to do something when Unity crashes is not the right approach

peak bloom
#

one fella told me to capture via winApi, which I'm trying to do now 😅

#

if this is a no go then yeah will do what you usaid

gloomy chasm
peak bloom
peak bloom
#

it's too massive for one person to handle tbfh

gloomy chasm
#

Man... I so want to know what it is xD

gloomy chasm
peak bloom
#

big O will put me in jail 😅

analog laurel
#

how come I'm having issues with element.FindPropertyRelative(value);?
I have a custom class I'm trying to display:

public class Attribute {
  private string _key;
  public string key {
    get => _key;
    set {
      if (_key != value) {
        Debug.Log("Key changed:" + value);
        _key = value;
      }
    }
  }
}```

void DrawListItems(Rect rect, int index, bool isActive, bool isFocused) {
SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index);

SerializedProperty property = element.FindPropertyRelative("key");
if (property != null) {
EditorGUI.PropertyField(
new Rect(rect.x + 20, rect.y + 1, 80, EditorGUIUtility.singleLineHeight),
property,
GUIContent.none
);
}

but it's not displaying the values properly
#

however, if I change _key to public and use:
SerializedProperty property = element.FindPropertyRelative("_key"); instead it works fine

#

even though as far as I can tell, key should be returning _key anyways?

waxen sandal
#

Properties are not serialized so you can't use serializedproperties (I know confusing name)

analog laurel
#

why does _key work but key doesn't?

clear kite
analog laurel
#

so is there no way to get the property instead?

hollow bluff
#

@gloomy chasm Is your editor extension here: https://github.com/MechWarrior99/Bewildered-Core made in IMGUI? I asked about some issues I was having with property drawers here the other day, and you said that trying to use a UI Toolkit property drawer in an IMGUI-based extension might be causing the problem. The particular drawer I was having issues with was inside one of that extension's UDictionary data types, and I'm not having issues with that drawer anywhere else, so I was thinking that that might be the problem?

gloomy chasm
hollow bluff
gloomy chasm
burnt dove
#

How can I show the gizmos of a component which I used hideFlags to make it invisible in the inspector?

gloomy chasm
burnt dove
#

mmm, the idea was to have the gizmos in that component

gloomy chasm
burnt dove
#

The manager component isn't a MonoBehaviour so it doesn't have gizmos.

#

I rewrited my gizmos to use handles instead... thought for the next time I would like to have used gizmos

gloomy chasm
#

You could have your manager add a callback to SceneView.duringSceneGUI and check against Selection.gameObject

burnt dove
#

duringSceneGUI support Gizmos?

gloomy chasm
#

I don't remember, I think so... maybe

#

But Handles has almost all the exact same controls

peak bloom
#

Yeah I went with poor man's way of handling it
1, Serialize to json (only for the active/related tabs)
2. Use SessionState(int) to check on 1st boot after crash (default SS is 0, means it's fresh start)
3. Have a boolean in ScriptableSingleton subscribed to EditorApplication.quitting if quit normally = true, else false
4. Crash the editor.
5. on initializer [InitializeOnLoad] check for SessionState if = 0, means fresh start then check the bool in ScriptableSingleton if false = was crashed, else was fine
6. Deserialize back the json , then reset the states in ss

🥹

#

@gloomy chasm

#

Did it via WinApi too, it worked but was a bit iffy so, yeah

#

time to go home now *putMySunglassesOn 😎

whole steppe
#

Hi! I'm having issue with a property drawer suddenly stopping working and now keeps sending me nullref errors I cant track. I tried rolling back the custom drawer to find out what it was but it's straight up broken it completely and not even reimporting works

#

Atm the property drawer just calls a EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); wrapped around a "BeguinProperty"

whole steppe
#

Nevermind, solved

gloomy chasm
peak bloom
#

almost getting used to this whole custom editor thingy.. still a lot to learn lmao

whole steppe
#

Same mate, same

#

I just learned how the error of trying to FindPropertyRelative with a bad string looks

peak bloom
#

if it wasn't bcos of uitoolkit I'll never want to dive deeper into custom editor stuff

waxen sandal
#

It's not that bad

peak bloom
#

IMGui was super bad kekwait .. UITK made everything, way way easier

weary sage
#

Anyone know why this doesn't work, but if I set the main container it will set the background color for the title container and main container of a custom node?

#

I just want the title to be a different colour, and set the background color for the main container separately....

gloomy chasm
visual stag
#

Maybe the misspelling of dialogue is an issue, who knows

snow summit
#

Anyone knows how to get these foldouts? I cant get the dark background using EditorGUILayout.Foldout or EditorGUILayout.BeginFoldoutGroup

gloomy chasm
snow summit
#

With a GUIStyle?

gloomy chasm
#

Yeah, or you can just draw rects

snow summit
#

Same thing for those? The one highlighted

#

This one is from the editor directly

gloomy chasm
#

I think there might be an internal class that handles drawing that one. But it is component specific. Really, for both you can open up the IMGUI debugger and inspect their style and see for yourself what it is called and what is set

pulsar mica
#

Hello, I hope this channel is close enough to the topic i need help with:
My editor is giving me this error and i think i'm close to solving it but idk where is the right address (see image)
If i could make a forum thread out of this that would be ok too. This problem isnt urgent. Thanks for your time🙏

snow summit
rain flax
#

Has anyone gotten EditorGUI.ObjectField() to take an interface as a type constraint?

#

There are lots of examples in git repos of this working. But those examples no longer work in the current versions of Unity. I wonder if support was actually dropped for this at some point.

waxen sandal
#

Yeah it's pretty new

waxen sandal
rain beacon
#

hey, I'm manipulating directories via code (editor script) (to be specific and speak about Y right away, I'm making a package template, which automatically renames folders, asmdefs, etc), e.g. deleting, moving, renaming and it works fine, except I can't get Unity to properly register my changes. it requires me to restart editor and everything works then. this is unacceptable. I added AssetDatabase.Refresh() and UnityEditor.PackageManager.Client.Resolve() callbacks, but still no luck. specifically I get this warning:

Couldn't create 'C:!my\gamedev\unity-projects\testing-package-template\Packages\com.company-name.package-name/~UnityDirMonSyncFile~44d261d1b2c0f344499aeafe0c15a0ca~'
(it tries to create some sort of internal file in a folder I renamed)

and this error:

ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.UIElements.PropertyField.<CreatePropertyIMGUIContainer>b__43_0 ()
// etc...

how do I mitigate it? is there some guide on manipulating directories from within scripts?

peak bloom
#

in what condition an Undo would lose it's states or cleared from the buffer? I have this weird quirk where one of my Undo.DestroyImmediate and it's derivatives would lose their undo states

waxen sandal
peak bloom
#

yeah thats what I thought, still looking for the cause of it

rain beacon
#

(I should always prefer using FileUtil over System.IO functionality, right?)

waxen sandal
#

I'm not sure what exactly you're trying to do but I'd guess so

rain beacon
waxen sandal
#

It's pretty new so not too familiar with it

#

(that api)

rain beacon
#

I'd guess so
alright

#

I hope it handles meta files automatically 😄

#

otherwise will be pain in the ass

waxen sandal
#

Is the source

waxen sandal
rain beacon
#

oh thanks

waxen sandal
#

Looks like somethigns are native unfortuantely

rain beacon
#

yeah, I will just test how it works practically

waxen sandal
#

Which bit specifically?

rain beacon
# waxen sandal Which bit specifically?

I linked to specific quote, it opens like this highlighting it (in edge at least)
anyway, here it is:

Make sure to include the name of the files or directories at the end of the "to" argument.

waxen sandal
#

They mean dest argument

#

Probably renamed it and forgot to update the docs

rain beacon
waxen sandal
#

Yeah it is

rain beacon
waxen sandal
#

What doesn't work?

rain beacon
#

nothing changed when I replaced System.IO with FileUtil's functions

waxen sandal
rain beacon
#

the thing is

#

everything works

#

except I get these errors

#

which is unacceptable since I'm going to ship this

rain beacon
#

it's just I need to somehow tell Unity that "hey I just renamed these folders, hey I deleted these folders" so that it doesn't try doing its' things to them and throw errors
(presumably some refresh callbacks but idk)

#

ok I now manually remove .meta files of folders I delete, still same errors (warning and error)
I'm totally stuck at this point 😦

peak bloom
#

do your own filtering there

flat remnant
#

Hey, anyone with some knowledge of the Asset PostProcessor? i.e: OnPostprocessAllAssets()
I wrote an Editor script to mass import asset (models/textures) and auto assign textures/materials to models, then generating a prefab.

The problem is that whenever I disable that script (In the Editor folder), my prefabs models loose their materials list.

Am I missing something and there's some api call to make the imported assets "permanent" (so they don't get re-imported again if the script is triggered?)

Any ideas? thanks

waxen sandal
#

It's been a while but that sounds like something else is setting them to null

crude relic
# flat remnant Hey, anyone with some knowledge of the Asset PostProcessor? i.e: OnPostprocessAl...

You are assigning materials to imported models?

Your import stack needs to be deterministic. If you disable a script that performs a postprocess step then that means you've changed the deterministic output and have no reason to expect the imported assets to remain the same (whether that is immediately, after a reload, or if cloning the project directory to a new location).

If you perform a postprocess step that modifies an import then you need to always apply that step. There's no such thing as "fire-and-forget" when dealing with importers

waxen sandal
#

But that shouldn't change assets that are not being reimported (and disabling an importer shouldn't reimport assets)

#

Which is at least my interpretation

crude relic
#

The argument I'm making is that it is moot because the import stack is not deterministic and any future reimport for any reason will overwrite his changes

waxen sandal
#

For sure

#

It also sounds like an xy problem, why do you need to disable that script anyways

crude relic
#

I'm assuming because it is not efficient

#

But I am also curious why you're disabling it

crude relic
#

OnAssignMaterialModel TIL this callback exists

rain beacon
#

what filtering are you proposing me to do?

rain beacon
rain beacon
#

I think I can trigger editor restart, but it's not ideal and I want to avoid that

crude relic
#

@rain beacon call AssetDatabase.ImportAsset or one of its variants

#

and use DeleteAsset instead of file APIs to delete the folders

#

CreateFolder to make folders

#

etc.

#

and use StartAssetEditing and StopAssetEditing to make sure all your changes are batched

#

AssetDatabase has most of the methods you need to do manipulations so you shouldn't need to use raw file apis most of the time

#

just for file writing usually, in which case you'll use ImportAsset

#

Oh, but you are dealing with packages, not project assets?

#

How does that work?

rain beacon
#

not /Packages/

crude relic
#

AssetDatabase is relative to the project root, not the assets folder

#

so there's nothing stopping you from accessing the Packages folder, I don't think

rain beacon
#

well I will try that when I'm home, thanks

crude relic
#

👍

rain beacon
#

so far neither FileUtil nor System.IO work properly

#

(they work, just Unity doesn't register changes properly)

crude relic
#

fileutil is for raw file manipulations, so it doesn't have any knowledge of the asset structure of unity

#

(or vice versa)

rain beacon
#

other than it being from Unity, and therefore knowing about its asset structure, and therefore working with them properly, I don't see it's purpose compared to System.IO

crude relic
#

I think it's on the tin -- it's literally a util for File operations. It looks like it provides a simpler API for common file operations that aren't as intuitive using the std library

#

sometimes there are reasons for doing raw file operations

rain beacon
#

what is example use case

#

for deleting or moving specifically

crude relic
#

anything regarding streamingassets directory

#

I've also done some editor plugin stuff that requires manual file operations

#

but I then import those files using ImportAsset

rain beacon
crude relic
#

yah, so use DeleteAsset when deleting (inc. folders)

#

and ImportAsset for created stuff

rain beacon
#

but.. importing deleted files?

#

ah

#

DeleteAsset

#

alright

crude relic
#

@rain beacon and dont forget to bookend with StartAssetEditing and StopAssetEditing

rain beacon
#

🤔🤔🤔

#

okay..

crude relic
#

it will batch all of your operations so they happen at once

#

rather than import, wait, import, wait

#

it'll be one import op

rain beacon
crude relic
#

it's not really a micro-optimization, it's just a best practice

#

no reason not to get into the habit

rain beacon
#

gotcha

rain beacon
# crude relic it will batch all of your operations so they happen at once

does it actually do anything in this case?

AssetDatabase.StartAssetEditing();
if (pathsToDelete.Count != 0)
{
    AssetDatabase.DeleteAssets(pathsToDelete.ToArray(), new List<string>());
}
AssetDatabase.StopAssetEditing();

it's like a single operation, but at the same time multiple operations 🤔
(well, it's better to make these calls from inside if, but that's not what question is about 😄)

peak bloom
#

what is the best way to get duplicates of objects in hierarchy, like when people doing ctrl+d in hierarchy?

#

I mean, without having to iterate all unrelated objects via HierarchyChanged

peak bloom
#

(pretty sure there's no other way to do it) kekwait

gloomy chasm
peak bloom
#

you're late this time Mr. MechWarrior!

#

😆

earnest copper
#
    [CustomPropertyDrawer(typeof(ItemSpawnConfig))]
    public class ItemSpawnConfigEditor : PropertyDrawer
    {
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;
            if (property.isExpanded) height += 2 * EditorGUIUtility.singleLineHeight;
            return height;
        }

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label);
            if (property.isExpanded)
            {
                var itemIdProp = property.FindPropertyRelative("ItemId");
                var weightProp = property.FindPropertyRelative("Weight");
                EditorGUILayout.PropertyField(itemIdProp);
                EditorGUILayout.PropertyField(weightProp);
            }
        }
    }

I have this custom property drawer (for Item0, 1, etc), but it renders below where the items are supposed to be; am I missing something? I tried using EditorGUI instead of layout as well, it seems the input rect is just starting at the end of where it would've been without a custom drawer

gloomy chasm
flat remnant
waxen sandal
#

I would recommend separating by folder or name then

flat remnant
earnest copper
#

I am dumb, I tried that but I modified the rect.y instead of rect.height 🤦‍♀️
thanks

crude relic
#

afaik it's not tremendously straightforward to extend the functionality of existing importers

#

the 'easiest' way to do this based on what you've said so far would be to create a custom file extension that has its own scripted importer & creates the models with the appropriate settings

peak bloom
#

how can I hide this?

#

second question : How can I prevent user adding new component via dragNdrop on the inspector?

#

Currently I'm thinking of doiing it via MonoB.Reset but proly there's a more graceful way of doing this

crude relic
#

Reset won't allow you to prevent the adding of components

#

Why would you want to prevent the user from adding components

peak bloom
peak bloom
crude relic
crude relic
#

You may be able to do something with hideflags

#

HideFlags.NotEditable

#

Maybe setting that on the gameobject will prevent adding new components?

peak bloom
crude relic
#

It will also prevent values in components from being editable, though

peak bloom
# crude relic Wut

you heard me right, they're doing binding to another api, and the gameObjects in the scene are for retaining some states

#

like there are tons of componnenets there

crude relic
#

Order of components should never be relevant

peak bloom
#

doon't ask me why 😂

crude relic
#

🤔

#

That use case is not supported by the editor

peak bloom
crude relic
#

I don't think GetComponent even makes guarantees about the order in which components are retrieved

peak bloom
#

my keybvoard is broken so pardonn for dplicate lletters 😂

crude relic
#

All good

#

That sucks for coding

peak bloom
#

switching to my other keyboard.. it should fine now UnityChanThumbsUp

crude relic
#

NotEditable is your best bet, but it has other tradeoffs

crude relic
#

Can't edit component values

peak bloom
#

yeah, that's not an option sadly kekwait

crude relic
#

I would seriously question the architecture of something that depends of component order, tho

#

Is this a professional project?

peak bloom
#

the last added will always be put at the bottom/last order

#

just like list

crude relic
#

Note: GetComponent returns only the first matching component found on the GameObject on which it is called, and the order that the components are checked is not defined. Therefore, if there are more than one of the specified type that could match, and you need to find a specific one, you should use Component.GetComponents and check the list of components returned to identify the one you want.

#

The API does not guarantee that the components will be checked in a specific order

peak bloom
crude relic
#

Just because it's doing something specific now doesn't mean it can't change later

#

Practically it's a moot point because as you say it likely iterates down the list in order in the implementation.

peak bloom
crude relic
#

I'm more pointing out the principle that the architecture is poorly thought out and isn't technically to spec

peak bloom
peak bloom
#

I tested this myself as said, it is guaranteed to be always in order with GetComponenets

crude relic
#

Anyway, it's not really possible to prevent people from adding components

peak bloom
crude relic
#

It's one of the core features of the engine 😄

crude relic
crude relic
#

If the project you're working on is an asset that will carry over multiple project versions then this is relevant. If it's a product that is fixed to one version then I'm making a purely rhetorical point since the handling of component order will not realistically change randomly within the same version.

#

And at the end of the day none of this matters because its not your code and you can't make structural changes to it sounds like

peak bloom
crude relic
#

I'll climb off my soapbox now

#

Anyway you're SOL for all intents and purposes

peak bloom
#

definitely true 🥹

#

truly appreciate your help, dude! 👍

crude relic
#

No worries, sorry for the bad news

#

😄

visual stag
waxen sandal
#

Oh my god

#

Did they finally do it?

visual stag
#

Editor: Removed importing of scripts and plugins. The import artifacts for script and plugins are now generated in each Unity Editor session as transient artifacts. This change improves Editor performance as the transient artifacts are faster to generate than performing the imports.
This is also a cool change

gloomy chasm
#

(Even has an example already 😄 )

visual stag
#

Yes (the docs didn't exist when I posted it)

#

I just looked at the source, which was up to date

gloomy chasm
#

Yeah, I was just confused at what it was. So I figured I would check the docs before he source code haha

#

I do kind of feel like they could have just addded support to the existing attribute system instead of creating a new attribute that you need to inherit from though

visual stag
#

I imagine it's a performance consideration or something

gloomy chasm
#

It has been a while since I looked at the property drawer code. But from what I remember, they do special handling for lists/arrays. And this would have been the easiest way to do it with the existing code

visual stag
#

it is weird, because built-in things like Header presumably won't work

gloomy chasm
#

What... looking at the code, it looks very unneeded

visual stag
#

and something like that will now need to have [CollectionHeader] and [Header]?

visual stag
#

I suppose you do already have the PropertyAttribute there in that case, and the other case I'm looking at

gloomy chasm
#

OOOh, I get it, they did it this way because decorator attribtes apply to the elements in the list.

#

But wouldn't it be better to simply add a optional bool to the decorator drawer like applyToCollection or something

#

That seems like a much cleaner way to do it. And lets you use Headers and stuff

visual stag
#

That's what I don't get

#

why not just add a new bool to PropertyAttribute

gloomy chasm
#

Since it is a alpha, I am going to make a forum post and hope that maybe they will be willing to change it to do that instead

#

It would be so much nicer implementation and usage

#

Not that I am holding my breath

visual stag
#

Like am I crazy, but you can't even make Header inherit from PropertyCollectionAttribute to give it the additional functionality of applying to collections instead of the elements

#

because that would make it so you can't apply to normal fields?

gloomy chasm
#

You are not crazy. You would need to make a whole new set of attributes just for collections

#

Like Header and CollectionHeader, Space, CollectionSpace, etc.

visual stag
#

Just seems like a totally nonsensical way to write this

gloomy chasm
#

Thinking about it more, it is even more code too then just a bool

visual stag
#

Yes, you should really open the source with your IDE

gloomy chasm
#

Why is that?

visual stag
#

to see what code is relevant with find references

gloomy chasm
#

Github lets you do that now 😄

visual stag
#

Poorly and slowly

gloomy chasm
#

Seems to work fine enough for this

visual stag
#

Like, do they have some usecase where it would make sense to restrict a PropertyCollectionAttribute from being applied to normal fields

#

Is it like "what if I read arrayLength and use that somehow and now need to handle single fields too"

#

one usecase that I can't even think of a reason for, vs duplicating attributes for most other decorators

gloomy chasm
#

And you could get around that usecase by having the bool be virtual so you can just force it to always be collections only

gloomy chasm
visual stag
gloomy chasm
#

Now, here's hoping they can and will change it! 🤞

alpine bolt
#

Has anyone figured out the correct way to sync transition animation USS classes in UIToolkit with the Unity Editor for Editor Tooling?

#

I'm currently using EditorApplication.update with some boolean checks

        private void OnEditorUpdate()
        {
            if (_updateButtonVisuals)
            {
                _updateButtonVisuals = false;
                DisplayCorrectButtonVisuals();
            }

            if (_updateFieldVisuals)
            {
                _updateFieldVisuals = false;
                DisplayCorrectField();
            }
        }```
alpine bolt
#

So, I have this custom UXML element. It uses context menu (Generic Menu) to switch between some fields with animations (swipes out right one field, swipes left in another field). Turns out that at some given times, if I spam the switch button, the transition animation skips to the end.

#

The way I worked it out is to let the EditorApplication.update do that work for me with the if statements you see in the code

#

But I'm thinking I might be doing something wrong.

#

This is an editor-only tool.

gloomy chasm
alpine bolt
#

because the transition animations of the USS classes take 0.25s, not 0s.

gloomy chasm
#

I guess I am not understanding the issue. So if you spam the button it can sometimes skip the transition. Besides looking a bit ugly. What is the issue that this causes that the above code is fixing

alpine bolt
#

The issue the above code fixes is that it will never skip. It's synced with the Editor and will work as intended

gloomy chasm
#

So it is the ugly skipping to the end that you are trying to fix?

alpine bolt
#

Exactly. I'm just wondering if there's a better way to do it. await Task.Yield(); also seemed to work but I was advised not to use it.

#

It made sense to use it since they are supposedly using async methods in UIToolkit (BindProperty() for example)

gloomy chasm
#

Tbh, I wouldn't worry about it. The chances of someone spamming it are not very high imo. Though would report the issue for sure.

gloomy chasm
alpine bolt
gloomy chasm
blissful burrow
#

is there a good way to store cached session data in the editor, in a way that serializes/survives assembly reload without a lot of boilerplate handling?

#

I've often used hidden game objects with a component on it but it's always felt like such a hack

alpine bolt
blissful burrow
#

without using third party solutions!

visual stag
blissful burrow
#

(this is for a plugin of my own, I don't like having dependencies)

alpine bolt
#

No licensing

blissful burrow
visual stag
#

Also note that both editors and editor windows can have stuff serialized in them while they are open, I feel like a surprising amount of people don't realise that

blissful burrow
#

yeah, in this case it's data I need across separate windows and states

visual stag
#

Darn. Mostly painful then afaik

blissful burrow
#

(it's currently living in an editor tool for example, but I need access to it even when the tool isn't open and from gizmo drawing calls and whatnot)

alpine bolt
#

Everytime I went down that road, the answer I always got was: build your own serializer kekwait

blissful burrow
#

the serialization itself isn't really the issue

#

it's more about lifetime, data storage method and ease of read/write

#

I was thinking maybe I can do the hidden gameobject thing but with a ScriptableObject instead? like a SO HideAndDontSave singleton just sticking around as a data holder. but idk if that's possible

#

you know this kind of thing

gloomy chasm
blissful burrow
#

oh that looks like exactly what I want!

#

thank you!

alpine bolt
#

I had a few problems with its lazy instantiating

#

Ended up using my own version

blissful burrow
#

what kind of issues?

alpine bolt
#

It was like 1 year ago. I can't remember, sorry

#

But it was giving me exceptions

#

I might have a commit somewhere in my version control. I will investigate

peak bloom
#

ScriptableSingleton is just too awesome, lemme tell ya!

#

sad I just found out about it like 4 months ago kekwait

gloomy chasm
#

Yeah I use it a lot. So does Unity internally

blissful burrow
#

mmkay, gonna try this, thanks!

alpine bolt
blissful burrow
#

hmm, okay, we'll see if I run into that

#

my use case is that, I'm making a spline tool, and I need data on which spline components you have selected in the editor, along with which control points on each spline are selected, as well as cached data about each spline (for editor performance reasons)

#

and I have multiple different things that need access to this (inspectors, EditorTool, EditorWindow)

#

and so I wanted to centralize this selection and cached data someplace that survives assembly reloads and isn't tied to any of these other temporary/optional tools/windows

blissful burrow
alpine bolt
blissful burrow
alpine bolt
#

I was mentioning the Blackboard pattern. Maybe it is something you want to pursuit

blissful burrow
#

oh, I, have no clue, I don't know any patterns haha

#

anyway I shouldn't have to initialize it in a static constructor so I think I shoooould be fine

gloomy chasm
# blissful burrow

I think the actually issue is that you are initalizing it in its own static constructor. I feel like I have some code somewhere where I access a ScriptableSingleton in a InitalizeOnLoad static constructor. But I could be wrong.

blissful burrow
#

I feel like it shouldn't matter where it's initializing from

#

I would expect the same issue in a different static constructor

gloomy chasm
#

I was thinking that maybe the InitalizeOnLoad was playing funny with the instance constructor. But I guess not

alpine bolt
gloomy chasm
#

Works fine calling it from other a InitalizeOnLoad static constructor

blissful burrow
#

oh, huh, bizarre

#

I don't thiiiink I'll need to statically load it anyway, so I should be good

#

thanks for the help!

gloomy chasm
#

Sure thing!

peak bloom
#

@gloomy chasm is ObjectFactory.componentWasAdded gives the actual reference to the component that's just added to the gameObject or not?

gloomy chasm
peak bloom
gloomy chasm
peak bloom
#

aight, thanks.. as usual 👍

blissful burrow
#

is there a SerializableDictionary in editor yet?

#

I vaguely recall there was some

#

in some obscure namespace, like Rendering or something

#

oh here we go lol

#

love it when Unity.Cloud.Collaborate.Common

gloomy chasm
#

You would think that at this point they would have added one. I know there are a number of internal implementations like that one in cloud. But here we are, still not serializable dictionary.

blissful burrow
#

yeeeah it's odd

short tiger
#

Unity has commitment issues. Easier to make another internal implementation and not have to deal with writing documentation for it and supporting it forevermore.

#

Or in this case, copy one from Unity Answers :P

blissful burrow
#

yeah I just stole the same code that unity did

gloomy chasm
#

lol

brazen cave
#

I need a camera object to always look at another object in the scene view. that is in the editor window. am i in the correct chat section

crude relic
#

Yes

#

The simplest way to do this imo is by using a script annotated with the ExecuteAlways attribute

peak bloom
#

It's kinda odd that they added dependencies feature to their own official packages but would not allow us to have access to it

#

my concern is that I'm planning to make an asset store package but it depends on another package on assets store, and we don't have a way too automagically download the dependencies on AssetsStore

#

I'm guessing their burden on this matter related to licensing issues

flat remnant
# crude relic You are assigning materials to imported models? Your import stack needs to be d...

Yes, I am creating/assigning materials and textures manually then turning it into a prefab, but there's also the model asset which "holds" the materials. (script: https://pastebin.com/UiRTLf89)

Thanks for explaining, and sorry though, I need to wrap my head around this, I (wrongly) assumed the processed assets would become a unique "piece" of data, as unique assets and it's components.
But it does seem that removing the custom AssetProcessor script from the Editor folder, causes the assets to re-import and of course no custom processing, the assets are re-imported with raw default settings.

Is there some way the processed assets can be saved for lack of a better word "be hardcoded" and not be re-imported if the AssetProcessor script is triggered?

Thanks

cinder crow
#
using UnityEngine;
using UnityEngine.PostProcessing;

namespace UnityEditor.PostProcessing
{
    [CustomPropertyDrawer(typeof(MinAttribute))]
    sealed class MinDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            MinAttribute attribute = (MinAttribute)base.attribute;

            if (property.propertyType == SerializedPropertyType.Integer)
            {
                int v = EditorGUI.IntField(position, label, property.intValue);
                property.intValue = (int)Mathf.Max(v, attribute.min);
            }
            else if (property.propertyType == SerializedPropertyType.Float)
            {
                float v = EditorGUI.FloatField(position, label, property.floatValue);
                property.floatValue = Mathf.Max(v, attribute.min);
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
            }
        }
    }
}

waxen sandal
#

Don't do using UnityEngine.PostProcessing;

#

Also you know you could've asked q uestion isntead of just posting an error

#

Oh wiat

#

It's not even a custom editor

#

Fully qualify the type instead

peak bloom
#

how would you make the custom editor window remember where it was docked in the Unity editor?

waxen sandal
#

It does by default

peak bloom
#

thanks!

peak bloom
waxen sandal
#

I forgot but look at the parent classes of EditorWindow

#

IIRC one of them has something

#

There's no predefined areas though

#

So you need to look at which windows are docked in the same area

peak bloom
#

noted, thanks! looking into it now 👍

gloomy chasm
peak bloom
#

aight, thanks Mr.Mecha! I'll be back with tons of questions once I hit a brick wall 😂

shell beacon
#

Hi, is there a way to detect when a user changes "pro skin"? or should I check every frame 🤔

waxen sandal
#

IIRC it recreates the windows when you change skin and it should work automatically if you check on creation?

shell beacon
#

Oh I'll check that

#

Oh yea it works 🙂 thanks!

crude relic
#

I bet there's a way to make that work using a custom scripted importer as well but not sure without playing with it myself

peak bloom
tawdry plume
#

Greetings, I am writing a PropertyDrawer for a generic class, so something like this.

[Serializable]
public class Foo<T> {}

[CustomPropertyDrawer(typeof(Foo<>))]
public class FooDrawer : PropertyDrawer {}

In FooDrawer, I need to get the generic argument T of Foo. This is easily done with

fieldInfo.FieldType.GetGenericArguments()[0];

However, this does not work, when there is an array of Foos, as fieldInfo will point to the array itself. Currently I have the following solution.

type = (fieldInfo.FieldType.IsArray ? fieldInfo.FieldType.GetElementType() : fieldInfo.FieldType).GetGenericArguments()[0];

I did however notice that there is an extension method to SerializedProperty in Unity.VisualScripting, GetUnderlyingType, which seems to get directly to Foo, even if it's in an array. So the following would work.

type = property.GetUnderlyingType().GetGenericArguments()[0];

So my questions are:

  • Is either of these two approaches better, or is there an even better solution?
  • I've never interacted with VisualScripting, but why is there a namespace for it in C#? Is there a reason to not use it?

Thanks!

waxen sandal
#

Both seem fine to me

#

I'm guessing visualscripting might be in an optional package so it might not be available in other projects

#

And for why it's there, well I guess they need some C# side of things for the editor and stuff

tawdry plume
#

Alright, thanks.

weary sage
#

Can anyone help with the syntax here? I'm trying to get the Asset name of a file from a SerializableObject. I can see the property I need is m_Name, but when I use find property and string value the string is empty.

crude relic
#

Try "name"

weary sage
crude relic
#

👍

shell beacon
#

Hi guys, does EditorGUI.GetPropertyHeight() ignore HeaderAttribute? consider the code in this image

#

Produces the following result (notice the 4 keyword fields, yea it should be 4 lol)

#

Oh and this is the class BTW

shell beacon
waxen sandal
#

Not sure but I think your addition of height is wrong

#

Doesn't it set rect.height to height before adding it to y?

#

Hence you're taking the new property's height instead of the one you just drew

#

Pretty sure somethin else in your math is also wrong

#

Look at keywords for example

#

It's supposed to draw 4 fields

shell beacon
#

That's how it works, isn't it? you define a rect and then draw it

waxen sandal
#

But there's only 3 properly layouted and 1 drawn behind

shell beacon
#

Yes it got swallowed lol

shell beacon
#

Oh I'll add this now and see!

waxen sandal
#

It won't fix the issue but it'll look nicer

#

I think like 26 is wrong

#

Set height to EditorGUIUtility.SingleLineHeight

shell beacon
#

Line 26 is fine tho.. it's just the height of the foldout

waxen sandal
#

It's the height of the foldout plus all it's children

shell beacon
#

The last bool parameter (include children) doesn't changes anything

#

This is how it looks without my PropertyDrawer

#

I only need it to detect if something has changed lol 🤦‍♂️

waxen sandal
#

Detect whether anything has changed?

#

Or detect whether a specific thing has changed

shell beacon
#

Anything.. ColorScheme is a serializable class that I'm using in a ScriptableObject. two instances for dark and light..

waxen sandal
#

I'd just make a custom editor for your ScriptableObject then that just calls EditorGUILayout.PropertyField

#

Way easier

shell beacon
#

I draw that SO (called Theme) in a settings provider but I want to detect if any color has changed (not the foldout lol) regardless of where it shows up (settings or inspector)
GUI.changed is true even if the foldout toggle is changed.. so it isn't good

waxen sandal
#

Ah

shell beacon
#

Yea I tried that but it doesn't detect changes within ColorScheme..

#

With that PropertyDrawer workaround looks like only the properties that have a HeaderAttribute are pushed down

waxen sandal
#

I mean you can try to see if it has the wrong height for that property

#

But I doubt it

#

Because it shouldn't be any different from how Unity draws it

#

Do me a favor and replace line 37 with

rect.y += rect.height;
rect.height = height;
shell beacon
#

oh I just did that lol

#

Yea it was it

#

🤦‍♂️

#

I suddenly understood what you said earlier.. I feel stupid now 😅 thanks! looks awesome now

waxen sandal
#

👍

#

@shell beacon You should change that _foldout to be property.isExpanded instead

shell beacon
#

Thanks, will do!

#

Final code. we work so hard to make it looks like we didn't do anything lol

peak summit
#

does onscenegui work as an update

#

apparently it does

#

I want the function of Handles.PositionHandle but with a different visual indicator than this

#

the green red and blue lines are too noisy

#

anyone know what I should do, or at least what I should look up

gloomy chasm
peak summit
#

oh, sorry, i didn't clarify that I want to get rid of the arrows and just use like a dot to drag a point in the editor like how cinemachine has those dragable dots in the track

#

@gloomy chasm

gloomy chasm
peak summit
#

Cool i'll try it out

#

@gloomy chasm Awesome it's perfect

gloomy chasm
peak summit
#

i wanna just draw like a circle sprite, instead of using the sphere handle cap

#

which would require a custom handlecap function

#

and theres no documentation on how to do that

#

I'll just ignore it tho and use the ugly spheres lol

gloomy chasm
#

Basically all the handle cap functions are, are GL calls

peak bloom
#

is there any callback for when we're in the middle of dragging scene objects in hierarchy?

peak bloom
#

Aight, testing it.. I'll be back 🫡

rain beacon
#

how do I make these unfoldable lists respect EditorGUI.indentLevel? it doesn't work on them (e.g. fields on the above are indentLevel 1)🤔

#

actually ok I'm dumb there, I use this code:

            public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.indentLevel = ((IndentAttribute)attribute).indent;
            EditorGUI.PropertyField(position, property, label);
            EditorGUI.indentLevel = 0;
        }

but lists/arrays are obviously not properties🙃 (yes?...)

bitter forge
#

is there any simple and possible free extension that convert ContextMenu(..) to Button in the editor? or even use a different attribute so you can specify other things? 😅

peak bloom
#

many new stuffs

whole steppe
#

Hey. I'm writing a PropertyDrawer. It works for the case that the type is not used as an array. But when the type is used as an array, the drawer renders outside of the assigned array space

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

When I use EditorGui.LabelField(position, label) it works, but I need other components of EditorGuiLayout

gloomy chasm
gloomy chasm
whole steppe
#

So I can only use EditorGui?

gloomy chasm
whole steppe
#

God damn, Unity UI is such a mess...
Thank you

gloomy chasm
whole steppe
#

Need the DropdownButton, but there is also one in EditorGUI as I just noticed. Would just be nice to not calculate all the positions manually.

gloomy chasm
#

Ahh, yeah it is a bit annoying. But makes sense once you understand how it all works

whole steppe
#

Thank you anyway

whole steppe
#

In a PropertyDrawer I want to display a HelpBox under certain conditions. That means that my Property draws in different heights.
How would I properly do that? As I need to feed the height with float GetPropertyHeight(SerializedProperty property, GUIContent label) which seems to get called before OnGui. And the HelpBox has different size depending on the content and the width of the Inspector window. Thus I would need to get the height of the TextBox before I know what is needed.

I would create a elements I need beforehand in float GetPropertyHeight(...) but I'm not allowed to store them as member of the Drawer.

In Addition, how would I get the size of EditorGUI.HelpBox(...)? That function just draws the element, I don't event get a Handle to the Element to do something with it

gloomy chasm
# whole steppe In a PropertyDrawer I want to display a HelpBox under certain conditions. That m...

GetPropertyHeight is called before OnGUI, but they both get called 'every' frame.

You can use EditorStyles.helpBox to get the style, and you can calculate the height from that. Sadly the only real way to get the width is to use EditorGUIUtility.currentViewWidth.

This isn't really something that was considered (or was and ignored) when they designed the PropertyDrawer system. It is what it is.
At least UIToolkit is much better with this sort of thing.

whole steppe
#

What other Options would i have to the PropertyDrawer? I only want to change the rendering for that single Type, I don't want to write an Editor for the entire outer class, which would also mean that the Type would not work when used somewhere else.

EditorGuiLayout was working properly with the dynamic height, until I failed with the array stuff. Now I wrote a Wrapper for Rect to easier align the elements for EditorGUI and now it fails at the dynamic height...

shell beacon
#

I have a basic question..
Is it a good practice to let serializable classes to inherit from UnityEngine.Object? just to deal with it as a serialized property..

#

For example, let's say we have a mono behavior class called "MyClass", within it we have serializable inner class called "Data" and within MyClass we have a few "Data" fields

blissful burrow
#

I would say you should only inherit from UnityEngine.Object if you intend to store that object either in the scene or as an asset, since it now has a lifetime dependent on those

#

so if the data is solely the responsibility of your monobehavior, then you should definitely not have fields that are UnityEngine.Object, unless you want those to be assigned assets from your assets folder, or similar

#

I tend to have several nested serialized C# types (non-UnityEngine.Objects) in my scripts

#

uh ping @shell beacon, just in case henlo

gloomy chasm
#

I don't think you can inherit directly from UnityEngine.Object even.

#

If memory serves it requires a C++ counterpart.

blissful burrow
#

oh, in my case I'm assuming by "inherit from UnityEngine.Object" to mean "inherit from any type inheriting from UnityEngine.Object", which usually means ScriptableObject

gloomy chasm
#

Oh, yeah I wasn't quite sure which way it was intended.

shell beacon
#

Oh I meant directly from UnityEngine.Object lol
So we can't? I assumed we can

gloomy chasm
#

But yeah, just have plain old C# class and structs that are Serializable unless you have a benefit for using ScriptableObjects.

gloomy chasm
blissful burrow
#

regular ol C# types serialize just fine as long as you mark the type as [Serializable] and use serializable types within the fields, and mark them with [SerializeField] in case they're not public but should be serialized

gloomy chasm
#

What was your thinking/reasoning @shell beacon for wanting to inherit from UnityEngine.Object instead?

shell beacon
#

But you need to create a serialized object for them to let the editor "do stuff" for you.. no?

blissful burrow
#

now I'm not sure what you mean. you don't need a serialized object in order to do things in the editor

#

but I guess it depends on what you mean by "do stuff"

shell beacon
gloomy chasm
shell beacon
#

yes

blissful burrow
#

oh is this specifically for drawing the GUI of a serialized field?

gloomy chasm
shell beacon
#

Yes I have something open..

blissful burrow
#

then usually if you want to do something fancy you would make a PropertyDrawer for your type

shell beacon
#

I need that object value lol

shell beacon
gloomy chasm
shell beacon
#

Well.. there isn't any issue there but lets assume isDefaultProperty is not a boolean but a serializable class

blissful burrow
gloomy chasm
#

Then you do isDefaultProperty.FindRelativeProperty("myBool")

gloomy chasm
blissful burrow
#

yeah, like I said you probably shouldn't use it directly

shell beacon
gloomy chasm
blissful burrow
#

yeah

#

anyway I also have a question henlo

shell beacon
#

lol I'll treat it with care 😂

#

Thanks guys!

gloomy chasm
blissful burrow
#

how do I make custom icons/gizmos for scripts not look like trashgarbage? and yes I have bilinear mip filtering on, as you can see the scene view version looks fine

#

do I have to set up like a custom icon drawer script to retreive the correct version based on DPI and and and and tired

gloomy chasm
#

Yeah it is 16x16 for the component icons

blissful burrow
#

they're not 16x16 in the scene view though

#

so clearly there's some support for scaling that shouldn't use point filtering in Unity's own components

gloomy chasm
#

I think that is the @2x alternative that you are seeing

blissful burrow
#

it's possible yeah, but, is there a way to implement that? I don't see any way to pick different icons for scene view vs component 1x vs component 2x

gloomy chasm
#

It does it automagically

#

Like it does with dark vs light icons

blissful burrow
#

I know that's how the GUI icons work, but I don't know how to add it to my custom script components

gloomy chasm
#

I think it looks at the file path for the assigned icon and checks for an texture with the correct name. It has been a bit since I did custom icons for a component though, so...

blissful burrow
#

hm, I can only find the name rules for, a general icon, not the scene view/gizmo or the 2x variants

#

I can experiment I suppose

#

I just don't understand why the component UI icon is point filtered tired

gloomy chasm
#

Also if you are in 2021, looks like there is a [Icon] attribute you add to the MonoBehaviour.

blissful burrow
#

hmm, project relative path sounds, scary

gloomy chasm
#

Packages

blissful burrow
#

(it's for a plugin, so, users could theoretically put it anywhere)

#

me: oh Ill do something relaxing, like adding cute lil icons to my plugin henlo
unity:

gloomy chasm
#

Not quite sure about the scene icon

blissful burrow
#

that works for only the 16x16 case though

#

but then the scene view and the high-DPI monitor variants look bad

gloomy chasm
#

Not sure about the sceneview yet. But it should automatically use the high DPI variant if it is using the correct suffix

blissful burrow
#

the high DPI variant is separate from the scene view icon

gloomy chasm
#

Yeah, seems so

#

I would take a look at the Splines package or the new Cinemachine 3.0 package and see if you can see how they handle the SceneView.
It really is sad how much of a undocumented pain it is to add icons to components. They make components so much nicer and polished

gloomy chasm
blissful burrow
#

hmmyeah, still not sure how to make unity use them for custom components though

gloomy chasm
#

You mean the gizmos?

blissful burrow
#

yeah, well, the gizmos and the icons

#

fine if I was making a custom UI, but this is Unity's UI

tepid pine
#

I have implemented a DrawIf functionality using an attribute that disables a field in the inspector if a condition is false. My problem is that I would like to apply it to a class that already has a property drawer to display it nicely, but unfortunately it doesn't work as expected. The property drawer for DrawIf seems to override or interfere with the existing property drawer in a way that I don't understand.

#
public TypeReference<int> type;
#
[DrawIf(nameof(greatNumber), 6, DisablingType.ReadOnly, ComparisonOperator.GreaterThanOrEqual)]
public TypeReference<int> type;
#

For now i use

EditorGUI.PropertyField(position, property, label, true);

to draw the property field from DrawIf

peak bloom
#

how can I use serializedObject.FindProperty on a List?

#

for example if I want to find stuff at myList[i]

#

ah I see now.. we must contain it in SerializedObject first then iterate over it

waxen sandal
#

Find the list then get element at position

#

At index I mean

peak bloom
#

yes, I made it to work already, thanks 👍

quasi bluff
#

Hey people, I get the following errors when I try to install the "Netcode for GameObjects" package, anyone know what should I do about it ? is it a problem with my connection or is it something I need to do ?

[Package Manager Window] Cannot perform upm operation: Unable to add package [com.unity.netcode.gameobjects@1.4.0]: One or more dependencies could not be added to the local file system: com.unity.burst: aborted [NotFound]. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

[Package Manager Window] Error adding package: com.unity.netcode.gameobjects@1.4.0. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

the first error asks for the "Burst" compiler package as a dependency, when I tried to install that separately it gave me an error as well,
I deleted the "packages-lock.json" and "manifest" files and reseted my packages to default from the "help" tab and it didnt help.

any other suggestions would be helpful.

visual stag
peak bloom
#

I have this specific case where I made a custom inspector then I also want to mirror/show it to custom Editor window via InspectorElement in uitk..

So how should i go about hiding the inspector one(not shown in the inspector) but I want to just display it in my custom editor window

This what I came up with, it works, but as you see it's ugly and can go south pretty easily

        public override VisualElement CreateInspectorGUI()
        {
            rootHost = new VisualElement();

            try
            {
                return rootHost;
            }
            finally
            {
                rootHost.schedule.Execute(()=>
                {
                    if(rootHost.parent.name != "hostInput")
                    {
                        rootHost.RemoveFromHierarchy();
                    }
                }).ExecuteLater(16);
            }
        }
#

note : "hostInput" is my custom editor container

#

oh wait, it removes whats shown in my custom editor too.. lmao.. I mean, its via inspectorelement so that's kinda expected lol

#

oh! hideflags did the job!

#

it's hidden in inspector but shown in my inspectorElement ✨ 🤘

zinc wasp
#

How can I put a drop-down selection menu in an EditorWindow? (Similar to an enum selector in the inspector)

#

can't find anything like it in the UI Builder

zinc wasp
# gloomy chasm

Interesting, that's not there on my version (2020)
I'm currently in the process of porting to 2022 so that might fix it

glad cliff
#

I have a small problem where Undo/Redo operaions in my custom tool takes some time to execute. Whenever something changes in my data I use Undo.RegisterCompleteObjectUndo, because there is quite a lot of things that can change at once.
Now, I need some clarification on how Undo.RecordObject works couse im not sure. As I understand it records only a single change, right? So I assume it is the first change made to the object after invoking this method, correct?

#

and this undo operation then stores only info about a single property change and not about whole object? or not?

#

because I wonder if instead of doing this:

private void OnChangesMade(){
Undo.RegisterCompleteObjectUndo(myObject, "change")
//Apply all the changes
}

making it like so:

private void OnChangesMade(){
Undo.CreateGroup() //dont remember proper invokation, but its not important
foreach(var change in changes)
{
Undo.RecordObject()
//Apply Single Change
}
Undo.CollapseUndo()
}

will result in faster Undo/Redo

#

obv this operation would look different, but you get the point. I would like to know if this will work faster before trying to implement it, couse in reality It will be much more coding :/

gloomy chasm
peak bloom
glad cliff
#

simply saying RecordObject stores info only about a single change, and RegisterComplete will create a copy of full object to compare the changes made

#

but I dont know how the real nooks and crannies of it work

gloomy chasm
#

@glad cliff @peak bloom so (per the docs) RecordObject creates a copy of the object, and at the end of the frame does a diff to see what properties changed. RegisterCompleteObjectUndo stores a complete copy of the object that it restores.

glad cliff
#

thus I wonder if doing multiple RecordObject will result in faster Undo operations than REgisterComplete

gloomy chasm
#

If you can help it, using SerializedObject is far better for modifying properties in the editor than Undo

glad cliff
gloomy chasm
peak bloom
#

ah I see

glad cliff
#

ohh so you mean it does not create AND SAVE the copy, but rather create copy and the only thing that is remembered is a difference? (with RecordObject)

gloomy chasm
#

Yup

glad cliff
#

right roght!