#↕️┃editor-extensions
1 messages · Page 36 of 1
(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)
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
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
It is, but requires using reflection to access internal classes and methods. They have refactored it a number of times, but you can look for like MenuUtility, MenuItem, MenuCommand or something along those lines and it might get you in the right direction
Thankyou much.. I'll look into that.. (just tinkering anyway)
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
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);
}
}
hmm..I haven't used ShowPopup() before -- I use UnityEditor.PopupWindow.Show to display a PopupWindowContent-derived window
Urgh, nevermind. I had to use Instantiate instead of GetWindow
I've used it before but I feel like I remember it being something very stupid
Ah yeah
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
Yeah. I understood my mistake when I read the example a third time ^^'
I think the best you can do is look at similar editor tools that work and do what they do.
I also always forget when I should call SerializedObject.Update and SerializedObject.ApplyModifiedProperties, and how to ensure it records everything nicely into the undo history.
I still don't really know if I can create a SerializedObject once and hold onto it for a long time
this was prompted by some confusion about how to iterate over serialized properties (i'm writing an editor that handles drawing every property on an object)
It looks like serializedObject.GetIterator() returns the "root" SerializedProperty
I think that's fine, but it's just a snapshot when you create it, and you have to call Update to get any changes that have been made to it.
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?
Hmmm, this is tickling my 'this ain't right' bone...
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)
I'm writing an Editor for this because I want to be able to do this for an entire inspector – previously, I only did it for fields with a [DrawGadgets] property attribute attached
Hence running into this
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
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
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
I thought that is what you said you were doing
thus leading to comedy
i never want to run past the end of the SerializedProperty that I'm given
one thing that has helped is realizing that the YAML layout is exactly what you get when iterating through SerializedProperty objects
I guess I don't really get what you are doing exactly.
Yeah that helps once you realize that. To your original question, it is kind of hard to lay out a clear set of rules since it most ends up feeling like say 'just use the API' haha (this is why I never make tutorials or guides 😛 )
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
- Group A
Rather than all four children being parented directly to Root
i have been pretty well-served by strictly using SerializedProperty and SerializedObject, rather than trying to make changes to C# objects and then asking Unity to pretty-please figure it out
I was getting confused because I was being inconsistent with the original property. Sometimes I would try to draw a PropertyField for it, and sometimes I wouldn't
(the former could cause infinite recursion, which is extra-funny)
to draw a Foo: first, draw a Foo...
Yeah, basically you either want to handle the drawing of a SerializedProperty and all of its children your self, or you want to let it do it via PropertyField, never both.
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
That's what the skipTo variable is for: it fast-forwards to the next direct child of my original property
oh.. yeah that is what the bool parameter is for in the Next method
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)
The easiest thing is to just do
foreach(SerializedProperty child in prop.GetEnumerator())
{
}
Okay, yes, this is working as expected now
I call Next(true) once to enter the first child, then start using Next(false) to step over each child
do you mean foreach (SerializedProperty child in prop) ?
Uhh, yeah
It looks like the enumerator enters child properties
owie
(this is a five-layer nesting)
Huh I was pretty sure it didn't...
this kind of thing
This is already a lot nicer. I don’t need that “end” property anymore
Huh yeah guess it does enter the children https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/SerializedProperty.bindings.cs#L259
er – I should say, I don't need to manually skip over all of the grandchild properties
i still need to check for when I've run off the end of my current property
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));
}
}
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
Yeah, it is annoying that it has to totally take over all inspector drawing for components :/
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 😭
Isn't that what a PropertyAttribute does?
that tells Unity to use a certain property drawer for a specific serialized property
i want to make every instance of Inner1 use the property drawer
[CustomPropertyDrawer(typeof(ExampleAsset.Inner1))]
public class ExampleAssetPropertyDrawers : GadgetPropertyDrawer
{
}
so I have to do this
it's just mildly annoying
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
Right
Does CustomPropertyDrawer have a option for inheriting or is that only editor?
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
Ahh got it. Yeah that is a really rare case, so understandable why they don't realy support it I guess
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"
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
So I'm unclear if this is even a problem
(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
Hi does anyone know if theres an older version of graph tool kit on earlier versions of unity than 6.2
There is not. It most likely would still work on older versions though.
An alternative is to use the 'experimental' Graph system from UIToolkit, but that is more bare bones and just the UI part of it.
How would u install it on older versions
For example 6.0
You can try just adding it by putting in the name of the package, otherwise, you just copy-paste the folder in to the local packages folder of your project
Yeah it says unable to find it by name where would i find the folder without 6.2 install
I was pretty sure it would let you install it by name. But otherwise you would have to have 6.2 installed, so you could add the package to a project.
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
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
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.
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)
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)
Is possible by code get the assemblies in a certain package?
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
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.
youll want to look at some of these i believe https://docs.unity3d.com/6000.2/Documentation/ScriptReference/PrefabUtility.html
Thanks, will take a look
it sounds like you want PrefabUtility.LoadPrefabContents in particular
⚠️ make sure to unload the prefab when you are done otherwise it remains loaded and hidden and unity will moan at you
mmm, I'm not sure how can I filter for assemblies in the search.
I used CompilationPipeline.GetAssemblies, then matched each one with an assembly from AppDomain.CurrentDomain.GetAssemblies and finally filter then with PackageInfo.FindForAssembly(...).packageId.
But I'm not sure how resilient is that.
oh, I didn't realize that FindForAssembly existed, ha
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"
I think this is a valid solution. domain reload resets the managed code state so having things be serialized lets unity save them and restore the values afterwards for you.
otherwise you would need to save things to an asset/file
(or native memory but probably too much effort)
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
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)
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
my unity editor goes black when i run my project
what happens if you reset the current layout?
how it relate with layout
🤷♂️ then dont
no i just curious, i just ask you bro.
btw i am very new in unity, so i do not that much knowledge.
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?
resetting your layout can help if one of the editor windowes is broken
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
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
Tool change
Editor tool
Tool context (Group of editor tools, like the spline editing tools)
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
I think you can use the gizmo used by box colliders? but you would need to set that up
The rect gizmo is for xy so that doesnt work well for you here
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
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)
Very unknown, but they actually are! https://docs.unity3d.com/6000.2/Documentation/ScriptReference/IMGUI.Controls.BoxBoundsHandle.html
Nice one i half remembered something but i wasnt able to locate it
Yeah they have it kind of hidden haha
I had, I just overlooked PositionHandle I mainly know of the class for its DrawFoo methods
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
can you maybe grab them off the style that you find here? https://github.com/DefaultLP/UnityEditorStyles
that doesnt seem to have the pure texture though, just screenshots of them
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
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;
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
tysm
The main docs are pretty good
https://docs.unity3d.com/6000.2/Documentation/Manual/UIE-HowTo-CreateEditorWindow.html
Thanks! This is something I was looking for
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
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
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!
You can get the type with reflection then pass it to the method
that would rely on an existing window in the scene of the BuildProfileWindow, correct?
What?
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
If you invoke the method via reflection too it should be possible https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodinfo.makegenericmethod?view=net-9.0
Only usable with mono disclaimer
Yep, that's how you can do it
I mean, i is literally just this
UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(typeof(T));
return wins != null && wins.Length > 0;
So no real need to use the method at all. You can just get the type and call the Find method your self
What do you mean?
vs. Object.FindObjectsOfType
the Resources method can find some "internal" stuff that the Object method can't
Ahh, that is because it returns all objects that are actually loaded in memory of the specified type. Where as Object.FindObjectsOfType operates on objects in the 'engine user land'
hey guys im using jetbrains rider for the first time and i dont know how to setup autocomplete, any help?
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
@nimble sinew 👆
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
Reset layout? May get rid of those windows for you.
Ayyye that worked! ty. I tried switching layouts and that didnt work, didnt think to try the reset layout button.
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
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
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
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
you can have a look at the scripting API and make a custom override/extension https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@5.0/api/UnityEngine.Tilemaps.RuleOverrideTile.html
So high level, setup the rule tile like normal and then create custom overrides for edge cases?
thats the idea of that particular class, but you can probably even implement a fully custom rule tile if you derive from TileBase directly. https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Tilemaps.TileBase.html
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?
(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)
Its very possible that the style "ToolbarSearchTextField" was removed or renamed. If you open the IMGUIDebugger window, then pick the search bar in the project browser it will give you the name of the style it uses.
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
PrefabUtility has methods for doing both of those things
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
I think this is the method you want https://docs.unity3d.com/6000.2/Documentation/ScriptReference/PrefabUtility.GetCorrespondingObjectFromSource.html
I always have a hard time with the naming remembering what is what
Yep
Thanks so much for the point outs
I'm doing my best to do configurable and simple editor code
is there no way to fix that?
huh? The solution is remove using statements that use namespaces that dont exist
You can also exit safe mode without fixing compile errors if you want
oh so you want that namespace? perhaps mention that in your message next time 😐
unity uses an older c# version. Some newer .net classes are avaliable on nuget
why there is more than one?
this wont work, dont bother
😭
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
TPL Dataflow promotes actor/agent-oriented designs through primitives for in-process message passing, dataflow, and pipelining. TDF builds upon the APIs and scheduling infrastructure provided by the Task Parallel Library (TPL), and integrates with the language support for asynchrony provided by C#, Visual Basic, and F#.
Commonly Used Types:
Sys...
download package, open file using 7zip/nanazip/winrar/explorer and extract the dll for .net standard 2.1
how to download the package?
download button
i can't find any download button
oh... I found it
where do I extract it?
in what folder?
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
ok i found the dll. how do I use that?
oh!!
I did it
thx @surreal girder
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?
This is what SerializeReference is for
Thank you very much. I played around with google and mistral.ai for 30 minutes because I was not aware of the keyword and mistral kept trying to sell me weird wrapper workarounds or bloated bad solutions.
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?
Im not sure if coroutines work fully in editor. If you use a debugger does your coroutine start?
Using async would be the alternative to not rely on coroutines (via UniTask or Awaitable)
The coroutine starts, _inTransition does get set to true but never returns to false.
Did you use a debugger to see if the for loop continues after yield is first hit?
If not then may be as I thought (that they do not work)
Pretty sure they do
Perhaps its started incorrectly?
Maybe try a yield return waiuntil?
This is why I just use async
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.
Oo yea that sucks
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?
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
by making your own logging solution
but its not possible to change the console tab to add just more types of errors?
Not really no

It isn't, but what is the reason you want other types, and what are they?
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
i know thats possible, but thats not exactly what i want, i want to filter them and have custom icons...
so yeah i guess its not possible, ive tried searching for it too and couldnt find anything anyways
(thats why i came here)
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#
i have no idea what harmony is so i think i shouldnt mess with it yet
i would see later on, thanks for helping
Harmony is a library that lets you add to or replace the body of compiled methods. Not for the faint of heart haha. Probably not worth it, yeah.
i already found a better way to do what i wanted though, by just making my own console window 🤷♂️
Yeah, that would probably be 'easier' 👍
for sure 
Normal Coroutines don't run properly in edit mode, you need to either use EditorCoroutines or async
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!
Also should't this question go in #1390346827005431951 ?
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?
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.
It also weirdly seems like it doesn't work, I can return a GameObject on HandleUtilityOnPickGameObjectCustomPasses, and HandleUtility.PickGameObject will still return null
I'm on 6000.2.10f1, is this just a broken method?
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 :/
thank you
How to put a string here via code, and filter project files with it?
You dont, you can use search service and trigger a search with that instead (which opens the new search window)
https://docs.unity3d.com/ScriptReference/Search.SearchService.html
This is helpful, thank you 🙏
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
I think you are using the wrong overload, check the doc page: https://docs.unity3d.com/ScriptReference/Presets.PresetSelector.ShowSelector.html
Is there a reason the width of graphRect displays differently from the EditorGUI.Slider's width despite using the same parameter?
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();
}```
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.
So I add 150 to graphRect.width?
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.
And this still works in inspectors right?
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
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. 🤔
The problem is that it yells at me if I only put GUIStyle.none for the bar but leave the GUIStyle for the handle blank
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.
There we go. Everything works as intended now

Hello, guys
There are a way to use the variables that I have in a Custom Editor Window in another script?
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;
}
}
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
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
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?
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?
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.
What are your VS and Unity versions?
Also do you have vs unity package installed
!vs
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)
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...
install vs 2022 and select that in unity as your ide so a sln is generated
Im not surprised vs 2026 has little/no support as of yet
something else is wrong then
With 2026 none the less. Sad when a solo developer can implement support faster than a multi million company
Could be
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
I am just intercepting and passing the logic from Unity to VS. So anything like that will still be in place
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
That wasn't working, as Unity wasn't sending new file opens there.
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
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
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?
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?
I dont think so. ping is basically the best we got without new search service
fr bet
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
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?
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?
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.
PrefabUtility should have something (if you still need it)
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
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
Remember the scene must be marked as dirty to save. Are you only trying to modify things when a scene save is attempted?
EditorSceneManager.MarkSceneDirty(scene);
Normally you should use Undo to record the change (which also marks things as dirty)
yes calling that, but I think I found the issue, the component itself does not seemed as marked as dirty
Yea that would be best as that makes the scene dirty too
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
can you hide .asset Scriptable Object from showing in Project Window?
its config file
You can set the hideFlag to not show in the project browser iirc
its still showing in project window i have tried all flags
Hide flags dont always work in all situations so id just accept its going to be there
You can place it in a folder that ends with a tilde(~) but that might remove it from the entire project
yeah i want to use it in build and that did not work for me,
i end up using ScriptableSingleton with ScriptableObject in editor it will use the Singleton but in build i use IPreprocessBuildWithReport to create ScriptableObject copy of the ScriptableSingleton , this way i can have config file in ProjectSettings folder away from assets folder
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?
If this is for the editor, then you can use a Curve field
https://docs.unity3d.com/6000.2/Documentation/Manual/UIE-uxml-element-CurveField.html
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)
I see. Splines would be good for that but I dont know if the Spline package works with UI toolkit
How can I get a SerializedProperty as a string no matter the underlying type?
assuming it's not an Object type
looks like there's not a nice way to do it and I'll have to switch on the prop type
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
There's the other way around MonoScript.GetClass, but even that is wrong in some cases
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
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 🙁
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
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?
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
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 😄
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
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
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
if i have the monoscript reference it does this already, i justs need the script
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
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
i suppose i could do that as well to avoid potential lag on opening the inspector for it if that where to happen
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?
The main docs are a good place to start
https://docs.unity3d.com/6000.2/Documentation/Manual/UIE-support-for-editor-ui.html
ok
@worldly crag Don't cross-post, please. Keep it in #1179447338188673034
Yes, sorry, I saw afterward the #1179447338188673034 channel
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?
You don't
i tried to look up codes, and i found result of some deeper level code....
unsafe level
i think i just be careful lol
where
apparently its not something i should do
LostMedia Code functions be like:
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
Probably doesnt support more than once instance at one time as each inspector probably has its own instance
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)
I haven't used it myself for a very long time, personally I would go about it differently if I was to rewrite it
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
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.
Aligning the Scene View with the main camera actually goes a long way.
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.
Your property should have an isExpanded state that you can modify
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?
Editor Collider Drawer
Tools - > Collider Drawer
Put empty object in patent, set height etc..
And click Draw Mode
https://pastecode.dev/s/0mvos0il
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);
}
}```
CreateGUI might be called before OnEnable, therefore diagram is still null at this point.
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
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
Ah, thats simple enough, thanks
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
what line is the stack trace pointing to?
it may be inside the CopyFromInputFieldContext method
it points to this line
newComp.CopyFromInputFieldContext(oldComp);
i am very very very sure
you'd only get that exception from that line if newComp was null
why is it null if i literally add the component
double clicking on the log entry sometimes takes you to an earlier point in the stack trace
is TMP_InputFieldExtensions your own class?
exact same code
Yes
ah
you aren't allowed to attach multiple selectable components to a single object at once
Selectable has the DisallowMultipleComponent attribute on it
this is an annoying problem, because you can't easily move a component from one object to another
sooo what could i do?
maybe you can:
- create a new game object
- put your
TMP_InputFieldExtensionscomponent on it - copy from the existing input field
- destroy the existing input field
- replace it with your
TMP_InputFieldExtensionscomponent - 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)

wait
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
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
how do i do that?
ive never heard of monoScript, or maybe i did but just dont know
also yes it does inherit
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)
do i need to SetDirty or not?
or is so.ApplyModifiedProperties(); enough
As long as you’re only using SerializedObject and SerializedProperty, everything gets handled by that ApplyModifiedProperties call
(including for prefab instances)
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?
That looks correct.
okay let me see, hope everything works
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();
}
(including undo and redo)
but now it doesnt get called
Reset only executes for newly-added components or when you hit the Reset button in the context menu
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
if i do this? like switch the script??
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
ah
i see
i thought the whole thing actually destroys from existence
i understand
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
yeah, I used to think that the C# object actually vanished
it doesn't; Unity just refuses to let you do anything with it (anything that involves Unity, at least)
tbh scared me since i saved scene but its still there
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
okay i see
thank you
sorry i was a little bit busy at the moment but yeah i understand
thanks
no problem!
im not sure if this is the right channel but can someone please help
Not the correct channel, this channel is for editor scripting.
Anyway it says "see console for details" so check that.
It's running into an error when trying to check the last-modified time of a file
is the "Doesn't garbage collect them" thing relevant in the editor as well? It would essentially be a memory leak & slowdown every time until domain is refreshed if so right?
https://docs.unity3d.com/6000.3/Documentation/Manual/performance-gc-avoid-reflection.html
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
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
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
...
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
Scene Hierarchy Editor Script Written in Unity 6 LTS doesn't work in Unity 6.3 LTS
is there a way to remove / hide / group existing items in these menus that are built in the unity editor?
Not really I believe :/
I'm trying to edit a Sprite Library Asset but it seems to not be working as classical assets, not sure how to fix https://discussions.unity.com/t/sprite-library-asset-modification-are-not-saved-even-if-correctly-dirty/1698901
It won't work this way. Unity has an intermediate class type in memory ...
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
It is a lot better in Unity 6.x if you can upgrade
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
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?
Nope, not that I know of. But wouldn't need AI to do that depending on what the blueprint looks like. It could be done procedurally.
maybe not probuilder but Muse can generate levels using a list of existing assets, free while Unity AI is in beta
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
@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 .
why not use the asset manager? it's amazing and the team working behind it is actively updating based on User requests.
it took them less than a day to add a feature I emailed them about. (such goats!)
try it out, I use it to share assets between lots of different projects where if I update it in one, it auto updates in the rest. like prefabs across scenes but projects.
Ive never heard of it, in our case we need to port some data from 1 project to other, not sync and stuff
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)
what do you mean port?
just one way?
you can export to Unity package and import on the other project
yes, one way, once
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
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?
its meant to work identical to Ctrl+C/V but between editors
Im not touching guids because im saving raw C# types
ctrl+c / v of the file in the project tab?
it doesnt work between 2 editor instances
and manualy taking file trough explorer breaks references to scripts
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
yes
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
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?
what happens after you move the file
we have different guids on components
this
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
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
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.
this sounds like a job for a GUID Remapper, this one has a release https://github.com/ibrahimpenekli/unity-guid-mapper
you can work on types but honestly that sounds like it could bring a lot of mess. I would try to avoid it and really keep it to last resort
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
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
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);
}
What is Ah sorry didn't realize it was a new built in typeMainToolbarSlider?
I would restart Unity and if that doesn't fix it then report as a bug
yeah this is definitely a bug
I will report it
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?
Most likely incompatible versions, you should check the editor log file since for some reason unity doesn't log errors related to importing analyzers in the console
Oh yea it was an incompatible nuget package thaks
I just downgraded the version
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?
how are you editing the namespace?
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)
Did you do Open by File extension and select the editor?
Thank you that was it
"Open by file extension" is used if you want to use an editor that has no special Unity integration, yeah
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?
Well the \n is your issue. You should use Environment.NewLine or at least \r\n
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
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?
Oh wait, I think just using \r seems to work? (at least im not seeing the line endings popup when I reopen the scripts), all the code looks formatted correctly in VS and in notepad, though Unitys inspector for some reason removed all spacing and line endings but that doesnt seem to be an actual issue - thanks
You should probably still use Environment.NewLine.
\n is old, not used anymore. Windows uses \r\n, and Unix systems use \r
Ah I see, when the popup happened, one option was "Windows (CR)", and looking it up, the CR was for "Carriage Return", which suggested "\r" for that, but I didnt look too deep into it, and using Envirionment.NewLine created the popup again, though I guess I could replace every line in the script with that instead of just the "namespace" line, which might remove the popup?
im sure you have seen your ide warn you sometime about inconsistent line endings
Right, using \r removed that warning, and using \r\n or \n or Environment.NewLine produced that warning again, but im only changing 1 line in the scripts
There is no guarantee a file uses the line endings from the OS
I think git can even change them when it modifies files
Ah I see, so it sounds like ill have to change every line to Environments version and not just the namespace line
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
You can use whatever the file already uses as no ide or compiler will mind
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.
Could someone help me?
hey, how can I make a script that will spawn a prefab where the mouse is touching (at z=0) (in the editor ofc)
Use prefab utility to create the instances
https://docs.unity3d.com/ScriptReference/PrefabUtility.InstantiatePrefab.html
You may need to set the scene as dirty after I'm not fully sure
not that i'm aware of (you'll have to save it to persist the change, of course)
I mention it because many things wont dirty an object/scene automatically
things like odin do that for you if you use things like [Button]
that is necessary if you do things "behind unity's back" – like modifying random C# objects instead of using SerializedObject/SerializedProperty
one thing you should do is call Undo.RegisterCreatedObjectUndo so that you can correctly undo the creation of the object
yea thats true, undo records will do that for us
otherwise we have to set dirty and perhaps update prefab instances to detect overrides
yeah, all of that is necessary if you don't go through SerializedProperty
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
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?
what editor vesrion are you using?
switched to 3.2f1, problem is still there
I'm having issues with undo operations where I:
- instantiate a prefab with
PrefabUtility.InstantiatePrefaband then record its creation usingUndo.RegisterCreatedObjectUndo - use
Undo.AddComponentto 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
Sounds like it's working as intended
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
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
Did the reimport all thing but no luck
Can you locate a mesh asset with that name?
you can search the project window for t:mesh pb_Mesh75492
Nope, I can't seem to find it
oh, I bet that's a probuilder mesh
it is
it will be more annoying to find the mesh in the scene
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
also, if it helps, I used Probuilder's Experimental boolean tool to make those models
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)
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
Hello. Is there a way to change the position of an object in hierarchy window in the editor by a script?
I cannot confirm right now, but I assume the ordering to be based on the sibling index. Transform.SetSiblingIndex, Transform.SetAsFirstSibling etc. allows to change the indexing within a parent transform. Take a look at the documentation of the Transform class to see all the ways you can access and modify the indexing.
That only works for child objects. Can't remember how the roots are ordered
I will presume that this works even for top level objects
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
How is the data copied? serialized properties or just modifying serialized fields?
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?
both "target" and "nidrs" are the C# representation of the assets. both are assets in the project that get loaded by the migration wizard
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
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
AH
damn
ok yeah that would explain it
nice catch :$
i'll have to check what's it from, thanks
Just so you know, this would not work because UpdateIfRequiredOrScript update all values on the SerializedObject to match the in-memory object, meaning it clears all changes.
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.
https://discussions.unity.com/t/global-properties-for-vfx-graph/1542716/2
would a global property work?
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?
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
I am not even scared of API changes anymore because of AI. You can just copy paste all errors and tell it to fix it
(Opus 4.5)
For example, it just turned my simple array into this pokedex viewer
wow so you made nothing
@zen3773 muted
Reason: Sending too many attachments.
Duration: 29 minutes and 40 seconds
I’ve coded these before would’ve taken a day (localization, auto translate, workflow dirty change) but this took 5 mins
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!
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?
Comment the inheritance out instead class Abc // : Editor
If i do that then some override methods will fail
Can't you just comment out the contents of the class?
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..
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"
The override methods won't have any virtual methods to override, compile error
Yes... altho it'll be slower
But oh well
The better mindset to have is to just comment it out and don't look back
I meant doing both what I and MeshWarrior suggested
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
Nope, not officially supported currently.
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?
I'm assuming the enum values are not nothing/everything? I don't see anything wrong
no, i have like 15 values in this enum
i fixed it though so dw about it
[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.
My first guess would be because you are destroying them while enumerating the transform. Similar to how removing items from a collection that you are enumerating is not allowed.
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)
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).
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.
The Search API should be able to do it I think
Thanks, I'll check it out!
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.
Not built-in at least
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
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
};
}
}```
(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)
Odin and similar tools use attributes where you can specify a bool var or function name that's used to define the visibility
Naughty attributes is open source so you can see how they do it
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;
}```
how can i make a window like this for long migrations for my own tool?
How do I set a toggle to mixed state in UI Toolkit?
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
Is there a way to change the font size of [Headers] ??
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
If you define your own DecoratorDrawer you can do this
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
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
@safe sorrel You most likely need to use PrefabUtility to finalize the changes
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
This all but confirms my suggestion is the vase
when modifying prefab instances you often need RecordPrefabInstancePropertyModifications() for it to detect and serialize the changes only.
now that I'm using SerializedProperty, it's working correctly everywhere
i'm just amused by how i had the opposite problem, somehow
But im a "just edit the object" kinda guy
it worked only when it was a prefab instance
No, you can set the values as well. Like if you create a instance and set values on it and then assign it to managedReferenceValue`
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
What I linked above is for when the current gameobject + components were modified
meaning not yet serialized
No pls 
if I wanted to directly edit the C# object, I mean
Yep. Undo.RecordObject makes the script work properly when editing the prefab
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
interestingly, it also works fine on a prefab instance
leaving the scene and returning shows that the override stuck
(i didn't call RecordPrefabInstancePropertyModifications)
Perhaps using Undo is enough. I used to do lots of manual dirtying + prefab record modification stuffs
and undo/redo works correctly
Mysterious
The documentation is explicit that you must use both methods
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 🙁
but I can't cause it to fail now
go figure
@safe sorrel have you tried doing PrefabUtility.SavePrefabAsset() after doing serializedObject.ApplyModifiedProperties()
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
i'm having a skill issue and can't figure out how to correctly use PrefabUtility.SavePrefabAsset
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
Hmm, if in the prefab editor you might need to use PrefabUtility to get the source asset from your component.
I am not 100% clear on how Unity handles prefab editing in the editor
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)
I mean that is what I always suggest doing anyway. Surprised though that setting the managedReferenceValue is having issues
In prefab stage this does not work, you need to get the current stage and then the asset path of the prefab open
If you use that in a prefab stage then it gets the base prefab if its a prefab variant, very fucking annoying
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
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
and then you call PrefabUtility.ReticulateSplinesForPrefabOverrideDeluxeWithCheese
Sometimes i wish that prefabs were not treated as gameobjects directly but a different asset type to make some of this shit easier
kind of like how scenes are an asset type, right
Thats true but only for editor
With addressables its atleast possible to kinda serialize a ref to a scene but thats not perfect
how do i get omnisharp to detect my slnx, since unity wont generate me an sln? running arch, using nvim
for now my teammate sending me a generated sln is the way, i couldnt find any other lsp
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!
for property drawers is there a default draw inspector function anywhere
I dunno about with UI Toolkit but for the IMGUI implementation I think you just would call the base.OnGUI inside the overriding implementation and it will do the default draw.
So I think that’s what you’d do if you only wanted to add things and not overall change how it’s drawn
i tried calling base it just says gui not implemented yet
not sure why
Just nest a property drawer field
what do you mean
I mean to use PropertyField
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
How does Unity know to reimport an asset? Does it save a hash somewhere in /Library?
I thought it checked file modification date but could be wrong
Hm... Surely not.
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.
The asset file was modified or any of its dependencies were modified
what's the weird behaviour you're having?
My question is how it knows that it was modified
I need to try a few more things to work it out, i think there are a few things going wrong. I'll be back at it tomorrow during the day.
For .NET there's the FileSystemWatcher
That would only work while unity is open. It needs to reimport when opening the project.
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
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
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"
Unity uses multiple data points to check if a file was modified, not just the timestamp. See https://docs.unity3d.com/6000.3/Documentation/Manual/asset-database-contents.html
Specifically the SourceAssetDB bit
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
Sounds like the correct choice, keep in mind that in 6.4 and beyond there are some changes coming to dependencies: https://discussions.unity.com/t/narrowing-artifact-dependencies-in-unity-6-4/1690877
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
Thanks, good to know. I'm giving it a read.
Anyone know why this line wouldn't trigger my ScriptedImporter, but right clicking the aset and clicking "reimport" does?
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)
neat!
ImportAsset takes a path, not a GUID!
That was it 😆 Thank you!
I just noticed before
(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
Yeah, shame there is a GUID type, but sometimes it's a string.
Mysteriously
it takes less data to serialise a GUID as a string than serialising a 128 bit integer as string in yaml/json. when they are crossing application boundaries, its also robust to store them as text.
It's going to be a string either way if you're saving yaml. Doesn't have anything to do with runtime types.
In fact the string is itself a serialised 128 bit integer.
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.
I think you can technically by manually editing the menu but don't think ther's an easy way
<@&502884371011731486> gambling scam thing
?ban 1311378926911623220 bot
deepak058196 was banned.
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