#↕️┃editor-extensions

1 messages · Page 34 of 1

dusk dome
#

oh right

#

do handles have equivalent API?

#

for stuff like drawing spheres and circles?

minor knoll
#

Yes, for those things it has almost the same things as the gizmos

#

but it misses some things that are not available so if you really need gizmos you can create a monobehaviour in the scene in OnEnable and in onDestroy of your window you can delete the object

real spindle
dusk dome
real spindle
#

Use the docs/google mate

#

But no i havent seen a capsule function

#

Two spherehandlecaps + one cylinderhandlecap should do it though

#

Idk if you mean 3D or 2D capsule though

dusk dome
#

why does it look so different in the builder vs in the actual window?

gloomy chasm
#

The reason it is different is the UIBuilder is using the runtime/in-game uss styling. Not the editor styling

dusk dome
#

this is done exactly what i needed

#

no more guessing lol

gloomy chasm
#

Hahaha

dusk dome
#

im getting started with it rn, its a lot at once but I think i'll pick it up pretty quickly

#

its mostly just object fields that i plan to mess with currently.

#

object fields and inspector elements

#

nothing too fancy

#

ah the object field didnt show up in the old mode, now im in editor mode this looks a lot easier

gloomy chasm
#

Yeah haha

#

Same with like PropertyField and some toolbars and stuff

dusk dome
gloomy chasm
#

Yeah that that is annoying to do. Though not too hard.

dusk dome
gloomy chasm
# dusk dome How can I make something happen when a value changes? You said it was an event o...

If you want to bind the value of the field to a vale on your data object (component, editor window, or scriptable object), you can set the binding path to be the SerializedProperty path.

If you just want to do something when the value changes, you just regiter a change event in C#

objField.RegisterValueChangeEvent(evt => {
 // Do something here. You can make it a method instead of a lambda if you want.
});
dusk dome
gloomy chasm
#

Yuuup exactly like that

#

Was about to say haha. Basically that is just fancy way of looping through every element recursively to find one that is of type VisualElement and with .name set to "MainElement"

#

(I think it does caching and stuff so it is faster than doing a recursive loop yourself though. Could be wrong)

#

And that Q method is just a wrapper around a larger .Query() API that you can use if you need more specific/advanced searching. Like excluding (I think) and checking for specific decedents chains.

dusk dome
gloomy chasm
#

You would want to use a class called a PreviewRenderUtility and call it's render methods inside of a IMGUIContainer `VisualElement.

dusk dome
#

it would make more sense to just use the prefab window

gloomy chasm
dusk dome
#

an API I forgot about

dusk dome
#

making some progress, but i feel like a long list like this could do with better formatting. Is there a way for me to achieve something like that?

dusk dome
#
 private void ActiveMoveValueChanged(ChangeEvent<string> evt)
    {
        if (moveDictionary.TryGetValue(evt.newValue, out Move move))
        {
            Debug.Log("Move changed to " + move.Name);
            activeMove = move;
            UpdateActiveMoveWindow();
            SerializedObject serializedObject = new SerializedObject(activeMove);
            MoveDataField.Bind(serializedObject);
            Debug.Log("Bound to " + serializedObject.targetObject.name);
            
        }
    }

I've bound to a serialised object, yet i dont see anything in the window. what am i doing wrong?

gloomy chasm
dusk dome
#

and what do i change it to

gloomy chasm
#

You set the bindingPath on the element to be the path of the serialized field you want to bind to. So if your BrawlerMoveset class has a field like [SerializeField] private string _myName; you se the binding path to "_myName"

dusk dome
gloomy chasm
dusk dome
# gloomy chasm The fields searches 'up' to the first parent/ancestor that is bound. So you can ...

I see.

public class Move : AssetObject
    {
// ONE FIELD FOR THIS STUFF
        [Header("Basic Information")]
        public string MoveName => "metarig_" + Name;
        public int stateID;
        public FP RecoveryFramesFP => (FP._1 / (FP)60) * RecoveryFrames;
        public FP LandingFramesFP => (FP._1 / (FP)60) * LandingFrames;

        public string Name;
        public QBoolean isAttack;
        public QBoolean moveIsGrab;
        public MoveDirection MoveDirection;
        public ButtonState moveButton;
        
        public int RecoveryFrames = 6;
        public int LandingFrames = 10;
        
        [Header("Misc. Information")]
        public QBoolean dontChargeUlt;
        public QBoolean followAttackerVelocity;
        public QBoolean dontHitStop;
        public QBoolean persistent;
        public int persistentTimerLength;
        public bool recoveryMove;
        public bool dontInterruptOnLand;
        public int invulnFrames;
        public int intangFrames;

        [Header("Sound Information")]
        public AudioClip[] moveHitClips;
        public AudioClip[] moveSwingClips;
// END FIELD

        [Header("Frame Data")]
        public List<FrameData> FrameData;
// ONE FIELD FOR A SINGULAR FRAME DATA INSTANCE WITH AN INDEX

        [Header("Misc Information")]
        public FP chargeCost;
    }

Essentially, What I wanna do here is make 2 fields, as the comments show

gloomy chasm
#

What do you mean by a 'field'?

dusk dome
gloomy chasm
#

You just add a element for each serialized field and set the binding path. You can just add a PropertyField for each instead of having to use the specific type per field. Like a TextField for a string and a EnumDropdown for ButtonState, etc.

dusk dome
gloomy chasm
#

Nope, unless you want to group them all inside of a class instead.

#

It isn't too bad, just takes like 2 minutes

dusk dome
#

what about for the list of FrameDatas? can I display a singular FrameData object without much problem using data bindings and an index?

gloomy chasm
#

Yup, just data bind a ListView and it will use the property drawer for the FrameData and automatically populate it.

dusk dome
gloomy chasm
#

Ah then you will have to do that manually, but it isn't too bad.

#

Just whenever the slider value changes, you do

var newIndex = evt.newValue;
frameDataPropertyField.bindingPath = $"FrameData.Array.data[{newIndex}]";

That should rebinding it. And just have frameDataPropertyField be a PropertyField

#

If you don't like using strings like that you can also doframeDataPropertyField.BindProperty(serializedObject.FindProperty("FrameData").GetArrayElementAt(newIndex));

dusk dome
#

or I guess when I create the buttons I can just assign the callbacks in the for each loop

gloomy chasm
dusk dome
#

how can I just flush out all the buttons in a visual element? I've been using them as divs of sorts, if that's a good idea or not

dusk dome
gloomy chasm
#

You probably want to use a Radio button then

dusk dome
#

instead of a long single file line

#

I see

dusk dome
gloomy chasm
#

element.Clear()

dusk dome
#

and that clears any children of the element?

gloomy chasm
gloomy chasm
dusk dome
#

should be done by tomorrow with this

gloomy chasm
#

Nice!

ruby kite
#

are there any extensions to allow you to run a serverbuild in the inspector? so i can see the loaded objects etc

crisp portal
#

Hey, is there any way to change the external script editor via code? I'm using cursor but want to debug in rider, so I created a button in the editor to open rider for debugging, but it doesn't attach the unity project because it's not set as external editor in the preferences...

dusk dome
#

cus I see you're using Array in that binding path

dusk dome
gloomy chasm
#

Also, lists and arrays are both just serialized as arrays, since there is no difference in their data (a list is just a fancy wrapper around an array after all)

dusk dome
gloomy chasm
dusk dome
#

or maybe making the datatype FrameDatum

#

but that doesn't really work either

#

I'll just stick with this

gloomy chasm
#

I think it is fine in this case, it is pretty common to have the type and property name the same

topaz bobcat
#

Hi everyone, I'm trying to create a custom inspector for a script using UI Toolkit and I have a foldout that displays some extra information to users. The problem I'm having is that I want this foldout to keep its state (either open or closed) when clicking other objects or entering playmode, but no matter what I do, it keeps resetting state. I've tried using a static variable and it works fine when clicking on other objects, but as soon as I enter playmode, because there's a domain reload, the variable resets state again.
Is there a way to save the state when entering playmode? I thought about using PlayerPrefs but sounds like overkill for something so small...

#

Like, Unity keeps the state of a list foldout between Edit mode and Play mode, but how do they do it?

gloomy chasm
#

Similar API to EditorPrefs or PlayerPrefs but only keeps the data while the editor is open.

topaz bobcat
twin dawn
#

Presumably nodeMap.gizmoColor; is beige. Have you debugged it? Like logged the color?

robust ridge
twin dawn
idle violet
idle violet
twin dawn
idle violet
robust ridge
robust ridge
#

Theoretically they should both be the same but I don't know

twin dawn
#

why hestitate to just log both

#

get as much info as possible

idle violet
#

Then where do I go?

surreal girder
robust ridge
#

Turns out whenever the sphere is clicked, it immediately becomes gizmoColor, but sometimes, when hovering the mouse near it, it just becomes that weird beige color. I just want it to always be gizmoColor, so I got no idea what's going on

gloomy chasm
#

You can look at the source code for more insight on how it is implement, it is relatively straight forward.

hardy raptor
#

I wanted to add a scroll view to my editor window, but only vertically. But no matter what I try Unity keeps adding a horizontal one too even if there is more than enough horizontal space it still adds one for a few px of scrolling. (if the window is a bit smaller it cuts off half even though it fits fine in the window without a scroll view)
I only want it to scroll vertically and horizontal should behave like without a scroll view. Is that possible?

I also tried

GUILayout.BeginVertical(GUILayout.Width(width));

but if it just gets ignored unless I make it bigger than Unity already made the contnet

dusk dome
#

I have these buttons with flex grow 1. How can I make it so there are max 5 Buttons before an overflow?

#

i dont seem to see a grid option

surreal girder
gloomy chasm
#

I think that would do it at least

#

But yeah, a grid isn't exactly supported. There is a multi column tree view, which is basically a table. With rows and columns but I think that is overkill for what you need.

dusk dome
#

its annoying for buttons with longer names

#

maybe i'll make it 3 per instead

gloomy chasm
#

Yeah uss is just amore limited subset of css! 😄

dusk dome
#

okay, i've got a good start here, but with these serialised objects, it doesnt appear to draw the custom property drawers. How can I do that?

#

this is what theyre meant to look like

#

interestingly enough, the drawer appears to be rendering with the Charge Cost, but not for the Self Launch Angle, both of which use the same type

#

every time the domain reloads different things get serialised 😭

#

okay now they're all here??? wtf

#

and now theyre all gone again

#

im so damn confused

#

it appears to be very temperamental. How can I sort this out?

past crane
#

That is indeed weird. Maybe the height for the drawer is incorrect?

dusk dome
#

I'll check, but I haven't hard coded any heights

#

as you can see, in the start, it renders properly. when I go to a new one which hasnt been rendered yet, it appears to not render properly.

past crane
#

Oh, I didn't know this was with UI Toolkit. With the old GUI editor, you usually have to calculate the height . . .

dusk dome
#

left it for tonight but there must be a way to like, force it to render the IMGUI container?

potent marlin
#

Hey everyone, after 3 days of fighting with this and ChatGPT I need help. I have a custom editor that I have watered down to next to nothing and Unity keeps clipping content that is in a negative position. I have seen many other editors that have pan and zoom functionality render stuff outside of the default viewport but I cannot get this to work for the life of me. Any guidance please? NOTE The editor script is too long for discord so I attached it as a .cs file

gloomy chasm
potent marlin
#

These are the 2 nodes, both are partially drawn due to being out of the initial windows size:

#

The one on the right is just barely clipping whereas the one on the is almost fully clipped. When you pan with the middle mouse button, they also don't appear

#

I'm missing something small, I know it. I just cannot figure it out

gloomy chasm
#

Hmm, what if you just remove the panning code?

#

This line GUI.matrix = Matrix4x4.TRS(panOffset, Quaternion.identity, Vector3.one) * GUI.matrix;

potent marlin
#

Thanks I'll give it a go, the panning and zooming seem to work as expected. That line is definitely the source of the problem I just don't know how to fix it. I'll take a look through your reference, thank you

visual stag
#

There's almost no reason to be doing this with IMGUI

#

UIToolkit makes this simple, and there are even open source graph frameworks to build on

tough cairn
#

for me personally i can see how much faster IMGUI is compared to UIToolkit , especially when im running on battery mode , a simple task like resizing the editor window in 2018 and unity-6 can be been comapred to playing a game at 60 fps vs 15 fps

visual stag
#

Performance in dynamic situations isn't generally where a stateful solution like UITK shines. Compare the idle performance and you'll probably see the opposite.

#

But note that it's mostly irrelevant when talking about developing a graph solution (i.e. what's being commented on), where UITK has tools to modify transforms without remeshing, and it's as simple as adding one line of code to get pretty robust pan and zoom behaviour.

dusk dome
# dusk dome

hey guys, doesn't anyone understand why rendering custom property drawers is so temperamental here?

dusk dome
#

this could possibly be a step

waxen sandal
#

Should probably provide some code

dusk dome
waxen sandal
#

No idea what a quantum is

daring shard
#

I would like to make a custom editor similar to the ShaderGraph's: designers can create and and connect blocks which are read as data by a separate program. Does anyone know of a tutorial that tackles this, or even what it's called in Unity jargon? I've tried looking it up myself, but haven't had any success as of yet

gloomy chasm
dusk dome
#

Is there a way to name these better? essentially what I want to do is force open the fold out via code. Is this possible?

dusk dome
dusk dome
#
FrameDataElement.Clear();
        var frameProp = currentSerialisedMove.FindProperty("FrameData").GetArrayElementAtIndex(CurrentFrame);
        PropertyField propertyField = new PropertyField();
        propertyField.BindProperty(frameProp);
        FrameDataElement.Add(propertyField);
        Foldout frameDataFoldout = propertyField.Q<Foldout>();
        frameDataFoldout.value = true;
        
#

confused as to why this Foldout grab isnt working.

#

there is a foldout there, being the "Element 0" thing.

#

maybe the foldout isnt there at the time of adding?

gloomy chasm
dusk dome
#

yeah i thought it was something like that. shame

gloomy chasm
#

Easiest way is do use the schedualer, something like propertyField.schedule.Execute(() => ... ).AfterDelay(100);

#

(I don't remember the method name, could be StartAfter, StartDelay, After,Delay or something like that)

dusk dome
#

I'll try that. Thanks! I'm just glad i got the main bit fixed with the FrameData stuff lmao

gloomy chasm
#

There is also a SerializedPropertyBind event, but I don't remember if that is public in Unity 6 or not. I remember making a wrapper for it via reflection a while back

dusk dome
#

btw, with scrollTo, it scrolls the bottom of the page to the element right?

gloomy chasm
#

Actually... if that foldout is automatically created by the PropertyField, you can just do frameProp.isExpanded = true

#

Followed by applying the modified properties

gloomy chasm
dusk dome
#

scroll behaviour appears to be a bit broken in some bits though. could that be to do with the order of actions?

gloomy chasm
#

But what you can do is something like use the scheduler and run it every frame until the children change or soemthing like that

dusk dome
dusk dome
dusk dome
#

i wanna draw some circles and squares and stuff

gloomy chasm
#

If it is an Editor and you only want them visible when object is selected, you can use the OnSceneGUI method in Editor. If you want them visible even when not selected, you would use the SceneView.duringSceneGUI event and subscribe to it.

#

If you want to manipulate the handles, you probably want to look in to Tools and EditorToolContext

dusk dome
dusk dome
gloomy chasm
#

For Editor window you use the SceneView event

#

Just subscribe in OnEnable and unsub in OnDisable

dusk dome
#

okay cool, i've got that now 😄

dusk dome
#

like this, and then after that, scroll to?

dusk dome
#

ah damn

dusk dome
#

is there a way to change the color of a sliderl ike this?

#

i cant seem to find any se3ttings in the UI builder

past crane
willow jackal
#

In UIToolkit, is there anyway to have the same label width as a PropertyField would give.

#

Nvm, found it. Really unintuitive. (BaseField<float>.alignedFieldUssClassName)

half current
#

Any of you folks using localization in your projects? If so, which did you go with? It seems like the big two are i2 and unity

steady copper
half current
steady copper
#

However the reason I left it behind was less about its functionality and more about the legality of project sharing.

#

I have to strip down most of proprietary assets, tools and libraries for this purpose.

#

So the less of proprietary 3rd party assets, the less of my worriness.

half current
dusk dome
#

is there a way to force someone into a layout when you open your special editor window?

patent river
#

can odin inspector support 2d arrays of int, gameobject, etc?

dusk dome
#

is there a way to create a class for this to copy and paste in code?

#

like how you can create buttons

#

and stuff

gloomy chasm
#

Or just manually create the hierarchy in code

dusk dome
dusk dome
#

seems to work!

dusk dome
#

How can you make a button selected?

#

like change the color to make it look "active"

gloomy chasm
dusk dome
#

cus I think the active color is like blue or something

gloomy chasm
#

And in uss you do

.my-button--selected {
   background-color: red`
}
dusk dome
#

ah right

#

easy enough, thanks 😅

#

is there a unity preset colour for like button selected?

gloomy chasm
#

You can use the 'active' color by doing

background-color: var(--unity-colors-button-background-pressed);
border-color: var(--unity-colors-button-border-pressed);
dusk dome
#

I know it's like a darkish blue

#

oh right perfect

gloomy chasm
dusk dome
#

much appreciated 😊

gloomy chasm
#

You're welcome 😄

dusk dome
#

you've helped me out through a lot of my UI builder journey lmao, I really do appreciate your assistance 😀

dusk dome
#

how can I access unity icons?

#

like play and pause and such

dusk dome
#

but I'll have a look thank you

dusk dome
#

how can I make it so these items dont shrink?

#

oaky, it seems chaning this fixes it? strange

gloomy chasm
dusk dome
gloomy chasm
dusk dome
#

lest it go back to squished

gloomy chasm
#

haha

past crane
#

If you had to do align-self, then possibly they overlapped each other . . .

ruby kite
#

are there any extensions to allow for visual folders in hierarchy
Instead of using empty gameobject as a parent are there extensions that allow me to sort stuff into visual folders for organization

gloomy chasm
dusk dome
#

@gloomy chasm excuse the ping, just wanted to show you what I was able to cook up with some of your help 😄

#

very pleased with this, should speed up the workflow immensely

gloomy chasm
dusk dome
#

where does the manipulator happen

#

also another question, is there a way to make it so if i drag my mouse along these buttons, they do their click event?

#

in that gif im holding the mouse button down btw

gloomy chasm
# dusk dome also another question, is there a way to make it so if i drag my mouse along the...

You can't with buttons because it 'eats' the event. However, all a button is is this:

element.RegisterCallback<PointerDownEvent>(evt => { Do think here });
element.AddToClassList(Button.ussClassName);` // Just adds button styling to the element.

So if on your parent, you register events to down and up pointer events, you can get the index or whatever of the down and then of the up and select all between them. And/or use the enter/leave events and check if the pointer is pressed and if so add to the selection.

#

There however, is no good way to show mixed fields. Like wen you select multiple GameObjects and editing the position in one changes all of them.

dusk dome
#

I don't want to show all of them

#

also in regards to the manipulator thing, how can I make that show up? it says add manipulator, but I'm not sure how it would show up

gloomy chasm
gloomy chasm
steady copper
#

he couldn't find this method element.AddManipulator

dusk dome
dusk dome
gloomy chasm
gloomy chasm
dusk dome
#

also, can I open a contextual menu with a left click? similar to a dropdown?

gloomy chasm
#

if (element.ContainsPoint(mousePosition))

dusk dome
#

oh right

gloomy chasm
dusk dome
topaz bobcat
#

Hi everyone, I wanna see if you guys can help me. I'm creating a custom tool and I want to create a txt inside the Resources folder when the user presses a button and automatically load this file as a TextAsset after creation.
I'm using File.WriteAllText() to create the text file and then I call AssetDatabase.Refresh() to import the text as a TextAsset, and then I have a script that inherits from AssetPostprocessor in order to detect if the file was imported. The problem I'm facing is that if I try to call Resources.Load() inside the AssetPostprocessor, it returns an empty array. But if I call it manually after like, a second, it correctly loads the file.
My question is: is there a way to know when a file was fully imported by Unity? Since apparently I can't use AssetPostprocessor for that...

surreal girder
topaz bobcat
surreal girder
topaz bobcat
#

Yeah, I just tried waiting a single frame using an async method and apparently it works. Thanks

gloomy chasm
topaz bobcat
gloomy chasm
topaz bobcat
#

Ok, I have another question: with UI Toolkit, I'm creating a small popup with a TextField inside by calling PopupWindow.Show(), but for some reason my TextField doesn't gain focus until I either click on it or press Tab. I've tried calling myTextField.Focus() inside the OnOpen method of the Popup, but nothing happens. I've also tried changing the TextField TabIndex value to something bigger than zero but again, nothing changed. Do anyone know how to automatically give focus to a field inside a PopupWindowContent?

#

Ah, well, again, seems like the solution was to wait a single frame

#

Waiting a frame for stuff always felt kinda hacky

gloomy chasm
topaz bobcat
thorny rock
#

Is there a convenient way of resizing AssetPreview.GetAssetPreview()? I need to check a couple of textures, which I do with this method, but the textures are too big for my taste:

void DrawTextureArea(string label, ref Vector2 scrollPosition, Texture2D[] textures)
{
    GUILayout.Label(label);
    scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(128));
    using (new GUILayout.HorizontalScope())
    {
        for (int i = 0; i < textures.Length; i++)
        {
            Texture2D texture = AssetPreview.GetAssetPreview(textures[i]);
            GUILayout.Label(texture);
        }
    }
    EditorGUILayout.EndScrollView();
}
surreal girder
open rivet
#

why is my gameobject not appearing in the play scene?

open rivet
#

also i have another issue when i create a new project and runs it it gives me compiler errors despite having no scripts and only gets fixed when i restart the editor

olive sluice
#

hello everyone my player is stucking on the platform like this anyone have any idea how to solve it?

crisp temple
#

Hi everyone, I keep getting this error. I think its tied to the [RequireComponent] attribute which i have on some of my components. But no idea what is actually causing it.

Anyone have an idea what this error means?

past crane
woven imp
#

Is there a way to determine when a checkbox in the inspector is checked?
Like I have a MonoBehavior component and in it I have:

public bool MyBool;

When it is clicked in the inspector, I'd like to execute code while in the editor. Specifically, I'd like to hide the game object it is clicked on.
The thing is that this bool also controls if I want to have this object active when the game starts.

fiery canopy
#

So I was wondering is it possible to make a grid view for an custom editor window like how it is done for the Tile Palette Editor Window? If anyone has any suggestions that would be appreciated.

surreal girder
woven imp
#

So when the checkbox is pressed, I'd like to change the visibility in the editor.

surreal girder
#

tbh I have no idea if that is controllable from c#

woven imp
#

Basically, I have this:

#
    void Awake() {
        if(Application.isEditor)
            gameObject.SetActive(ShouldBeVisibleInEditor);
        else
            gameObject.SetActive(Application.isMobilePlatform);
    }

And so far I made it to be active in the editor in the game mode only when the checkbox is clicked.
But when I disable this checkbox, it's still visible in the Editor mode. To hide it in the editor mode I still need to click the eye icon.

gloomy chasm
#

Disabling the gameObject should make it not show in the editor anymore, no?

gloomy chasm
fiery canopy
woven imp
gloomy chasm
# fiery canopy UITK is what I normally use.

Depends on how big the grid is, could just do a bunch of elements with border styling. Or could use the vector painting API to draw the lines and then use maths to figure out what cell the pointer is in when it clicks.

gloomy chasm
fiery canopy
gloomy chasm
woven imp
woven imp
#

Oh I guess SceneVisibilityManager.instance.Hide(gameObject, true);

fiery canopy
#

I was just hoping someone knew of another simpler way to do it 😅

gloomy chasm
#

Ahh, sadly not. Though it really isn't too bad to make a simple one.

woven imp
#
    void OnValidate() {
        if(!ShouldBeVisibleInEditor)
            SceneVisibilityManager.instance.Hide(gameObject, true);
        else
            SceneVisibilityManager.instance.Show(gameObject, true);
    }
#

Yay

#

It also works in the deployment?

surreal girder
#

it will not exist in builds and will cause a compile error

woven imp
#

Oh, so I have to add the preprocessor directive. Good to know.

#

Wait, how do I then hide and show the objects in deployment without deactivating them? No generic way?

surreal girder
#

nope, you will have to enable/disable renderers and other things

topaz bobcat
#

Hi everyone, I've got another question: I have a button that, on click, shows a list of options using GenericDropdownMenu. Then, when I click one of the options of the GenericDropdownMenu, I'm showing a popup using PopupWindow.Show(). The problem I'm having is that when the Popup opens, the GenericDropdownMenu is still active and I can still interact with it. The weird thing is that this only seems to happen when I call PopupWindow.Show(). If I do anything else, like logging some text, the GenericDropdownMenu disappears as expected.

#

If I click "Option 1", the popup appears but the GenericDropdownMenu is still there. If I click "Option 2", I'm logging a text to the console and the GenericDropdownMenu disappears as expected

topaz bobcat
#

Not the solution I wanted, but using UnityEditor.GenericMenu instead of UnityEngine.UIElements.GenericDropdownMenu seems to work as expected.

past crane
topaz bobcat
past crane
topaz bobcat
# past crane What is your callback logic for when the button is clicked? Does anything stop o...

Not really? Here's a slightly modified version:

var optionsButton = parent.Q<Button>("options-button");

var menu = new GenericDropdownMenu();
menu.AddItem("Option 1", false, () => PopupWindow.Show(optionsButton.worldBound, new MyCustomPopup()));
menu.AddItem("Option 2", false, () => Debug.Log("Test"));
            
optionsButton.clicked += () =>
{
    menu.DropDown(optionsButton.worldBound, optionsButton);
};
fiery canopy
#

It just took me a while to figure out how to set it up since there is not much documentation on it.

ruby kite
#

is UniTask the best coroutine alternative or should i use something else

fiery canopy
#

Unity has an Editor Coroutines package you can use. I know nothing about UniTask so I can't really say if I recommend it or not.

topaz bobcat
fiery canopy
gloomy chasm
#

You can also use C#'s Task system and async/await.

surreal girder
#

But replaced with Awaitable or UniTask

gloomy chasm
surreal girder
#

instead of using System.Task we should use Awaitable or UniTask as the task type

gloomy chasm
#

Ahh, generally yeah, but it's not too big of a deal for use in the editor.

surreal girder
#

UniTask offers support for a "frame yield" even in editor so its a good replacement for coroutines

gloomy chasm
#

Not saying UniTask ain't handy. Just that for doing async programming in the editor it isn't needed. As it can be a rather 'large' dependency for otherwise small tasks.

#

At least from my understanding of things. I admittedly don't do a lot of async work in the editor.

surreal girder
#

I dont really either but I use UniTask and async code everywhere in runtime code so its nice to have it usable in editor too if required (e.g. load lots of data for some editor window but not freeze the main thread)

topaz bobcat
#

I'm seeing here that SearchWindow and ISearchWindowProvider are still experimental in Unity 6. Do anyone know if there's a non-experimental alternative to a searchable popup list?

pure sinew
#

Hello, how do you all handle mono behaviours used for authoring? I've been using #if UNITY_EDITOR, however this results in my build logs being spammed of missing mono scripts or serialization layout being changed. Is it possible to somehow remove such scripts from Game Objects during build?

An example of such script:

#if UNITY_EDITOR == false

...usings

internal sealed class AssetRoot : MonoBehaviour
{
    private void Awake()
    {
        Destroy(this);
    }
}


#else

...usings

[SelectionBase]
internal sealed class AssetRoot : MonoBehaviour
{
    private readonly HashSet<string> invalidTransformCache = new();

    [FoldoutGroup("Filtering")]
    [Required]
    [SerializeField]
    private List<Transform> ignorePositions = new();

    [FoldoutGroup("Filtering")]
    [Required]
    [SerializeField]
    private List<Transform> ignoreRotations = new();
    
    ...a bunch of Editor specific stuff
}

#endif

Logs:

04-23 12:02:39.418 23410 23520 E Unity   : A scripted object (probably AssetRoot?) has a different serialization layout when loading. (Read 32 bytes but expected 40 bytes)
04-23 12:02:39.418 23410 23520 E Unity   : Did you #if UNITY_EDITOR a section of your serialized properties in any of your scripts?
queen wharf
pure sinew
queen wharf
#

you'd probably have to store that information yourself

pure sinew
#

Could you elaborate on this 🤔

smoky radish
#

Hey all,
How can I toggle OnSceneGUI visibility ?

pure sinew
gloomy chasm
pure sinew
gloomy chasm
pure sinew
#

I had thought about this, however the issue I'm experiencing is on components which are added on objects that should be included in build. Hide flags affect the whole game object :/

gloomy chasm
#

I could be misremembering though of course.

pure sinew
#

Hmm, I'll do some testing to double check, currently stuck on some other issues... Last time I've used it I think it affected the whole game object, thanks for the tip!

cyan monolith
#

Anyone know why unity cloud projects aren’t showing up in the hub? Or at least the one I’m looking for, it shows up on my windows computers but not on Mac. Some show up but not the one I’m looking for.

pure sinew
# gloomy chasm As far as I know, the DontIncludeInBuild HideFlags are per-component

Had some time to test this out, it seems that it yeets the GameObject, dropped these two components on a GameObject and the ExtraScript doesn't log anything in build:

public class AuthoringScript : MonoBehaviour
{
#if UNITY_EDITOR
    [SerializeField]
    private HideFlags flags = HideFlags.DontSaveInBuild;

    private void OnValidate()
    {
        gameObject.hideFlags = flags;
    }
#endif

    private void Awake()
    {
        Debug.Log("I shouldn't be here");
    }
}

public class ExtraScript : MonoBehaviour
{
    private void Awake()
    {
        Debug.Log("I should still print stuff");
    }
}
surreal girder
#

these dont even work properly in prefabs so they really half assed them

#

i swear even in addressable scenes they dont work

olive hollow
#

Is there any way to set a particular scene as the default in the editor when a project is first opened?
I am submitting a Unity project as a take home task and whenever I download my project repo on a separate machine and open the project from Unity hub, it seems to open a default untitled scene instead of my scene
My scene still exists, but the user has to manually navigate to the scene's location and open it.
I have ensured that my scene is the only one in the project and is the first and only scene in the Build data scene list

#

I am using the standard unity .gitignore template so im not sure if it might have something to do with that

gloomy chasm
#

You can write a script using [InitializeOnLoad] to load the scene on first load if the current scene is not persistent/an asset

olive hollow
#

ah i see

past crane
topaz bobcat
past crane
#

Oh, nice. That's pretty sweet . . .

dusk dome
#

how can I prevent a foldout closing when I press the left key?

muted cave
#

Is there a way to check if a folder in the projects window is empty and/or expanded/collapsed?

glad pivot
#

so i have an attribute public string title {get; private set;}, where PropertyFields dont work well with attributes defined like this so i have to do it manually. so i have this to get the FieldInfo:

private string _getBackingFieldName(string propertyName)
{
    return string.Format("<{0}>k__BackingField", propertyName);
}

private FieldInfo _getBackingField(object obj, string propertyName)
{
    return obj.GetType().GetField(_getBackingFieldName(propertyName), BindingFlags.Instance | BindingFlags.NonPublic);
}

I can edit it and all just fine. but its not being correctly saved. when i simply do:

string previousTitle = TitleField.GetValue(script) as string;
string newTitle = EditorGUILayout.TextField("Title", previousTitle);
if (previousTitle != newTitle)
{
    TitleField.SetValue(script, newTitle);
    EditorUtility.SetDirty(script);
}

whenever i close and open the project, the edits are gone.
how do i fix this so that the edit is actually written correctly to the asset? (this is a scriptable object)

glad pivot
#

~~wait, i could maybe work around this by using internal instead of private and do script.title = newTitle right? or does using the namespace then give access to it as well?~~~nvm, the editor has an editor assembly so that dont work

gloomy chasm
gloomy chasm
#

After you add the attribute you can access it via SerializedProperty like normal

glad pivot
#

ah really its that small thing again cri it was just missing field:

gloomy chasm
#

Yeah, it is because unity only serializes fields, not properties. field: tells the attribute to apply to the backing field and not the property.

glad pivot
#

so thats how that works

#

well now its working 👍 thanky

glad pivot
#

how do i use PackageInfo.FindForAssetPath() ??? i have tried all i can think of that should work for getting my package info both when its imported and in my dev environment. all just returning null.
ive tried
Packages/com.name.package with and without a /, and with /package.json.
same with Assets/packageLocation

#

i thought maybe it only finds installed packages but i cant even get it to work when it is shruggie
i cant even check what it does cuz its an external call so the c# reference is no help here

#

idk if this is how you should do it. i guess i could load the .json itself but it seems like this should be the intended way to do it

glad pivot
#

And that the development environment is just the unity project im using to make the package. Im saying that because there will be a difference in file location. Where im developing it, the package won't be installed as a package as its already in the project

surreal girder
#

You can also just search all entries for a match and get it this way

glad pivot
glad pivot
#

Ok holdon let me double check. Im pretty sure find by for name was not available in this version

surreal girder
#

You can put the whole package in that folder: e.g. Packages/mycoolpackage

And it will work and be editable in editor

glad pivot
surreal girder
queen wharf
#

(can check with the little dropdown)

glad pivot
#

Yeah im on 21

tidal goblet
#

i cant find a proper channel for the editor itself so i think this is close enough,why is the camera clipping so early? it wasnt like this before,i could zoom all the way into the monitor of that pc but now the camera clips everything and its getting hard to work with

glad pivot
#

Or you mean going through all the package folders to check for yours?

glad pivot
tidal goblet
glad pivot
#

welp, i suppose i will have to filter thought unnecessary data unless i make a json solution myself in that caseshruggie

glad pivot
queen wharf
#

unity isn't the police

surreal girder
#

Project root/Packages
Where the manifest.json lives.
This works as I use it for a package myself

queen wharf
#

make it in file explorer

surreal girder
#

Yep do it outside of unity

glad pivot
#

ah ok

#

oh yeah you right

#

that would make things easier

glad pivot
#

ohno, its super inconvenient to make it from the package folder. every time i export it as a unity package i gotta move the entire thing, unless i only use github

surreal girder
#

I clone my package repo in there and commit it as is

#

I don't have it inside a unity project in the repo

glad pivot
#

what i mean is when you export a unity package it only allows you to select files thats within the scope of Assets/. Even the asset store validator does that. only time its not inconvenient is if i dont export unity packages, and host it on github as is

surreal girder
#

No this is all for a package via the package manager

#

.unitypackage files you can do whatever cus they are not special

glad pivot
#

then how would you export while it is in the package folder? both exporting a unity package and uploading directly to the asset store requires the files to be in the asset folder

surreal girder
#

I didnt realise this was for the asset store. you will have to do it the shit old way then 🤷‍♂️
a package is not the same as a "unity package of files"

#

i have no idea if the asset store supports upm packages yet

glad pivot
#

it is only code and assembly files with the required demo, but it should function the same as any other package installed through git

astral hemlock
#

I created a window with a MultiColumnLisView. How do I save the column widths when they are changed? Currently whenever the window is rebuilt, the column widths are reset (which are tiny).

visual stag
#

Serialize an array to the window, it's a scriptable object

main vessel
#

I want to make something like this but for a scriptable object inspector does anyone know how and preferably a dropdown add button for an array style

#

it has to be nested in other stuff like this for now i was using dictionaries

#

each effect has there own properties that can be edited

visual stag
#

and you can customize the add button for a list via ListView.onAdd in UITK

#

there's no easy way to modify it without manually drawing the list sadly

main vessel
#

oh kk

#

thanks

main vessel
#

and im also too broke for odin inspector

visual stag
#

Sadly no, it's very complicated. Maybe there's some packages out there that do it

main vessel
#

kk

astral hemlock
main vessel
#

nvm

main vessel
#

i managed to do it without custom inspector somehow

full cedar
#

Hey, I am trying to make a new shortcut that would create a script, I just can't figure out how to tie it to a specific context :/
I want this to only be registered in the Project view, not Scene view etc.
Here's the code I have so far:

public class EditorShortcuts : MonoBehaviour
{
    [Shortcut("NewNnScript", KeyCode.S, ShortcutModifiers.Control | ShortcutModifiers.Alt)]
    private static void NewScript() =>
        ProjectWindowUtil.CreateScriptAssetFromTemplateFile("Assets/NnUtils/Scripts/Editor/NnScriptTemplate.txt", "NnScript.cs");
}

Please @ me and thanks in advance!

waxen sandal
#

The sample there seems to match what you want, except you need to change the focusedWindow

full cedar
waxen sandal
#

No idea, maybe they do, I just learned about this API 😛

full cedar
#

ye :/

#

Thanks either way, this solution is better than no solution at all ig

pure sinew
#

Is it possible to check if game is about to quit when inside the Editor? I'm doing some logic inside OnDestroy to cleanup and need to exclude some paths during editor game shutdown

I've tried hooking into UnityEditor.EditorApplication.playModeStateChanged, but it doesn't seem to fire before OnDestroy 🤔

waxen sandal
pure sinew
#

Will check this out tomorrow, thanks!

pure sinew
waxen sandal
#

Ah I misread

pure sinew
gloomy chasm
#

Oh, should of read the convo more, my bad!

twin prism
waxen sandal
#

time = new List<string>?

twin prism
waxen sandal
#

The only thing that can be null on line 20 is that collection

#

So if it's not that, then your linenumbers are probably wrong and anyone through chat will just be guessing

twin prism
#

wait nevermind, the error isn't that anymore

#

it's a drawer error

muted cave
# twin prism

that error usually means you are trying to attach a non-MonoBehaviour to a gameObject, usually when you change a script from MonoBehaviour to something else while it is still attached somewhere.'

And you shouldn't need both Visual Element and onGUI. At the very least I would combine them into one class or it might cause some problems.

surreal girder
#

2022 and later can show either one so yea you dont have to make a version for both gui systems

twin prism
twin prism
twin prism
muted cave
#

maybe search for it in the hierarchy (and projects) folder "SO_DailyTasks"

muted cave
#

the warning in the middle might be on to something

#

you either have two script named SO_DailyTasks or one and it is not derived from ScriptableObject

twin prism
#

Yes this one

muted cave
#

uff.
Usually you have a script named:
MyClass
and the drawer script (which has to be inside a folder named "Editor") is called:
MyClassDrawer

You are kinda mixing both into a single script, that doesn't work

#

There are a couple tutorials on drawers and editors, or you could look up how Unity handles it, here is the script for a VerticalLayoutGroup (this is an editor though and not a drawer)
https://paste.mod.gg/obnisnqfjgwe/0

twin prism
twin prism
surreal girder
#

Or a drawer for your own class

muted cave
#

or at the very least you have to display the start and endTime as float and then convert it to TimeSpan once the game starts

surreal girder
#

you can store the time as milliseconds or seconds or even minutes as int or long but dont use float

#

can be whatever tbh but your problem is the drawer gui i guess

twin prism
#

same on the UI in game

#

and also it will be used inside SO because each prison will have different timings for the tasks

twin prism
surreal girder
twin prism
surreal girder
#

ill give a general overview of how it would work:

  • const for time interval such as 1h
  • make list of strings for options that start at interval and go up x amount (01:00, 02:00 ect)
  • look at variable to figure out what string should be "selected" rn (e.g. 5 meaning 5 hours so string at index 4)
  • convert new selected option index to new selected time e.g. 6
  • write to int or long
#

the serialized var could be int hours; for example

#

the whole idea is taking some variable and mapping to and from your custom gui options

twin prism
surreal girder
#

but that isnt serializable by unity so it can be stored as a number

twin prism
surreal girder
#

then i cant help you 😆

#

a time span object represents some amount of time, NUMBERS CAN TOO

twin prism
surreal girder
#

im not going to check things like a teacher

twin prism
vapid prism
#

I have an object with 2 fields. I have subscribed to RegisterValueChangeCallback on my first field, when I edit it I also edit the other value through SerializedProperty and finally ApplyModifiedProperties. Both are currently drawn using UITK PropertyField. For some reason the other field doesn't seem to update though, do I need to force UITK to redraw it somehow? This is in a PropertyDrawe

#

If I close and open the window the value is was clearly properly serialized correctly

#

I've worked around it by manually unbinding and then rebinding the property. Feels a bit hack-ish so if someone has a better idea that would be great

gloomy chasm
muted cave
#

anybody know why I can't change anything in the first list and I can't expand/collapse the items in the second list. It's an editor window

    public class SettingsWindow : EditorWindow
    {
        [MenuItem("Tools/AdvancedScriptTemplates/Settings")]
        public static void ShowWindow()
        {
            GetWindow(typeof(SettingsWindow));
        }
        private void OnGUI()
        {
            UnityEditor.Editor m_MyScriptableObjectEditor = UnityEditor.Editor.CreateEditor(TemplateSettings.instance);
            m_MyScriptableObjectEditor.OnInspectorGUI();
        }
        private void OnDestroy()
        {
            TemplateSettings.instance.Save();
        }
    }
waxen sandal
#

Probably because the editor is recreated every frame

muted cave
outer ember
#

has anyone run into the issue when unity remote 5 wont show the Mobile keyboard with textmeshpro input field

glad pivot
#

im using FieldInfo a couple of places in my editors, but for some reason one of them are resetting back to the previous value after ive changed the field value when i call serializedObject.ApplyModifiedProperties();, why does that happen? instead should i only call this once im changing serialized properties and not when im changing fields as those are not serialized properties?

#

hmm, when i dont call it, something breaks so im not too sure

real spindle
#

How are you using FieldInfo? What exactly is "resetting"?

glad pivot
#

holdon if im gonna show code i gotta get a new things

#

but essentially, im doing a few things to figure out which index i want from a list, then im storing that index. the index is being set through FieldInfo as its public get; private set; but the list of items are not using FIeldInfo, those are using serialized properties. its the list that is being changed which should then set the index for the FieldInfo

#

so because im using both, i have to call ´serializedObject.ApplyModifiedProperties();´ to allow the list elements to update properly, but then the FieldInfo is reverted back to what it was before the serialized properties where changed

#

This is part of the code i have in OnInspectorGUI

if(_Scenes.serializedObject.hasModifiedProperties)
{
    Undo.RegisterCompleteObjectUndo(target, "MultiSeneTools: Scene Collection Active Scene Index = " + ActiveIndexField.GetValue(script));
    updateActiveSceneIndex();
}
serializedObject.ApplyModifiedProperties();
#

The ActiveIndexField correctly set during updateActiveASceneIndex() to what it should, but once again as it reaches the apply method, its back to what it was before the method ran

#

if you want to see the entire logic for that i can post that as well

real spindle
#

Not an expert when it comes to this but try calling SetDirty and/or serializedObject.Update before applying

glad pivot
#

but im calling ActiveIndexField.SetValue(script, index); where im setting the new value

glad pivot
#

ok im getting somehwere so i might be able to figure someting out

#

thanky

#

nice, fixed it! added an serializedObject.Update() after changing the fieldinfo, then im applying the modified properties after ive changed them, instead of doing both after both thumbsupani

gloomy chasm
# glad pivot nice, fixed it! added an `serializedObject.Update()` after changing the fieldinf...

The reason is because ApplyModifiedProperties() changes all the properties in the target object to match the serialized. So it will overwrite any changes made to the target object. While Update() changes all of the properties in the serialized object to match the target.

You can think of ApplyModifiedProperties() as sending the data from the serialized to the target object.
And Update() as sending the data from the target to the serialized.

glad pivot
#

ok so this is the last bug i cant figure out. ive been trying for several hours trying several things and googling, which i found that this might be a unity bug so idk. but ill ask anyway.

I have a strange issue with opening editor windows automatically with the ´[InitializeOnLoadMethod]´ attribute, where it shouldnt open multiple windows but somehow it opens some kind of invisible windows that are bugged, but show up on the taskbar.

this is simplified for the example but i have this code:

[InitializeOnLoadMethod]
static void Startup()
{
    CheckUpdates(); // checks if an update has been detected, if it has opens the setup window
}

where CheckUpdates() is calling SetupWizard.MenuEntryCall(); where its needed.
ive tried storing the wizard instance in my config scriptable object and not opening one when the config has an open wizard, so that so when the project reloads the instance isnt lost, but this had no effect as far as i can tell. and its still opening blank windows

#

MenuEntryCall isnt doing anything other than just opening the window with setting some default values for where its on the screen

gloomy chasm
#

But a work around is probably to just do the check in EditorApplication.delayCall += () => CheckUpdates();

glad pivot
#

this is all

[MenuItem("Tools/Multi Scene Tools Lite/Setup", false, 1)]
public static void MenuEntryCall() 
{
    MultiSceneToolsSetup_Wizard _Wizard = (MultiSceneToolsSetup_Wizard)GetWindow(typeof(MultiSceneToolsSetup_Wizard));
    Wizard.titleContent = new GUIContent("Multi Scene Tools Setup", "Creates or updates the config");
    _Wizard.position = new Rect(Screen.currentResolution.width/3, Screen.currentResolution.height/4, _Wizard.position.width, _Wizard.position.height);
    _Wizard.minSize = new Vector2(684, 520);
    _Wizard.Show();
}
gloomy chasm
glad pivot
#

yep

gloomy chasm
#

That calls Show already

glad pivot
#

isee, i originally didnt have that there but i added it as i was hoping the hidden windows would then be forced to show themsevles but ofc it didnt do anything

glad pivot
gloomy chasm
#

You can do this:

var wizard = Resources.FindObjectsOfType<MultiSceneToolsSetup_Wizard >().FirstOrDefault();
if (wizard == null)
    wizard = CreateInstance<MultiSceneToolsSetup_Wizard >();

// Set properties on 'wizard'...
wizard.Show();
#

Looking at what I did in the past, I did do the delay call to open it. Also when testing I would reset the layout of Unity so those bugged windows are closed.

glad pivot
#

ah, i didnt even think of trying to open a different layout, ive been reopening the project each time cri

glad pivot
glad pivot
gloomy chasm
fiery canopy
#

OK I'm at a loss

I created a Custom GridBrush and a GridBrushEditor. Almost everything works except the fact that in the Tile Palette window the grid brush will draw itself when you click on a random position in the Tile Palette Window. Is that by design or am I missing something.

I thought the override for drawing in the inspector would fix that but it doesn't help at all.

zealous cradle
#

anyone know why the animation rigging package gizmos won't get disabled when i toggle the gizmo's visibility ?

burnt dove
#

How can I get the GUID of an Scene?

real spindle
burnt dove
#

Oh, I didn't. I'll try that, thanks

untold nymph
#

you gotta disable the bone renderer

zealous cradle
#

I wasnt talking about the bone renderer

#

Iwas talking about the constraint targets

untold nymph
#

ahh mb, i dont know much about disabling those gizmos

alpine bolt
#

Where can I find this "right-click" option in source code?

gloomy chasm
alpine bolt
shadow minnow
#

I'm using a material property block to assign properties to the shader being used for this tilemap. When the object is dirty, and the scene gets saved, these properties are reset. Is there a method or event or something i can hook onto to reapply my material property block when the object gets saved?

#

currently i refresh the material property block on Awake(), OnValidate(), and OnBecameVisible(), but none of those occur when the object is saved.

queen echo
#

Are you not able to use EditorGUILayout.Foldout inside OnInspectorGUI? the internet is fraught with people saying it doesnt work in various scenarios, but there is never really any answer.

I am storing the state of the foldout in the MB it acts as the inspector for to mitigate any problem of the state being broken during drawing, but it just never seems to register a click on the label, even with the toggle on label set to true, i.e:

myExternalVisibleState = EditorGUILayout.Foldout(myExternalVisibleState, ShowImplementations, "The label to be shown", true);

(Oh I am also using Unity 2022.3, I was using 2021 but thought maybe it was something that regressed between versions so bumped up one to check if that fixed it, it didnt 😦 )

waxen sandal
#

Editorguilayout doesn't work in property drawers

#

SerializedProperties have an isExpanded field which you can use for your foldout

queen echo
#

Can you point me to an example?

queen echo
#

I have tried searching for what you mean, cant find anything, also I use EditorGuiLayout stuff quite a bit in the inspector and the rest of it seems fine, the confusing thing is there are lots of posts of people saying it should work in the inspectors fine as its just another editor thing

queen wharf
#

they don't work in drawers

queen echo
#

Is there any alternative that does the same thing? I cant really use an attribute as I am having to loop over properties within objects and spit them out into their own bits of the UI

queen echo
#

its fine, it does work, but for some reason it wasnt treating the data as a reference so was constantly just overwritting the value, wrapped it in a class to ensure it is correctly using the reference and works as intended now

queen echo
#

Sure

#

oh sorry its not letting me share, let me chop it up a bit

#
[CustomEditor(typeof(ObservableGroupViewer))]
public class ObservableGroupViewerInspector : global::UnityEditor.Editor
{
    public class VisibilityState
    {
        public bool ShowGroup { get; set; }
    }
    public Dictionary<LookupGroup, VisibilityState> VisibleStates = new();
    
    public override void OnInspectorGUI()
    {
        var observableGroupViewer = (ObservableGroupViewer)target;
        if(observableGroupViewer == null) {  return; }
        var observableGroupManager = observableGroupViewer.ObservableGroupManager;
        
        EditorGUIHelper.WithLabel("Active Groups");
        foreach (var observableGroup in observableGroupManager.ObservableGroups.OrderByDescending(x => x.Count))
        {
            if (!VisibleStates.ContainsKey(observableGroup.Group))
            { VisibleStates.Add(observableGroup.Group, new VisibilityState()); }
            var visibleState = VisibleStates[observableGroup.Group];
                        
            EditorGUI.indentLevel++;
            visibleState.ShowGroup = EditorGUILayout.Foldout(visibleState.ShowGroup, label, true);
            EditorGUI.indentLevel--;
            
            if (!visibleState.ShowGroup) { return; }                
            GroupUIAspect.DrawGroupUI(componentTypeLookup, observableGroup.Group);
        }
    }
}
#

Thats a slightly chopped up and bolted together version, but that works, it doesnt retain through reselection but thats what I wanted, if I wanted it to persist I could just move the data tracking the visible states into the MonoBehavior its sourcing data from.

waxen sandal
#

Right

#

GUILayout does work in Editor derived classes but not in PropertyDrawers

hollow valve
#

Does anyone know of a good free dungeon generation tool I can use in my Lethal Company inspired game? I found these demos which look like exactly what I want. 2d demo, 3d demo 2. These are demos from an existing Godot plugin.

willow jackal
queen wharf
#

Lethal Company uses the paid asset DunGen, for reference

runic maple
fiery canopy
#

Looks like your ListView is not populating the data correctly 🤔

#

Have you set the ItemSource to the correct object?

runic maple
severe lance
#

Are there any edge cases for script extending from Editor such that OnEnable() isn't called? Furthermore, what's the best way to clean up materials and other unity objects when the editor object is deselected? How much can I rely on OnDisable() being called, or should I consider alternatives?

waxen sandal
#

Should be reliable afaik

still nexus
#

Is it possible to bind using UI Builder before unity 6?

gloomy chasm
still nexus
#

thanks! I'll probably try updating to unity 6 and if I have too many issues I'll use the serializedproperties.

gloomy chasm
still nexus
#

Oh so the runtime binding is only for non-inspector UI? Gotcha

brittle urchin
#

Hi! I am making some scriptable object assets with a custom editor. Now and then when updating the assets via user interaction i get this error. Do you know a way of finding where this error occurs?

gentle narwhal
#

Anyone have any good extensions for cinema creation?

gloomy chasm
#

And Timeline?

gentle narwhal
#

ok

#

i gess

viscid sapphire
#

any extensions to help me bulk sort a messy project cause like got 2 separate projects that need to be organized and merged into one and both exceed 17GB

odd badger
#

In the CreatePropertyGUI() of the PropertyDrawer class, is there any way to get the label text passed by the second argument of the PropertyField constructor? Or do I have no other way than to use OnGUI()?

odd badger
#

Thank you for replying:)
In my project, the PropertyDrawer of the parent element passes a runtime-generated name to the child element through the second argument of the PropertyField constructor.
In the CreatePropertyGUI(), property.displayName only gives the display style name string of the original variable name. Instead, I want to get the passed name.

vapid prism
odd badger
muted cave
#
public StatsData virusData = default;
public List<StatsData> enemyStats = default;
``` This is in a custom EditorWindow. 
The first line is assignable in the Inspector, the second line isn't. StatsData is a ScriptableObject.
What is the reason for that and is there a workaround other than creating a new SO that has a List<StatsData>?
glad cliff
#

How do I align my elements in inspector within a custom PropertyDrawer? As im digging in it seems like only visual elements deriving from BaseField<T> can inherit this functionality of auto-alignment with other fields in inspector, but is there any other way to get it to work?

public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
    VisualElement root = new VisualElement() { tooltip = property.tooltip, style = { flexDirection = FlexDirection.Row } };
    Label fieldLabel = new Label(property.displayName);
    fieldLabel.AddToClassList(PropertyField.labelUssClassName);
    VisualElement inputField = new VisualElement() { style = { flexDirection = FlexDirection.Row } };
    inputField.AddToClassList(PropertyField.inputUssClassName);

    root.Add(fieldLabel);
    root.Add(inputField);

    Rebuild(inputField, property);
    root.TrackPropertyValue(property, prop => Rebuild(inputField, prop));

    return root;
}

This is a simple case, label and some visual element to serve as an input

hollow valve
#

Either way I'm swaying towards buying DenGen anyway.

gusty oracle
#

Can someone spot my error or misunderstanding? Both fields are assigned in Inspector and this code works if the editor is playing, but not when stopped


using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

public class EditorHelper : MonoBehaviour
{
    private static SceneHelper sceneHelper;
    
    [MenuItem("Scenes/Open Menu Scene", false, 0)]
    private static void OpenMenuScene()
    {
        FindSceneHelper();

        if (EditorApplication.isPlaying)
        {
            SceneManager.LoadScene(sceneHelper.mainMenuScene.Name);
        }
        else
        {
            EditorSceneManager.OpenScene(sceneHelper.mainMenuScene.Name);
        }
    }

    [MenuItem("Scenes/Open Gameplay Scene", false, 1)]
    private static void OpenGameplayScene()
    {
        FindSceneHelper();
        
        if (EditorApplication.isPlaying)
        {
            SceneManager.LoadScene(sceneHelper.mainGameplayScene.Name);
        }
        else
        {
            EditorSceneManager.OpenScene(sceneHelper.mainGameplayScene.Name);
        }
    }

    private static void FindSceneHelper()
    {
        if (sceneHelper != null)
            return;
        
        Debug.Log($"Finding Helpers...");
        SceneHelper[] sceneHelpers = FindObjectsOfType(typeof(SceneHelper)) as SceneHelper[];

        if (sceneHelpers is { Length: > 0 })
        {
            sceneHelper = sceneHelpers[0];
            Debug.Log($"Found {sceneHelpers[0].gameObject.name} {sceneHelper == null}");

            if (sceneHelper)
            {
                Debug.Log($"{sceneHelper.mainMenuScene.Name}, {sceneHelper.mainGameplayScene.Name}");
            }
            
            if (sceneHelpers is { Length: > 1 })
            {
                Debug.LogError("There is more than one SceneHelper object in the scene!");
            }
        }
    }
}
#

Ignore this, solved my issue

queen wharf
real ivy
#

Hi. I'm making a custom importer AssetPostprocessor. Specifically OnPostprocessGameObjectWithUserProperties and OnPostprocessModel
So these processes all models. Fbx, and .blend
Is there a way to mark certain assets to use this custom importer or not?

#

Do i perhaps, like, gotta name the asset with a "_Level" suffix, then the custom importer i just check for this suffix to run it? I imagine this is simple and would work, but is there a more correct way to mark it?

lavish canopy
#

Heey, I'm working on making some editors utilizing PreviewRenderUtility along Handles drawing & interactivity, and the general execution flow goes like:

  • PRU.BeginPreview
  • PRU.EndAndDrawPreview
  • Handles.SetCamera(PRU.Camera)
  • Draw Handles
    Im experiencing some weird issues with how the handles are drawn, and it seems to only happen in docked mode for the preview window. Handles shift around based on camera positioning, and the rect its drawn in appears shifted down from the actual preview rect. However, these issues are fully resolved in floating window mode, the handles there work perfectly as expected. Does anyone have any experience with drawing handles in preview windows and know how to get around this? Moving handle drawing between begin/end preview doesnt help, tried making sure the FOV is constant, setting the camera pixel rect to the preview rect, etc...

Some forum posts i looked at but none of them seemed to resolve anything for me. Click interaction works perfectly fine btw.
https://discussions.unity.com/t/previewrenderutility-and-handles/783621
https://discussions.unity.com/t/writing-an-editor-window-that-mimics-the-scene-view/728634/35

karmic basin
#

Not sure if this the right place to ask, but how do I move these things? I draw them with EditorGUILayout. The problem is that toggle checkmark is drawing over the label, so I want to add some offset between. I tried margin/padding in the GUIStyle, but it didn't work

surreal girder
#

draw your own prefix label and toggle to make the label wider

karmic basin
surreal girder
# karmic basin how do I do that
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("FooBar", GUILayout.Width(50f));
EditorGUILayout.Toggle(false);
EditorGUILayout.EndHorizontal();

something like this (written from memory so may have mistakes)
The idea is to give the label a fixed width that better suits what you desire.

surreal girder
karmic basin
surreal girder
#

do what i did and you ommit the arg for a label when you dont need it... like in my example 😐

#

basically all of those control gui layout functions have an overload without a label arg

karmic basin
#

PrefixLabel asks for GUIStyle, not GUILayoutOption

surreal girder
#

perhaps Label is better suited here than PrefixLabel

karmic basin
surreal girder
zealous hill
#

It seems that EditorGUI.FloatField doesn't allow you to drag to edit floats.

I tried using EditorGUILayout.FloatField which does allow dragable edit, but it broke the rest of my property drawer.

Is there a way to add that functionality to regular EditorGUI.FloatField?

muted cave
#

I'm using

Undo.RecordObjects(scriptObjects.ToArray(), "Namespace Fix");
```The problem is this doesn't show up in the undo history. 
I use FileReadAllText() and File.WriteAllText() to make changes to the scripts. 
I assume the editor doesn't detect the changes and I have to tell it manually that they have changed but I don't know how.
surreal girder
hot quarry
#

when i add a custom attribute to my script (if that script happens to be open) the formatting/styling is whacked
but if i add a script w/ the custom attribute already in there and compiled i guess.. it works fine..
it isn't until i cycle back to have it selected does it look correct..

i can share more or the scripts if need be.. but i think theres just something im missing (or forgetting to do)
how can i go about having it style/ or redraw or w/e it needs to do when adding to a component already in the inspector

gloomy chasm
hot quarry
#

while i was writing it logically i thought (we'll if theres no buttons, then theres no header either.. so theres really nothing to style.. so makes sense to have my InitializeStyle() method at the top of the DrawSeperated() method..

real ivy
#

Hi guys. I'm usingii OnPostprocessGameObjectWithUserProperties, and added component SpriteRenderer, and do Resources.Load SpriteAtlas and use GetSprite
Deblog says it can find the sprite no problem (the sprite name has a (Clone) suffix), but when i see in inspector, no sprite assigned. What's going on?

tawdry onyx
#

Hey guys, I'm trying to make an editor button that when I click calls an event

glacial sail
#

How do you guys go about auto saving ScriptableSingleton in a non sucky way?
Currently without needing to save, I can just do:

private void Toggle(ref bool value, string title)
{
    value = GUILayout.Toggle(value, title);
}
Toggle(ref SomeScriptableSingleton.instance.SomeBoolField, "...");

But if I want toggling the field to cause the singleton to save, I don't see a clean way of doing it without a bunch of boilerplate code.

gloomy chasm
gloomy chasm
#

Can't do the ref setting like that any more. But really, it is best not to use public fields anyway.

glacial sail
#

I think saving on OnDisable is also a decent enough compromise.

gloomy chasm
#

Can you find the actual file and see it has the saved data?

glacial sail
#

Yep, the file does get created and the data seems fine.

gloomy chasm
gloomy chasm
glacial sail
#

Yep, exactly one to one.

gloomy chasm
#

Did you try it as a new file?

glacial sail
#

I didn't, but I guess might as well.

#

Oh, does the file name have to match the class name or something?

gloomy chasm
#

No it shouldn't any more. But Unity might have that file in a weird state for some reason

#

Might just to make sure, have the file name be the same

glacial sail
#

After a bit of trial and error, the issue seems to be that it doesn't work if the scriptable singleton class is nested inside another class.

#

When nested, the serialized m_Script is empty while m_EditorClassIdentifier is non empty, so it seems to me that there is specific code meant to handle this case but it doesn't actually work?

visual stag
#

You still need one Object per class, and I'd expect nesting to break it

#

MonoScript relies on tying the script to its file, and that's what m_Script is

valid seal
#

(Apologies if assetdatabase problems don't go here)

Right now im working on an sdk for my game and im trying to make a pallet system,
When i create a pallet in prefab mode on the object using the button i made, it creates it but it does not drop the object in the scriptable object...
But when i use the prefab in the project window it seems to drop it there?

#

i maybe doing something wrong with getassetpath or loadassetpath but im not so clear on it

valid seal
frigid iron
#

Does anyone know where GLTFast is now in the package manager? (in 6000.1.5f1), i can't seem to find it....

surreal girder
#

you can add it by name yourself

#

com.unity.cloud.gltfast

floral nest
#

Heya! how do i keep state in an EditorWindow beyond a code reload? Its making development extremely annoying to have to refill all information into a window

#

my current setup consists of having a handler object that the window communicates with

#

basically a front/backend infrastructure where the EditorWindow is responsible for displaying things and the handler is responsible for doing the heavy lifting

#

however the handler object becomes null after every code reload

#

easiest way to replicate my setup

[Serializable]
public class Handler : UnityEngine.Object {
  int data;
}
public class Window : EditorWindow {
  [SerializeReference] Handler h;
  void OnEnable() {
    if(!h) {
      h = new();
      Debug.Log("this should only run once");
    }
  }
}
#

"this should only run once" is printed every time the code reloads

#

if i simply do

public class Window : EditorWindow {
  int data;
  void OnEnable() {
    if(data == 0) {
      data = 5;
      Debug.Log("this should only run once");
    }
  }
}
``` it works
muted cave
#

you could store the data in a ScriptableObject or ScriptableSingleton

floral nest
#

Thank you!!!!

#

that works

#

i thought UnityEngine.Object was enough

gloomy chasm
floral nest
#

well it wasnt ^^`

gloomy chasm
#

Also the field is never serialized since it isn't public or has [SerializeField].

#

As long as the window is open it will serialize all serializable fields. Meaning they will persist between domain reloads.

#

So no need for the Handler at all.

#

Also, [SerializeReference] does nothing on fields of a type that inherit from UnityEngine.Object. They are made for POCOs

#

Same with [Serializable]

floral nest
#

got it

lapis summit
#

Unity doesnt recognize .Ink when building the projects

#

But my dialogue works

#

Idk if this is the right place to ask about ink but how would i fix that?

#

Assembly reference crap just floods my whole project with errors

analog field
#

Hello!
I have these Sprite Renderers (in a 3D game) that the default preview is always rotated to the other way
Is there a way to default the rotation on the PREVIEW to face a certain angle? (I tried having the prefab be rotated but it doesn't do anything)
(the hierarchy of the prefab is literally that single SR, and I think that if I add a parent it should be solved but it would just add unnecessary GOs to the hierarchy)

unborn warren
#

I'm making a list of items which can be dragged from the inspector into the scene. i want these items to be in capsule shaped boxes, so i modified the GUI.skin.label style and set the background to a generated capsule texture, however this texture doesn't look how its supposed to in the inspector. you can compare the capsule shaped one (which is just the texture put on a material and rendered on a quad) and the misshapen one which is rendered in the inspector through this script:
https://pastebin.com/qaAQZaEC

tough cairn
#

any one knows what is TextureID in Profiler ?

#

i tried logging all textures ID's in the project , but none of them seem to match

var id = (int) tex.GetNativeTexturePtr();
var instance_id = tex.GetInstanceID();
unborn warren
pure siren
#

Is there a way to check if there is at least one dirty asset in the AssetDatabase?

tough cairn
#

bump that thread , maybe the devs will add it

#

so i decided to scan the entire DB ... but still no luck , here is the code i used :

    public void ScanAllTextures()
    {
        var EVERYTHING = AssetDatabase.GetAllAssetPaths();

        foreach( var x in EVERYTHING )
        {
            var GUID = AssetDatabase.GUIDFromAssetPath(x);
            var TYPE = AssetDatabase.GetMainAssetTypeFromGUID(GUID);

            if( TYPE == typeof(Texture2D) )
            {
                var tex = AssetDatabase.LoadAssetAtPath<Texture2D>(x);
                var id = tex.GetNativeTexturePtr();

                Debug.Log( $"GUID:{GUID} TexID:{id} PATH:{x}");

                tex = null;

                EditorUtility.UnloadUnusedAssetsImmediate();
            }
        }
    }
grizzled tide
#

how would I spawn a new gameobject not as a clone, but as an actual prefab? Correctly linked and all that?

#

when I Instantiate() they are grey and not counted as prefab instances like if I dragged one into the scene

#

I think this might be it?

queen wharf
#

Is there a recomended way to draw a solid tri in scene? I know you can draw meshes but between handles and gizmos i cant find anything that does it on a tri by tri basis

#

ive seen some suggestions of using the GL commands directly but i've had trouble getting those working nicely

#

(i'd use a mesh but im doing some dynamic adjustments to the info in a way where ideally i wouldn't wanna constantly build a new mesh)

real spindle
queen wharf
#

I assume it's related to using it in a 3d context as the example code linked by mechwarrior is seemingly partial and my interpreted guess at how to use the matrix referenced in that page was wrong

#

I couldn't find a fully fledged example online

gloomy chasm
#

Feel free to share some code if you are still having issues!

pure siren
#

Is there a way to display an indeterminate progress bar that blocks the editor from being interacted with?

real spindle
#

OnPostRender does not work if you use URP or HDRP, need to use one of the events in RenderPipelineManager instead

#

@queen wharf

queen wharf
pure siren
gloomy chasm
#

Can you share your the usage of it?

pure siren
gloomy chasm
pure siren
# gloomy chasm ... you shouldn't be able to... it is what is used when scripts reload, assets i...
private static void ShowIndeterminateProgress(string title)
{
    EditorUtility.DisplayProgressBar(
                title,
                "Please wait...",
                -1
            );
}

private static void StopIndeterminateProgress()
{
    EditorUtility.ClearProgressBar();
}

private static async Task BuildTask(Builder builder, BuildOptions buildOptions, string outputLocation)
{
    ShowIndeterminateProgress("Running Pre Build");
    try
    {
        await builder.PreBuildAsync();
    }
    finally
    {
        StopIndeterminateProgress();
    }
}
pure siren
gloomy chasm
#

I looked at my usage and it is the same. Weird...

pure siren
#

Seems it used to block, but now it doesn't

queen wharf
# real spindle OnPostRender does not work if you use URP or HDRP, need to use one of the events...

Does something like this look right? Or do i need to actually use the cameras or something.

Ideally i want to draw triangles in the scene, during play mode


public class GLTest : MonoBehaviour
{
    // Draws a triangle that covers the middle of the screen
    public Material mat;

    private void Awake()
    {
        RenderPipelineManager.endFrameRendering += PostRender;
    }

    void PostRender(ScriptableRenderContext con, Camera[] _)
    {
        if (!mat)
        {
            Debug.LogError("Please Assign a material on the inspector");
            return;
        }
        GL.PushMatrix();
        mat.SetPass(0);
        GL.LoadOrtho();
        GL.Begin(GL.TRIANGLES);
        GL.Vertex3(0, 0, 0);
        GL.Vertex3(1, 1, 0);
        GL.Vertex3(0, 1, 0);
        GL.End();
        GL.PopMatrix();
    }
}

So far this isn't drawing a tri at 0,0,0 but not sure if i need to use any of the like setmatrix functions or color functions etc.

humble kernel
#

is there anything here that would cause my pc memory to explode and crash my game?

queen wharf
#

there's an attribute somewhere that tells unity what name to use when serializing something in a list if it cant find a name-esque string inside it, anyone recall what that is?

#

eg. so i can give these an explicit name

glad flare
#

oh wait i misread one of the inherited props as being its own prop...

queen wharf
#

its too early in the morning i was about to post a cute cat gif in response before realising what discord im in.

will have to see if it actually does what i want but that is what i was recalling i think ty

glad flare
#

i'll just test it for you brb

#

it was in fact not that

queen wharf
#

i think thats what i was thinking of so it might just not exist lol

glad flare
#

i thought it was that because of the applyToCollection prop but i didn't see it was inherited lol

#

or i suppose use SerializedDictionary<string, T> lol

queen wharf
#

refreshing myself abit on propertydrawers,

i'm drawing two serializedproperties here via PropertyField with a different rect each (rn one is just 20 y more than the first). visually looks how i want but the mouseover controls seem to overlap/be shared between both bools here. Just curious what aspect of a custom propertydrawer actually decides the control space of a field since it seems to be seperate from the visual rect?

#

I can post code if needed but I know i'm doing a couple things wrong rn, just curious whats in charge of that

queen wharf
#

Resolved I am dumb dumb and used a silly rect value for the height

willow jackal
burnt dove
#

Given an ScriptableObject how can I get the path where it's stored? AssetDatabase.GetAssetPath doesn't work when the object is "inlined" into an scene or prefab

surreal girder
#

If its an asset reference it should work 🤔

gloomy chasm
crisp rapids
#

I have a set of scripts (extensions, attributes, editor windows) that I use all the time now, and I use some of them for a framework/plugin that I’m preparing to sell on the asset store. Ideally I’d like to also offer the whole set as a separate asset but also include just the ones in use in the first framework as a part of that first package. Is there any friction then if someone purchases both? I will test by making the two separate packages and see what happens when I import them together, but was curious if anyone had experience with this. Like I imagine if you have a free vs premium version of a code asset you’d have come across this before.

#

I’m guessing if you just target the same directories and use the same name for the asmdef then the user can just add and replace smoothly but would like to hear from experience

gloomy chasm
crisp rapids
queen wharf
#

When I use Handles.Label how can i know when it's been hovered over? googling online mentions controlids a couple times but i dont understand it

north sphinx
#

it's immediate mode gui

queen wharf
north sphinx
#

Could you define hovered?

queen wharf
#

eg. whatever makes it start using the hovered part of the guistyle

#

(my mouse is over that)

north sphinx
#

Hm, I'm not sure you can extract information as such

queen wharf
#

🥺

#

brutal

#

i can't find a way to calculate the used rect of it in the context of the 3d space either so i can do comparable rect checking afaik

north sphinx
#

maybe you can do with just separate button?

queen wharf
#

wym?

north sphinx
#

draw label + button below

#

so your onHover will be whenever button is clicked

queen wharf
#

would need to be on button hover not click but maybe

#

worried if theres overhead on that at scale tho

north sphinx
#

You are already in a territory where it's not supposed to scale tbf

queen wharf
#

might be hitting 100-10,000 range practical min max with these

#

probably more on upper

#

just annoying that clearly the info is somewhere cuz it changes style usage

north sphinx
#

since it's IMGUI I have a feeling all it does is this somewhere in call chain:
Color drawColor = isHovered : style.onHover : style.normal;

#

and whether it's hovered or not is resolved right away here

queen wharf
#

:/

bright phoenix
queen wharf
#

I did see that but I don't know how I could determine the rect

bright phoenix
#

what do you mean? it determines the rect

queen wharf
#

From the description it seems like that's for 2d labels at a 3d point, where as my label is a 3d label at a 3d point, no?

bright phoenix
#

there are not 3d labels 🤔

#

this is kinda what Label deos: cs public static void Label (Vector3 position, GUIContent content, GUIStyle style) { Vector3 val = HandleUtility.WorldToGUIPointWithDepth (position); if (!(val.z < 0f)) { BeginGUI (); GUI.Label (HandleUtility.WorldPointToSizedRect (position, content, style), content, style); EndGUI (); } }

queen wharf
#

3d might not be the best wording, i mean that the label is manipulated by the handle matrices' rotation and position from the camera and stuff

#

i see

queen wharf
queen wharf
#

I assume this takes the camera rotation aspect into consideration right? My points are static so was curious if i could cache the results

#

Feel like i cant

surreal girder
#

world to screen transformation is dependent on the current camera transform so no

glad cliff
#

Hey guys!
For the past fiew months I've been working on some ScriptableObject oriented reactive framework with full tooling and stuff (if you are familiar with it, its basically like "Scriptable Objects Architecture Pattern (SOAP)" package, but imo way more advanced and flexible). Im slowly coming to release-ready state and before I publish it on Asset Store I would like to let some people mess with it a bit for the purpose of beta-tests. To be clear a fully commercial game is being developed on the first draft of this tool, so it is not a complete shot in a dark, but version I want to publish has been rewritten from scratch, so it would be nice to test it separately.
Ofc it will be a paid asset so im more than happy to share a license after publishing to anyone that wants to contribute, so if you are intrested feel free to DM me.

Some technical info to be aware of:
version: Unity 6
scripting backend: works on both, yet it is to be tested to what extend IL2CPP handles it due to some reflection based solutions and runtime code emiting
documentation: package includes a sample project (1 for now) and built in manual, but full documentation with API and stuff is WIP
support: I would not recommend making a game with beta version I would provide, as there will most likely be breaking updates by the time of release

bright phoenix
# glad cliff Hey guys! For the past fiew months I've been working on some ScriptableObject or...

I'm not the biggest fan of SOAP (sorry 😅), though I've never used it for more than 2 days... doesn't it have an issue that suddenly you have over 9000 SOs that you need to PERFECTLY configure in order for things to work well, and if you don't - it may take you days to understand why? (That's a genuine question, it's how it always felt to me.)
With that said though, I'm always curious to see different approaches to things, so I'm curious what makes your framework more advanced and how it works in general. Do you have some basic summary and/or examples?

glad cliff
#

I mean, yeah, if you think about it that way you remove code dependency by treating data and events as assets, effectively transforming the code referencing spaghetti problem into asset management hell XD Whatever floats your boat in that case I guess, personally I prefer latter one.
In terms of features of my framework, overall its more composition oriented then SOAP thanks to utilisation of recently added support for generic [SerializeReference] (little thinks like instead of ScriptableVariables having an option of being clamped or something, you can define as many as you wish your own validators/modifiers), less manual work with defining concrete types for generic ScriptableObject types thanks to static analysis and editor-side code-gen pass, and many more, but the core and a single feature that gave birth to an idea of making this framework in a first place is polymorphism.
To understand the issue: we had values as SO's with typical event "onValueChanged", but it was pain in the *** to keep signature of every handler fitting the event it was observing, even tho in most cases argument wasnt even used, so I made a system in which every reactive piece of data derived from type representing a parametrless event and then rest is a history...
We ended up with a system that allowed us to observe every value in multiple different ways letting us choose if we want to handle it with no param, with new value, or new and old value. If some system expects a reference to a parametrless event we can pass a value to it as it will be treated as one that triggers whenever value changes. Seems silly but it really allows for very flexible approach to designing in-game systems.

glad cliff
bright phoenix
glad cliff
#

Great! Feel free to DM me if you want to try it then, I have ready PATs to hand for downloading via UPM

burnt dove
#

Given the path to an scene (or the scene object, I don't care), how can I get a list of all inlined assets? i.e: for example if someone created an scriptable object but instead of storing it in a different file they stored it inside the scene itself. AssetDatabase.LoadAllAssetsAtPath doesn't work.
I could use Resources.FindObjectsOfTypeAll, but I don't know how can I filter the elements to I only have the ones of the specified scene.

glad cliff
#

If you use Resources.FindObjectsOfTypeAll and you filter out specific type that you desire maybe comparing path to your scene with AssetDatabase.GetAssetOrScenePath will help you filter the inlined assets in that specific scene.

burnt dove
surreal girder
#

Then those aren't sub assets but are serialized in the scene itself

burnt dove
surreal girder
#

I don't know how that works for scriptable objects but may not be doable easily

burnt dove
glad cliff
#

Well that may be overdoing it but I remember some utility class has option to find all dependencies for an object, so if any dependency within a scene that is of type ScriptableObject exists without a path it needs to be serialised in a scene, maybe that will do it

surreal girder
#

That may still only be for assets

glad cliff
#

Possibly, it's just a blind guess from me

#

Ok so most likely solution is to still use Reaources.FindObjectsOfTypeAll and filter by type as well as by !EditorUtility.IsPersistant && !AssetDatabase.Contains, that will yield only assets serialised in scene, and after that I'm afraid the only solution to determine in which scene exactly it is serialised is to iterate through serialised objects of the scene to find any property referencing it, or read directly from a file to find in which scene file this instance id is present. It would be much simpler to just ensure only one scene is loaded though, then there is no problem with that

surreal girder
#

Sometimes this is the way to go. I wrote something to find what unity events referenced an object (e.g. called a function on this game object/component) and had to do Find and reflection to do it

#

Would be nice if we could examine a scene asset externally as im sure its done in native code

gloomy chasm
#

Or don't 'inline' assets in a scene in the first place 😉

surreal girder
#

Yea its not wise but may be a lib/package so they want to account for this

nova swallow
#

hi
I try to work with the GraphView and i have a problem.
I want to know when the user add a remove an edge between nodes.
It look like graphViewChanged must do that work, with the parameter GraphViewChange.edgesToCreate but this callback is not call when and edge is added or removed.
Is there an other way to have the information when an edge change ?

glad cliff
atomic sable
#

Hey guys for the tool I'm making I need to make assembly definitions, and it mostly works, but not entirely? The problem I'm facing is that there seems to be issues referencing these assembly definitions I've made with GUIDs. For example, Rider will say that it doesn't exist, and sometimes unity will pop up saying there's duplicate references.

This is what I'm putting into the file:

        private const string k_ASSEMBLY_EDITOR_ONLY = @"
        ""includePlatforms"": [
        ""Editor""
    ],";

        private string AssemblyContents =>
            $@"{{
    ""name"": ""{_assemblyName}"",
    ""rootNamespace"": ""{_rootNamespace}"",
    ""allowUnsafeCode"": false,
    ""overrideReferences"": false,
    ""autoReferenced"": {(_autoReferenced ? "true" : "false")},
    $EDITOR_ONLY_MARKER$
    ""noEngineReferences"": false
}}";
```(`$EDITOR_ONLY_MARKER$` gets replaced with `k_ASSEMBLY_EDITOR_ONLY` if it's editor only, or the entire line deleted if not.)

I then import everything using:
```cs
UnityEditor.PackageManager.Client.Resolve();
AssetDatabase.ImportAsset($"Packages/{formattedName}", ImportAssetOptions.ImportRecursive);
AssetDatabase.Refresh();
```but I'm not sure if AssetDatabase methods works in the Packages folder. The GUI references problem can be fixed if I right-click on the assembly file and re-import it. How do I correctly import the assembly definition if it's in the packagees folder??
elder wasp
#

Hello, I've been using for a long time the Unity Graph View package, and there's one single thing that I can't figure out how to fix. Is there any way (with specific GraphView methods or general UI Elements configuration) to set the anchors of all visual Elements to be at the center? They all have their anchors at the top left corner, which brings issues when trying to ensure that everything follows the mouse

stable nebula
#

I'm trying to set a specific icon for every ScriptableObject instance of a certain type. I've made an Editor for that type and use EditorGUIUtility.SetIconForObject in OnEnable which seems to work as icon in the inspector and as preview in the Project window, but the Project window icon is the standard ScriptableObject icon unless I manually reimport that asset. Does anybody know how to fix this? Overriding RenderStaticPreview was unsuccessful 🙂
Image attached to show what I mean with preview vs. icon in the Project window. The icon is the ScriptableObject icon. And of course the preview goes away entirely if you use the slider in the Project window and then the custom icon is nowhere to be seen.

glad cliff
#

not for the object itself

#

cool icon btw 😄

round basin
#

So I've got a custom property drawer. This property drawer has extra functionality where a it needs to have ApplyModifiedProperties called or the inspector won't update. Normally its fine.

However, ApplyModifiedProperties does not trigger a repaint the very first time its called after a domain reload. I've tried MarkAsDirty and Update, neither help. Any help please?

atomic sable
#

what?

elder wasp
visual stag
safe sorrel
#

I'm having issues with updating an existing Mesh asset. I have a script that creates a mesh based on terrain. It works fine if it's creating the asset for the first time, but if I change the number of vertices and then update the existing asset, it doesn't actually write out the new vertices.

This results in only part of the terrain being covered by the mesh.

#
 public static void UpdateOrCreateAsset<T>(T obj, string path) where T : UnityEngine.Object
    {
        var output = AssetDatabase.LoadAssetAtPath<T>(path);
        
        if (output)
        {
            string oldName = output.name;
            EditorUtility.CopySerialized(obj, output);
            output.name = oldName;
            AssetDatabase.SaveAssets();
        }
        else
        {
            AssetDatabase.CreateAsset(obj, path);
        }
    }
#

this is how I'm updating the existing mesh asset

#

The weird thing is that the triangles do update

#

The example above had its resolution reduced from 512x512 to 256x256. Since the vertices didn't update, only 1/4th of the terrain is covered by the triangles

#

The mesh creation isn't that exciting

#
        result.SetVertices(vertices);
        result.SetTriangles(triangles, 0);

that's how I actually set the vertices and triangles

safe sorrel
safe sorrel
#

I tried using Mesh.vertices instead of Mesh.SetVertices and got the same result

safe sorrel
#

...both before and after copying

#

This would make sense if the resulting mesh had too many vertices, and if I were only updating some of them

#

If I sculpt the terrain, the min/max Y values change correctly on output after copying

#

Uh oh

#

Restarting the editor fixes it

#

reimporting the asset doesn't do anything

#

so, in short: if I change the vertices of an existing mesh asset, Unity ignores these changes until I restart the editor

bright phoenix
#

I heard you need to CLear the old mesh before you CopySerialized

safe sorrel
#

bingo

#

that's annoying!

#
        if (output)
        {
            if (output is Mesh mesh)
                mesh.Clear();
            
            string oldName = output.name;
            EditorUtility.CopySerialized(obj, output);

            output.name = oldName;
            AssetDatabase.SaveAssets();
        }
        else
        {
            AssetDatabase.CreateAsset(obj, path);
        }
stable solar
#

hello what are the dots icon called? the icon i have selected in the screenshot is called sv_label_0 but im not sure about the name for the dots

plucky knot
# stable solar hello what are the dots icon called? the icon i have selected in the screenshot ...

From some utils I use but these are all the values and their associated names

internal static class MonoScriptIconExtensions {
    public static void SetIcon(GameObject gObj, MonoScriptLabelIcon icon) {
        Texture2D iconAsTexture = EditorGUIUtility.IconContent($"sv_label_{(int)icon}").image as Texture2D;
        SetIcon(gObj, iconAsTexture);
    }

    public static void SetIcon(GameObject gObj, MonoScriptIcon icon) {
        Texture2D iconAsTexture = EditorGUIUtility.IconContent($"sv_icon_dot{(int)icon}_pix16_gizmo").image as Texture2D;
        SetIcon(gObj, iconAsTexture);
    }

    private static void SetIcon(GameObject gObj, Texture2D texture) {
        EditorGUIUtility.SetIconForObject(gObj, texture);
    }
}

internal enum MonoScriptLabelIcon {
    Gray = 0,
    Blue,
    Teal,
    Green,
    Yellow,
    Orange,
    Red,
    Magenta
}

internal enum MonoScriptIcon {
    CircleGray = 0,
    CircleBlue,
    CircleTeal,
    CircleGreen,
    CircleYellow,
    CircleOrange,
    CircleRed,
    CircleMagenta,
    DiamondGray,
    DiamondBlue,
    DiamondTeal,
    DiamondGreen,
    DiamondYellow,
    DiamondOrange,
    DiamondRed,
    DiamondMagenta
}
stable solar
tough cairn
#

anyone knows how to quickly create a Settings popup on the target Object ? similar to how you can right click on a gameobject / component and a new floating window will appear. - something like EditorUtility.PopUpSettings( target_object )

tough cairn
#

nvm i figured it out :

static System.Reflection.MethodInfo mOpenPropertyEditor;
public static void OpenPropertyEditor( UnityEngine.Object obj ) {
    if( mOpenPropertyEditor != null ) {
        mOpenPropertyEditor.Invoke( null, new object[] { obj, true } ); 
        return;
    }
    mOpenPropertyEditor = typeof(EditorWindow).Assembly
        .GetType("UnityEditor.PropertyEditor")
        .GetMethod("OpenPropertyEditor", 
            System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic,
            null, new System.Type[] { typeof(UnityEngine.Object) , typeof(bool) }, null);
    if( mOpenPropertyEditor != null ) OpenPropertyEditor( obj );
}
muted cave
#

Is there a way to get the width of the red line?

visual stag
muted cave
#

nvm I figured something out

night swallow
#

EditorGUIUtility.labelWidth

visual stag
#

Not even sure if they're using IMGUI

muted cave
#

I was just trying to make a custom drawer, but my Label wasn't the same length as the default Labels. I was using a "normal" Label instead of EditorGUI.PrefixLabel() and now it fits nicely

atomic sable
# visual stag Show some code

ah sorry figured it out. Im not sure why, but it had something to do with the type being in a different editor-only assembly. It started working when I moved the files to be in the proper assemblies.

wet solstice
#

Do you guys think that you should use the VR package for unity(openXR) or just create your own scripts for tracking/inputs? Navigating and reading the openXR package contents is confusing as hell

gloomy chasm
wet solstice
#

thanks

dire ruin
#

Not sure if this is the best place to ask, but I've had such a hard time finding a visual list of built in icons to make my editor windows. While I finally did find a library on github, is there any documented reasons as to why unity doesn't have a library already? And don't get me started on their doc website. The majority doesn't have an image of what the icon, window, etc.

Also yes. I'm a terribly new newb

gloomy chasm
dire ruin
gloomy chasm
#

#📱┃mobile is probably what you want. This channel is for discussion around creating custom editor windows, inspectors, and that sort of thing. You can look at the description of a channel if you are not sure what it is about! 🙂

gloomy chasm
muted cave
#

Anybody know why my Vector2 is wrapping over two lines when I show it in my custom property drawer like so:

EditorGUI.PropertyField(position, property);

Image 1 is what it looks like when it has enough space, Image 2 is what happens when the horizontal space gets too small. This doesn't happen without my CustomDrawer.

muted cave
#

or is it possible to retrieve the custom drawer and then read the PropertyHeight from there?

red kiln
#

I want to run a script on project load and then never have it active again, but I am not sure if an attribute or something as I tried InitializeOnLoad but happens every time script updated

bright phoenix
#

Oh... or create a file marker... I don't remember if there's anything like EditorPrefs that's per project 🤔 (Of course you can always create a file with whatever data)

gloomy chasm
gloomy chasm
bright phoenix
#

yeah, that's why I wrote he other line, I guess I should've explained more 😄 👍

red kiln
#

ok, odd there is not an event for like when a project has loaded. I really just want to trigger the C# project to open at start but if it repeats it takes focus off Unity!!

waxen sandal
#

Is it just once for that editor session or you only want it to run once ever?

gloomy chasm
#

You can look at the docs for how to do the ScriptableSingleton, they have a great example

waxen sandal
#

Or if it's just for this instance/session of the editor, use SessionState

red kiln
gloomy chasm
red kiln
#

yeah SessionState does seem a way to keep it in 1 class...

gloomy chasm
red kiln
atomic sable
#

How do I make my property drawer for my attribute work when in a nested field like how the range attribute does? OnGUI is not even called when it's a nested field.

waxen sandal
#

Wdym

atomic sable
# waxen sandal Wdym

this method does not run:

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (attribute is ShowIfAttribute showIfAttribute && showIfAttribute.EvaluateCondition(property))
            {
                EditorGUI.PropertyField(position, property, label, property.isExpanded);
            }
        }

Under this condition:

[Serializable]
public class Foo
{
// attribute applied to this field does not have OnGUI called for its property drawer
  public int a;
}

public class Bar : MonoBehaviour
{
  public Foo test;
}
waxen sandal
#

I don't see your attribute there at all?

atomic sable
#

I didn't think that my example with my comment that I wrote inside of discord would need to show the attribute being applied

#

imagine it is there

waxen sandal
#

What about the rest of your property drawer?

trail quartz
#

Hi, i want to ask whether anyone know how to hide the size element (number on the right) on the element that unity draws by default when putting a list in PropertyField(), currently using IMGUI to make my first editor extension and id like to somehow disable that part of the editor

gloomy chasm
#

You could also use a ReorderableList instead of PropertyField, but you would have to setup a good chunk of the logic yourself

trail quartz
#

I see, thanks for the help, i think i will look back on this issue later and finish making it work for now while ignoring the array size.

atomic sable
glad cliff
#

How can I include offline documentation in .html format in my package so UPM can register it?
Manual states that you can either include documentationURL in package.json to point to a webside or put offline documentation with this folder structure:

  └── Documentation~
       └── <package-name>.md

but documentationUrl doesnt seem to work with path to .html file relative to a package (at least as far as I tested) and including it in Documentation~ folder also doesnt work as it is not a markdown.
I have my full documentation configured to be generated in html format and I want to ship it with the package, but UPM seems a bit stubborn about it.

knotty oracle
#

I assume you expanded foo in foldout, child properties code is not run if foldout is not expanded.

atomic sable
#

Yea its expanded and ShotIfAttribute does extend ProperyAttribute and the height method is properly called just not the OnGUI method

knotty oracle
#

That's interesting, it should definitely work by default.
Maybe there is some custom editor code somewhere that hooked over drawing Foo, and is doing some simulation of default Unity editor behavior? You can check the stack trace of who is calling into GetPropertyHeight

sage epoch
#

I'm trying to create a prefab variant from a blend file in editor code. It works, but it puts an instance into the current scene. I tried creating a preview scene and passing that to InstantiatePrefab but it still adds it to the current scene.

waxen sandal
#

Can you share some code?

sage epoch
#

Typical. I edit the code to get a sample ready, and suddenly it works

waxen sandal
#

You're welcome? 😛

harsh bough
#

Yo, anyone who uses VS Code with Git. Can ya'll tell me why I'm getting this error? For some reason, when I try to commit, it's taking all of my computer's files even though. I'm using a specific folder for my app

harsh bough
#

Yup, figured out the issue. Thanks

gloomy chasm
#

Anyone know how the heck to add settings to the build profile section?

waxen siren
#

can unitask work on update/fixedupdate/lateupdate ?

#

i know it can work on void start

bright phoenix
#

You don't mean in Edit mode, right? 😅 If so, then yes, it has a... something... it's in the docs though 😅

#

await UniTask.Yield(PlayerLoopTiming.FixedUpdate)

surreal girder
#

yea all of the delay functions they provide can change the timing mode.
Outside of play mode it will use EditorApplication update

white lynx
#

Anyone here with knowledge about Handles, EditorWindow and color?

am having a problem with drawing, in the code I use the same Color for the DrawAAConvexPolygon() and DrawSolidArc(), yet they differ in color.

    Handles.color = new Color(color.r, color.g, color.b, color.a * color.a); // even without the a times a it bugs
    Handles.DrawSolidArc(pointA, Vector3.forward, startDir, 180, radius);
    Handles.DrawSolidArc(pointB, Vector3.forward, -startDir, 180, radius);

    Handles.color = new Color(color.r, color.g, color.b, color.a);
    Handles.DrawAAConvexPolygon(
            new Vector3(pointA.x, pointA.y, 0) + startDir * radius,
            new Vector3(pointA.x, pointA.y, 0) + startDirR * radius,
            new Vector3(pointB.x, pointB.y, 0) + startDirR * radius,
            new Vector3(pointB.x, pointB.y, 0) + startDir * radius
    );
twin dawn
white lynx
#

yeah, but even when i use the normal, it also has differant colors

twin dawn
#

I'm not sure what I'm supposed to be looking at in the screenshot

white lynx
#

sorry, the cap at the end should be supposed to be the same color as the rest of the body

#

should a pill shape same color and outline that has its alpha set to 1

#

this is whitout the different alphas,

obsidian pine
white lynx
#

Oh nice thank you, have already fixed the problem. How did you do it?

obsidian pine
#

and drew an outline around it

obsidian pine
#

you kinda inspired me. i gotta make a thing for this contract soon so i think i'm gonna make an editor tool for it as a personal package as a bonus

#

inspector radar charts for configuration

gloomy chasm
obsidian pine
#

i did the thing guys. took me all day but aint she purdy

#

has configurable named attributes, independent min/max range values, and you can edit the underlying data with the graph itself

fickle copper
#

Greetings!

I am trying to create a quick inline-editor for scriptable objects using ui-toolkit and i have encountered a scenario where this inline-editor would recursively draw itself to oblivion, causing the engine to stall.

Is there any good way to make it not redraw itself should it encounter a self-reference?

white lynx
#

Maybe a hashset could work here

fickle copper
# white lynx Maybe a hashset could work here

I have tried something similar, but the issue is:
Due to the nature of ui toolkit having to create things once, whenever the user assigns a scriptable object that self references itself, it would somehow need to check and update the hashset and conversly create an object field, not a property field.

#

The InspectElement component doesnt have this check and i am not sure how to create a custom one that updates itself during the runtime

glad cliff
#

Im developing a custom package and there is one thing I cant seem to grasp...

  • If package wants to load some assets that come with it, it can use a virtual path "Packages/<package-name>/path"
  • In order for this to work package needs to be registered by UPM and cant be inside Assets folder
  • As I develop the package I need to have access to this functionality, so I store it somewhere else on disk and import it with UPM
  • But now I cant upload it to a pending page on asset store nor I can export it to a .unitypackage, as its not in Assets folder.
    I feel like there is some crucial step in this process that im missing....
    My package uses virtual paths to access relative assets so I cant develop it directly in Assets folder, but it needs to be in Assets folder for it to be exported/uploaded.
    How do other developers handle this process?
gloomy chasm
#

The package manager will automatically notice it

glad cliff
#

Yeah I bet there is number of options where I can put it, the point is that it cant be in Assets, yet it needs to be in Assets :/

#

unless you mean putting it in Assets/Packages?

gloomy chasm
gloomy chasm
glad cliff
#

oh rly? Thats an info giving some hope!

#

although it should be communicated more clearly then, because for me it states that is must be in Assets foldet and my package is in MyPtoject/LocalPackages/com.me.package with a relative path given in manifest.json for UPM

gloomy chasm
glad cliff
#

There it is! I knew there is a simple widely known step that I missed somehow! XD Now I know, thanks a lot!

gloomy chasm
#

You're welcome haha. Once you move it there, you can just use the Asset Store Publisher Tools to upload it as a package, so when it is installed it will be as a embed package.

glad cliff
#

I scanned through this part of docs briefly, I guess I ignored that part as my package does not have dependencies so it must not be info for me XD

gloomy chasm
#

Haha

glad cliff
#

it send me through a deep rabbit hole of understanding the difference between .unitypackage and an actual "Package" (which apparently is not the same) and finding some concept of "Hybrid Pacakge" or something... story concludes that Asset Store Uploader hides this functionality as experimental feature you need to activate with a define symbol ehhhh

gloomy chasm
# glad cliff it send me through a deep rabbit hole of understanding the difference between .u...

a .unitypackage is just a .zip file basically that Unity has built in support for extracting and putting the assets in the project.
A UPM Package is structure for handling collections of assets and scripts that can have versions and dependencies.
A 'hybrid package' is just a UPM Package that has been put in a .unitypackage so when the .unitypackage is added to the project, the UPM Package is embeded inside of the Packages folder instead of being added to the Assets folder

rough crater
#

How can I open a specific folder in the project window? All I found was theres the ping object method which can highlight an object, but I want it to enter the specific folder

gloomy chasm
glad cliff
#

yeap, for some odd reason project window is internal :/

surreal girder
#

The new search window would have been great if we could have it show certain assets but that isnt possible either :/

#

The best alternative is to "select" the assets and then the project window should show em