#↕️┃editor-extensions

1 messages · Page 22 of 1

north sphinx
#

But that limits functionality to what I add

#

And I'd like to have full hierarchy functionaly: create empty, disable object and all that stuff

gloomy chasm
#

Going to have to use a good bit of reflection and custom code, but I think it should be mostly do-able. I would look at the source for the hierarchy. Last I checked it had a poco that did a lot of the heavy lifting.
But I think they might have also changed it in 2022 or 2023 to accommodate DOTS.

#

But no there is no easy way to do it. And while it is sort of possible to embed one window in another, there is a lot of careful management and hackery that goes in to it.

north sphinx
#

except for entities one

proven forge
#

holy fuck i hate writing scripts for the editor

#

satan himself ascended from hell to bestow upon us this nightmare

north sphinx
#

Hmmm. So basically I have a field for prefab asset.
I want to get a callback whenever prefab inside of that field changes (for example hierarchy changes and etc).
But I don't get how to create SerializedObject for specific field

#

Here's where I'm at atm

    public class CustomHierarchy : EditorWindow
    {
        [SerializeField] [AssetsOnly] private GameObject _prefab;
        private void CreateGUI()
        {
            var serializedObject = new SerializedObject(this);

            var selector = new PropertyField();
            selector.label = "Prefab to edit";
            selector.bindingPath = nameof(_prefab);

            var property = selector.BindProperty(serializedObject);
            selector.TrackPropertyValue(property, serializedProperty => { Debug.Log("Changed"); });
#

and this does not track Changed when asset changed

gloomy chasm
north sphinx
#

so basically, I am making custom hierarchy for prefab

#

and I need to update hierarchy if prefab is reimported

#

because user might have added something to it

gloomy chasm
north sphinx
#

isn't there a way to just serialize object and track it's changed via script?

gloomy chasm
#

No because a SerializedObject is scoped to the UnityEngine.Object it was created for. And doesn't go in to any of the other UnityEngine.Objects it references

#

So GameObject is basically only the name, instanceId, tag, and layer

north sphinx
#

so... I can just create scope each time property of field changes?

gloomy chasm
#

There is no way that I know of to use SerializedObject to get when a component is added or removed, or when the transform hierarchy changes.

floral tangle
#

is it possible to extend the context menu for properties of a certain type in the inspector?

I'd like to be able to add a custom menu item when right-clicking on any script property, e.g.:

whole steppe
visual stag
visual stag
visual stag
#

you inherit from Editor

whole steppe
#

works fine now blushie

north sphinx
#

How can I open Right click of game object in hierarchy outside of hierarchy? I have my custom one, but I want to open same menu dropdown as when you right click entries from normal hierarchy

gloomy chasm
gloomy chasm
#

Does passing it "GameObject/" not open it?

north sphinx
#

🤔

gloomy chasm
#

(maybe with or without the forward slash)

north sphinx
#

it doesn't have an overload for any object

#

I think this is closer to what I need

#

but still unsure

#

need to experiment

gloomy chasm
#

Ahh yeah

blissful burrow
#

I wish it was possble to put prefabs as subassets of scriptable objects ;-;

#

I can do it the other way around, but, that's not as nice

blissful burrow
#

the struggle

short tiger
#

But it means you'll have to serialize the ScriptableObject to a text file with some unique file extension so the ScriptedImporter can import it.

#

And it's extra editor GUI work to make the file editable within Unity, since imported assets are usually immutable.

olive atlas
#

is this the right place to ask stuff about custom editors / property drawers?

#

Oh nvm

#

I'm having an issue with implementing custom PropertyDrawers inside other custom PropertyDrawers

blissful burrow
#

I might just have to create the prefab separately and reference it from the mesh data SO instead

olive atlas
#

When a custom property drawer has a foldout, I can't figure out how to include it within another custom property drawer and have the property height and placemnt working correctly

#

if I use GetPropertyHeight, it causes a stack overflow for some reason

short tiger
#

The import settings are serialized separately, in the .meta file, and are mutable.

visual stag
blissful burrow
#

I'm not if I can use importers for this use case though, I need to be able to update the data/asset in real-time

#

my use case is for a 3D modeler inside unity, and so editing mesh data can't go through an import step if it has any kind of performance impact/load

blissful burrow
#

oh whoops that deleted my original mesh data lol

#

I feel like I'm gonna have to give up the idea of having a prefab be part of the same asset

#

and instead create it separately and reference it from the SO

#

just gives me asset management anxiety to let it go and let users rename/duplicate/delete either of the two separate parts at will

short tiger
short tiger
#

It's assuming it will find the GameObject as the main object.

#

Probably trivial to fix in this case, but there are probably other cases as well

visual stag
#

Yeh I wouldn't have expected it to play nice

#

But it's good to know you can get it to a half broken imported version UnityChanCelebrate

blissful burrow
short tiger
blissful burrow
#

right, but then the main issue is likely the thing you posted above then, with the prefab/GO not working as expected

#

it's probably best in my case to keep the prefab separate and reference it from the mesh data instead

#

for stability

#

that also makes it possible to create mesh data without prefabs, which is useful

short tiger
#

but scriptedimporter is cool :c

wraith hazel
#

Hey guys!
I'm trying to make a static EditorInput class that has similar syntax to the runtime Input class. I'm done implementing all the stuff for it but I have a small problem.


        [ExecuteInEditMode]
        private static void StartUpdateLoop()
        {
            Debug.Log("EditorInput is now observing EditorApplication.delayCall!");
            EditorApplication.delayCall += UpdateLoop;
        }

        private static void UpdateLoop()
        {
            // update all keys' down/up/held statuses
        }

The StartUpdateLoop() is supposed to start the update loop for the EditorInput class. The update loop should be running each time "Event.current" changes. Does there exist a callback for this?
PS: the StartUpdateLoop() never runs in the current state, even after compilation.

#1: Got the StartUpdateLoop to run after making it a static constructor. Still haven't found the appropriate callback, however

#2: Found a solution that is dirty but it works. Essentially, I converted the UpdateLoop to be controlled by other editor windows rather than by itself, because editor windows have access to GUI methods and they can refresh the keys remotely from there. This could lead to performance issues though if there is 10 editor windows at once, but the refreshing can be throttled using a minimum ms delay or something (if needed).

short tiger
# blissful burrow right, but then the main issue is likely the thing you posted above then, with t...

It doesn't solve the prefab problem, no, so this is not longer relevant to your question but I think you should consider ScriptedImporter as an alternative to AssetDatabase.AddObjectToAsset. Even with working sub assets, you'd be serializing the mesh data twice in two different formats (SO and Mesh) as source assets in the project, while ScriptedImporter allows you to generate the derived assets on demand and they're only stored in the Library cache. Maybe too late to make this change now, but something to keep in mind for future problems. ScriptedImporter is cool.

blissful burrow
#

probably not too late no! this is when I should be thinking about these things

#

so if the main asset isn't the SO anymore, but a custom file, what would the serialization to disk workflow look like?

#

because rn dealing with it as a regular SO makes things pretty straightforward

short tiger
#

During editing, you would still just be working directly with the SO.

blissful burrow
#

hmm, ok, SG has also been notoriously slow and annoying to me in that regard

#

but that might be more so the shader compilation rather than the importer

short tiger
#

Granted, it is more work for Unity. It would be nice to be able to tell Unity that the runtime SO is already up to date so it doesn't need to reimport, but that would break the deterministic guarantee of the asset import result.

blissful burrow
#

yeah I'm a little worried it would trigger redundant reimports, and that I'd have to manage asset dirty state manually

#

ie when I need to shove the SO data into the asset

#

or load it I suppose

short tiger
#

Yeah, you would need to decide when to write to disk.

blissful burrow
#

relatedly - is there a way to mark fields as disabled due to being managed by another script? kinda like how grid layouts lock down rect transforms etc. specifically on mesh filters and mesh renderers (ideally without a custom inspector for them)

blissful burrow
short tiger
bright fox
#

do I have a way to make handles that can be selected in scene view for my bezier curves without creating dummy objects?

wraith hazel
#

I can't for the life of me figure out how to do this:

Say there's struct A containing one string field (for simplicity's sake). How do I draw that struct in an EditorWindow's OnGUI method? There's nothing for displaying structs in EditorGUILayout, but the default Unity inspector still shows all kinds of classes and structs.

blissful burrow
wraith hazel
blissful burrow
#

what's the boilerplate?

#

bc it should display all sub properties automatically as far as I know

#

or do you mean just to get the serialized property rather than a direct ref?

wraith hazel
#

And structs aren't UnityEngine.Objects so I don't know how it'd even be possible without making them a class or a SO

blissful burrow
#

well they're serialized somewhere I hope

wraith hazel
#

But I don't even really need it now because I'd have used it for a keybind/shortcut struct for defining multiple keycodes for input, but I decided that because it'd get reset anyways when the custom editor got disabled, that it'd be useless to make them configurable

#

So I just have them defined in code

visual stag
blissful burrow
deep basin
#

playfab has never worked for me, and is spamming this error into my console. "could not CompressIPIData because PlayFabSettings could not be found" Please help me, i need this for my game to be playable

stark geyser
silent otter
#

The custom inspector for Unity's SpriteRenderer gets a bunch of properties that I can't find in the Unity CSReference. Is it possible to find their definitions somewhere?

#

This also applies to the base class RendererEditorBase which has some useful stuff like gui for sorting layers which is hidden in internal

visual stag
#

You have to look at the serialized data or editors to know how it's laid out

manic pilot
#

is there any way to make EditorGUILayout.ObjectField exclude inactive objects in the scene? rn it just fills up with a bunch of deactivated junk which makes it far less useful than I'd like

surreal delta
manic pilot
#

That'd only apply after the list is shown though, right? I might just not be getting what you mean here.

surreal delta
#

what exactly are you trying to achieve

manic pilot
gloomy chasm
#

Sorry, I know that isn't helpful. If you are in 2022.3(might need to be 2023?), there is a new selection window using the new search API which you can open and can limit that to enable/disabled GOs.

manic pilot
#

god that's lame. thanks for the sanity check

#

nah, stuck in 2020 for now. legacy project

#

thanks for letting me know though 👍

gloomy chasm
#

Ah, then yeah, nothing can be done 😦

manic pilot
#

Thanks anyway!

north sphinx
#

Is there a way I can somehow subscribe my asset to depend on another? SO for example, my timeline playable asset references scriptable object. So when that scriptable object changes, I want my timeline playable to get rebuilt

plucky tiger
#

Does anyone know how to Fix that? ☠️

#

Ok i fixed one error somehow

#

But there is still one

#

Building C:\Users\ASUS\Downloads\ms freshy\index.html failed with output:

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

gloomy chasm
gloomy chasm
north sphinx
#

AddDependency

#

hmmm. Does it mean if I pas dependency path for asset I want and register hash of another asset I want

#

that would be it?

#

I guess scripted importer could do better job

gloomy chasm
#

Huh, I guess that is what I was thinking of. I was sure there was another method for it though...

north sphinx
#

because it obtains dependency string out of reading raw text

#

var lines = File.ReadAllLines(ctx.assetPath);

#

🤔

#

or is that just normal asset path?

gloomy chasm
#

It is just a path to an asset as normal

north sphinx
#
                                    var abilityPath = AssetDatabase.GetAssetPath(targetAsset.abilityGraph);
                                    ctx.DependsOnSourceAsset(abilityPath);
#

so that's it ig

#

and when that reimports

#

if I don't call it

#

dependency will be gone, right?

gloomy chasm
#

I assume so

north sphinx
#
The scripted importer 'TimelineScriptedImporter' attempted to register file type '.playable', which is handled by a native Unity importer. Registration rejected.
short tiger
north sphinx
#

any ideas then?

#

I need to add dependency to timeline asset

#

🤔

#

or alternatively I just need to get a callback when registered asset changes

#

so I can update existing timeline on it's own

short tiger
north sphinx
short tiger
#

In what way does the SO reference affect the timeline? Does the timeline somehow read this reference and change itself based on what it contains?

#

You're not losing the reference to the SO when it changes, right? So what's the problem?

north sphinx
#

so when I edit SO, I want timeline to be updated

#

but as of now, playable is not recreated

#

and I need to reopen timeline to refresh

short tiger
#

So the timeline is automatically generated based on what is contained in the SO? Is that normal or something custom? I thought timelines are hand authored.

north sphinx
#

alternatively, I need to edit timeline asset itself

#

then it will recreate playables

north sphinx
#

just consider timeline is SO that references other SO

#

and I draw gizmo based of data of timeline + other SO

#

while not having ownership of callback when gizmo data gets baked

#

so if I edit timeline asset itself

#

I get callback to recreate gizmo data

#

so I read other SO accordingly

#

but when I modify other SO only, without touching timeline

#

nothing happens

#

so I was thinking about making timeline reimport

#

by adding additional dependency

#

but looks like Unity forbids that for native assets

short tiger
#

Well you can't create a scripted importer for a file extension that already has an importer. And you wouldn't want to, because then you'd have to manage the whole import with no way to call the base importer. You might be able to hook into it with an AssetPostprocessor, but then you'll have to process all assets, ignoring assets not ending with .timeline. Just creating the script will cause a full project reimport.

north sphinx
#

it doesn't cause full reimport, until asset is reimported explicitly btw

#

found that out myself

#

eh, wanted to avoid this

#

because we have so many asset postprocessors atm

#

this is really bad

short tiger
#

I'm not sure it would work anyway, because dependencies are not checked unless an asset is being imported. I don't think a scriptable object change counts as an asset import.

north sphinx
#

well, timeline does update somehow when I edit values though

#

meaning it does have some sort of serialization callback listener

#

all I want is to just trigger it when ability graph changes

gloomy chasm
north sphinx
#

called from native somewhere

fervent scaffold
#

guys how do i get a refrence to a prefab

#

i got the prefabs as strings, paths

flat crag
#

can anyone tell me what does internal mean

#

and why is my visual studio not autofilling unity scripts

peak bloom
#

is there a way to hide certain components from showing up in AddComponent ?

peak bloom
hollow urchin
#

Any idea on how to stop Unity blend file importer?
I can only think of rename blend to something else to make it work with scripted importer

north sphinx
#

Any idea why query field does not get saved between Window instances?

    public class BalancingWindow : EditorWindow
    {
        private void CreateGUI()
        {
            var obj = new SerializedObject(this);

            var header = new VisualElement();
            rootVisualElement.Add(header);

            var queryProperty = obj.FindProperty(nameof(query));
            var queryField = new PropertyField(queryProperty);
            queryField.Bind(obj);

            header.Add(queryField);
        }
#

public MonoScript[] query;

#

it's public serializable field

#

and it does get saved properly with odin window, but when doing it manually

#

it gets reset each time

#

🤔

#

@peak bloom you probably know what's up here

peak bloom
#

Unity's serializer can't serialize types, thus youur monoscript will reset

#

what you're trying todo @north sphinx

north sphinx
peak bloom
north sphinx
#

yeah, I'm getting component and trying to make a table

#

tried that with odin, but it struggles with tables really hard

#

potentially considering getting only specific fields maybe

#

but this does not look good

peak bloom
#

those prefabs are in form of assets or they're instantiated in your scene already?

#

iirc components prefab assets aren't initialized yet until they're instantiated

#

I mean obviously, duh

north sphinx
#

there is no problem with assets serialization

#

except making proper UI

#

which at best would be Odin's

#

but odin itself struggles to make a table with inlined component inspectors

#

so my plan is to create list view with multi columns

#

and just slap ImGUI on each

#

but I am struggling now with serialization of settings

#

annoyingly, odin has no problem serializing MonoScript

#

but I can't use UI toolkit with Odin

peak bloom
north sphinx
#

well yeah, that's what I said

#

I was meaning drawing table within Odin inspector

#

UITK table

broken lichen
#

Is Visual Studio the most popular editor for Unity?

atomic sable
#
            private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
            {
                Room asset = AssetDatabase.LoadAssetAtPath<Room>(importedAssets[0]);

                Debug.Log("test");

                if (asset is Room room)
                {
                    Debug.Log("test2");
                }
            }

why's it called twice when i create an asset once?

broken lichen
# cobalt yoke I think so

Any downside to using VSCode with extensions? I read that there is almost no autocomplete, do you know if that's true?

peak bloom
#

does anybody know what's the timing of EditorApplication.update?

#

That's the worst docs ever

#

They should at least tell us the technical aspect of it

gloomy chasm
#

I think it is is 30 calls per second

peak bloom
sleek anvil
waxen sandal
gloomy chasm
peak bloom
waxen sandal
#

It depends on the loopConditionFunction no?

peak bloom
#

Not quite sure tbfh 😌 , I just need to know the entry for the update timing while in edit mode

#

fek it, lemme print them all

#

stay tuned! 😂

peak bloom
#

btw here

waxen sandal
peak bloom
north sphinx
#

Is there a built in command to open file explorer for specific path?

gloomy chasm
#

Found it

#

There is also one for opening to a folder and one for saving

north sphinx
#

no

#

that's select file

#

what I want

#

is to open explorer

#

and that's it

gloomy chasm
#

Oh that one

north sphinx
#

similiar to Show in Explorer button

#

when you right click smth

gloomy chasm
#

Yeah there is

#

let me find it

gloomy chasm
north sphinx
#

yeaah

#

that's the one

#

thanks

gloomy chasm
#

Sure thing!

north sphinx
#

hmm, is there any way to get unique identifier of currently running editor instance?

#

I'm making a test tool for editor server and I just need to ensure that editor that runs it can be uniquely identified

#

so it doesn't overlap with other editors

gloomy chasm
atomic sable
#
            private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
            {
                if (importedAssets.Length == 0)
                    return;

                Room asset = AssetDatabase.LoadAssetAtPath<Room>(importedAssets[0]);

                if (asset != null && asset.m_thisPrefab == null)
                {
                    string path = CreatePrefabForRoom(asset, importedAssets[0]);

                    if (EditorUtility.DisplayDialog("Room Creation", "Open room prefab in isolation?", "Yes", "No") && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                        PrefabStageUtility.OpenPrefab(path, null, PrefabStage.Mode.InIsolation);
                }
            }

How can I make sure that this only runs once? On an AssetPostprocessor. It's called twice each time an asset is imported.

atomic sable
#
public class RoomCreationCompletor : AssetPostprocessor
{
    private static readonly HashSet<string> _createdAssets = new();
    private static readonly HashSet<string> _readyRooms = new();

    // must be done like this because this method is called twice for imported assets, once before they are finished importing and once after... for some reason
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        if (importedAssets.Length == 0)
            return;

        Room asset;

        // add prefabs to rooms that are ready
        if (_readyRooms.Count > 0)
        {
            foreach (string room in _readyRooms)
            {
                asset = AssetDatabase.LoadAssetAtPath<Room>(room);

                CreatePrefabForRoom(asset, room, out GameObject prefab, out string prefabPath);
                asset.m_thisPrefab = prefab;

                if (_readyRooms.Count == 1 && EditorUtility.DisplayDialog("Room Creation", "Open room prefab in isolation?", "Yes", "No") && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                    PrefabStageUtility.OpenPrefab(prefabPath, null, PrefabStage.Mode.InIsolation);
            }

            _readyRooms.Clear();
        }

        // find rooms that are ready in imported assets
        foreach (string path in importedAssets)
        {
            asset = AssetDatabase.LoadAssetAtPath<Room>(path);

            if (asset == null || asset.m_thisPrefab != null)
                continue;

            if (_createdAssets.Contains(path))
            {
                _readyRooms.Add(path);
                _createdAssets.Remove(path);
            }
        }

        _createdAssets.Clear();
    }

    public static void CreatePrefabForRoom(Room room, out GameObject prefab) => CreatePrefabForRoom(room, AssetDatabase.GetAssetPath(room), out prefab, out _);

    public static void CreatePrefabForRoom(Room room, string roomPath, out GameObject prefab, out string prefabPath)
    {
        prefabPath = $"{roomPath[..roomPath.LastIndexOf('/')]}{roomPath[roomPath.LastIndexOf('/')..roomPath.LastIndexOf('.')]}_Prefab.prefab";
        prefab = PrefabUtility.SaveAsPrefabAsset(room.m_basePrefab, prefabPath);
    }

    public class RoomPathChecker : AssetModificationProcessor
    {
        public static void OnWillCreateAsset(string assetPath)
        {
            _createdAssets.Add(assetPath);
        }
    }
}

This is the best I could come up with. Seems very unweildy for something that should be simple...

atomic sable
#

additionally, this does not create a prefab variant, even though documentatino says it should:

GameObject temp = Instantiate(room.m_basePrefab);
prefab = PrefabUtility.SaveAsPrefabAsset(temp, prefabPath);
DestroyImmediate(temp);
hybrid sand
#

ih

#

hi

#

im trying to change my external code editor to vs code and it is stuck on code.cmd bc when i try to change it it just opens a new preferences window and it stays on code.cmd. Ive already deleted code.cmd and it still wont change.

short tiger
whole steppe
#

How to properly do an editor extension to a class inheriting from a unity thingie?
https://gdl.space/yexulobizo.cs
(In here, I always have to grab reference each property one by one each time)

peak bloom
#

the screenRate there is just 1/screenRefreshRate to fake the 1 frame/second

waxen sandal
#

Isn't timeSinceStartup's precision 1 second?

peak bloom
#

I don't think

waxen sandal
#

The docs seem to imply that

#

Maybe I was thining of something else, something to do with the inspector instead

peak bloom
#

I really think they should make another api similar to Time.frameCount that works in Edit mode

#

proly there's already?

waxen sandal
#

WEll you can just do that by requesting an update

peak bloom
#

iirc the EditorCoroutine is also faking the frame timing by doing 1/screenRefreshRate

#

for edit mode

#

or proly it was something else.. but anyway, it's kinda important to have frameCount to simulate things that are affected by frames such as tweening, interpolation etc....

#

kinda sucks I had to fake it for all my editor tools

pure coral
#

any idea how to make a bound listview read only?

#

like with ugui greyed out fields pretty much

velvet kettle
#

Hey, are there anyone who is aware of how to add a font into unity so it will display sybols that is not in the defutl font?

velvet kettle
#

editor

peak bloom
#

its similar to TotalSeconds in stopwatch class

limpid yarrow
#

Hi does anyone know how can I draw this type of gizmos? The ones that are an arrow that expands along the line

waxen sandal
#

It's just a line with an arrow cap

#

Draw a line, draw arrows at certain points

chilly steeple
#

Anyone know why this would crash the editor (in Edit mode, called on button click)

proper harbor
#

am I crazy to think that vector2fields should have the right-click copy/paste menu available? Do I have to enable something or does it require more work than I hope?

#

(my google-fu on this one fails me)

proper harbor
#

aah.., turns out I just need to treat it as as a propertyfield and not a vector2field

glad cliff
#

How do I access unity built in variables for uss in code?
What I need is to make background-color: var(--unity-colors-some_element-background) but in c# code like myElement.style.backgroundColor = builtinUnityVariable

lone halo
#

Or should I read the data at this step and store it elsewhere somehow until I need it?

short tiger
lone halo
#

Makes sense

pine gull
#

so currently i use "RegisterValueChangedCallback" to assign a changed value to the appropriate variable
Is there any way to make this only trigger upon pressing enter or something, instead of every time I change the number in the field?(so that I can have it wait until I enter 0.5 before submitting it vs submitting 0, 0., and then 0.5)

gloomy chasm
pine gull
#

hmmm ok
its a floatfield

#

I want to use it to change resolution of something, but I dont want it to set resolution every time I add a digit

gloomy chasm
#

Yeah, you want isDelayed

pine gull
#

ok thanks!

#

ah yes this looks perfect thanks!

slender mantle
#

Hey folks! Sorry if this doesn't belong here, but I'm pretty new to editor window scripting. I'm having trouble with the following method:

 {
     //tech.targetSelf = targetSelf;
     if ((GUILayout.Button("Save As")))
     {
         tech = CreateInstance<SimpleTechEffect>();

         tech.name = fileName;
         tech.methodName = SimpleTechEffect.onHitMethods[TechniqueEffectMaker.selectedMethod];
         tech.statTarget = TechniqueEffectMaker.targetedStat;
         Debug.Log(tech);
         //insert logic for initiall=izing fields here...
         if (!Directory.Exists(UnityEngine.Application.dataPath + "Assets/GeneratedTechniqueEffects/"))
             Directory.CreateDirectory(UnityEngine.Application.dataPath + "Assets/GeneratedTechniqueEffects/");
         AssetDatabase.CreateAsset(tech, UnityEngine.Application.dataPath + "/GeneratedTechniqueEffects/" + fileName + ".asset");
         
     }

     fileName = GUILayout.TextField(fileName);
 }```
#

I've tried it several similar ways and tried trouble shooting the path but uhhh... no luck

plush spade
#

Does anyone have information about GraphView api?

#

I'm trying to do something using the GraphView API, but I can't figure out that after using the SetPosition(Rect rect) method of a specific node, the position does not change instantly?

When I debug the position before and after this line, it is the same, but when I execute the next log schudule executeLater and put a 100 ms wait in between, it gets better, what exactly is the reason for this?

At the same time, when you use the SetPosition(Rect rect) method, nothing is reflected in OnGraphChange, so I can't use it there either.

I can't do the alignments because I can't change them instantly.

slender mantle
peak bloom
#

I've a very funky workaround but I can't recall what I did, proly try as said above 1st

#

I can peek my code later once I'm at home

plush spade
#

@peak bloom I would be very happy 🙏🏼 , I have been looking for a solution for days 😶‍🌫️

plush spade
#

@peak bloom I finally found a proper way i think when u create a node in general in init method we should use this RegisterCallback<GeometryChangedEvent>(OnGeometryChange);

After that private bool _scheduleForOrganize = false; field will responsible for triggering when u need use SetPosition(Rect) u need to change that bool value to true before the SetPosition(Rect rect).

After that in OnGeometryChange method will check i need to organize or not and if it is that will do the operation immediately and change true to false.

peak bloom
#

if that works for you, then 👍

alpine bolt
#

Where is this context menu added in the Unity code or how can I add to it instead of just overwrite by adding a manipulator?

#

It seems to me that this part of the Editor code hasn't been converted to UIElements yet

whole steppe
#

Is there anyone who knows about this error? I was trying to fix it but still I couldn't find any way to handle it

snow summit
#

Is there a way to get the original prefab in the asset folder from an instanced GameObject in a scene?

wild edge
lone halo
#

I can't instantiate objects from the PostProcessor as the AssetDatabase calls are limited. Loading the asset from disk gives me a null references. Is there a reliable way to queue a function to be called Post-PostProcessing?

#

I tried makignt his and adding my call to instantiate the asset to the queue, but the ExecuteQueuedActions() function never triggers

public static class PostprocessExecutionQueue
{
    private static readonly Queue<Action> executionQueue = new Queue<Action>();
    static PostprocessExecutionQueue()
    {
        EditorApplication.update += ExecuteQueuedActions;
    }    
        public static void EnqueueAction(Action action)
    {
        executionQueue.Enqueue(action);
    }    
        private static void ExecuteQueuedActions()
    {
        while (executionQueue.Count > 0)
        {
            executionQueue.Dequeue().Invoke();
        }
    }
}
gloomy chasm
lone halo
#

That seems to work but I don't think my idea is any good now. It's calling it once a second but never runs the function I put in the queue. Need to think of a different way to instantiate a gameobject during this process

elder wasp
#

How can I add a command buffer to the scene camera?

short tiger
# elder wasp How can I add a command buffer to the scene camera?

You can have multiple scene views open, so there can be multiple scene cameras, but to get a reference to them, you get the SceneViews with SceneView.sceneViews and their cameras with SceneView.camera. If you're fine with it only working in one scene view to simplify code, you can use SceneView.lastActiveSceneView.camera.

elder wasp
#

The problem is that documentation says that if i get that camera, all settings will be reseted before rendering

#

So i thought i would lose the command buffers set

short tiger
elder wasp
#

Okay I will give it a try

tulip epoch
#

Is there a way to modify unity's default package list for new projects? I have my own utility editor scripts that I want to use in every project

peak bloom
#

does custom PlayerLoop will get reset/cleared after domain reload while in playMode?

#

for context I have my own custom Updates in PlayerLoop subsystem

#

aight I can just check this myself 🤣

indigo condor
#

I need help, the next code it's supposted to save another boxhelp height on boxHelpHeight var, that works correctly, cause the log shows me the values changing... But when i try to apply the var's value to the right boxhelp it doesn't work... What could happen? The right boxhelp changes it's vertical size to a really small one and it doesn't do nothing with that code```csharp
boxHelpHeight = GUILayoutUtility.GetLastRect().height;
Debug.Log("BoxHelp Height: " + boxHelpHeight);

// RIGHT BOXHELP
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Height(boxHelpHeight), GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

GUILayout.Space(2);
GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
propertyAdditionMenu.Draw();
GUILayout.Space(15);
GUI.backgroundColor = Color.white;

EditorGUILayout.EndVertical();```

gloomy chasm
indigo condor
# gloomy chasm If you want them to be the same size you could do pass `GUILayout.ExapndHeight(t...

@gloomy chasm i've given that param to both boxhelp... but it does something strange...```csharp
// LEFT BOXHELP
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true));

        string elementName = jsonDataList[index].Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);


        DrawMultipleInstancesOptions();


        EditorGUILayout.EndVertical();


        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();```
gloomy chasm
indigo condor
#

hmm i want both boxhelps to have the same vertical size, but just adding spaces on the left one

#

Am I expressing well myself?

waxen sandal
#

Nope

indigo condor
# waxen sandal Nope

I want the BoxHelp on the right to resize vertically based on the BoxHelp on the right in real-time...

waxen sandal
#

Ah

#

You'll either have to put both in them in a parent containter that scales to the max height of the left one

#

Then have the right one fill the rest of the space

indigo condor
waxen sandal
#

Begin horizontal/vertical invis unless you give it a style

#

But IIRC it does have some padding by default

indigo condor
indigo condor
# waxen sandal Begin horizontal/vertical invis unless you give it a style

oh, i realise they are already on a horizontal container... ```csharp
EditorGUILayout.BeginHorizontal();
GUILayout.Space(10);

        // LEFT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        string elementName = jsonDataList[index].Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);


        DrawMultipleInstancesOptions();


        EditorGUILayout.EndVertical();


        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();

        GUILayout.Space(5);
        EditorGUILayout.EndHorizontal();```
peak bloom
#

when I'm tweening things while in playmode in the editor, change my script, domain reload kicks in, once done my tweening script is broken or nullref 100%
I tried couple of random libs and do the same, they didn't error
is there some sort of secret black magic they used or what?

waxen sandal
peak bloom
#

dayum, this thing is one massive monster to serialize

indigo condor
waxen sandal
#

If that doesn't work, you gotta figure out why there's that extra space 🤔

#

Or just use GetLastRect and GUILayout.Height to set the height of the right one to the same as the left

indigo condor
#

I'll try both

indigo condor
#

what does that error mean?

waxen sandal
#

That's not how flexible space works

indigo condor
# waxen sandal https://docs.unity3d.com/ScriptReference/GUILayout.FlexibleSpace.html look at th...

Flexible space doesn't work for me... ```csharp
EditorGUILayout.BeginHorizontal();
GUILayout.Space(10);

        // LEFT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        string elementName = jsonDataList[index].Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);


        DrawMultipleInstancesOptions();


        EditorGUILayout.EndVertical();

        GUILayout.FlexibleSpace();

        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();

        GUILayout.Space(5);
        EditorGUILayout.EndHorizontal();```
waxen sandal
#

You put it in the wrong place

#

Needs to be after you draw teh content of the right box before the end vertical

indigo condor
#

it's the same the other param hehe

#

why is it acting like that?

waxen sandal
#

It thinks it has extra space to consume for some reason

#

Hard to say why at this point

indigo condor
indigo condor
waxen sandal
#

You don't have ot position it manually by the way

#

Just pass Height with the output of GetLastRect().height

#

Or something like that

indigo condor
#

@waxen sandal could i save the heigh on a var and then just apply it to right boxhelp?

waxen sandal
#

Yeah

indigo condor
# waxen sandal Yeah

and how could i apply the var height into the right boxhelp? ```csharp
// RIGHT BOXHELP
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

GUILayout.Space(2);
GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
propertyAdditionMenu.Draw();
GUILayout.Space(15);
GUI.backgroundColor = Color.white;

EditorGUILayout.EndVertical();```

waxen sandal
#

The same as the width

#

Just use height instead

#

It's more of a hint but It'll probbaly work

indigo condor
# waxen sandal The same as the width

hmm it looks enormous...```csharp
boxHelpHeight = GUILayoutUtility.GetLastRect().height;
Debug.Log("BoxHelp Height: " + boxHelpHeight);

        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f), GUILayout.Height(EditorGUIUtility.currentViewWidth + boxHelpHeight));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();``` and as you can see the log works
waxen sandal
#

It's becuase you're adding currentViewWidth

#

No reason for that

indigo condor
waxen sandal
#

Yh

indigo condor
#
            boxHelpHeight = GUILayoutUtility.GetLastRect().height;
            Debug.Log("BoxHelp Height: " + boxHelpHeight);

            // RIGHT BOXHELP
            EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f), GUILayout.Height(boxHelpHeight));

            GUILayout.Space(2);
            GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
            propertyAdditionMenu.Draw();
            GUILayout.Space(15);
            GUI.backgroundColor = Color.white;```
indigo condor
waxen sandal
#

It's because the ui is drawn in multiple passes I forgot how to fix it though

#

Maybe you can just cache it on the class

#

And just never allow it to set it to 1

indigo condor
gloomy chasm
waxen sandal
gloomy chasm
#

@waxen sandal @indigo condor I think this should be it, no? Or do they end up expanding to fill all available space?

using (new GUILayout.VerticalScope())
{
    // The two upper boxes.
    using (new GUILayout.HorizontalScope())
    {
      // Left box.
      using (new GUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
      {
        // Content of left box here...
      }
      // Right box.
      using (new GUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
      {
        // Content of right box here...
      }
    }

    // Bottom box.
    using (new GUILayout.VerticalScope())
    {
      // Content of bottom box here.
    }
}
waxen sandal
#

That's what they had before no?

#

Which gets that extra space

indigo condor
indigo condor
#

i've tried to give a shape to the horizontal container, and i don't know why it gets expanded too

gloomy chasm
#

I don't remember how it works specifically, you could try setting ExpandHeight to false for the containing horizontal scope

indigo condor
# gloomy chasm I don't remember how it works specifically, you could try setting `ExpandHeight`...

nothing```csharp
EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
GUILayout.Space(10);

        // LEFT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        string elementName = jsonDataList[index].Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);


        DrawMultipleInstancesOptions();


        EditorGUILayout.EndVertical();

        float boxHelpHeight;

        boxHelpHeight = GUILayoutUtility.GetLastRect().height;
        Debug.Log("BoxHelp Height: " + boxHelpHeight);

        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f), GUILayout.ExpandHeight(true));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();

        GUILayout.Space(5);
        EditorGUILayout.EndHorizontal();```
gloomy chasm
#

Yeah figured as much, worth a try though

indigo condor
#

If you both can't help me with this, I'll throw in the towel :>

#

so... @waxen sandal and @gloomy chasm any more ideas?

gloomy chasm
#

Not sure the project requirements, but could try just manually setting the height/max height?

#

Another option, the EditorGUILayout version of the vertical/horizontal methods return rects. Which I think are always sized properly... could use the one returned from the left as the height fro the right.

indigo condor
# gloomy chasm Another option, the EditorGUILayout version of the vertical/horizontal methods r...

i've also tried that...```csharp
boxHelpHeight = GUILayoutUtility.GetLastRect().height;
Debug.Log("BoxHelp Height: " + boxHelpHeight);

        // RIGHT BOXHELP
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f), GUILayout.Height(boxHelpHeight));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;``` but that happens
indigo condor
gloomy chasm
peak bloom
#

is Unity editor capping the fps while in edit mode (NOT playmode)?
is there editor api to check or change this?

visual stag
peak bloom
#

the whole editor in general

#

including inspector etc

visual stag
#

It doesn't update at an FPS or anything, this is only when interacting or if a view is set to always repaint

#

If you turn throttling off you can open yourself up to angry GPUs and input issues

peak bloom
#

oh I see... never knew we can check it from there, thanks Verts! 👍

#

well noted

still pecan
#

I am making a dialogue editor in unity using the GraphView

i currently have the this...

#

my problem is that the output port is cutoff /hidden, and i have no clue where or how to fix it. if anyone has any idea

waxen sandal
#

Maybe your input fields are too big?

#

Try making them smaller

still pecan
#

damn

#

thanks. all i did was added maxWidht to 50.... and then slowly tested and tried going to 100.. and it works

waxen sandal
#

I'm guessing you can also just make the node bigger

#

But not sure how to do that (Since I don't know grpah view)

still pecan
waxen sandal
#

If that didn't work then I guess the content is not scaling properly to the size of the node

alpine bolt
#
Assertion failed on expression: 'IsInSyncWithParentSerializedObject()'
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)```I'm finding that this line `_arrayProperty.InsertArrayElementAtIndex(i);` is throwing this error
I found this https://forum.unity.com/threads/error-when-changing-array-property-with-custom-property-drawer.1465607/ that basically describes almost the same thing I'm experiencing
dusky plover
#

I'm having some really weird issue with Undo.RecordObject, and I think I'm forgetting something obvious, could someone give another pair of eyes please?

I have this class:

[Serializable]
public class MapScreenshotSegmentPreset : ScriptableObject, ISerializationCallbackReceiver
{
[SerializeField]
private List<string> m_segmentKeys = new List<string>();

public int AddNewSegment()
{
    m_segmentKeys.Add("New Segment");
    return m_segmentKeys.Count - 1;
}

}

And in its custom inspector I have a button that does this:

        Undo.RecordObject(target, "Added New Segment");

        m_currentSegmentIndex = presetAsset.AddNewSegment();

        EditorUtility.SetDirty(presetAsset);

(presetAsset is the casted target object).

If I breakpoint after AddNewSegment, I see that the element was added to the list, but the next time that OnInspectorGUI() happens, the list is back to being empty.
What could possibly be resetting the state of the object between inspector draw ticks?

waxen sandal
#

Why not just use serializedobject?

dusky plover
#

Since I have other methods that modify the list, including inserts and indexed removal, and working with collections as serialized properties is a pain ><

#

I will if I have to, but RecordObject should work for a case like this, so I don't know.

#

Wait, nevermind, I'm just dumb. I was overriding this collection in the serialization callbacks.

plush sigil
#

I made a custom type that can hold two variables and they’ll be displayed side by side in the inspector however i want the two fields to be positioned based on the label, and i want the labels position to be calculated so that no matter how big it is it doesn’t extend past the edge of the container it’s in

vapid prism
#

Is there any built-in reference to a certain folder in Assets/? Similar to how you can reference an object

plush sigil
#

what

#

and that’ll work?

alpine bolt
plush sigil
#

i appreciate you wasting your time to help me

#

i didn’t think it would be this complicated just get the size of the container the variable is in, get the size of the label, and then just calculate the position to make sure the label doesn’t go past the edge, everything in coding is harder then it seems

#

i tried getting chatgpt to do it but it didn’t work very well

alpine bolt
#

Like everything, practice makes us better. UIElements has many caviats and workarounds.

plush sigil
#

i want everything to be dynamic

alpine bolt
plush sigil
#

ok thank you

plush sigil
#

one more thing i’ll need to do findpropertyrelative to get the list variable, is there a way to dynamically get that variable

alpine bolt
# plush sigil one more thing i’ll need to do findpropertyrelative to get the list variable, is...

Using the iterator functions to run through each property. In the following example, I have a custom PropertyDrawer for all my objects, that is loading the serialized properties inside my object (in this case, a property drawer).

        public void BindProperty(SerializedProperty property)
        {
            var target = property.GetTargetObjectOfProperty();
            var displayName = property.displayName;
            
            var iterates = property.NextVisible(true); // Moves to the next property. TRUE to enter the original property's properties.
            if (!iterates)
            {
                AddToClassList("display-none");
                return;
            }
            
            var container = new Foldout()
            {
                text = displayName,
            };
            Add(container);
            
            var type = target.GetType();
            var fieldInfosDict = Get_NameXFieldInfos_Dictionary(type);

            HandlePropertyField(ref property, fieldInfosDict, target, type, container, InspectorType);
            
            while (property.NextVisible(false)) // Moves to the next property. FALSE to stay at the same property level/depth
            {
                HandlePropertyField(ref property, fieldInfosDict, target, type, container, InspectorType);
            }
        }
```The original property is the target of the PropertyDrawer. `property.NextVisible(true);` is the first visible property that lives in the original property's object. At this point I still don't know what kind of property it is.
plush sigil
#

ok thank you

gloomy chasm
#

In UITK is there a good way to make a ScrollView 'reversed'? Basically I have a ScrollView and I add items to it over time, and sometimes change size. I want the scroll to default to be at the bottom and show the items. Like Discord type of scrolling I guess.

#

Sorry, having a hard time articulating it.

safe sorrel
#

ScriptableSingleton is not reading data back from the file it's writing.

#
[FilePath("ProjectSettings/Pursuit/GameConfig.yaml", FilePathAttribute.Location.ProjectFolder)]
public class GameConfig : ScriptableSingleton<GameConfig>
{
    [SerializeField] private GameMode mode;
    [SerializeField] private int x = 3;
    public GameMode Mode
    {
        get => mode;
        set
        {
            if (value != mode)
            {
                x = 10;
                mode = value;
                Save(true);
            }
        }
    }

    [InitializeOnEnterPlayMode]
    static void Setup()
    {
        Debug.Log("x: " + instance.x);
        Debug.Log("Mode: " + instance.Mode);
        GameController.editorGameMode = GameConfig.instance.Mode;
    }
}

It isn't remembering the game mode I picked. I stuck the x field in to see if it would read values from the YAML file it writes at all.

The GameConfig.yaml file includes a line storing a value of 10 for x, but when I restart the editor and print out the value, it's a 3 again.

#

My understanding is that, when you access the instance property of a ScriptableSingleton for the first time, Unity will read the serialized data from disk and apply it to the instance it creates

#

And it is indeed correctly writing that data..

#

oh, hm: when I enter play mode, that DOES log x: 10

#

...and now it isn't. wat.

#

oh, right, because I forgot about that x = 10 near the middle. whoops. false alarm.

#

I implemented ISerializationCallbackReceiver to see when deserialization is happening. I only see this happen after I recompile, and it's cleraly not reading anything from the yaml file

#

very confused.

safe sorrel
#

when I modify the value, then quit and reload, the value persists

safe sorrel
#

okay, this is really baffling. I pasted the example code from there into my GameConfig class and it's still misbehaving

#

Oh. I'm a dummy.

#

I didn't define it in its own file

#

That's got to be it.

#

Yep. That was the issue.

plush sigil
# alpine bolt Using the iterator functions to run through each property. In the following exam...

Its saying serializedobject does not contain a definition for GetTargetObjectOfProperty and chatgpt gave me this ```public void BindProperty(SerializedProperty property)
{
var serializedObject = property.serializedObject;
var target = serializedObject.targetObject;
var displayName = property.displayName;

var iterates = property.NextVisible(true);
if (!iterates)
{
    AddToClassList("display-none");
    return;
}

var container = new Foldout()
{
    text = displayName,
};
Add(container);

var type = target.GetType();
var fieldInfosDict = Get_NameXFieldInfos_Dictionary(type);

HandlePropertyField(ref property, fieldInfosDict, target, type, container, InspectorType);

while (property.NextVisible(false))
{
    HandlePropertyField(ref property, fieldInfosDict, target, type, container, InspectorType);
}

}

#

AddToClassList doesnt exist Add doesnt exist Get_NameXFieldInfos_Dictionary doesnt exist HandlePropertyField doesnt exist and InspectorType doesnt exist

safe sorrel
#

that's because ChatGPT made everything up

#

oh, that's not what ChatGPT spat out; that's a modification of the original code taunting sent

#

taunting's code is using methods they defined elsewhere, presumably. this is just an example of what the code will look like

safe sorrel
alpine bolt
plush sigil
#

ah

plush sigil
#

and how could i get the size of a field, i want to get the size of a field in my editor script so i can position it properly relative to the label

#

i tried doing property.findpropertyrelative(“variable1”).bounds etc but that kept returning 0

alpine bolt
plush sigil
#

no i haven’t i’ll try it

plush sigil
alpine bolt
plush sigil
#

unity has made it so hard to make a dynamic editor script

plush sigil
#

chatgpt has been of no help i’ve tried numerous different ways to get the field in the class i have the class being derived from PropertyDrawer looking at and none of it has worked

visual stag
#

Can you describe what you're trying to do in simple terms without mentioning ChatGPT or showing bullshit it's made up?

plush sigil
#

i have a type that can hold 2 variables and i have it so the 2 variables show up side by side in the inspector, i want the fields and label positioned correctly so that if you make the label long it won’t go off the edge of the container it’s in, for example if you have it in a list, or even just sitting in the inspector

gloomy chasm
plush sigil
#

i am yea

gloomy chasm
#

You using IMGUI or UIToolkit?

plush sigil
#

i’mgui

gloomy chasm
#

Then just use the returned rect for placing your two fields (the returned rect is the area to the right of the label, where you would expect to see a field)

plush sigil
#

ok bet how could i dynamically get the size of a field

gloomy chasm
#

What do you mean?

plush sigil
#

like the width of a field

#

so i can make sure the field doesn’t overlap the label

gloomy chasm
# plush sigil so i can make sure the field doesn’t overlap the label
Rect fieldRect = EditorGUI.PrefixLabel(rect, new GUIContent("My Two Fields"));

// Divide rect in two...
Rect leftHalf = new Rect()
{
  x = fieldRect.x,
  y = fieldRect.y,
  width = fieldRect.width / 2
  height = fieldRect.height
}

Rect rightHalf = new Rect()
{
  x = leftHalf.xMax,
  y = leftHalf.y,
  width = leftHalf.width
  height = leftHalf.height
}

// Whatever you want your two fields to be
EditorGUI.IntField(leftHalf, 5);
EditorGUI.IntField(rightHalf, 5);
plush sigil
#

well shit

#

one more thing i have CustomPropertyDrawer to tell the script what class to look at

#

is there a way to dynamically get each variable from that class without having to use the variables name manually

gloomy chasm
#

You can iterate over the serialized property

plush sigil
#

would you mind showing me how to do that

plush sigil
#

thank you

gloomy chasm
#

Let me know if you have more questions after reading that 🙂

plush sigil
#

will do thank you

plush sigil
#

I have this

public class MultiList : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        EditorGUILayout.BeginHorizontal();

        GUILayout.Space(EditorGUIUtility.singleLineHeight);
        GUILayout.FlexibleSpace();

        //GUILayout.Label("adwa");

        var enumerator = property.GetEnumerator();
        while (enumerator.MoveNext())
        {
            var prop = enumerator.Current as SerializedProperty;
            if (prop == null) continue;
            //Add your treatment to the current child property...
            EditorGUILayout.PropertyField(prop, GUILayout.Width(150));
        }
        EditorGUILayout.EndHorizontal();
        EditorGUI.EndProperty();
    }
}```

It is putting the name of the variable next to each field as a label, is there a way to remove that using this method or will I have to use a different method
gloomy chasm
#

First thing at least, you can't use GUILayout methods inside of a PropertyDrawer

plush sigil
#

oh

#

it seemed to be working

#

ig maybe it works it just doesnt work as its supposed to

gloomy chasm
#

Well, if things break, you know why

#

PropertyField has a overload which takes a GUIContent, just pass a empty one to it to hide the labels

plush sigil
#

ohhh

#

where

gloomy chasm
#

One of those (+ 3 overloads) 😉

plush sigil
#

Ive tried doing EditorGUILayout.PropertyField(prop, null, GUILayout.MinWidth(100)); and its saying theres a ambigous reference

gloomy chasm
#

No, not null, empty, like GUIContent.none or new GUIContent()

plush sigil
#

ohhh

#

ok

gloomy chasm
#

And a ambiguous reference means that multiple overloads match the signature you provided, in this case Rect, null, GUILayoutOption

grand flame
#

Hey all, so I found a custom editor script which I adapted for my item system.

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(GoodsObject))]
public class GoodsEditor : Editor
{
    GoodsObject ItemBase;

    private void OnEnable()
    {
        ItemBase = target as GoodsObject;
    }

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        if (ItemBase.item.DisplaySprite == null)
            return;

        Texture2D texture = AssetPreview.GetAssetPreview(ItemBase.item.DisplaySprite);
        GUILayout.Label("", GUILayout.Height(80), GUILayout.Width(80));
        GUI.DrawTexture(GUILayoutUtility.GetLastRect(), texture);
    }
}

it displays an image of the sprite asigned to the item in the inspector.
and it worked great, but I have since re-done how I will do items and now I have an array of items rather than a single item per scriptable object, and i can't figure out how to get an item to display on each element in the array.

Does anyone know how to do this?

alpine bolt
#

The way you expose singular items' content that are represented in a array/list fashion is by creating a PropertyDrawer for that type.

slow moon
#

Hi!, I'm not sure to which channel should it be posted because it's not ready plugin yet. I post it to check what people think about that idea, if it will be helpful etc. I know there is a lot of tween plugins, but decided to develop my own tween plugin which will give possibility to animate whatever you want (with inspector editor, coding also available) and not depend on functionality provided by plugin. In my plugin user can animate whatever property or public field component provides, it's enough to put just object you want to animate and it will find every property and public field in every component of this object, so it gives even possibility to animate properties and fields from you custom scripts. What you think about this plugin, is here someone who would like to have such tool? Should it be paid plugin (minimum amount on asset store) or free plugin with possibility to donate. Let me know (I know there is a lot of messages so feedback with thumb up or down is enough)

grand flame
plush sigil
#

I have this ```#if UNITY_EDITOR

using NUnit.Framework;
using System;
using System.Collections.Generic;
using Tools;
using UnityEditor;
using UnityEngine;
using static Tools.TwoVariables;

[CustomPropertyDrawer(typeof(TwoVariablesA<,>))]
public class MultiList : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
EditorGUILayout.BeginHorizontal();

    GUILayout.Space(EditorGUIUtility.currentViewWidth * 0.2f);
    //GUILayout.FlexibleSpace();

    GUILayout.Label("adwa         ");

    var enumerator = property.GetEnumerator();
    while (enumerator.MoveNext())
    {
        var prop = enumerator.Current as SerializedProperty;
      
        if (prop == null) continue;
        //Add your treatment to the current child property...
        Debug.Log(prop.arrayElementType);
        EditorGUILayout.PropertyField(prop, GUIContent.none);
    }
    Debug.Log("MultiTypeList Working");
    Debug.Log(property.name + " ");
    //IndirectlyAccessScript.GetVariable(TwoVariables.TwoVariablesA<varTypeList[0]., varTypeList[1]>);

    EditorGUILayout.EndHorizontal();
    EditorGUI.EndProperty();
}

}

#endif

prop represents a variable within the class that property represents, how can I get the type of that variable properly
plush sigil
#

I got it

gloomy chasm
potent turret
#

Hello. I have a problem. When assembling bundles in Addressable, the RAM overflows and the assembly is not assembled. How can this be fixed? In one place I read: "I solved that by creating binary files containing all label data for each tile and added the binary file as TextAsset to the prefab, reducing the file size of all prefabs to 280 MB. So the build process worked again.". But I don't know how to do this. Please, Help me.

agile flicker
#

Hey, does anybody which UI Toolkit element to use to achieve accordeon dropdowns like this one?

visual stag
agile flicker
agile flicker
#

Whoops, thanks

#

I have another silly question, is there a way to reuse styles that unity applies to default property labels and fields?
The problem is I have a custom field with custom styling to fit in with default ones, but it just mismatches on certain widths

agile flicker
#

Lmao, amazing website name, thanks

visual stag
sly lily
#

Does anyone know if the Git project for AutoLOD is broken? I get errors when I try to add the package via Git URL.

#
GitHub

Automatic LOD generation + scene optimization. Contribute to Unity-Technologies/AutoLOD development by creating an account on GitHub.

GitHub

Automatic LOD generation + scene optimization. Contribute to Unity-Technologies/AutoLOD development by creating an account on GitHub.

sly lily
pine anvil
#

hi!

#

I'm working on a addon and i got a issue

#

each of these are a BeginVertical/EndVertical container

#

but i also want to be able to click on them, and have them themselves be buttons

#

so that i can select specific ones and have my editor do stuff with it

#

similar to the UnityEvent ui, where it contains fields but also is selectable

#

how can i do this? is there a way to detect a click on a BeginVertical area?

#

turns out this is literally what EditorGUILayout.button does

#

no fucking way so cool

#

take notes kids

meager juniper
#

how would I fix this? My UI is very small and blurry, no option to scale it in the editor as well

#

it's mostly the blur

#

OS: Ubuntu Linux 22.04.03

gloomy chasm
# pine anvil turns out this is literally what EditorGUILayout.button does

You can also do it 'manually`

Rect r = EditorGUILayout.BeginVertical();

// We get if the mouse is inside of our vertical area to know if we should care about any events. And if it is, we check if the event is a mouse down event. Aka. if the vertical area was clicked.
if (r.Contains(Event.curent.mousePosition) && 
Event.current.type is EventType.MouseDown)
{
    // Do something when the mouse is clicked...

    Event.current.Use(); // Tell Unity we did something with this event so that other controls don't also use it.
}
EditorGUILayout.EndVertical
trim spoke
#

Hey guys, what is the current "best" way to share a project with a friend for free?

trim spoke
surreal delta
#

if you want in editor version control, check out unity version control, previously known as plasticSCM

trim spoke
#

Thanks! I´ll look unto that!

trim spoke
surreal delta
#

its free if you only use 2 or 3 seats i think

pine anvil
#

does anyone know what the GUIStyle for these buttons is?

surreal delta
pine anvil
surreal delta
#

looks right to me

pine anvil
#

oh wait it

#

OH YEAH no that is it that is correct

#

im confused tho the buttons go all the way down

surreal delta
#

could be just a rect

pine anvil
#

truu

pine anvil
#

like one that fills up the rest of the space vertically

gloomy chasm
surreal delta
#

position it on the center of the window then set the height to the window height

pine anvil
surreal delta
gloomy chasm
pine anvil
gloomy chasm
#

I mean Analysus, my bad

pine anvil
#

ah

pine anvil
#

get the window height

#

and wouldnt the window height make it exceed the height of the actual window, because there's other elements?

gloomy chasm
#

it all depends on how you are drawing

pine anvil
#

im using OnGUI

gloomy chasm
#

The easiest way is if you use GUILayout and EditorGUILayout

#

Those have automatic layout, or you can use GUI and EditorGUI and position UI manually using rects

#

But if it is just if you use GUILayout, you can do like GUILayout.Button("My Button", GUILayout.ExpandHeight(true)) to have a button that expands to fill all vertical space 🙂

pine anvil
#

hm okay right

#

yeah thats what im doing actually

#
GUILayout.BeginVertical(GUILayout.Width(200f));
        if (GUILayout.Button("Change Log", "SettingsListItem"))
            currentPage = SplashScreenPages.ChangeLog;

        if (GUILayout.Button("Settings", "SettingsListItem"))
            currentPage = SplashScreenPages.Settings;

        GUILayout.Label(GUIContent.none, EditorStyles.toolbarButton, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
        GUILayout.EndVertical();
surreal delta
#

why are you using a label?

pine anvil
#

idk i mean what else was i supposed to use

surreal delta
#

a rect

pine anvil
#

what rect would i use?

surreal delta
#

GUILayout.DrawRect or GUI.DrawRect

pine anvil
#

well yeah but

#

i need a rect for it to draw

#

like i have to give it a rect as a argument

surreal delta
#

or EditorGUI or EditorGUILayout

surreal delta
#

create one

pine anvil
#

so where would i get that

surreal delta
#

new Rect(x, y, w, h)

pine anvil
#

how would i create a rect that fills the rest of the space

surreal delta
#

set the rect height to the height of the window

#

rect y to the center of the window

pine anvil
#

id also need the rects start point, so i can subtract it from the height of the window so it doesnt go over and cause a scrollwheel or anything

gloomy chasm
#

And saves you the hassle of having to reserve the layout rect and check the event type

surreal delta
#

ok, didnt know that

gloomy chasm
#

The BeginVertical/Horizontal also take a style so you can do it that way too

surreal delta
gloomy chasm
#

Yeah, it all depends on what you need

pine anvil
#

the rest of the vertical space filling

#

but expandheight doesn't seem to want to do that

#

another thing i noticed:

pine anvil
# pine anvil

the change log and settings button uses the same class as the buttons in the project settings, but the project settings ones go blue when one is selected

#

how do i do that?

surreal delta
#

they could be changing a default style

surreal delta
#

or use UI builder

pine anvil
#

hm okay

#

no issue

#

i just need the vertical space filling up

pine anvil
#

neat

tough cairn
#

is there a utility to draw a tree structure like this ?

pine anvil
gloomy chasm
#

(Both IMGUI and UIToolkit has one)

tough cairn
#

awesome , thanks mech

gloomy chasm
#

Suuure thing!

pine anvil
#

treeviews annoy the hell out of me

peak bloom
#

treeview in uitoolkit is just terrible yeah. just make your own

#

I see that we can use UnityEngine.Splines namespace, isn't Splines is a separate package in unity?

gloomy chasm
peak bloom
#

@gloomy chasm while youre here, does Unity's ANimationCurve has a default easing function presets other than Linear we can use?
e.g: QuadInOut, ElasticInOut, etc

#

making this one by one sounds like a pain in the buttocks

gloomy chasm
#

nope

peak bloom
#

dang it notlikethis

#

I really think the ANimationCurve should have these as the default

#

but nope...

alpine bolt
peak bloom
#

yeah you can use Animation.EaseInOut() api for that, it's in their doc. meanwhile easing functions are like the defacto in ui animation which I really think should've been available as default presets

#

btw that Animation.EaseInOut api, you'd need to port it manually by hand and test them out

#

won't be as pretty. like hella pain

gloomy chasm
#

I would take a look on github or something. I am sure someone has done it before. I remember seeing it I think

peak bloom
#

but see how tons of things there are hard coded.

#

magical values

#

dayum I sounded like a karen ngl 😂..

short tiger
peak bloom
#

either way I should not mad about this really 😂

gloomy chasm
peak bloom
forest jasper
#

I am trying to create a custom PropertyDrawer for an Attribute using UI Elements.
How do I copy Unity's default label width?

What I've tried doing is comparing my own Label's style to that of a "vanilla" ObjectField's Label using the UI Toolkit Debugger
But I can't seem to figure out the logic of its width. It's not a set px amount, but it's not a set percentage either.
It's roughly 40% with a minimum of 120px, but depending on the horizontal sizing of the Inspector it can be noticeably different.

I know I could probably find that inside of .unity-label or .unity-base-field__label but I'm not sure how to access it.
Does anyone more knowledgeable on the subject have some pointers on how to proceed?

gloomy chasm
#

I think it is unity-base-field__aligned-label or something like that. You can check the classes in the UIToolkit debugger and find it

alpine bolt
#

Pretty close

lofty rain
#

anybody knows how do I set this from script?

#

I was looking in the EditorUserBuildSettings class

#

but didn't find anything meaningful except for this

#

but then I have no idea on what to type

waxen sandal
#

It's CodeOptimization

#
          case "disksize":
            return WasmCodeOptimization.DiskSize;
          case "speed":
          case "runtimespeed":
            return WasmCodeOptimization.RuntimeSpeed;
          default:
            return WasmCodeOptimization.BuildTimes;```
Are the options
lofty rain
#

but I can't find this setting

#

I found this enum, yeah

#

now I only need to know where to set it

waxen sandal
#

It's the name of the property

#

set => EditorUserBuildSettings.SetPlatformSettings(BuildPipeline.GetBuildTargetName((BuildTarget) 20), "CodeOptimization", value.ToString()); you use it like this

lofty rain
#

ok

#

let me see

waxen sandal
#

Or use UnityEditor.WebGL.UserBuildSettings.codeOptimization

#

Guess that works as well

lofty rain
#

yeah, that's much better

#

thank you

#

I want to have menu items to change a set of configs when switching from test to production

#

the build times can take too long

gloomy chasm
#

In UIToolkit is there a good way to have a PropertyField (or similar) that only draws the sub-properties of a property and not the foldout header?

waxen sandal
#

Probably not except adding propertyfields manually for each direct child

gloomy chasm
#

Dang, I need it for drawing a ManagedReference inside of a list view

#

wonder if I can add them in bindItem and remove them in unbindItem...

turbid junco
#

Hi guys, I have a question about the proxy system
How to disable the use of Unity editor proxy

waxen sandal
#

what?

turbid junco
#

Con't Play With this Vpn
Now I want to use vpn, but it doesn't affect the editor. It can be done in other places so that it doesn't use it.

#

For example, it is possible to do this in IDM so that it does not use a proxy. I could not find this option in Unity. Is there a solution for this?

#

@static idol میتونی راهنماییم بکنی : )

waxen sandal
#

Don't ping admins please

#

This is probably related to Remote Config right?

turbid junco
waxen sandal
#

This channel is more for creation your own editor extensions

#

(so we don't know about UGS)

alpine bolt
#

is there any way to know if unity is currently building the library?

peak bloom
#

you mean assembly reloading or something else?

alpine bolt
#

Well, when the AssetDatabase is being rebuilt (because Library folder was deleted, or whatever the case may be) I have UITK stuff trying to load UXMLs and USSs into my Custom VisualElements. Understandably some errors occur. I wonder how could I beat the errors

pale cliff
#

i have a GeneratorController with a list of Generators, I am trying to make an clean editor inspector for it.

My GeneratorControllerEditor XUML has a ListView for the generators property
My GeneratorDrawer has a PropertyField for the _IsGenerated boolean

Ive been able to successfully bind the buttons in the UI to the objects functions
My issue is the PropertyField binding just is not working
The 3rd picture shows the relevant part of code trying to listen to the value change, but this doesnt work

i tried a more minimal case with a single serialized int "counter" and an IntField bound to this but this doesnt update in the propertyfield either

#

eg this is what it looks like in the editor, and the UI debugger shows it is bound to the correct variable

#

the generator class is a super minimal abstract thing, all the generators in the list including in the example inherit from

[Serializable]
public abstract class Generator : MonoBehaviour
{
    public virtual string Name => "N/A";
    public virtual bool IsComposite => false;
    public virtual Generator[] ComposedGenerators => new Generator[0];
    public bool IsGenerated { get => _IsGenerated; set => _IsGenerated = value; }

    public abstract void Generate();

    public abstract void Clear();

    public bool ContainsGenerator(Generator generator)
    {
        return IsComposite && (ComposedGenerators.Contains(generator) || ComposedGenerators.Any(cg => cg.ContainsGenerator(generator)));
    }

    [SerializeField] public bool _IsGenerated = false;
}

the manual backing field of _IsGenerated was just the first attempt to get it to work, I assumed it didnt work with an automatic IsGenerated { get; set; }

#

i realize thats alot of info but i thought id just throw it all in as usually with stuff like this its a single key issue buried deep down and it takes forever to find

#

i appreciate any help anyone gives

visual stag
pale cliff
#

this still gives nothing

#

i can visually see the serialized bool in the inspector in the other script component changing

#

because even the simple int field binding didnt work i feel its something deeper thats just not supposed to work with my setup somehow, perhaps because its a list of the abstract base class Generators? or because its a serialized bool inside a property field inside a custom editor?

peak bloom
#

is there alternatives to AssemblyReloadEvents.beforeAssemblyReload that will be executed much much earlier than that?

peak bloom
#

basically before AssemblyReloadEvents.beforeAssemblyReload gets executed

waxen sandal
#

But what's the use case

peak bloom
#

basically we have a multithreaded editor tool that would tidy up things before/after asm reload event. this would work unreliably somehow and would throw cant do something during serializing..

#

throught we could do things before asm.beforeasmreload callback kicks and lock those threads

peak bloom
boreal crystal
#

PrefabUtility.GetObjectOverrides only works for prefab instances. What is the preferred way to check for overrides on prefab variant assets? Do i have to open the prefab in stage and check the instance, and then iteratively open base prefabs to check again?
Edit: i guess it's 'PrefabUtility.GetPropertyModifications' ? So for instances those are 'overrides' and for prefabs they are 'modifications' ?

peak bloom
#

Thanks, Navi! 👍

waxen sandal
#

No idea if it works if you call it in beforeAssemblyReload but worth a try at least

peak bloom
#

will do, appreciated the help!

peak bloom
#

thought that by doing this

myUnityEvent.AddListener(new UnityAction(MySystemActionDelegate));

Will make it survive assembly reload, but nope

#

how can I do this without using persistentListener

#

is there a way?

waxen sandal
#

There's UnityEventTools iirc

#

That lets you add a persistent listener

waxen sandal
#

I mean non persistent listeners don't persist..

peak bloom
#

yeah, we used to abuse BF to roundtrip that, but sadly they deprecated it and we need to update our apis

waxen sandal
#

BF?

peak bloom
#

BinaryFormatter

waxen sandal
#

Ah

#

Just json srialize it?

peak bloom
# waxen sandal Just json srialize it?
  SomeClass something = SomeClass();
  something.FuncA<T>= someMethod();

        BinaryFormatter formatter = new BinaryFormatter();
        using (var stream = new FileStream("blob.bin", FileMode.Create, FileAccess.Write, FileShare.None))
        {
            formatter.Serialize(stream, something);
        }
        
      //pseudo code here, too long
      var des = (SomeClass)formatter.Deserialize(stream);
      Debug.Log(des.FunA()); //this will work
#

no wonder they deprecated it.. Imagine a dumbo coder would do that to a pointer

waxen sandal
#

There's a giant list of vulnerabilities with BF somewhere

tough cairn
#

how do i add a button here ?

sinful mountain
#

Im having an insane ms peak here 4500ms+ and its cuz of loading.lockpersistentmanager , does anyone know what this is exactly and how to optimize it

agile flicker
#

Hey, does anybody know the nature the error in the image? I'm trying to create a game object, save it as prefab and assign it to the serialized property when the button is clicked.
I'm using reflections because this is an attribute property and I don't know the type of the component on compile time. It successfully creates the object and adds the needed component to it.
Tho it seems that the lines

data.Property.objectReferenceValue = savedPrefab;
data.Property.serializedObject.ApplyModifiedProperties();

produce an error. It seems to be non-blocking, but trying to figure out why it's happening in the first place.

This specific code is fired on "Create" button press

      GameObject gameObject = new();
      var gameObjectMethods = gameObject.GetType().GetMethods();
      var addComponentMethod = gameObjectMethods.ToList().Find(method =>
        method.Name == "AddComponent" && method.GetParameters().Length == 0 && method.IsGenericMethod
      );
      var methodWithBindedGeneric = addComponentMethod?.MakeGenericMethod(fieldTypeOptions[typeSelect.index]);
      methodWithBindedGeneric?.Invoke(gameObject, null);
      
      var path = $"{CustomInspectorsHelper.GetCurrentProjectFolderPath()}/{fileNameField.value}.prefab";
      var index = 0;
      while (File.Exists(path))
      {
        index += 1;
        path = $"{CustomInspectorsHelper.GetCurrentProjectFolderPath()}/{fileNameField.value}{index}.prefab";
      }
      
      var savedPrefab = PrefabUtility.SaveAsPrefabAsset(gameObject, path);
      data.Property.objectReferenceValue = savedPrefab;
      data.Property.serializedObject.ApplyModifiedProperties();
agile flicker
#

(The error happens when you press on the button to be more clear)

agile flicker
#

Figured out that you can actually pass type as a parameter to AddComponent function. Deprecated the reflection, the bug is still happening

agile flicker
#

Seems like the bug is related to how the object is actually created, since if I omit the lines that modify the serialized property and then manually drag and drop newly created object I still get that error. **BUT ** if I firstly double click on the new prefab so that it opens up in an isolated scene and THEN drag and drop it I receive no error. Tried tinkering with AssetDatabase and PrefabUtility more but to no avail, still getting the error
Also here is somewhat cleaned up code from above:

      var componentType = fieldTypeOptions[typeSelect.index];
      var path = AssetDatabase.GenerateUniqueAssetPath(
        $"{CustomInspectorsHelper.GetCurrentProjectFolderPath()}/{fileNameField.value}.prefab");

      GameObject gameObject = new();
      gameObject.AddComponent(componentType);
      var savedPrefab = PrefabUtility.SaveAsPrefabAsset(gameObject, path);
      Object.DestroyImmediate(gameObject);

      data.Property.objectReferenceValue = savedPrefab;
      data.Property.serializedObject.ApplyModifiedProperties();
glad cliff
#

Im having a fatal crash of the editor each time a specific property is having its stringValue set. According to the logs it is from unity native code, so I dont know if I can do anything about it? Is it some sort of known issue or something?

=================================================================
    Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at UnityEditor.SerializedProperty:SetStringValueInternal <0x0009b>
      at UnityEditor.SerializedProperty:set_stringValue <0x000ea>
      at <>c__DisplayClass0_0:<CreatePropertyGUI>b__7 <0x00122>
...some more stack trace but of my own code
#

apparently updating editor from 2022.3.10 to 2022.3.17 fixed the problem but im still curious of the issue 🤔

waxen sandal
#

Probably just some bug in the implementation somewhere

#

you might be able to find into in the changelogs

pine anvil
#

I've got a question

#
  • 1: Can unity build a project, but with a single scene
  • 2: Can you trigger unity to build the project from c# code
visual stag
#

RectTransform doesn't hide the Transform, it completely replaces it—as it's a Transform itself

#

(which is why you can do (RectTransform)transform instead of GetComponent<RectTransform>)

gloomy chasm
#

Can add [ExecuteAlways] to your component, and hide the transform from Awake I think

pseudo mauve
visual stag
#

Are the hideflags actually directly related to your object drawing weirdly?

pseudo mauve
#

The CustomEditor is for my custom component, I should have mentioned

visual stag
#

Because if hiding another object is causing yours to draw strangely that seems like a bug

#

Make sure there's no errors/warnings in the console when you see the issue

pseudo mauve
pseudo mauve
gloomy chasm
#

Btw, the issue is that when you click off the inspector the editors for all the components are destroyed. And if a component is collapsed, the editor for it is not created.

pseudo mauve
gloomy chasm
visual stag
gloomy chasm
visual stag
#

It seems like an obscure bug to me that'd probably just get marked as wontfix 😄

#

(die IMGUI die)

hearty pasture
#

New to Unity and trying to setup the Unity extensions in VSCode (Unity & Unity Code Snippets). I've got .NET installed and restarted but now I'm getting this output

2024-01-26 19:04:44.266 [error] (Z:\Unity\Projects\Floppy Birb\Assembly-CSharp.csproj): SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath)
   at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable`1& errors, IEnumerable`1& warnings)""
2024-01-26 19:04:44.318 [error] Failed to load project 'Z:\Unity\Projects\Floppy Birb\Assembly-CSharp.csproj'. One or more errors occurred. (SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath)
   at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable`1& errors, IEnumerable`1& warnings)""  Z:\Unity\Projects\Floppy Birb\Assembly-CSharp.csproj)
2024-01-26 19:04:44.321 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.

Sorry if this is the wrong channel to post this in

glad pivot
#

how should i draw a layermask in a editorwindow? i would assume the best would be a serialized property but does windows even have access to that? since i cant really figure it out

waxen sandal
#

You can make a SerializedObject out of whatever you want

agile flicker
# agile flicker Seems like the bug is related to how the object is actually created, since if I ...

Didn't fully resolve this yet, but it seems like the error is tied to specific prefab variants in the project, because you can reproduce the error manually by creating and inserting a new prefab into them. Codex is working fine. Gotta figure out why specifci prefabs break and how to mitigate that (there is also a related post for that error that talks about unused prefab overrrides, hoping it would help)

safe sorrel
#

I'm trying to copy and paste a struct that contains four uint values (it's a guid)

#

however, it looks like Unity copies these values as Int32s

#
GenericPropertyJSON:{"name":"guid","type":-1,"children":[{"name":"m_Value0","type":0,"val":-1294386108},{"name":"m_Value1","type":0,"val":-2130491570},{"name":"m_Value2","type":0,"val":-1684811608},{"name":"m_Value3","type":0,"val":-203354843}]}
#

The negative values don't get pasted at all

#

I guess I could rewrite it to just store int values and reinterpret it as a uint when the value is needed?

#

It's serialized just fine as an unsigned integer, though

#
  _guid:
    m_Value0: 13887954
    m_Value1: 4073751759
    m_Value2: 2602826982
    m_Value3: 1580258371
safe sorrel
#

I think I will get around this with a custom editor window. Still curious if I can make copy-paste work, though!

#

This is necessary for manually editing serialized data. It's Unity-serializable, so it shows up in the inspector, but my Guid type doesn't have an editor UI for actually changing the values in it

#

I was hoping I could just copy-paste the entire struct

safe sorrel
#

hm, it looks like there's no "unsigned integer" serialized property type (more specifically: ClipboardParser doesn't care about it)

#

it doesn't use uintValue

#

just intValue

#

that seems like a bug!

#
        static object GetIntegerValue(in SerializedProperty p)
        {
            switch (p.type)
            {
                case "long":
                case "ulong":
                    return p.longValue;
            }

            return p.intValue;
        }
#

it clearly can know about uints and ulongs

short tiger
safe sorrel
#

ahh, I didn't know that

#

that makes sense

#

dear mr. unity:

#

may i have a mere crumb of uint? 🥺

#

extraordinarily cursed idea: I'm generating these GUIDs myself to identify specific components

#

I could just keep generating them until all four uint pieces fit into an int...

#

i'd only lose 4 out of 128 bits of randomness by doing that...

short tiger
#

Is there anything wrong with a signed GUID?

safe sorrel
#

I'd need to be able to reinterpret the ints as uints when turning the Guid struct into a string

short tiger
#

There are ways to do that

safe sorrel
#

either unsafe pointer nonsense or just adding 1<<31, haha

#

this will also probably screw up existing serialized data

#

I have a lot of serialized Guids -- but almost all of them are on assets, and for those, I'm just copying unity's asset GUID over

#

i only have a few Guids on non-assets that I'd need to go fix

#

and I haven't yet let people save anything in my game, so it wouldn't break existing save data 😛

#

well, what the heck, let's just see what happens if I change these

safe sorrel
safe sorrel
#

You know, I have to do this so infrequently that I'm just gonna' manually edit the YAML for now

silent sage
#

Hey guys i'm having problems manipulating Probuilder mesh vertices through an editor script, I posted the question here #🛠️┃probuilder message, maybe sombody can help out. Thanks for your time

fading escarp
#

New to editor scripting things - how would you implement a similar functionality to this (snapping to grid when resizing a spriterenderer) without messing up the transform component in the editor?
https://gdl.space/sexolohasa.cpp

indigo condor
#

Hi everyone... I've been quite bothered by a little something in Unity for a while now, specifically with the size of some box helps created in a window. I need this right box help to automatically adjust to the size of the left box help for aesthetic reasons, but I don't know why the heck it's getting so complicated for me... I've asked about this in this forum before, but we couldn't solve the prob... Any ideas? Here's the code for both box helps:```csharp
private void DrawLeftBox(JsonData jsonData)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        string elementName = jsonData.Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);

        DrawMultipleInstancesOptions();

        EditorGUILayout.EndVertical();
    }

    private void DrawRightBox()
    {
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Height(EditorGUIUtility.singleLineHeight * 8), GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();
    }```
outer kraken
#

You've been struggling with this for at least a week now..

I'm noticing that you use singleLineHeight * 8 for the right one, but you don't specify any height on the left one.

Many people already told you already, but a "proper" usage of ExpandHeight could solve that issue.

Another thing you should be able to do is, use GetLastRect after ending the vertical layout of the left box, and use that height for the right one.

indigo condor
#

@outer kraken I've done this, but it acts weird...```csharp
private float leftBoxHeight; // Variable para almacenar la altura del DrawLeftBox

private void DrawClassElement(int index)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Space(10);

DrawLeftBox(jsonDataList[index]);
// Ahora vamos a establecer la altura del DrawRightBox manualmente
DrawRightBox(GUILayoutUtility.GetLastRect().height); // Pasamos la altura del DrawLeftBox

GUILayout.Space(7);
EditorGUILayout.EndHorizontal();
GUILayout.Space(2);

DrawDangerZone(index);

EditorGUILayout.Space(5);
EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
EditorGUILayout.Space(5);

}

private void DrawLeftBox(JsonData jsonData)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);

string elementName = jsonData.Name;

GUILayout.Space(7.5f);
GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
GUILayout.Space(-7.5f);

EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
GUILayout.Space(5f);

string newName = EditorGUILayout.TextField("Class Name:", elementName);

if (newName != elementName)
{
    elementName = newName;
}

showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);

DrawMultipleInstancesOptions();

EditorGUILayout.EndVertical();

// Guardamos la altura del DrawLeftBox
leftBoxHeight = GUILayoutUtility.GetLastRect().height;

}

private void DrawRightBox(float height)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Height(height)); // Establecemos la altura manualmente

GUILayout.Space(2);
GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
propertyAdditionMenu.Draw();
GUILayout.Space(15);
GUI.backgroundColor = Color.white;

EditorGUILayout.EndVertical();

}```

#

I've also done what you said me.... but it's the same ```csharp
private void DrawLeftBox(JsonData jsonData)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        string elementName = jsonData.Name;

        GUILayout.Space(7.5f);
        GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
        GUILayout.Space(-7.5f);

        EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
        GUILayout.Space(5f);

        string newName = EditorGUILayout.TextField("Class Name:", elementName);

        if (newName != elementName)
        {
            elementName = newName;
        }

        showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
        showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);

        DrawMultipleInstancesOptions();

        EditorGUILayout.EndVertical();

        // Get the height of the left box after it's been rendered
        GUILayout.Space(5); // Add some spacing
        Rect lastRect = GUILayoutUtility.GetLastRect(); // Get the last rectangle drawn (which is the left box)
        GUILayout.Space(5); // Add more spacing if necessary
        EditorGUIUtility.AddCursorRect(lastRect, MouseCursor.Arrow); // Ensure the cursor changes properly
    }

    private void DrawRightBox()
    {
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true)); // Use ExpandHeight to adjust dynamically

        GUILayout.Space(2);
        GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
        propertyAdditionMenu.Draw();
        GUILayout.Space(15);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndVertical();
    }```
outer kraken
outer kraken
indigo condor
indigo condor
#

it still not working

#

😦

#

I've done what you said me... but it still weird hehe. when the content doesn't fit on the screen the right boxhelp reduces it's height immediately

#

and for some reason, the larger the left helpbox is, the thicker the right one gets

#

answer me when you're home

#

I've waited for a week, i can wait a few hours more :>

outer kraken
indigo condor
# outer kraken Are you specifying any width for the Layouts..? It won't expand the right one be...

No... I'm just doing this :> ```csharp
private void DrawClassElement(int index)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Space(10);

DrawLeftBox(jsonDataList[index]);
DrawRightBox();

GUILayout.Space(7);
EditorGUILayout.EndHorizontal();
GUILayout.Space(2);

DrawDangerZone(index);

EditorGUILayout.Space(5);
EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
EditorGUILayout.Space(5);

}

private void DrawLeftBox(JsonData jsonData)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true));

string elementName = jsonData.Name;

GUILayout.Space(7.5f);
GUILayout.Label(elementName, GUIStyles.GetFontStyle(true, "#3498db"));
GUILayout.Space(-7.5f);

EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
GUILayout.Space(5f);

string newName = EditorGUILayout.TextField("Class Name:", elementName);

if (newName != elementName)
{
    elementName = newName;
}

showOptions[1] = EditorGUILayout.Toggle("Something Else", showOptions[1]);
showOptions[2] = EditorGUILayout.Toggle("Something Else", showOptions[2]);

DrawMultipleInstancesOptions();

EditorGUILayout.EndVertical();

}

private void DrawRightBox()
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(true));

GUILayout.Space(2);
GUI.backgroundColor = new Color(46f / 255f, 204f / 255f, 113f / 255f);
propertyAdditionMenu.Draw();
GUILayout.Space(15);
GUI.backgroundColor = Color.white;

EditorGUILayout.EndVertical();

}```

twin dawn
#

Anyone have any idea where I would/should start to make a custom selectable list of rows that looks like the hierarchy window in an editor window? My best efforts so far have been less than impressive.

gloomy chasm
#

Also, do you want a list or tree?

twin dawn
gloomy chasm
#

Got it, what part are you having trouble with?

twin dawn
#

I'm very bad at IMGUI though and am generally lost when I'm not just using canned GUILayout/EditorGUILayout bits.

#

I guess I need to do all the math myself and calculate the exact rect i need for the rows and the blue highlight?

#

I also don't really know how to handle clicking and I want to do drag+ drop as well but that can come later. Just clicking to select for now would be a good start

#

I don't know how to get the width of the window for example to have the rect extend through the whole width of the window

gloomy chasm
twin dawn
#

I also wouldn't mind using UITK if there are better/cleaner ways to do it there

gloomy chasm
#

If you are on 2022+ I would recommend using UITK though if ya can.

twin dawn
#

is there a UITK treeview?

gloomy chasm
#

Sure is.

#

Also a ListView

twin dawn
#

Is it possible to handle drag + drop between UITK editor windows and the rest of Unity Editor?

#

Right now I'm doing some drag and drop like this

gloomy chasm
#

Yeah, UITK has DragEnter event (along with others)

twin dawn
#

Ok

#

A lot to learn 😓

#

Wait can I build an EditorWindow the UI Builder? Or does it have to all be in code?

gloomy chasm
#

If you are using UIToolkit you can build it in either code or the builder, UIBuilder just makes UXML which you need to load in code. But most of your binding and interaction logic needs to be done in code

twin dawn
#

Excellent, thank you

gloomy chasm
#

Feel free to @ me if you have any questions or want clarification on something you come across 😄

twin dawn
#

If I create a UI with UI builder, how do I access a VisualElement from the xml from code? I assume there's some way to traverse the tree or lookup by an ID?

#

Is that the view-data-key?

gloomy chasm
# twin dawn If I create a UI with UI builder, how do I access a VisualElement from the xml f...

Inside of void CreateGUI() (assuming doing an editor window)
You would load the UXML in as a VisualTreeAsset (any normal asset loading method, AssetDatabase, Resource, etc.)
Then you do visualTreeAsset.Clone(rootVisualElement);.

This basically creates all of the VisualElements defined in the UXML. You can find elements using the Q() extension method.
So if you have a button with the name of Foo then you can do rootVisualElement.Q<Button>(name: "Foo");.

VisualElements also have classes which are basically 'tags'. You can also search for them instead of by name

gloomy chasm
# twin dawn Is that the `view-data-key`?

The view-data-key is something Unity uses to store the 'view state' of an element. It can be used to store state that survies longer, long a foldout state or the position of a scrollview. The values that this applies to is predetermined by Unity and you can't add your own values. Basically if you set the view-data-key then it will saves these values.

twin dawn
#

ok so name or class is how you look things up generally, which I suppose is how JS/CSS works.

hollow ore
#

Hi, how do I create and update shader and material asset in code? I am writing an editor tool that in a huge simplification takes a game object with special script, and based on it's children hierarchy creates a shader source code. I wanted to avoid creating shader and material as files and keeping references to them, I just want to have unity store them under the hood

#

I did something like


private void OnValidate() {
    if (!raymarchingShader) raymarchingShader = RaymarchingShader.instance; // that's a ScriptableSingleton
    EditorApplication.delayCall += RebuildShader;
    if (!sceneRenderer) sceneRenderer = GetComponent<Renderer>();
    // ... some cached properties updated here
}

public void RebuildShader() {
    // https://forum.unity.com/threads/onvalidate-alternative-to-allow-structural-changes.1521247/
    if (this == null) return; // yeah, wtf, but this is needed, sometimes objects are destroyed...

    var shaderText = AssembleShaderSource();
    Debug.LogFormat("Shader code:\n---\n{0}\n---", shaderText);
    if (shaderAsset == null) {
        shaderAsset = ShaderUtil.CreateShaderAsset(shaderText);
    } else {
        ShaderUtil.UpdateShaderAsset(shaderAsset, shaderText);
    }

    if (materialAsset == null) {
        materialAsset = new Material(shaderAsset)
        {
            name = shaderAsset.name,
        };
    }
}
#

but there is a problem when I use an #include 'something.hlsl' inside generated shader source, because when I update those hlsl files, the displayed shader doesnt change in any way.

#

So I assumed "maybe reference includes as assets in the ScriptableSingleton", but it also doesn't change a thing:

public class RaymarchingShader : ScriptableSingleton<RaymarchingShader> {
    public ShaderInclude[] dependentIncludes = null!;

    private RaymarchingShader() {}
    private void OnEnable() {
        dependentIncludes = new[]
        {
            "Packages/me.tooster.sdf/Editor/Resources/Includes/types.hlsl",
            "Packages/me.tooster.sdf/Editor/Resources/Includes/util.hlsl",
            // ...
        }.Select(AssetDatabase.LoadAssetAtPath<ShaderInclude>).ToArray();
    }
}
twin dawn
north sphinx
#

PrefabUtility.GetCorrespondingObjectFromOriginalSource(gameObject); so looks like this returns you original prefab even if instance is from prefab variant

#

while I want to get a reference to prefab variant instance is created from

north sphinx
#

A (root) > B > C.
I pass C to it, I get A prefab asset.

plush spade
#

Problem with Graph View Group Class
When you right click on any node in the graph view or the graph view itself, you can write the queries you want in the contextual menu build process and add new elements etc. to your contextual menu.

But when you create a group and right click on the group, none of this happens, only if you manage to select the group and click on a different point on the graph view, I can see if it is in the selections and do it that way.

What is the reason for the click problems on the group class ?

I can't right click on any point or should I use the group class specifically for this and create a new customGroup class and listen to RegisterCallback<OnMouseClick etc> in it and apply ways in that way ?

Thanks

full badge
#

Hey, I have a class like this:

[Serializable]
public class ObservableField<T> : IObservableField<T> {
    [SerializeField] T _value;
    ...
}
```And a simple drawer:
```cs
public override VisualElement CreatePropertyGUI(SerializedProperty property) {
    return new PropertyField {
        bindingPath = "_value",
        label = property.displayName
    };
}
```I also have a property drawer for the struct `Attribute` that creates a foldout with the text from `property.displayName`:
```cs
    public override VisualElement CreatePropertyGUI(SerializedProperty property) {
        var foldout = new Foldout {
            text = property.displayName,
            name = FoldoutUssName,
            value = property.isExpanded
        };
        ...
    }
```Problem comes when I serialize an `ObservableField<Attribute>`, because the `Attribute` property that is being serialized is actually named "_value" so the text on the foldout just becomes "Value" without taking into account the property name of the "root" `ObservableField` property.
waxen sandal
#

Sounds like you need to draw a foldout in your ObservableField drawer?

#

Or change the label?

short tiger
full badge
#

Works perfectly, thanks :D

dawn root
#

when a tilemap region(via select brush) is moved I want to move prefabs within that region. Is it possible to write a custom brush or some other method to do it?
I know that there is a prefab tilemap system but I can't use that due to some issues.

vague spear
#

Hello anyone knows an alternative to Physics.OverlapSphere outside playmode? I'm trying to create a tool that deletes some stuff while in editor

gloomy chasm
vague spear
gloomy chasm
vague spear
# gloomy chasm Show code?

This didn't work for me. Objects had boxcolliders with isTrigger set to true.

Collider[] collsion = Physics.OverlapSphere(Vector3.zero, 0.5f, LayerMask.NameToLayer("Block"));

gloomy chasm
vague spear
#

yep it is running had a debug for number of objects in array and printed 0

vague spear
calm burrow
#

Yo why does Unity do this shit by default, I tested this using Odin and also just raw unity, if you make multiples of the same component which have collections in them, and open the last one, then switch off to another gameobject and come back, it opens all of them, and if you close this last one, that change aalso applies to the rest. What is this? I don't like this behaviour and would much rather have it retain what the state of that specific component is rather than assuming a state globally across all of the same ones.. super weird.

Please ping if u have any ideas on how to fix this

visual stag
# calm burrow Yo why does Unity do this shit by default, I tested this using Odin and also jus...

Why?
https://docs.unity3d.com/ScriptReference/SerializedProperty-isExpanded.html

Note that the value of this flag is shared across all instances of the serialized property in question that have the same property path and target type. For example, folding up a particular property in the inspector for a component will make the same property folded up in the inspector for all other instances of the same component type.

calm burrow
#

Oh interesting.. didn't realize this was public. In theory that means I could write an editor script that uses a locally stored variable on the component itself and then control folding in and out maybe?

#

Thanks for the insight btw, makes a lot of sense

visual stag
#

However mixing it with property drawers and editors would probably be a pain in the ass

waxen sandal
#

As long as all editors use isExpanded properly, you could just override it all when selection is changed based on your internal data

#

(also isExpanded persists between editor sessions so SessionState is probably a bad idea)

visual stag
#

Ah I suppose you could set the states from outside of the Editor/Inspector completely, that's a good idea

waxen sandal
#

Yeah I've done that before with a generic expand all button

#

Or searching in child properties

#

Set all parents to expand

calm burrow
visual stag
#

If you want to do it more globally (I might imagine still requiring an attribute on fields that desire that behaviour?) you would do it from the selection changed callback, iterating the properties then (or after a delay)

calm burrow
#

Just got a solution from the Odin side that basically does the instanceID tactic to store custom expanded data

#

works perfectly now

waxen sandal
#

InstanceId tactic?

visual stag
#

Presumably as I said, tracking the expanded state per-object using instanceId

waxen sandal
#

Oh, I read over that somehow 😅

#

Technically not stable across restarts but often is iirc

visual stag
waxen sandal
#

isExpanded does work across restarts though

visual stag
waxen sandal
#

EditorGui.BeginChangeCheck/EndChagneCheck

vague spear
violet solstice
#

Trying to draw custom icons for scriptable objects using the object's "Icon" member, got that all working just fine, but I can't seem to find any way to prevent the rendering of the default icon behind it. Suggestions?

#

Tried searching everywhere I could, but seem to be having no luck. Getting the vibe that it might not be a thing one can do.

violet solstice
#

Figured. Thanks for confirming at least. 😊

gusty mortar
#

Say I have a ScriptableObject with a custom inspector and I inline it in some scenario. Is there a way for me to check if the editor is at root level ? I found how to nest it, but i miss the way to tell them apart:

var editor = UnityEditor.Editor.CreateEditor(objectFieldValues);
VisualElement inspector = editor.CreateInspectorGUI();
if (inspector == null)
{
    inspector = new IMGUIContainer(editor.OnInspectorGUI);
}
waxen sandal
#

I guess you can walk the tree up

#

But other than that, not that I am aware

gusty mortar
#

Can I access the tree from within the CreateInspectorGUI ? Thought I would only be able to access the local tree but not the one my editor will be added to.

visual stag
#

Then just access your element's parents

gusty mortar
#

Thanks, I'll have a look at it 🙂

carmine bone
#

jesus christ how in the hell do you assign new clips to a blendtree's motion fields without messing up the parameters and what not? It seems almost impossible notlikethis

gloomy chasm
#

(Unless you mean in editor from code)

bright fox
#

If i have parent class "SomeClass" and then I have a few derived classes "SomeChildClassA, SomeChildClassB, etc"

Is there an existing flow to expose in the editor/populate a List<SomeClass> whilst exposing the serialized fields proper to the sub classes?

visual stag
bright fox
#

@visual stag thank you

carmine bone