#↕️┃editor-extensions

1 messages · Page 36 of 1

safe sorrel
#

One brute-force way to diagnose that is to attach a debugger, start the game, wait a few seconds, and then pause the debugger

#

(well, that's not really "brute force"...)

#

if you're stuck in an infinite loop, that'll point out where the issue is

#

Infinite recursion can be easier to spot, since it'll cause an error very quickly

#

(except on my Macbook, where it just instantly kills the editor)

pure siren
#

Is there a way to have a DecoratorDrawer access the SerializedProperty? I know it is usually not intended this way, but I want to add a decorator based on a value and I don't want to take the PropertyDrawer slot in case it has one already

hot quarry
#

is it possible to remove these Create templates?
I can manually remove the files which makes em inaccessible..
but they remain in the menu grey'd out

got referred over to here.. not sure its applicable. (no biggie if its not possible) just curious

#

i've made alternatives in my own sub-menu.. just trying to experiment a bit w/ the menus and templates

gloomy chasm
hot quarry
safe sorrel
#

Is there somewhere that clearly explains the rules of interacting with SerializedObjects and SerializedProperties? I feel like I'm pretty good at this now, but I also feel like I've just learned through trial and error

#

I'm writing custom editor code that other people are actually going to be relying on, so I'm a little more nervous about "yoloing it", as it were

gusty mortar
#

Hi ! Could someone explain to me why ShowPopup (https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorWindow.ShowPopup.html) does not do what is shown in the documentation ? I still obtain a dockable window, seeing no difference with EditorWindow.Show().

public class DatatableElementSearch : UnityEditor.EditorWindow
{
    public static void Open(UnityEngine.Rect callPosition)
    {
        var window = GetWindow<DatatableElementSearch>();
        window.position = new UnityEngine.Rect(callPosition.xMin, callPosition.yMin, 250, 600);
        window.ShowPopup();
    }

    private void CreateGUI()
    {
        TextField searchField = new();
        this.rootVisualElement.Add(searchField);
    }
}
safe sorrel
#

hmm..I haven't used ShowPopup() before -- I use UnityEditor.PopupWindow.Show to display a PopupWindowContent-derived window

gusty mortar
#

Urgh, nevermind. I had to use Instantiate instead of GetWindow

waxen sandal
#

I've used it before but I feel like I remember it being something very stupid

#

Ah yeah

safe sorrel
#

Oh, that makes sense

#

GetWindow already created a normal-style window

#

(or found an existing one)

#

the example here uses ScriptableObject.CreateInstance to produce the window object

gusty mortar
#

Yeah. I understood my mistake when I read the example a third time ^^'

short tiger
safe sorrel
#

I still don't really know if I can create a SerializedObject once and hold onto it for a long time

safe sorrel
#

It looks like serializedObject.GetIterator() returns the "root" SerializedProperty

short tiger
safe sorrel
#

which has every serialized property of the object under it

#

so you call Next(true) once on it to move to the first child

#

(or NextVisible(true) in my case, to skip all of the random non-visible stuff I don't want to draw anyway)

#

Annoyingly, you can't call GetEndProperty on this "root" property; you get an error

#

the code winds up working like this

#
SerializedProperty end = null;
var iterateOver = property.Copy();

iterateOver.NextVisible(true);

if (notRoot)
{
    end = iterateOver.GetEndProperty(true);
}
#

then it does

#
while (!SerializedProperty.EqualContents(iterateOver, end))
{
  Debug.Log(iterateOver.propertyPath);
  var skipTo = iterateOver.GetEndProperty(false);
 // do some work 

 bool hitEnd = false;

  while (!hitEnd && !SerializedProperty.EqualContents(iterateOver, skipTo))
  {
      Debug.Log(iterateOver.propertyPath + " " + skipTo.propertyPath);
      hitEnd = !iterateOver.NextVisible(true);
  }
  
  if (hitEnd)
      break;
}
#

it stops when it either:

  • runs off the end of the iterator
  • reaches the end-property of the property we were given
#

I don't feel like EqualContents is the most efficient thing to use here

#

i think i just want to compare the property paths?

gloomy chasm
#

Hmmm, this is tickling my 'this ain't right' bone...

safe sorrel
#

It's making me itchy

#

I need to do this because I'm grouping multiple property fields together in the UI

#

so that I can reveal or hide parts of the inspector as needed

#

(i have also added a gratuitous number of tooltip buttons)

safe sorrel
safe sorrel
#

since I am now starting out with the "root" property, instead of being handed a specific SerializedProperty to draw

#

It looks like it's working fine. It's just...awkward

gloomy chasm
#

Ahh I know why it is tickling me! It is because getting the end property is totally pointless since you already want to iterate over all of them

safe sorrel
#

Not necessarily.

#

A property drawer gets handed a SerializedProperty and is told to render some UI for it

#

But there's nothing stopping you from running off the end of that property and reading through the rest of the serialized object's properties

gloomy chasm
#

I thought that is what you said you were doing

safe sorrel
#

one thing that has helped is realizing that the YAML layout is exactly what you get when iterating through SerializedProperty objects

gloomy chasm
gloomy chasm
safe sorrel
#

given a SerializedProperty, I want to draw all of its children. I also want to group these children up into separate UI elements

#

so it might look like this

#
  • Root
    • Group A
      • Child 1
      • Child 2
    • Group B
      • Child 3
      • Chile 4
#

Rather than all four children being parented directly to Root

safe sorrel
safe sorrel
#

(the former could cause infinite recursion, which is extra-funny)

#

to draw a Foo: first, draw a Foo...

gloomy chasm
safe sorrel
#

Right now I'm getting every direct child and creating a PropertyField for it

#

e.g. I'm creating PropertyFields for foo, bar, baz, and qux, but I am not trying to draw baz.list

safe sorrel
gloomy chasm
safe sorrel
#

you know, i was just squinting at that

#

I swear I ran into a problem when using that, though

#

I think I see what it was, though

#

I bet I tried to call prop.Next(false) on the original property

#

which would completely skip all of its children (duh)

gloomy chasm
#

The easiest thing is to just do

foreach(SerializedProperty child in prop.GetEnumerator())
{

}
safe sorrel
#

I call Next(true) once to enter the first child, then start using Next(false) to step over each child

gloomy chasm
#

Yup, that would be the way

#

Or using the enumerator like above

safe sorrel
safe sorrel
#

It looks like the enumerator enters child properties

#

(this is a five-layer nesting)

gloomy chasm
#

Huh I was pretty sure it didn't...

safe sorrel
#

this kind of thing

safe sorrel
gloomy chasm
safe sorrel
#

i still need to check for when I've run off the end of my current property

gloomy chasm
#

I had made this extension method for it a long time ago it looks like. So I guess I knew

        public static IEnumerable<SerializedProperty> EnumerateChildren(this SerializedProperty property)
        {
            SerializedProperty currentProperty = property.Copy();
            SerializedProperty endProperty = currentProperty.GetEndProperty();

            if (currentProperty.NextVisible(true))
            {
                do
                {
                    if (SerializedProperty.EqualContents(currentProperty, endProperty))
                        break;
                    
                    yield return currentProperty;

                } while (currentProperty.NextVisible(false));   
            }
        }
safe sorrel
#

that's a good idea 😉

#

i'm going through this hassle because I got tired of hand-creating UI documents every time I wanted to use these "reveal areas"

#

i want to create them by adding C# attributes to the code

#

the tricky part is that this is a "long-range" thing – it can't just be a PropertyAttribute with a corresponding custom property drawer, since it needs to group many property fields together

gloomy chasm
#

Yeah, it is annoying that it has to totally take over all inspector drawing for components :/

safe sorrel
#

I can partially avoid that with this PropertyAttribute -- it takes control of drawing the direct children of whatever you apply it to, but it won't mess with the grandchildren

#

of course, now you have to use this on anything that's going to have the reveal-areas

#

equivalently, I can create a property drawer that inherits from my GadgetPropertyDrawer and that targets Inner1

#

That's the more sensible thing, really

#

I shouldn't care if Inner1 wants to use these features or not

#

(i just wish you could add an attribute that says "use this property drawer for me!")

#

I guess this could be a place to use code generation...

#

except that I'm targeting 2022.3, and that's the very last version that doesn't have documentation for using source generators 😭

gloomy chasm
safe sorrel
#

that tells Unity to use a certain property drawer for a specific serialized property

safe sorrel
#
[CustomPropertyDrawer(typeof(ExampleAsset.Inner1))]
public class ExampleAssetPropertyDrawers : GadgetPropertyDrawer
{
    
}
#

so I have to do this

#

it's just mildly annoying

gloomy chasm
#

Oh you mean add a attribute to the class to tell it to use a property drawer instead of having to make a drawer for each one

safe sorrel
#

Right

gloomy chasm
#

Does CustomPropertyDrawer have a option for inheriting or is that only editor?

safe sorrel
#

It can be inherited, yeah – but all of these classes are unrelated to each other

#

i don't want to mandate that they all inherit from GadgetClass or something

gloomy chasm
#

Ahh got it. Yeah that is a really rare case, so understandable why they don't realy support it I guess

safe sorrel
#

it's definitely not enough of a problem to warrant trying to do source generation, haha

#

i should really come up with plausible names for these properties

#

not pictured: "Whatever"

safe sorrel
#

interesting issue with AssetDatabase.ForceReserializeAssets....

#

It balks when I try to reserialize a scene with a component in it that contains this type

#

this class looks like this

#
public class OverrideReference<TReferenced,TUpgradable> where TReferenced : UnityEngine.Object, IOverrideProvider<TUpgradable> where TUpgradable : Upgradable<TUpgradable> { ... }
#

so it's a bit of a complex type signature

#

unity serializes it just fine

#

It also looks like the rest of the assets reserialize correctly

#

even the scene is getting reserialized correctly!

#

if I add some random garbage to the YAML, it goes away when I reserialize

safe sorrel
#

(I'm writing a script that reserializes my package's "Sample Templates" folder, then nukes the existing Samples~ folder and copies the template folder over)

#

that part is scarier

#

i don't want to rm -rf my home directory lmao

spare bone
#

Hi does anyone know if theres an older version of graph tool kit on earlier versions of unity than 6.2

gloomy chasm
spare bone
#

For example 6.0

gloomy chasm
spare bone
#

Yeah it says unable to find it by name where would i find the folder without 6.2 install

gloomy chasm
safe sorrel
#

To "embed" a package, you copy it from /Library/PackageCache/foo to /Packages/foo

#

You'd have to install it in a 6.2 project first, yeah

spare bone
#

Ah fair the only reason i need it is cause my uni uses 6.0

#

So if i opened my project in 6.2 at home then reoped the project at uni after installing package it would still be usable

gloomy chasm
#

Upgrading and downgrading projects is pretty unstable (especially downgrading). I would just create a new project in 6.2, download the package, close the project, and copy-paste the package to your 'rea' project.

safe sorrel
#

It should also be possible to just directly download the package from the Unity registry. I've just never found a very nice way to do that

#

(beyond staring at a huge wall of json and finding my package)

safe sorrel
#

I'm having some trouble getting Handles.Label text to appear. I'm using Gizmos.DrawCube to draw these planes, and it looks like they're always winding up on top of the labels.

#

i'm calling Handles.Label after drawing the cubes, but I'm guessing these things get queued up and run later

#

I'll just turn the opacity way down for now (it looks nicer that way anyway)

burnt dove
#

Is possible by code get the assemblies in a certain package?

safe sorrel
#

You can search for all of the assembly definition assets (as well as assembly definition reference assets)

#

You'd also need to search for all DLLs, I guess

knotty compass
#

Hello everyone, I am trying to code an editor utility that modifies a number of prefabs to apply a certain template.
This means I want to take the template prefab and a given prefab, and make a copy of each object in the template and add it to the target.

For this, I have created a scriptablewizard with a GameObject field (template), and a List<Gameobject> (targets).

I tried to use Instantiate, but I'm not surprised at all to see that it doesn't work and it ends up crating the object in the scene.

Cannot instantiate objects with a parent which is persistent. New object will be created without a parent.

I don't know if I'm missing something simple, or the approach is completely incorrect from the ground up.

knotty compass
#

Thanks, will take a look

safe sorrel
surreal girder
#

⚠️ make sure to unload the prefab when you are done otherwise it remains loaded and hidden and unity will moan at you

burnt dove
safe sorrel
violet zephyr
#

I'm working in my Editor class to do stuff with my Tilemap, but each time I make changes somewhere in my project, once Unity does its Domain Reload, I get met with a handful of NullReferenceException errors.
I've resolved some of them just by using the [Serializable] and [SerializeField] attributes, but I want to have a better understanding of how I should actually do things with an Editor Extension

#

I dont really want to just throw those attributes onto everything and just go "yeah that'll probably be fine"

surreal girder
#

otherwise you would need to save things to an asset/file

#

(or native memory but probably too much effort)

violet zephyr
#

Is it a matter that anything which is a dependency of the Editor class, or dependencies of those classes in my Editor, should be given the attribute?
Theres some classes which I didnt think existed in the context of my Editor, which were showing as null references

#

The Editor namespace at the top there depends on all the other parts, but theres a long chain of dependencies. I assume I just need to serialize all of those

safe sorrel
#

An Editor is a kind of Unity Object, meaning that Unity is capable of serializing it (and its fields)

#

oh, wait, it's not literally a UnityEditor.Editor, is it?

#

(the class used to create custom inspectors)

violet zephyr
#

Rider automatically did UnityEditor.Editor due to the folder name that class is inside

#

It conflicts with namespace VoroSystem.Grids.Editor otherwise

#
namespace VoroSystem.Grids.Editor {
[CustomEditor(typeof(BasicTilemapComponent))]
public class TilemapEditor : UnityEditor.Editor {```
#

not really a fan of the name TilemapEditor tbh, but I havent come up with a better name

sterile sun
#

my unity editor goes black when i run my project

sterile sun
surreal girder
#

what happens if you reset the current layout?

sterile sun
#

how it relate with layout

surreal girder
#

🤷‍♂️ then dont

sterile sun
#

no i just curious, i just ask you bro.

#

btw i am very new in unity, so i do not that much knowledge.

minor heath
#

Hi I have question about extending search. I know how to add my own provider, but it does not have any filters. I can't find how to add my own filters to my provider. Is there any documention on that? Or some good tutorial?

safe sorrel
#

notably, in 2022.3.22f1, there's some weird bug where the Animator window pops out while it's already open, and closing the popup causes the original animator window to break

#

it just says "Failed to load!" and gets stuck

#

resetting the layout will clear issues like that up

crude forge
#

Finally getting a chance to dig this up. I'm not sure what the tool change event/attach event stuff is about, that's an entirely new corner to me...

#

but I suppose it's time to learn

gloomy chasm
violet zephyr
#

Does Unity provide any sort of transform handle that I can use to control the size of my rectangle? I've had to instance two GameObjects in order to do it

#

Itd be better if I could just make two different Transform within my class and control them that way

surreal girder
#

The rect gizmo is for xy so that doesnt work well for you here

violet zephyr
#

I dig some digging in the forums, and came across this post

        var cornerA = Handles.PositionHandle(t.Corner.A, Quaternion.identity);
        var cornerB = Handles.PositionHandle(t.Corner.B, Quaternion.identity);```Let me do it
surreal girder
#

Yea those handles are probably best. I guess you never checked the Handles class before now?

#

I guess the ones used by box collider arent usable by us. I think only the box drawing part is (not input)

surreal girder
gloomy chasm
#

Yeah they have it kind of hidden haha

violet zephyr
glad pivot
#

how can i grab the warning, error and log textures so i can use them myself? like say in GUIContent

#

im not finding much online and i cant seem to find them in the project either

#

i know EditorGUIUtility.FindTexture(); is a thing but i cant find what the texture should be called if i can get it with this

queen wharf
glad pivot
queen wharf
#

yes

#

you would get the style

#

then maybe get the texture off the style

glad pivot
#

oh its a lookup, i thought u meant id clone this. ok holdon

#

ok i managed to dig a little for the helpbox code and found EditorGUIUtility.GetHelpIcon(type)

#

i think thats what im looking for

#

oh.. i think its an internal method, doesnt seem like i can use that, unless i do reflection i suppose

stable nebula
#

I have this in my code for example:

private static readonly Texture s_unknownTexture = EditorGUIUtility.IconContent("Help").image;
private static readonly Texture s_validTexture = EditorGUIUtility.IconContent("d_GreenCheckmark").image;
private static readonly Texture s_noteTexture = EditorGUIUtility.IconContent("d_UnityEditor.DebugInspectorWindow").image;
private static readonly Texture s_warningTexture = EditorGUIUtility.IconContent("Warning").image;
private static readonly Texture s_invalidTexture = EditorGUIUtility.IconContent("d_false").image;
celest sundial
#

Is there a resource for how to properly make an EditorWindow using UIToolkit? I've been looking through some various asset packages code and they all do things slightly differently, but the main thing is having them create the entire layout via the code... am I crazy or shouldnt they just handle all of that via uss files?

#

Or is it perhaps some leftover conversion from IMGUI? So basically I'm pretty lost here at the many ways to do this since this stuff is a huge mishmash of different eras of how its been done and need some good pointers

celest sundial
glad pivot
#

i really dont know what is causing this error to appear. i understand that its editing something during a loop which is not allowed, but idk what loop its talking about where this is happening. i assume its something from the internals of the editor / inspector but outside of that i have no idea

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.List`1+Enumerator[T].MoveNextRare () (at <152439c387994a8da523328132967f8d>:0)
System.Collections.Generic.List`1+Enumerator[T].MoveNext () (at <152439c387994a8da523328132967f8d>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <5818bc53b12b4560b54110897827736e>:0)
#

it seems to happen when my custom window opens 🤷‍♂️

#

could it be because im creating a new window during the rendering of the inspector?

#

ok yeah that was it

glad pivot
#

ok so if i need to chache some stuff for the editor to use during a property drawer, whats the best way of doing that? should i just declare the properties in the class with #if UNITY_EDITOR around then read those from the drawer, or is there a way i can safely declare them in the propertydrawer itself without running into issues with shared variables in lists?

#

or maybe i should just find a way to do it without caching the variable and just keep it within scope of the GUI method? although the intention i had to declare the fields in the property drawer to begin with was so that it didnt need to populate it every update but im not seeing any good way of doing that outside of storing them like how i said in the target class with #if UNITY_EDITOR

edit: i found the answers i was looking for

merry nexus
#

looking for some input on solving this! i am trying to detect when the BuildProfileWindow is open but i cannot due to the protection level. is there any way around this? thank you!

waxen sandal
#

You can get the type with reflection then pass it to the method

merry nexus
waxen sandal
#

What?

glad pivot
#

yeah i dont think reflection works directly here unless you do some extra magic. just getting the type isnt gonna work as you cant pass a System.Type into < > brackets

surreal girder
#

Only usable with mono disclaimer

safe sorrel
#

Yep, that's how you can do it

gloomy chasm
#

So no real need to use the method at all. You can just get the type and call the Find method your self

safe sorrel
#

Resources.FindObjectsOfTypeAll is spooky

#

it finds...more stuff?

gloomy chasm
safe sorrel
#

vs. Object.FindObjectsOfType

safe sorrel
gloomy chasm
nimble sinew
#

hey guys im using jetbrains rider for the first time and i dont know how to setup autocomplete, any help?

dusty pineBOT
visual stag
#

@nimble sinew 👆

drifting summit
#

Im trying to learn editor windows and I accidentally made a script that opens a new tab OnInspectorGUI and now i have countless tabs open. Does unity have like, a close all tabs thing? im not sure what to do

surreal girder
drifting summit
mental sedge
#

just started my unity journey, for some reason vsc isnt autocompleting my sentences, any idea why that could be happening? I have the unity, C# and C# dev kit extensions

dusty pineBOT
mental sedge
#

did all that, for some reason it still isnt working, its giving me an error everytime i open vsc

#

i can send it if ya want

#

fixed it, reinstalled .net

dusky flare
#

Hi all. This is probably a stupid question, but what should I do if my tileset is too complicated for a Rule Tile? For example, I have some tiles that can have tiles in 8 directions, but in some directions, it has to be a specific subset of tiles

dusky flare
wild edge
knotty compass
#

hello! I found a package on github that may or may not work for what I need, but i'm not actually sure if it would work because it hasn't been updated in a couple years and it errors with GUI.skin.FindStyle("ToolbarSeachTextField") returning null
I presume the package wasn't made for unity 6 and it would need to be a different style name in this version of unity (6000.0)
anyone happens to know off the top of their head what I could use in place of ToolbarSeachTextField? or if there's an updated reference list somewhere?

knotty compass
#

(I'm still curious about the answer but I did find some workaround for it, and confirmed that the package isn't quite what I needed)

gloomy chasm
crude forge
#

Hmm. Two Qs. What would I use to create a new object (in editor, not game) that maintains it's link to the source prefab? And what would I do to check if that go comes from that source prefab?

#

Have a tool for creating objects from prefabs saved in my GO list

#

Just need to do that actual creation... And then the double checking on removal of that particular type

gloomy chasm
crude forge
#

I think I figured out the first one

#

Sorta just guessing on whether the second will work for my use case. Partly because this is me using a GO prefab list for the dropping the mobs

crude forge
#

Yep

#

Thanks so much for the point outs

#

I'm doing my best to do configurable and simple editor code

wild bronze
#

anyone can help me on this?

surreal girder
#

then save and let unity reload

wild bronze
#

is there no way to fix that?

surreal girder
wild bronze
#

seems like I can download that

#

i'm trying to install it

surreal girder
#

unity uses an older c# version. Some newer .net classes are avaliable on nuget

surreal girder
#

this wont work, dont bother

wild bronze
#

😭

surreal girder
#

the vs/vs code proj generated is purely for IDE use, it does not affect your unity project

#

you need to download a dll file manually and add it into your project

#

download package, open file using 7zip/nanazip/winrar/explorer and extract the dll for .net standard 2.1

surreal girder
#

download button

wild bronze
#

i can't find any download button

surreal girder
#

Ill be honest, are you sure you really need this?

wild bronze
#

oh... I found it

wild bronze
#

in what folder?

surreal girder
#

READ what i said

#

you open it as an archive and locate the dll:

#

e.g. using nanazip

#

I dont know if this dll will function but this is how I go about this

wild bronze
#

oh!!

#

I did it

#

thx @surreal girder

thorny rock
#

Quick question about serialization. I have a class that handles UI transitions. It has an enum TransitionStyle and a field of type Transition. Depending on the value of the enum a different derived class populates _transition (i.e. ScaleTransition, FadeTransition, ...). The editor only serialized the base class transition though. Is there a convenient way to make Unity serialize the derived class instead? Or do I have to check the value and then write a function for each enum value so I can see and adjust the right values?

twin dawn
thorny rock
#

Minor addition: I want to preview the transition with this function:

IEnumerator TransitionRoutine(Transition transition)
{
    _inTransition = true;
    float animationTimeInverted = 1f / transition._TransitionTime;

    for (float f = 0f; f <= 1f; f += Time.deltaTime * animationTimeInverted)
    {
        transition.UpdateTransition(f);
        yield return null;
    }

    _inTransition = false;
    OnTransitionEnded?.Invoke();
}

But even though I put [ExecuteAlways] above the class this does not work. My guess is that either deltaTime = 0 or yield return null does not work. How would you work around this?

surreal girder
#

Using async would be the alternative to not rely on coroutines (via UniTask or Awaitable)

thorny rock
#

The coroutine starts, _inTransition does get set to true but never returns to false.

surreal girder
#

If not then may be as I thought (that they do not work)

queen wharf
#

Pretty sure they do

surreal girder
#

Perhaps its started incorrectly?

queen wharf
#

Maybe try a yield return waiuntil?

surreal girder
#

This is why I just use async

thorny rock
#

I was just too impatient. In fact the coroutine runs but refreshs with the editors timing. So collapsing and expanding the component i.e. does finish the coroutine after a couple of clicks 😄

#

Not a good way to work but maybe I'll figure something out.

surreal girder
#

Oo yea that sucks

thorny rock
#

I have another question. Drawing my [SerializeReference] with the default inspector works without issues, but if I try do draw them with EditorGUILayout.PropertyField(openProp) it does not render correctly. Do you know why?

humble kernel
#

hey guys, do you know, would it be possible to make your own error types?

#

like how there is Log, Warning, Error

#

actually i thought of another way of doing it but if possible just let me know

#

ping me

queen wharf
#

by making your own logging solution

humble kernel
queen wharf
#

Not really no

humble kernel
gloomy chasm
humble kernel
gloomy chasm
# humble kernel no reason i just want more

Well.. okay. The console supports rich text. So you could make some with different formatting and colors. Just can't filter them like you can the other types or have custom icons

humble kernel
#

so yeah i guess its not possible, ive tried searching for it too and couldnt find anything anyways

#

(thats why i came here)

gloomy chasm
#

I mean there is a chance you could with reflection, and Harmony.

#

Just depends on how much of the console is in C++ vs C#

humble kernel
#

i would see later on, thanks for helping

gloomy chasm
humble kernel
gloomy chasm
humble kernel
real spindle
rose prism
#

hey guys, I hope this is the right channel.

I''ve just started using the Unity behaviour graphs and I'm a bit lost on how to share float value to the blackboard from a different component. During runtime, this particular float value keeps changing and i want the blackboard to sync with this changing float value from another component of the same game object.

Appreciate any feedbacks!

median osprey
#

Is there a decent way to add items to the scene view right-click context menu without just overriding it fully?

#

Not just for specific objects, but like, right-clicking even on empty space. Can I manually pull the GenericMenu and add things to it?

median osprey
#

Also weirdly HandleUtility.PickGameObject seems to miss empties - even using OnDrawGizmos to create a clickable region - is there a quick and easy way to override this? pickGameObjectCustomPasses seems like overkill? Trying to figure out what the options are.

median osprey
#

It also weirdly seems like it doesn't work, I can return a GameObject on HandleUtilityOnPickGameObjectCustomPasses, and HandleUtility.PickGameObject will still return null

median osprey
#

I'm on 6000.2.10f1, is this just a broken method?

split dune
#

Hello guys
How can I create a preset menu to save and load my data in a custom editor window?
I'm trying to find a solution in the docs, but I cannot :/

cyan karma
#

How to put a string here via code, and filter project files with it?

surreal girder
split dune
#

I'm trying to do a Load Preset in my custom editor window, but are returning me an error

unity cannot convert "Method Group" to "UnityEditor.Presets.PrsetSelectorReceiver"
I don't know how can I solve it :/

#

Save works, but Load not

candid ember
#

Is there a reason the width of graphRect displays differently from the EditorGUI.Slider's width despite using the same parameter?

https://media.discordapp.net/attachments/768488394523017216/1438350865873375377/Screenshot_2025-11-12_180742.png?ex=69169021&is=69153ea1&hm=6fdb5598817245937bdf2c563856484449eadd6f92aa4a676398e3a2ccec9ea9&=&format=webp&quality=lossless&width=533&height=315


testScript.timeToApex = EditorGUI.Slider(new Rect(graphRect.position.x, graphRect.position.y, graphRect.width, 0), testScript.timeToApex, 0.1f, 4.9f);

if (Event.current.type == EventType.Repaint)
{
    Handles.BeginGUI();

    //Draw container
    Handles.color = Color.white;
    Handles.DrawLine(graphRect.position, graphRect.position + Vector2.right * graphRect.width);
    Handles.DrawLine(graphRect.position, graphRect.position + Vector2.up * graphRect.height);
    Handles.DrawLine(graphRect.position + Vector2.right * graphRect.width, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height);
    Handles.DrawLine(graphRect.position + Vector2.up * graphRect.height, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height);

    Handles.EndGUI();
}```
quasi sentinel
# candid ember Is there a reason the width of graphRect displays differently from the EditorGUI...

Continuing just now, I found a problem with the code here.

   new Rect(graphRect.position.x, graphRect.position.y, graphRect.width, 0),
   testScript.timeToApex, 0.1f, 4.9f); ```

And specifically, these two things inside it are what make the slider’s visual width differ from your graph:
EditorGUI.Slider reserves label space internally even though you didn’t give it a label. By default, Unity splits the rect like this: 

[label area ][ bar area]

That label section (~150px by default) shrinks the visible slider bar width.
The built in slider always draws a background bar thefill track is part of the default GUI style (EditorStyles.numberField + EditorStyles.slider). You can’t hide that directly through EditorGUI.Slider.
candid ember
quasi sentinel
#

If you want:
A slider that covers exactly the graph’s width, and has no visible bar background (just the thumb handle), you’ll need to switch from EditorGUI.Slider() to a manual GUI.HorizontalSlider() call.

That control gives you full stylistic control you can remove the bar style entirely.

candid ember
quasi sentinel
#

Yeah

candid ember
# quasi sentinel Yeah

So what do I do with these GUIStyle arguments? The only value I can find is none which doesn't help me with the thumb field

#

What am I supposed to put for that?

#

I certainly solved the length problem at least, though

quasi sentinel
# candid ember What am I supposed to put for that?

The fix (no bar + same width as graph)

Rect graphRect = EditorGUILayout.GetControlRect(false, 150); // Use the same rect for slider and graph Rect sliderRect = new Rect(graphRect.x, graphRect.y - 10, graphRect.width, 20); // Draw a minimal horizontal slider no bar, only the handle testScript.timeToApex = GUI.HorizontalSlider( sliderRect, testScript.timeToApex, 0.1f, 4.9f, GUIStyle.none, // removes the bar GUI.skin.horizontalSliderThumb // keeps the handle ); // Then draw your graph using graphRect if (Event.current.type == EventType.Repaint) { Handles.BeginGUI(); Handles.color = Color.white; Handles.DrawLine(graphRect.position, graphRect.position + Vector2.right * graphRect.width); Handles.DrawLine(graphRect.position, graphRect.position + Vector2.up * graphRect.height); Handles.DrawLine(graphRect.position + Vector2.right * graphRect.width, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height); Handles.DrawLine(graphRect.position + Vector2.up * graphRect.height, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height); Handles.EndGUI(); }

Maybe it will work somehow

#

I also noted some comments for you to understand easily. 🤔

candid ember
quasi sentinel
# candid ember The problem is that it yells at me if I only put GUIStyle.none for the bar but l...

In GUI.HorizontalSlider, both slider and thumb style arguments are required if you’re using the overload that takes them. You cannot leave the thumb argument blank if you do, Unity will throw an error.

GUIStyle.none hides the bar.

GUI.skin.horizontalSliderThumb is Unity’s default handle style required, otherwise the slider has nothing to drag.

You can’t just omit it or leave it null, Unity won’t allow it.

If you want, you can even create a custom thumb style to change its size, color, or shape, but you always need some style there.

This is why you solved the length problem (the rect works), but can’t leave the thumb argument empty.

candid ember
quasi sentinel
split dune
#

Hello, guys
There are a way to use the variables that I have in a Custom Editor Window in another script?

elder wasp
#

Are there any known issue of the inpsector not properly loading all properties of a script?
I'm trying build a custom inpsector (here a reduced version) and I only get the first property drawn (alltough debugger says they are all there, only one loaded)

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

public class TestInspector : MonoBehaviour
{
    public float A;
    public float A1;
    public float A3;
    public GameObject A54;
    public float A6;
    public float A5;
    public float A9;
    public float A7;
    public float A8;
    public float A11;
    public float A22;
    public float A33;
    public float A44;
    public float A55;
    public float A66;
    public float A77;
}


[CustomEditor(typeof(TestInspector), true)]
public class TestInspectorInspector : Editor
{
    public override VisualElement CreateInspectorGUI()
    {
        VisualElement propertiesContainer = new VisualElement();
        SerializedProperty property = serializedObject.FindProperty(nameof(TestInspector.A));
        var currentDepth = property.depth;
        do{
            var prop = new PropertyField(property);
            propertiesContainer.Add(prop);
        }
        while (property.NextVisible(false) && property.depth >= currentDepth);
        return propertiesContainer;
    }
}
queen wharf
#

off the bat tho are you sure that property depth comparison is right?
it could be just the first thing that looks off from a glance

elder wasp
#

Yeah, so that's the thing. the properties are created

#

But not loaded

#

I managed to get four properties by adding a Bind() statement

#

But according to docs I shouldn't add it

vapid prism
#

How can I temporarily enable profiling in script in the editor? I'd like to capture a profiling snapshot of a function that's gonna run that does a ton of work over multiple seconds. I'd like to view the profiled info in the ProfilerWindow. It seems using Profiler.enabled and ProfilerDriver.profileEditor doesn't actually capture any info. Do I somehow have to wait a frame or something?

celest sundial
#

For an EditorWindow running only in edit mode as custom tooling, what's the right approach to handle a Selection change event? Currently the way I have it wired up the Selection value is picked up and used to replace text in a Label which works only when I enable/disable the UIToolkit live Reload so I know its working, but, obviously is only happening on manual update and I'm not gonna add a refresh button to have it work in that way. The code is in CreateGUI but may not be sufficient to handle this kind of click/Selection event? I added the code to detect the change in Update which did work as I intended this but seems inefficient as heck, yeah?

hard pine
#

Not sure if this is the best spot for this. I am trying to open code files in VisualStudio(not code). It keeps opening in a new instance of the program, instead of an already open one.

brisk pilot
#

Also do you have vs unity package installed

surreal girder
#

!vs

dusty pineBOT
# surreal girder !vs
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

hard pine
#

Didn't check the package! thanks

#

Well that didn't fix it.

I am using VS 2026 to be fair, so I wrote an entire program to sit between Unity and VS to intercept file open requests and send them to the right editor...

surreal girder
hard pine
#

Was happening for 2022 also, which is strange

#

My custom solution is working for now

surreal girder
#

something else is wrong then

hard pine
#

With 2026 none the less. Sad when a solo developer can implement support faster than a multi million company

hard pine
surreal girder
#

the unity vs package is producing the vs solution purely for vs to work

#

unless you did the same or utilized it then you are using vs in a reduced state

hard pine
#

I am just intercepting and passing the logic from Unity to VS. So anything like that will still be in place

surreal girder
#

you made your own thing to make/update a vs sln and projects then?

#

im confused 😆

#

id just open the sln in 2026 manually and be done with it

hard pine
hard pine
#

I created this exe, used that as the target IDE, processed the open logic for VS 2026, and made sure the env was setup right, and then passed the file. Also added logs so I can actually see what is happening.

#

I like 2026 looks funny

surreal girder
#

I guess the explanation is because Vs 2026 isn't selectable? Dunno but I'm sure it will be fixed

#

I was confused what you specifically meant by using this program

glad pivot
#

how come when i made my class an Unity.Object so i can draw it via an object field, my property drawer for it that uses property.FindPropertyRelative("property") just breaks?

#

o wait, i think i know, because it hasnt been initialized as an object and idk if a normal c# class can be initialized in that way? i think i read that i shouldnt be inheriting from UnityEngine.Object right?

#

so then i can make a serialized object and get it as a property from that right?

#

ok idk how i would make a serializedObject for something thats not an unity object.
so is there a way to turn a non unity object into a serialized property?

#

oh, even if i try to make it an Object, using object field doesnt work cuz it cant convert it so a serialized property. then is it even possible to do this? do i have to just make it hacky and serialize a temporary property to put my data in, get it as a serialized property from the component, then draw it and then reuse?

molten hollow
#
var folderObj = AssetDatabase.LoadAssetAtPath<Object>(folderPath);
EditorGUIUtility.PingObject(folderObj);```
this ping the folder but is there a way to open and go into the folder?
surreal girder
molten hollow
#

fr bet

analog acorn
#

not sure if this is the right place to ask but i want to make animations faster like i want to use code in the editor to say put the first animation clip in the timeline to the end or make an animation a certain length

candid ember
#

If I have a property [SerializeField] InputActionAsset actionMap; in a MonoBehaviour I want to make a custom editor for, how would I go about getting the custom inspector to be able to assign an InputActionAsset to that actionMap in the MonoBehaviour?

molten hollow
#

EditorGUILayout.GetControlRect
is this api means return a whole line of the window like a normal serialized int with a specified height?
it also said that: it should be used rather than GUILayout, like begin vertical/horizontal? for when used in property drawer which said doesnt work with GUILayout, but the options param of this api is only from GUILayout?

vapid prism
#

How can I revert perfab override from script if that prefab override is identical to the default value? For instance if I have a component and override a field to go from value A to B and then in another script modify the same field from B back to A (which is default) Unity will remember that it was overriden.

gloomy chasm
pastel bay
#

is there any way to remove the input of horizontal scrolling in windows like the tile palette? I got a new mouse and keep pressing l/r scroll accidentally

dusky pumice
#

Hello there,
I'm trying to modify a scene by adding some generated value before it saves, is OnWillSaveAssets the good place to do this ? It seems the data don't persist

surreal girder
dusky pumice
surreal girder
#

Normally you should use Undo to record the change (which also marks things as dirty)

dusky pumice
#

yes calling that, but I think I found the issue, the component itself does not seemed as marked as dirty

surreal girder
#

Yea that would be best as that makes the scene dirty too

viscid epoch
#

what does "save" do? I clicked it realising I forgot to do something before submitting, thinking it would save the current description so I could come back to it and submit it. It seems to have just submitted it? I don't know the difference between submit and save...

#

...nevermind. it has not been submitted. It is just not on the perforce. what did I do 😭 I'm just gonna check out everything and submit again...

#

NEVERMIND AGAIN
found it :3

vast isle
#

can you hide .asset Scriptable Object from showing in Project Window?
its config file

gloomy chasm
vast isle
surreal girder
#

Hide flags dont always work in all situations so id just accept its going to be there

lilac valve
vast isle
chrome sonnet
#

I'm trying to make a curve/line editor window using UI Toolkit - I've got the line/curve getting rendered both with the curve using De Casteljau's algo, and the line between points inside my CraftingPathElement, but I'm struggling to work out how I am supposed to add draggable handles to manipulate the points? I've worked out I need to have a manipulator, on a DraggableHandleElement VisualElement, and I've written some code to be able to move the handles around - but I am hitting a pain point either that, I can't add the DraggableHandleElement in the generateVisualContent, but if I try to make a new element for the handles, I can't work out how to make them each draggable with manipulators because the List of points I pass through is empty on the constructor, but then I can't use it in the generateVisualContent?

lilac valve
chrome sonnet
#

Yeah, its for the editor. I saw the CurveField, and tried using that first, but it doesn't quite meet my needs the way I wanted to use it (e.g. a curve that may curve back around on itself, or back past 0,0)

lilac valve
vapid prism
#

How can I get a SerializedProperty as a string no matter the underlying type?

#

assuming it's not an Object type

vapid prism
#

looks like there's not a nice way to do it and I'll have to switch on the prop type

vital mountain
#

is there an easy way to get the monoscript that implements a target type? or do i have to know the script path?

#

the script im trying to get is not a MonoBehaviour or ScriptableObject btw

waxen sandal
#

There's the other way around MonoScript.GetClass, but even that is wrong in some cases

vital mountain
#

yeah that doesnt really help much, i have the class already. i just want to have a reference to the monoscript in the editor cuz i want an object field as a reference to click so its easily openable

#

I found MonoImporter.GetAllRuntimeMonoScripts() idk if that would be a great idea to use every update of the inspector and filter it to the target script im looking for, tho i guess i could cache the result so it isnt

vapid prism
#

You can use FindAssets to find the t:MonoScript with filename matching your typename

#

Doesn't really work if you have multiple with the same name though 🙁

vital mountain
#

that wouldnt be so much different from the MonoImporter method tho? which would already be getting all types of monoscripts, id just need to do the filtering myself. idk if that would really change anything as idk if the importer has a more optimised search than searching every asset like that

waxen sandal
#

Can you elaborate what you're doing? You have a property drawer, and you want to add an object field to that that links to the file the class is defined in?

vital mountain
#

i have a property drawer for a class which has a couple of virtual methods that im using to make small extensions for variations of the class (a regular c# class). this editor is mainly for debugging at runtime to just view the data the class generates and whatnot, thats not super important. the variations that overrides those methods has data that uses different interfaces, so i just wanted to have some objectfields that displays the data interfaces as MonoScripts so we can easily find them and dont need to open the script itself and check

#

so the editor already knows what interfaces is being used as im already drawing the data from it, but the problem is just getting the mono script for easy access to the interface

#

altough i suppose i could also just use a labelfield and have it display the name of the interface but it would be nice to have the monoscript reference

vapid prism
#

Would it realistically make much of a diff though? It would just be a pretty label since you can't really pick it anyway (I assume at least).

#

but I also understand the point of pretty UI 😄

vital mountain
#

yeah its not huge, its just a difference of quality of life, like on components it by default has a monoscript object field on the top of the component so you can click it to automatically open the script for the component. so if i use a label it wont automatically open the script if you click it

#

it would be nice to have, but not by any means a requirement

vapid prism
#

UITK or IMGUI? You can always make the label clickable and manually ping/open the script. At that point it won't really matter if the code for finding the proper mono script is slow

vital mountain
#

the main reason i want it is because the editor philosophy im going with is that designers that knows less programming can more easily debug issues without help from me or other programmers as they might not even know where the interface script even is located. so then they can just click it and get it without worry

vital mountain
#

or at least im pretty sure it does

#

ive done serialized monoscripts like this before but not found by type

#

ok so im just doing this as a utility method

        public static MonoScript FindMonoScriptFromType(Type type)
        {
            MonoScript[] monoScripts = MonoImporter.GetAllRuntimeMonoScripts();
            foreach (MonoScript monoScript in monoScripts)
            {
                if (monoScript.GetClass() == type)
                {
                    return monoScript;
                }
            }

            return null;
        }

then im just caching the result to not constantly search

waxen sandal
#

Since you already know the name, you can just render the name as a thing that looks like an object field, then when the user clicks it, you can do the expensive search bit

vital mountain
#

i suppose i could do that as well to avoid potential lag on opening the inspector for it if that where to happen

nova seal
#

Heya I'm new and I wanted to know how to make these and how to make stuff like a button that adds and object to the scene or a thing where I can drag from one point to another and it uses that to make position and scale an object?

nova seal
#

ok

stark geyser
worldly crag
waxen siren
#

when we add certain new element in an inspector, the next element will somehow inherit the previous element right?

#

how can we stop this from happening?

waxen sandal
#

You don't

waxen siren
#

unsafe level

#

i think i just be careful lol

waxen siren
#

apparently its not something i should do

halcyon berry
queen wharf
#

Does anyone know why the Terrain inspector does this? Just curious what issue they are solving by having to exclusively use 1 inspector view for it

surreal girder
queen wharf
#

Hey @visual stag, Using your SerializeReference Dropdown package which has been super helpful but I had a suggestion/piece of feedback and was just curious where you would prefer me to send that 😄

#

(And if your not interested in considering feedback/suggestions that's totally cool too)

visual stag
queen wharf
#

Extremely valid, For the most part it's more than enough for what I need

#

My nitpick was just in regards to how they are presented when in a list, with the doubling up of the element header and the toggle expansion arrow outside of the scope of the background and/or present at all

dusky pumice
#

Hi there, is anyone aware of an existing addon that would allow to select GO from the Game View the way ctrl+left click works in the scene view now ? It's really a pain to go back to scene view and try to select the GO you want.

dusky pumice
#

Aligning the Scene View with the main camera actually goes a long way.

crimson cobalt
#

trying to dabble with a custom editor for a script i'm writing.

I want - purely for editor niceties - to be able to check a toggle and consequently set the Condition foldout to be (in)visible.

I can't seem to figure out how to make the Toggle value persist at an Editor level, without abusing something like EditorPrefs or SessionState, both of which would be pretty terrible solutions anyway.

#

I guess I could load it from the conditionSource serialized state maybe? but that too feels kind of dumb.

vapid prism
atomic sable
#

Hey guys, would this chat be the appropriate place to get help with a roslyn analyzer not working? It seems to be working, but it just... wont analyze the contents of my script files at all, only seemingly packages and dlls. Maybe it's related to unity somehow preventing their contents from being read or something? But if that's the case, how am I suppose to pass anything into the analyzer dll?

sick shell
#

Editor Collider Drawer
Tools - > Collider Drawer
Put empty object in patent, set height etc..
And click Draw Mode
https://pastecode.dev/s/0mvos0il

violet zephyr
#

In an EditorWindow class, why does the label never get drawn, Ive logged the event to confirm it gets called, so I know the diagram is being set here

I'm trying to draw the label for my "diagram",

  void OnEnable() {
    events = VoroEvents.GetInstance();
    events.OnDiagramCreatedEvent += OnDiagramCreated;
    // this method sets this.diagram = diagram;
  }

  void CreateGUI() {
    rootVisualElement.Clear();
    if (diagram != null) {
      var label = new Label($"Diagram: {diagram.name}");
      rootVisualElement.Add(label);
    }
  }```
gusty mortar
violet zephyr
#

I tried OnGUI, its got the same issue. Do neither of them update? Once Diagram exists I would have expected the label to be drawn

gusty mortar
#

CreateGUI is called once, so no, it won't update

#

If you try OnGUI while CreateGUI is still defined, it won't be called

#

You can define Update to set your label's text if it exists

violet zephyr
#

Ah, thats simple enough, thanks

humble kernel
#
foreach (var go in Selection.gameObjects)
        {
            if (!go.TryGetComponent<TMP_InputField>(out var oldComp)) continue;
            if (oldComp is TMP_InputFieldExtensions) continue;

            var newComp = go.AddComponent<TMP_InputFieldExtensions>();
            newComp.CopyFromInputFieldContext(oldComp);

            Object.DestroyImmediate(oldComp, true);

            EditorUtility.SetDirty(go);
            EditorUtility.SetDirty(newComp);
        }
#

i dont understand, what is the error here, why does newComp.CopyFromInputFieldContext(oldComp); give NullReferenceException: Object reference not set to an instance of an object

safe sorrel
#

what line is the stack trace pointing to?

#

it may be inside the CopyFromInputFieldContext method

humble kernel
#

i am very very very sure

safe sorrel
#

you'd only get that exception from that line if newComp was null

humble kernel
safe sorrel
#

double clicking on the log entry sometimes takes you to an earlier point in the stack trace

safe sorrel
#

is TMP_InputFieldExtensions your own class?

humble kernel
#

exact same code

humble kernel
safe sorrel
#

ah

#

you aren't allowed to attach multiple selectable components to a single object at once

#

Selectable has the DisallowMultipleComponent attribute on it

humble kernel
#

ah so even in that ms

#

so what can i do

safe sorrel
#

this is an annoying problem, because you can't easily move a component from one object to another

safe sorrel
#

maybe you can:

  • create a new game object
  • put your TMP_InputFieldExtensions component on it
  • copy from the existing input field
  • destroy the existing input field
  • replace it with your TMP_InputFieldExtensions component
  • copy into that component (you'd need to write code to do this)
  • destroy the new game object

it sounds awkward

#

Depending on how complex CopyFromInputFieldContext is, perhaps you could just extract all the data you need, destroy the input field, and add your component

#

(and then give it that data)

humble kernel
humble kernel
#

but could i do something like TMP_InputField and just save that into memory yk and then delete that component but still have TMP_InputField and then put it into new component

safe sorrel
#

There is one other possibility.

If TMP_InputFieldExtensions inherits from TMP_InputField, and all you're doing is copying stuff from the existing input field, you could just switch the existing component's MonoScript

#

so that Unity thinks it was your own class all along

humble kernel
#

ive never heard of monoScript, or maybe i did but just dont know

#

also yes it does inherit

safe sorrel
#
using UnityEditor;
using UnityEngine;

public class Foo : MonoBehaviour
{
    public int one;
    
    [ContextMenu("Replace With Bar")]
    void Replace()
    {
        var so = new SerializedObject(this);
        var script = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/Bar.cs");
        so.FindProperty("m_Script").objectReferenceValue = script;
        so.ApplyModifiedProperties();
    }
}

and

public class Bar : Foo
{
    public int two;
}
#

this seems to work correctly

#

if you look at a prefab in a text editor, each component will look something like this

#
--- !u!114 &1627357011001225765
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2418218989092051171}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 2db2d64783c04e68b663f65ab4186bc6, type: 3}
  m_Name: 
  m_EditorClassIdentifier: 
  one: 123
  two: 0
#

all we're doing here is swapping out that m_Script reference

#

I'm a bit concerned how this will behave for stuff that executes in edit mode (like all Selectable components do)

humble kernel
#

or is so.ApplyModifiedProperties(); enough

safe sorrel
#

As long as you’re only using SerializedObject and SerializedProperty, everything gets handled by that ApplyModifiedProperties call

#

(including for prefab instances)

humble kernel
# safe sorrel As long as you’re only using SerializedObject and SerializedProperty, everything...
foreach (var go in Selection.gameObjects)
        {
            if (!go.TryGetComponent<TMP_InputField>(out var oldComp)) continue;
            if (oldComp is TMP_InputFieldExtensions) continue;
            var so = new SerializedObject(oldComp);
            var script = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/Menu/Scripts/UI_Extensions/TMP_InputFieldExtensions.cs");
            so.FindProperty("m_Script").objectReferenceValue = script;
            so.ApplyModifiedProperties();
        }

so based on my script i do this then?

safe sorrel
#

That looks correct.

humble kernel
#

okay let me see, hope everything works

humble kernel
# safe sorrel That looks correct.

Yay it worked, one question tho, is there any call that would work when i do that? or should i just call it manually?

i used to have this

protected override void Reset()
    {
        base.Reset();
        SummonData();
    }
humble kernel
#

but now it doesnt get called

safe sorrel
#

In this case, you'll actually need to search for components again

#

I'm not entirely sure what happens to the existing C# objects when you change the script that is referenced by a component, actually

#

I'd expect Unity to mark the objects as destroyed

#

I dunno if there would be a good way to find the exact components that you just swapped from InputField to InputFieldExtensions

#

See what happens if you try go.TryGetComponent<TMP_InputFieldExtensions>() immediately after applying the property modifications

humble kernel
safe sorrel
#

Yeah.

#

I can find out, actually

#

yep

#
    void Replace()
    {
        var so = new SerializedObject(this);
        var script = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/Bar.cs");
        so.FindProperty("m_Script").objectReferenceValue = script;
        so.ApplyModifiedProperties();

        Debug.Log(this);
    }
#

this logs null

#

If a Unity object is destroyed, it will show up as null when you call ToString() on it, and it will also compare equal to null

#

and if I do GetComponent<Foo>(), Unity complains that I'm trying to get a destroyed component.

#

oh, right!

#

that's because I'm really doing this.GetComponent<Foo>()

#

where this is like your oldComp object

#

that is, indeed, now destroyed

humble kernel
#

ah

#

i see

#

i thought the whole thing actually destroys from existence

#

i understand

safe sorrel
#
    void Replace()
    {
        GameObject self = gameObject;
        
        var so = new SerializedObject(this);
        var script = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/Bar.cs");
        so.FindProperty("m_Script").objectReferenceValue = script;
        so.ApplyModifiedProperties();

        Debug.Log(self.GetComponent<Foo>());
    }
#

This works correctly

#

You don't have to save self in your case, because you already have the GameObject reference

safe sorrel
#

it doesn't; Unity just refuses to let you do anything with it (anything that involves Unity, at least)

humble kernel
#

tbh scared me since i saved scene but its still there

safe sorrel
#

so, after applying the modified properties, call go.GetComponent<TMP_InputFieldExtensions>() and do whatever setup you need to

#

all of the serialized properties from TMP_InputField are kept, and anything that referenced it still has a valid reference

#

that's neat; I haven't actually done that before

humble kernel
#

okay i see

#

thank you

#

sorry i was a little bit busy at the moment but yeah i understand

#

thanks

safe sorrel
#

no problem!

neat zenith
#

im not sure if this is the right channel but can someone please help

real spindle
safe sorrel
#

It's running into an error when trying to check the last-modified time of a file

atomic sable
safe sorrel
#

the only penalty here is that garbage collection takes slightly longer than usual

#

I would expect for huge amounts of reflection to be happening in the editor no matter what

#

so I doubt your own code matters there

onyx nova
#

There is a package that I made by following a YouTube Tutorial. It works great with 6.0 lts but yesterday when I imported that same package in newer 6.3 lts this package didn't worked. I fixed the issues with deprecated methods and after that the Scene Hierarchy window still didn't updated the Default Scene GameObject icons.

Please suggest me the potential fixes that might work and I'll implement them in the package as this made such a difference in Hierarchy window compared to default experience.

Here is the link to the package https://github.com/blackmagezeraf/Improved-Scene-Hierarchy and this is the video I used to create this package https://www.youtube.com/watch?v=EFh7tniBqkk

GitHub

Shows the icon of the first component in hierarchy of the scene window. Improves visibility for your gameobjects in the scene hierarchy window. - blackmagezeraf/Improved-Scene-Hierarchy

Take the Unity hierarchy to the next level and no longer have to view those boring boxes. With this tutorial we will improve the hierarchy 100% with relevant contextual icons for each game object!

🏪 Check out my new Unity Asset Store page
https://assetstore.unity.com/packages/tools/utilities/scene-view-bookmark-tool-244521?aid=1101liVpX

...

▶ Play video
waxen sandal
#

No one is going to download you package, try it out, figure out what the issues are, then tell you how to fix them

#

If you post actual errors or issues, maybe someone will answer

onyx nova
#

Scene Hierarchy Editor Script Written in Unity 6 LTS doesn't work in Unity 6.3 LTS

vocal tartan
#

is there a way to remove / hide / group existing items in these menus that are built in the unity editor?

dusky pumice
dusky pumice
#

It won't work this way. Unity has an intermediate class type in memory ...

gloomy chasm
vocal tartan
# gloomy chasm Nope.. well yes, but takes *heavy* reflection usage

I'm considering to start digging, definitely possible with reflection, this menu is such a mess, I could be much more productive if Unity would just let us edit, add and remove menu items.
even if it means going to project settings and ticking a box "DANGEROUS, Only do this if you know what you are doing!" it would be massive

gloomy chasm
vocal tartan
#

this screenshot is from Unity 6.x, some of this stuff are from packages and my own,
in general it would just be awesome if we could reorginize this menu

twin prism
#

hi, just wanted to ask is there any AI extension out there which can do stuffs like takes blueprints and create a full graybox style level with the help of the probuilder?

gloomy chasm
vocal tartan
meager compass
#

My friend asked me to make a tool that would let him paste GameObjects from 1 project to other
I know it stupid, but in our use case all we need are the values themself, not references (like int, vector, float)
so i wrote this tool, that serializes objects/components into binary data and then saves it on disk, what do you think?
(It is not finished, but base functionality works, it doesnt deserialize some types and wasnt tested with anything other than MeshRenderer/Filter and BoxCollider)

#

And no in our use case prefabs dont work either

twin prism
#

@gloomy chasm @vocal tartan thanks for the replies, I'm talking about a tool that can do this for example ( i have 1 house model with all rooms define with their region and wall data) so in promt I would type: please add 1 light lamb with stand in my bedroom so, AI agent would automatically go through my assets and place light lamb in my bedroom without me doing that manually.

and also if i type i need 2 stories house with a basement and vent system that would make house without me giving him any scaling, position, rotation data .

vocal tartan
meager compass
#

Ive never heard of it, in our case we need to port some data from 1 project to other, not sync and stuff

vocal tartan
# twin prism <@131292153300123648> <@278164575705104384> thanks for the replies, I'm talking...

that's very difficult if you are talking "generally" because the ai can't know where is the bedroom, or where inside it to place the light lamb.
it would need to:

  • find bedroom in scene
  • check it's dimensions, see if there are any objects inside
  • look for a fitting place via your description, verify no obstacles or colliding with anything
  • find the asset, place it in desired location

it's not an easy process, definitely possible with today's technology, I don't think anyone other than roblox or muse have tried this.
the second and third tasks here are what you should be looking for, but it could take a while for such a tool to release, and if you do find one please let me know, it would be game changer. (pun intended)

vocal tartan
#

you can export to Unity package and import on the other project

meager compass
#

yes, one way, once

vocal tartan
meager compass
# vocal tartan you can export to Unity package and import on the other project

this does NOT work in our case

or it did work, but after importing we had to manualy process some data to make it work, even simple stuff like scripts not setting due to guid being different

all my friend asked me was "can you make it that i can just copy and paste it from there" because importing, or manualy porting prefab file, is just taking too long when you need to port some kind of prefab that contains 1 script with bunch of data

#

Again we arent porting giant assets or something

We have a specific case where we need to port bunch of data from different project versions into one, that have identical script types but different guids

vocal tartan
#

new editor script to copy files sounds overkill...
have you tried manually copying and pasting them?
I read the script you posted, you don't touch any guid in there.
but you do try to convert some values,

is the issue that you have scripts which in the editor you assigned values, and you are trying to move the scripts to a different project with those values saved?

meager compass
#

Im not touching guids because im saving raw C# types

vocal tartan
#

ctrl+c / v of the file in the project tab?

meager compass
#

and manualy taking file trough explorer breaks references to scripts

vocal tartan
#

did you try opening the folder in the pc file manager and moving from there?

#

what do you mean by references

#

oh, I understand

#

you also need to move the .meta files.

#

they contain the references

meager compass
#

okay so

#

let me explain

#

all scripts

#

are stored as guids

#

right

vocal tartan
#

yes

meager compass
#

issue being

#

we have 2 identical code bases
with compleatly different guids

#

and different content/configs

#

so moving configs/prefabs from 1 version does not work

#

we have to manualy open the file and change guids on components

vocal tartan
#

that shouldn't matter, it should move without an issue.
what exactly happens after you move?

#

if you manually open it and change guids, does it fix the issue?

meager compass
#

yes

#

i told you

vocal tartan
#

what happens after you move the file

meager compass
#

we have different guids on components

vocal tartan
#

no, I mean what do you see in the editor

#

missing reference in the components?

meager compass
#

Warning saying that script doesnt exist in inspector

#

and that prefab cannot be saved because there is missing scripts

#

again

#

due to GUIDS being different

#

my solution simply:
made progress 15-35% faster by not having to move file manualy or export/import packages (now its just press of 2 buttons)
and relying on types instead of guids

vocal tartan
#

still, the meta files of the scripts/prefabs which has components that contain "broken references to scripts" should hold the guids of the correct reference scripts.
could it be you did not move all files at once but one by one?

usually it should be done via closing the second unity editor (sometimes Unity can change the guids of scripts without meta files if they are open)
move all files at once, with their meta files, then open unity again and let it reorginize

I would love if you can send me (here of via dm) an example of 2 files that when you share it to the other project, their reference break. I can test it on my pc

meager compass
# vocal tartan still, the meta files of the scripts/prefabs which has components that contain "...

im gonna explain the progress

A - Main Codebase
B - Second Codebase
C - Third Codebase

A is our main working project.

B and C are DECOMPILED versions of same project but on different versions.

So, A has identical scripts to B and C.

only issue being A, B and C dont share ANY of guids because, well, 2 of them are decompiled.

We port some content that was exclusively on B or C to our main codebase.
Most of it are configs in prefabs with 1/2 components.

But when we port content, well, it breaks due to script guids being different.
so we have to fix it.

Import/Export of package and manualy moving the file, gives same broken result, AND takes a while to do.

Solution?
A tool that relies on TYPES, that lets us port triggers, particles, AND our custom scripts to our main codebase, in matter of 2 clicks.

Why not to make script that ports them manualy?
Because we often add content that was just stripped from our main codebase, so we'd have to update our tool every time we do that, AND we'd still have to combine broken output and normal output, because of collision triggers and particles, that just makes process longer, when the initial issue was that it wad taking too long.

How did we lose code for versions?

Its simple, we never had it im the first place.

vocal tartan
safe sorrel
#

is there a reason you can't just fix the GUIDs of your script assets?

#

serializing type names, not MonoScript GUIDs, is what [SerializeReference] fields are doing, but I'm not aware of any way to do that for components

#

you could absolutely write a tool that serializes type names for each component and then rewrites assets to point at the correct MonoScript GUIDs, I guess

naive holly
#

is there a way to get rid of these UnitySerializedField labels or move them to like a sidebar or something, but keep the Unity Message labels? I mostly like codelens but having those in between all my variables really clogs up that part of my code

karmic basin
#

I'm trying to use the new MainToolbar API to add a slider, but if the minValue is greater than zero, then the slider is giving me an error and it's failed to load. Is that okay or is it a bug?

[MainToolbarElement("Surge Engine/FPS Limit", defaultDockPosition = MainToolbarDockPosition.Left)]
public static MainToolbarElement FrameRateSlider()
{
    var content = new MainToolbarContent("Frame Rate Limit");
    return new MainToolbarSlider(content, Application.targetFrameRate, 1, 3, OnSliderValueChanged);
}
gloomy chasm
#

I would restart Unity and if that doesn't fix it then report as a bug

karmic basin
#

I will report it

atomic sable
#

Hey, using a roslyn analyzer how do I stop unity from compiling? I report the diagnostic as an error but unity still compiles.

#

Additionally I don't see any of the warnings in the unity console, contrary to what the documentation says should happen

#

Rider loads my analyzer just fine however. When I follow the documentation to add the analyzers from the package linked, those work as well. Why would my analyzer load into rider but not work with unity?

waxen sandal
atomic sable
#

I just downgraded the version

shadow violet
#

Is there any way to force a script to use specific line endings? More specifically, I am making a editor that will update the namespaces of all scripts in a folder selection, it works fine but opening the scripts again has VS say "inconsistent line endings" because I modified the script with IO - is there a proper way to do this?

atomic sable
bright jackal
#

I want to add vs code as an external editor but the option is not there
I tried to add it as tool path but that did nothing

#

(Unity ver 6000.2.13f1)

halcyon berry
#

Did you do Open by File extension and select the editor?

bright jackal
#

Thank you that was it

safe sorrel
#

"Open by file extension" is used if you want to use an editor that has no special Unity integration, yeah

shadow violet
# atomic sable how are you editing the namespace?

Currently, I use StreamReader split by \n, for a line starting with "namespace", and replace it with my desired namespace in a StreamWriter, then call AssetDatabase to save/refresh, is there a better approach for this?

atomic sable
#

I think by default the scripts would be encoded with UTF-8 BOM and not UTF-8 (what the stream writer would use) but im not really sure what the practical difference is or if it would cause issues

shadow violet
#

Hmm, both seem to give the same line endings issue, though wouldnt the split return empty if the line endings are different and im specifically splitting by \n but the file is using something like Environment.NewLine?

shadow violet
atomic sable
shadow violet
surreal girder
#

im sure you have seen your ide warn you sometime about inconsistent line endings

shadow violet
surreal girder
#

There is no guarantee a file uses the line endings from the OS

#

I think git can even change them when it modifies files

shadow violet
#

Ah I see, so it sounds like ill have to change every line to Environments version and not just the namespace line

atomic sable
#

Nah just use \r. I have my ide set to crlf which would be \r\f

#

Im not sure why yours is using \r for some reason, but all this is a bit out of my scope of knowledge

surreal girder
#

You can use whatever the file already uses as no ide or compiler will mind

latent pewter
#

Not sure if this is the right place but does anyone know how to bypass the "Enable Output Suspension" in the audio section of the project settings? Like how to I wake up the output from being suspended?

I'd like to keep it enabled but after being away for a bit, some edit mode audio systems I made dont play because of this. The only way to get it back is to toggle the scene window audio mute button off, then on again OR enter and exit play mode.

viscid burrow
#

Could someone help me?

nova seal
#

hey, how can I make a script that will spawn a prefab where the mouse is touching (at z=0) (in the editor ofc)

surreal girder
#

You may need to set the scene as dirty after I'm not fully sure

safe sorrel
surreal girder
safe sorrel
#

that is necessary if you do things "behind unity's back" – like modifying random C# objects instead of using SerializedObject/SerializedProperty

surreal girder
#

yea thats true, undo records will do that for us

#

otherwise we have to set dirty and perhaps update prefab instances to detect overrides

safe sorrel
#

yeah, all of that is necessary if you don't go through SerializedProperty

safe sorrel
#

Does resetting your layout do anything?

#

top right corner of the editor

#

you'll probably still need to restart the editro after doing that

#

This can help if you get..."evil" windows

blissful sky
#

Hello! I am having an issue with Unity Search, I need to tweak some indices, and according to related article, you can open index management window by clicking Windows -> Search -> Index Management, but this opens completely different window in preferences, so what do I do?

safe sorrel
#

what editor vesrion are you using?

blissful sky
#

6000.3.1f1

#

documentation for 6.3

blissful sky
safe sorrel
#

I'm having issues with undo operations where I:

  • instantiate a prefab with PrefabUtility.InstantiatePrefab and then record its creation using Undo.RegisterCreatedObjectUndo
  • use Undo.AddComponent to attach a component to one of the prefab's child gameobjects

Undoing will delete the component, but the instantiated prefab remains.

#

If I add a component "normally" (so, by calling AddComponent() on the target object), it behaves properly when I undo

#

(but this feels wrong)

#

and it's possible I'll be adding components to an object that was not created as part of the same operation, so I definitely need the undo system to be aware of the new component

#

Oh, one important thing: I'm calling RegisterCreatedObjectUndo after adding the component

#

the code does this:

  • instantiate the prefab
  • run a bunch of setup actions on the prefab
    • if they all succeeded, tell the Undo system about the object
    • otherwise, destroy the object
#

I believe I had to do this to stop the undo stack from filling up

#

in some situations, I spam tons of prefabs and reject most of them

#

yep, that was it

#

that's annoying! it's a catch-22

#

it makes sense, though

#

I guess that the undo system decides that the object I'm adding a component to (and its parents) already existed

#

and then the subsequent RegisterCreatedObjectUndo does nothing

surreal girder
#

Sounds like it's working as intended

torpid warren
#

So I recently upgraded my editor for my game from Unity 2019 to 2022. After this whenever I try to bake lighting it gives me this error: "[PathTracer] Failed to add geometry for mesh 'pb_Mesh75492'; mesh contains non-finite values. Affected channel(s): TexCoord0." And the baking stays at 1%. Strange thing is, when I try baking it on the 2019 version(I duplicated the game with two versions) it bakes the lighting just fine. Idk if the error messages are linked or what, but I mentioned it nonetheless because the error also doesn't appear in the 2019 version

#

Did Unity made some changes to their lighting from 2019 to 2022? Also, I am using the Built-in renderpipeline

safe sorrel
#

I'd try reimporting the relevant asset (or just doing Assets > Reimport All if you're unsure)

#

a mesh has invalid UV coordinates in it

#

it's possible that something changed about how unity:

  • imports the mesh in the first place
  • interprets the mesh data when baking lightmaps

which is causing this to come up

torpid warren
safe sorrel
#

Can you locate a mesh asset with that name?

#

you can search the project window for t:mesh pb_Mesh75492

torpid warren
safe sorrel
#

oh, I bet that's a probuilder mesh

torpid warren
#

it is

safe sorrel
#

it will be more annoying to find the mesh in the scene

torpid warren
#

Also, when I click on the error it gives me a preview of the mesh and I KNOW the exact model from where its from but when I click on it it says in the inspector window that it contains a different probuilder mesh

#

ok, update, I found the object belonging to said Mesh and upon deleting it it had no change

#

nvm, another update; I found all the objects with meshes like that and I deleted them all, after that it baked everything just fine

torpid warren
#

also, if it helps, I used Probuilder's Experimental boolean tool to make those models

safe sorrel
#

I wouldn't be surprised if those sometimes generated bad data

#

I am unclear why it wasn't an issue in 2019, though

#

(unless the version change broke the existing data)

karmic basin
#

Hi. Is it possible to enable the new toolbar extensions introduced in Unity 6.3 per-project? I have a repository with a framework-like project and I have some very useful tools in the toolbar, but when importing, they're not enabled by default

lean fjord
#

Hello. Is there a way to change the position of an object in hierarchy window in the editor by a script?

clear kite
#

That only works for child objects. Can't remember how the roots are ordered

surreal girder
#

I will presume that this works even for top level objects

unreal light
#

I'm in an odd situation with a migration tool i'm working on currently.

The migration tool is moving all the data from one Scriptable Object type, to Another. (the former being the old and the latter being the new version)

I am not using SerializedObject for this process as the abstraction from working with the ScrobjC# instance would make it considerably more difficult.

While i have the process down, for some reason, none of the changes i'm doing to both objects get saved to disk, doesnt matter if i hit File/SaveProject. The only moment where it does decide to save is if i go out of my way to change a random field on the ScriptableObject itself.

Whenever i finish the migration process, i am doing an EditorUtil.SetDirty(), followed by an AssetDatabase.SaveAssetIfDirty(), i'm baffled as to why the changes are not being saved at all by the editor, i thought those two methods would ensure that things are being saved?

#

Also tried to wrap both assets into a SerializedObject, modify their C# representation and then use SerializedObject methods, but this also didnt write changes to disk

surreal girder
#

as long as the asset is dirtied and saved after modification that should work just fine. Are you dirtying the asset object or some field by accident?

unreal light
#

for what its worth, i do get both from Lists of the Wizard itself. I have a button on it that lets me search the project for the asset types, saves them on a list then when ran it iterates thru them

surreal girder
#

btw its EditorUtility.SetDirty() not EditorUtil

#

no idea where thats from

#

where the ref is from should not matter as long as its for a real asset

unreal light
#

AH

#

damn

#

ok yeah that would explain it

#

nice catch :$

#

i'll have to check what's it from, thanks

gloomy chasm
lucid dome
#

Hi guys. I'm kinda new to VFX Graph.

I need to make changes to many VFX Graph Asset which can get tedious. Can I make an editor tool to programatically edit the VFX graph?

Basically I just need to apply a Set Position via Graphics Buffer.

dusk dome
#

I've got an editor window and I want to try and display this enum, but when I load it in this happens. The only way it fixes is if I enter the UI builder sheet, open it and mess with it and then exit, and reload the window.

#

Is there no way to fix this?

celest sundial
#

I'm working on an EditorWindow for Unity 6000.3 LTS and am running into many API changes for the MultiColumnListView between versions. As much as I want to be one of the cool kids and use UIToolkit for my asset, how restricting will I be making my asset if I do this? Will it turn into preprocessor spaghetti to handle a bunch of different versions for this control (and others)? The bindings is the main culprit I'm finding here where it just keeps changing

I'm seeing a bunch of examples from multiple other assets out there just straight up using GUILayout stuff which goes way back to 2019 for compatibility but I am riding the struggle bus for nice new UI features

plucky mason
#

(Opus 4.5)

#

For example, it just turned my simple array into this pokedex viewer

dusty pineBOT
#

success @zen3773 muted

Reason: Sending too many attachments.
Duration: 29 minutes and 40 seconds

plucky mason
#

It’s even better at refactoring for api

#

I am sad that I spent $240,000 on a computer science degree but AI is just too good

#

Happy new years!

real ivy
#

Hi. I'm using odin and wanna let odin handle the inspector drawing of things
I want it to handle some classes from some unity asset that already has custom editor for those classes (i just ref search the attribute [CustomEditor(typeof(Abc), true)]

But if i simply comment these out, then i can't ref search them again. Is there a way to disable custom editor of these and still leave the attribute there?

gloomy chasm
real ivy
#

If i do that then some override methods will fail

real spindle
real ivy
#

Yea i can i guess

#

Oh wait, if i do that, then this custom editor will still takeover the drawing for the class' inspector

#

I guess there's no other way than commenting out the CustomEditor attribute..

real spindle
#

But if you do what MechWarrior said it shouldn't do that, no?

#

In any case I dont' see it as a big issue since you can always just text search "CustomEditor"

real ivy
real ivy
#

The better mindset to have is to just comment it out and don't look back

real spindle
#

I meant doing both what I and MeshWarrior suggested

lean crystal
#

In the new graph toolkit, is it not possible to add a maximum number of connections that a port can have?

Here's my code right now:

[Serializable]
    public class VisualElementNode : Node
    {
        protected override void OnDefineOptions(IOptionDefinitionContext context)
        {
            context.AddOption<string>("Visual Element Name").Build();
        }

        protected override void OnDefinePorts(IPortDefinitionContext context)
        {
            context.AddInputPort("Input").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
            context.AddOutputPort("Up").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
            context.AddOutputPort("Down").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
            context.AddOutputPort("Left").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
            context.AddOutputPort("Right").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
        }
    }

I can't find anything in the api reference and every AI suggests stuff that just doesn't exist, even the Unity AI

stable nebula
dusk dome
#

I've got an editor window and I want to try and display this enum, but when I load it in this happens. The only way it fixes is if I enter the UI builder sheet, open it and mess with it and then exit, and reload the window. Is there no way to fix this?

lean crystal
dusk dome
#

i fixed it though so dw about it

violet zephyr
#
[ExecuteAlways]
public class TileGrid : MonoBehaviour {
  [SerializeField] AreaGrid area;
  [SerializeField] List<WorldTile> tiles = new();

  static float GridSize => TileSettings.TileSize;

  public void SetArea(AreaGrid worldArea) {
    area = worldArea;
    area.Changed += OnAreaChanged;
    CreateGrid();
  }

  void OnAreaChanged(AreaGrid area) {
    this.area = area;
    tiles.Clear();
    foreach (Transform child in transform) {
      DestroyImmediate(child.gameObject);
    }
    CreateGrid();
  }
  
  void CreateGrid() {...} // creates grid of the WorldTile GameObjects
}```I'm calling `OnAreaChanged` as a way to regenerate all the tile objects when I move the map around. Although I have the ExecuteAlways attribute, those objects are only destroyed when I actually interact with the GameObject. You can see in the video that if I stop moving before some outside tiles are cleared, they remain in the scene, only after I start moving again do the tiles clear.

I was expecting OnAreaChanged to destroy every single WorldTile, then recreate them. I'm not really sure why it only partially destroys the instances and takes multiple calls to actually get rid of all of them.
gloomy chasm
#

I would also suggest seeing if there is another approach that might work since instantiating and destroying Unity objects like that each frame is pretty slow (might be that is just the best way, but thought I would mention it)

stable nebula
#

Hi, long shot and I probably know the answer, but is anyone aware of a package for making node-based editors (i.e. ShaderGraph etc.) other than xNode and NodeGraphProcessor and Unity's new Graph Toolkit?
Hard requirements are a permissive license (i.e. MIT) and more built-in functionality than just GraphView (because then I would just use that). Preferably built on UI Toolkit and at least somewhat actively maintained (that's the main thing holding me off NodeGraphProcessor).

mild sentinel
#

As a part of our builds we process scenes, as a part of this process GameObjects gets removed. Now the problem is that these removed GameObjects & their contents can be referenced elsewhere, and so what happens is that they get missing references. I want to clean up all these missing references & set them to null instead. I've been trying to find something already among the editor classes but haven't been able to spot much. I can use reflection to go over every member in every script, but that's really heavy & requires a lot of special considerations.

gloomy chasm
mild sentinel
dusky pumice
#

Hello there, are there any built in hierarchy remote debugger now in unity 6.3 ? Something like the frame debugger but for acessing the hierarchy.

waxen sandal
#

Not built-in at least

jagged stratus
#

Hello. I have a problem with the editor. Currently I'm using the lastest editor version 6000.3.2f1
For some reason. Each time I save a script or end a run of the game. the asset menu throw me to a random file. Each time I close the editor and open it again. it throws me to another random file when I save a script/end a run

#

currently it throws me to Curve edit utility

#

yesterday it was throwing me to whatever this file is. The day before it was throwing me to a random material

#

it is annoying. having to go back to the asset folder after each run or script editing

frigid dove
#

I'm currently making a level editor, and trying to implement fields that can be edited using an in-game level editor (through UI).
This includes certain editor fields that only appear when another field is set to a specific value.
(For example, the float field "Homing Speed" should appear only when the bool field "Homing" is set to true (Enabled))
How would I implement this kind of field, and the "condition"?

This is the current implementation I have:

public class EditorField
{
    public string name;
    public System.Type type; // this is used to define what type of UI element will be used for the field (radio button, text field, etc.)
    public List<Condition> conditions; // every condition within this list must be met for the EditorField to appear, altho idk if i'll ever use more than two conditions at the same time, just made a list out of habit
    public object value; 

    public EditorField(string name, System.Type type, List<Condition> conditions)
    {
        this.name = name;
        this.type = type;
        this.conditions = conditions;
    }
}

public class Condition // faulty implementation, included as proof of concept
{
    public object field; // the field whose value must be checked, I don't know if this works for value-type variables, probably doesn't
    public object value; // the value the field must have in order for the associated EditorField to appear, should probably be expanded to a list to allow for multiple values when dealing with enums
}```
#

The aim is something like this:

public class DebugTextEditorEvent : EditorEvent
{
    public EditorField text = new EditorField("Text", typeof(string), new List<Condition>());
    public EditorField special = new EditorField("Is Special", typeof(bool), new List<Condition>());
    public EditorField textType = new EditorField("TextType", typeof(DebugTextType), new List<Condition> { //DebugTextType is an enum, will be mapped to a dropdown
        new Condition(this.special.value, false)
    }); // intended result: the "textType" field only appears when "special" is true, obviously this results in a compile error in reality

    public DebugTextEditorEvent()
    {
        fields = new List<EditorField> // this will be used by the UI drawing script to draw the associated fields
        {
            text, special, textType // these three fields will be drawn in the editor
        };
    }
}```
frigid dove
#

(I'm also thinking of using GetFields() in the UI script instead of using the "EditorField" class, but I don't know how I would define the conditions in that case)

surreal girder
#

Naughty attributes is open source so you can see how they do it

frigid dove
#

For some reason, the field number of the 'events' (the green and white objects) are not counted correctly

The events are defined through an EditorEvent class. The white event (Empty) uses the base EditorEvent class, while the green event (Debug Text) uses a subclass derived from EditorEvent.
Here, the Debug Text events have 6 fields, while the Empty ones have 3 fields.

When I place and select a Debug Text event, there are 6 fields detected as intended.
However, as soon as I place an Empty event, all events are said to have 3 fields.

Deleting the Empty event makes it return to intended behavior for the Debug Text events (6 fields)

(See video embed below)

#

~~ Why does this happen, and how can I fix it?~~ solved

#

Relevant code:

    void UpdateWindow()
    {
        switch(EditorTimeline.instance.selectedEvents.Count)
        {
            case 0:
                topBar.SetActive(false);
                break;
            case 1:
                topBar.SetActive(true);
                EditorEvent selectedEvent = EditorTimeline.instance.levelEvents[0].instance.eventReference;
                FieldInfo[] fields = selectedEvent.GetType().GetFields();
                Debug.Log(fields.Length.ToString() + " fields found");
                break;
            default: //not yet implemented
                topBar.SetActive(true);
                break;
        }
    }

    private void OnEnable()
    {
        EditorTimeline.selectionUpdated += UpdateWindow;
    }```
dusk dome
#

how can i make a window like this for long migrations for my own tool?

vapid prism
#

How do I set a toggle to mixed state in UI Toolkit?

vapid prism
#

oh it was just called that haha

#

ty

frigid dove
#

how would i generally implement a field that can be edited using not only the field, but also using external methods (in-game)

#

for example, if I have a UI field that determines the position of an object, I would want it to be possible to edit it directly using the field, but also through dragging the object

#

in this case, the field should update automatically while dragging, but it should also stop updating when not (and especially when editing the field itself)

#

another thing to take into account is that the fields aren't always constant; they are removed and created depending on the type of object selected, so it's not possible to pre-assign anything specific before compiling as of now

#

one solution i came up with was updating every (numeric) field when 'something' was being dragged (so updating position, scale and timeline position, etc... whenever any element was being dragged), but that seems somewhat wrong

crystal rover
#

Is there a way to change the font size of [Headers] ??

surreal girder
#

No, would require a custom inspector. I dont think even odin offers this but they have more choice like box group

#

NaughtyAttributes is a free less featured alternative

vapid prism
safe sorrel
#

I'm modifying the object referred to by SerializedProperty.managedReferenceValue, then calling SerializedObject.ApplyModifiedProperties(). However, it looks like my changes are getting lost in some situations (e.g. when I'm in prefab mode).

Do I need to do something to make Unity understand that I've modified the managed reference?

#

maybe i should just assign the object back in

#

hm, nope, that didn't do the trick

#

It works fine if I do this to a prefab instance in a scene

#

the changes show up properly and survive a scene reload (and I can apply them as overrides to the original prefab)

#

however, if I run the same editor script while editing a prefab directly, the changes don't stick

#
        private void SetFeatureGUIDs()
        {
            var so = new SerializedObject(this);

            var prop = so.FindProperty(nameof(features));

            for (var idx = 0; idx < prop.arraySize; ++idx)
            {
                var elem = prop.GetArrayElementAtIndex(idx);

                if (EditorUtility.DisplayDialog("Auto-config",
                        $"Set GUID for feature #{idx}: {elem.managedReferenceValue.GetType().Name}?",
                        "Yes", "No"))
                {
                    var feature = (elem.managedReferenceValue as Feature)!;
                    feature.guid = System.Guid.NewGuid();
                    elem.managedReferenceValue = feature;
                }
            }

            so.ApplyModifiedProperties();
        }
#

it's pretty simple

#

(feature.guid is my own Guid class; it has an implicit conversion from System.Guid)

#

I can certainly work around this by dropping a prefab into a scene, running the script, applying the overrides, and deleting it

#

but there's clearly something wrong here!

#

(unity 6000.2.8f1, if it matters)

#

hmm, that's in the same ballpark

#

I'll bump up to the latest patch release and see if anything changes

safe sorrel
#

interestingly, setting managedReferenceValue to null and then re-assigning the object causes the editor script to not work at all

#

no change happens in the inspector (not even a temporary one)

#

I suppose that's because the C# object that the field is pointing to is no longer the object stored in that feature variable

#

ah!

#

I bet I'm meant to continue to use serialized properties to actually modify the managed reference

#

I'm mutating the C# object, and Unity isn't noticing

#

bingo, that's the issue

gloomy chasm
#

@safe sorrel You most likely need to use PrefabUtility to finalize the changes

safe sorrel
#

it's exactly the same as if I had been mutating C# fields on any other object

#

I guess that assigning to managedReferenceValue is only useful for setting the type

gloomy chasm
surreal girder
safe sorrel
#

now that I'm using SerializedProperty, it's working correctly everywhere

#

i'm just amused by how i had the opposite problem, somehow

surreal girder
#

But im a "just edit the object" kinda guy

safe sorrel
#

it worked only when it was a prefab instance

gloomy chasm
safe sorrel
#

I'll see what happens if I use call RecordPrefab... and edit the managed reference value directly

#

it doesn't make sense for that to help here, since I'm not editing a prefab instance

#

I'd expect to need that and oh, I probably just need Undo.RecordObject, actually

surreal girder
#

What I linked above is for when the current gameobject + components were modified

#

meaning not yet serialized

safe sorrel
#

if I wanted to directly edit the C# object, I mean

#

Yep. Undo.RecordObject makes the script work properly when editing the prefab

surreal girder
#

Speaking of prefabs, the prefab utility functions that let you find out what prefab asset an instance is for fuck up in Prefab stage so thats fun

#

Undo records the state AND marks it as dirty

safe sorrel
#

interestingly, it also works fine on a prefab instance

#

leaving the scene and returning shows that the override stuck

#

(i didn't call RecordPrefabInstancePropertyModifications)

surreal girder
#

Perhaps using Undo is enough. I used to do lots of manual dirtying + prefab record modification stuffs

safe sorrel
#

and undo/redo works correctly

#

Mysterious

#

The documentation is explicit that you must use both methods

surreal girder
#

Fyi naughty attributes button does not do any of this for you but Odin button does have the option to dirty on use

#

Being poor hurts 🙁

safe sorrel
#

go figure

gloomy chasm
safe sorrel
#

I should try that. The problem went away if I made any other change and then saved

#

(i can't save with ctrl+s if unity claims there are no outstanding changes)

#

I'm just surprised that this worked correctly in the scene view

#

I guess that calling ApplyModifiedProperties() dirtied the scene

#

and then, when Unity saved the scene, it noticed the change to the C# objects

safe sorrel
#

it just yells that it "Can't save a Prefab instance" if I pass it the game object itself

#

(that my component is attached to, and that i'm currently viewing in the prefab editor)

#

the object is not part of another prefab

gloomy chasm
#

I am not 100% clear on how Unity handles prefab editing in the editor

safe sorrel
#

I tried using PrefabUtility.GetCorrespondingObjectFromSource with the root object of the prefab, but that gave me null, i'm pretty sure

#

i'll check again later

#

(for now i'm just sticking to SerializedProperty, so this is all irrelevant)

gloomy chasm
surreal girder
#

If you use that in a prefab stage then it gets the base prefab if its a prefab variant, very fucking annoying

safe sorrel
#

ah, that sounds familiar

#

because it's not a prefab in that context

#

it's just a thing in the prefab stage

#

I remember working through this process once before

surreal girder
#

Yea but thankfully you can grab the current prefab stage blah blah if not null if root game object is the same blah blah get asset path

safe sorrel
#

and then you call PrefabUtility.ReticulateSplinesForPrefabOverrideDeluxeWithCheese

surreal girder
#

Sometimes i wish that prefabs were not treated as gameobjects directly but a different asset type to make some of this shit easier

safe sorrel
#

kind of like how scenes are an asset type, right

surreal girder
#

Thats true but only for editor

safe sorrel
#

scenes are so weird

#

are they an asset? yesn't

surreal girder
#

With addressables its atleast possible to kinda serialize a ref to a scene but thats not perfect

low heron
#

how do i get omnisharp to detect my slnx, since unity wont generate me an sln? running arch, using nvim

low heron
#

for now my teammate sending me a generated sln is the way, i couldnt find any other lsp

oak quest
#

Anyone else building tooling extensions? I've built a new snap system where the idea at least is that any tool can utilize it. Gives you full mesh/grid snapping, custom handle positioning, axis constraints ... all the good stuff 🙂 You just hook into it, make use of the simple API and visuals.

I'd love to chat if anyone wants to give it a try!

snow pebble
#

for property drawers is there a default draw inspector function anywhere

crisp rapids
#

So I think that’s what you’d do if you only wanted to add things and not overall change how it’s drawn

snow pebble
#

not sure why

visual stag
snow pebble
#

what do you mean

visual stag
#

I mean to use PropertyField

snow pebble
#

for each of the fields?

#

oh on the property passed in

#

good point 😛 thanks

safe sorrel
#

yeah, create one for every direct child property of the property you're given

#

calling someProp.NextVisible(false) will iterate to the next one you want

spring salmon
barren moat
#

How does Unity know to reimport an asset? Does it save a hash somewhere in /Library?

queen wharf
#

I thought it checked file modification date but could be wrong

barren moat
#

But maybe I guess.

#

Yeah actually, I lie, that would work.

#

I was thinking it wouldn't play with version control, but I think it would? Assuming modified date is changed whenver a file is moved though, or else there could be some edge cases with dragging old files into a project.

#

Anyway, doesn't explain what I'm seeing.

vapid prism
#

what's the weird behaviour you're having?

barren moat
barren moat
vapid prism
barren moat
#

So that can't be the whole solution

#

I definitely see new assets get imported when i close unity, change branch, and reopen the project

vapid prism
#

it very likely just stores the last modified timestamp in Library/ folder and on startup checks all the files. Just reading last modified is very fast as you're not really opening the file

barren moat
#

Yeah, that seems right. Okay i may well have misdiagnosed the issue then. The thing is kind of complex. Because the asset is localised part of its importer's process is modifying the localisation tables. But the upshot of this is that whether the asset needs to be reimported or not is not solely validated by that timestamp.

#

I.e. i can import this file, set all its references to the newly created localisation entries, but then not save the localisation tables.

#

And then it won't resync itself

#

Despite being "wrong"

stable nebula
#

Specifically the SourceAssetDB bit

barren moat
#

Yeah it does have a hash

#

Cool

#

Okay, well i think the idiomatic way to do this is to set the localisation tables as an importer dependency

vapid prism
barren moat
#

I also tried writing a script to force reimport the assets before our loc export, but i couldn't get them to run. They run when you right click reimport, but they fail via script

#

This doesn't trigger my importer for some reason:

AssetDatabase.ImportAsset(guid, ImportAssetOptions.ForceUpdate);

But manually selecting the assets and importing them works

barren moat
barren moat
wet oriole
#

Is this possible to add another tab here? Beside the Assets and Scene

(this menu is the window that pops up when clicking the circle in an object field)

safe sorrel
barren moat
#

I just noticed before

safe sorrel
#

(notably, there is no GUID until an asset is imported for the first time, so that'd be a chicken and egg problem)

#

I mess that up all the time

#

especially since GUIDs are just represented as strings

barren moat
#

Mysteriously

wild edge
barren moat
#

In fact the string is itself a serialised 128 bit integer.

atomic sable
#

Is it possible to move the red to the bottom without affecting the parent menu's location?

#

I want the submenu to look like it does here, but not have analysis hanging down at the bottom.

waxen sandal
#

I think you can technically by manually editing the menu but don't think ther's an easy way

surreal girder
#

<@&502884371011731486> gambling scam thing

trail dawn
#

?ban 1311378926911623220 bot

grave hingeBOT
#

dynoSuccess deepak058196 was banned.

daring glade
#

My build system worked before switching to 6.3, and now I'm getting lots of errors on build such as these:

Type '[glTFast]GLTFast.Jobs.ConvertBoneJointsUInt8ToUInt32Job' has an extra field 'input' of type 'System.Byte*' in the player and thus can't be serialized (expected 'inputByteStride' of type 'System.Int32')

Type '[glTFast]GLTFast.Jobs.ConvertUVsUInt8ToFloatInterleavedNormalizedJob' has an extra field 'input' of type 'System.Byte*' in the player and thus can't be serialized (expected 'outputByteStride' of type 'System.Int32')

Type '[Unity.AI.Assistant.Runtime]Unity.AI.Assistant.Data.AssistantFunctionCall' has an extra field 'CallId' of type 'System.Guid' in the player and thus can't be serialized

Does anyone have any idea why they started happening and what's the possible fix? 👀 There are a few dozen of these, I hand-picked just a few error messages. Most of them seem to point towards internal Unity API's