#βοΈβeditor-extensions
1 messages Β· Page 55 of 1
thats how i noticed the error
by reimporting
is that a problem on my editor's side?
im using vscode
Try what NFMynster said, regen your c# project
im sorry, can you explain how to do it?
suggestions on the web say to choose vscode again
by browsing
Opening the .sln file in a different code program and switching back would work, or you can do what he said and delete the .sln file from your project folder, right click in the asset folder and open C# project
right
ill try thanks
i can see its some omnisharp problem
because tmpro doesnt work too
The error is a generation problem so it might fix it, report back π
Well, i swtiched to visual studio 2019
reimported the package
and now it works
im scared of switching to vscode now
π
Haha, you can always switch again back to vs2019 π
I write my code on paper and scan it in
genius
Anyone experienced with setting a TextMeshPRO text using a custom editor script?
Have a problem where I can't find the property to set the text properly.
What's the difference between using
#if UNITY_EDITOR
and
if (Application.isEditor)
Do you have an example of when I should use one of those instead of the other?
If you want to add editor code outside of an editor assembly (be it an Editor folder or an asdmdef) you want it to be in a preprocessor if so you can build your game
Ah that makes sense
If you used a normal if the compiler for a build would tell you it has no idea what UnityEditor is
Another example, you can set up assmdefs to add preprocessor arguments if another package exists, so you can add code that refers to that package that only compiles when it could reference the package's content
Oh that's useful, I do have code that uses the UnityEngine.Rendering.Universal namespace, so I could use preprocessor arguments to only compile the code if the URP package is present? Neat!
I'll do some research
thank you
I see your comments on the Unity docs, thank you for that as well π
what does asdmdef and assmdef means?
Assembly Definitions
ahh ok ok
Asdmdef does not exist. Vertx meant 'asmdef' I guess
Look, mobile phones aren't the best
yeah I understand it but since I didn't know what does they mean I didn't know it was a typo, everyone does typos, we are still humans xD
That's why I clarified, we're just humans after all
Hi. I'm using TextMesh Pro sprites feature (TMP_SpriteAsset) to generate emojis, but I'm trying to see if there is any way to access to the invidual sprites so I can use them in other places as well from the same atlas. I wonder if someone could do it and have some clues for me?
Is it possible to use GUI.Box (or something similar where I can create a box and define its position), with contents like multiple buttons and text and images inside of GUILayout? Or do I have to manually set the Rect for each of the GUI.Button, GUI.Label, etc? (Im wondering if I can have elements kind of "auto format" themselves like GUILayout does, or if I have to specify each items rect and do the math myself for the "formatting")
using(new EditorGUILayout.VerticalScope("box")) {
...
}```
(obviously cache the guistyle)
Hey! What would be a way to show a UnityEvent in OnInspectorGUI?
I was able to show the event when I used one of my own events. I don't know how to show the event from a Slider. I have tried the following:
//GUICLASS
serializedObject.Update();
serializedObject.FindProperty("SliderEvent")
serializedObject.ApplyModifiedProperties();
//MyClass
public Slider.SliderEvent SliderEvent
{
get => slider.onValueChanged;
}
//GUICLASS
serializedObject.Update();
serializedObject.FindProperty("slider").FindPropertyRelative("onValueChanged")
serializedObject.ApplyModifiedProperties();
Hmm, I cant seem to specify a rect position for the vertical scope, even cashing the gui style, it does have margin which seems to kind of help, but I cant seem to "reset" the x back to 0 for a new row of content, I tried messing with the first param of margin a bit and it just continues to space out, is there something im missing?
var style = new GUIStyle("box");
if (i % 5 == 0 && i >= 5) { drawHeight += boxSize.y + padding.y; itemsInRow = 0; style.margin.left = 0; }
style.margin = new RectOffset((int)padding.x, (int)padding.x, (int)drawHeight, 0);
using (new EditorGUILayout.VerticalScope(style))
{
...
}
Hello everybody, I'm working on a project, which i want to update a version number and date when exporting to Unity package. The fact is, I'm really lazy and I work with other people who sometimes forget to updates these datas. My question is, are there events thrown by Unity before and/or after an export/import package ?
I don't know if these informations are mandatory, but I'm working on Unity 2019.2.8f1
In Custom PropertyDrawers, how can I get a reference to the variable that I'm currently displaying?
So that I may edit its value and whatnot
You get passed thet serialized property in your ongui method
Yes, but do I just... cast it somehow? I am not clear about how to change it
Read up on serializedobjects and serializedproperties
It's too much to just explain
I see, I'll keep digging around then
But let's say that
My property has a long type inside of it
I read that "property.longValue" is actually described as "value of an integer property as long"
Is there a way of getting a long declared value?
... I'm gonna guess this is also explained somewhere on the manual so I'll back to that
Despite the method's description implying it's designed for transforming an int into a float? Ok then, guess they just need to revise that description
The description is just shit
Got it
It's probably because a long counts as a SerializedPropertyType.Integer
Is there
Nvm
I'll just use long
I wanted to use ulong but I ain't gonna risk trying if it works or not
That should work just fine
@sterile steppe yes.
Thank you
Perhaps I am missing something... I have made a Custom Attribute such as the following:
[System.AttributeUsage(System.AttributeTargets.Field)]
public class CreatureTypeArrayAttribute : System.Attribute {}```
Destined to be assigned to string arrays. And then I have made a custom PropertyDrawer for it:
[CustomPropertyDrawer(typeof(CreatureTypeArrayAttribute))]
public class CreatureTypeAttributeDrawer : PropertyDrawer
{
//... OnGUI is overrided with a couple of Debug Messages.
}```
But it appears to not be working at all, I. E. the property with the attribute assigned to it still displays as if I had not overridden any method (it's not throwing any debug messages through the console). Any ideas as to why? What did I do wrong? Is it because the Attribute is an empty class or something?
... oh god, thanks
Yeah, it's UnityEngine.PropertyAttribute, thanks bud
... doesn't seem like it's working yet
Yeah it ain't working
Ok I think I see a behaviour
But I don't like it
It seems to be applying the PropertyDrawer to every string in the array but not treat the array itself as the main property?
Does that make sense?
It's basically put such that:
[CreatureTypeArray] public string[] data;
... Guess that's my problem then
What's a solution or workaround? Just make a class then?
Yep
I tried to be smart about it. Guess it ain't happening. Thanks for the help.
just put the node positions in a #if UNITY_EDITOR block
or keep them as separate data
I was just messing around with UIElements, and it seems that the Min-Max slider doesn't have value fields. Is there any good way to add them? I know I could just add 2 to the end, but was hoping to add one after the label, and before the slider.
you want to inject something into the slider field?
I got a min-max slider, but I want to see the actual values. So I added 2 fields at the end to show what the min, and max are. But on I want the min field on the left side, and the max on the right side.
So.. I guess so?
You know what, it isn't that big of a deal.
But if you happen to know how to change how many decimals places are allowed by default by a silder that would be cool. I don't need like 6. π
How can I get the Debug.Log output in the visual studio debugger even when Unity is frozen due to a resource hungry code?
You open the Editor.log and listen to it
So I can not check it out in real time?
Rider gets the log piped to it, but if you're using VS you just need to look at the log with a text program that refreshes often with changes
i know i shouldnt just simply ask question here, but does anyone have an editor script to group object + add empty game object as parent at the center of the group?
i feel like im missing a short cut for such simple stuff
Yeah scriptable objects don't need to be assets
@ancient moth No.
A ScriptableObject is serializable by nature. If you store it under another asset, it can't be hidden.
Changing the accesor (Public), or unserialize the class (which is not possible) or toying with the hideflags (HideInInspector) won't work.
When you state "save it in another SO", you means saving it as an asset in the project right?
It is save in the animator asset.
Every piece of information you see is save somewhere.
@ancient moth You can store data in binary format then load and serialize it at runtime. It won't be human readable in files.
What exactly is your goal?
This is the face of an empty Animator Controller
You can see the position in there
The position at the end, these are your nodes
Hum... I think you should not worry about this thing
Well
We know
That's why I am backing my last sentence, you should not worry about this thing
The stuff that is not used at runtime and not in Resources would not be built in.
Inspector can not inspect something that does not derive from Object
You can hook into Selection to be aware when the selection changes
does anybody here uses Roslynator with VSCODE?
I don't udnerstand how to set it up π¦
I mean, it's working but it's detecting the "uncalled" methods in my monobehaviours
and it shouldnt π
FYI for those using UI Builder, looks like loads of great fixes & improvements in 0.10.1 released a couple days ago
@gloomy chasm You can do what you want with the slider with what you have and a little USS magic
You'd probably want to make a new visual element class that automatically adds the slider and the two text boxes into a parent control just to make it easy to re-use
Then you'll need a style to adjust the width of the actual slider bar, possibly by adding margin or padding to either side of the slider, as well as the thumbs on it.
After that you can use relative positioning to position the textboxes
You'd want to use the UIElements Inspector, and maybe UI Builder to make this a bit easier to work through
Does anyone know why, whenever I click an button with the animation
it has a small delay
sometimes when I click, it doesn't play the animation
Wrong channel
Where should I ask it then?
You're going to have to provide more information though
Since it's possible to determine why it's happening atm
can I ask help about polybrush here?
If you're developing polybrush then yes, otherwise no
has anyone had the misfortune of trying to work with the Chromecast unity plugin lately?
@rugged herald Do not cross-post. This channel is for extending the editor, not for questions about plugins
aren't plugins editor extensions?
Sure, if you were making one that modified the Unity Editor yourself then this would be a relevant question.
it seemed like a cross topic sort of thing.. so i posted it here... on the hopes that someone might have some experience in it...
was worth a shot
Next time pick one channel and if you're not getting an answer after an hour or so, then you can think about cross-posting.
my bad... i shouldn't disturb the crickets in here...so busy my text just flew right by
having a strange issue where I can't seem to get this scrollview to encompass all of the content I'm rendering in an editor window. I'm literally just doing
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true);
EditorGUILayout.PropertyField(serializedProperty);
EditorGUILayout.EndScrollView();
but it only gives a small amount of scrollspace (pictured)
there are two more elements underneath these
Are those items using a custom propertydrawer?
If so then you're probably not setting yourheight correctly
is there a way to add a component to an object and NOT mark it as dirty?
in the end I want the added component to not be saved at all
(I can do that with hideflags I believe, but not sure how to not mark dirty while calling AddComponent<>())
there is this method but I only want the add component part π https://docs.unity3d.com/ScriptReference/EditorUtility.CreateGameObjectWithHideFlags.html
nvm my monologue then π
so iv been working on this project i only recently heard about pixel perfect. so i tried implementing into my game but I'm using clinemachine for the camera. pixel perfect is freaching the heck out because of this clinemachine.
just wondering if any of you guy and girls have had this issue?
I posted in #archived-dots, but didn't get much of a response. Has anyone written a custom inspector or scene handle gizmos in a Tiny project or even just for DOTS components/authoring?
@cosmic dagger this channel is about extending the Editor, not general questions
PLEASE i need an help regarding Polybrush
if somebody have confidence with it let me know
I have a issue while trying to instanciate bushes
those got placed at 90degrees π
it ignores the editor rotation overwrite
@versed flower check my messages a few lines up
you should be able to do EditorUtility.ClearDirty or even assign it some HideFlags (not 100% sure on how to check if it's marked as non-editable from Perforce though)
Hmm, I think I saw other functions which are related to the checking out process specifically
I wanted to know if it was something already in the engine or not
because for example I worked with Unreal Engine before and when a file is checked out by another user you can't even save the file, which is the functionality I want to avoid file conflicts
Hi, I'm trying to integrate some UIElements in one of my projects. Would be possible to use binding-path to bind my EditorWindow's float x to a label or FloatField without having to query it?
I think you can bind your editor window to the root of the uxml and have all children of that element try to use that instance
At least
That would be logical which you can't assume with UIElements
makes sense, maybe is what im missing
but shouldn't that happen when I call quickToolVisualTree.CloneTree(root);
my uxml contains some fields with binding-path to some members of my editorwindow
I've got no clue
I mean, i can access that with rootVisualElement.Query<UnityEditor.UIElements.FloatField>("LenghtThreshold").First().value but that sucks
There must be a nicer solution
no
Bind only occurs against objects that BindableElement.Bind is called upon
Insinde the Inspector this occurs automatically for each inspector listed
however in an Editor window this never happens
so if you'd like to bind in another window to different objects then you need to call bind yourself
Trying to add keyboard event to my UIElements
Like this:
rootVisualElement.RegisterCallback<MouseDownEvent>((e) => Debug.Log("Hello"));
rootVisualElement.RegisterCallback<KeyUpEvent>((e) => Debug.Log(e.keyCode));
Does anyone why MouseDownEvent is working
But when I try to use KeyUpEvent or KeyDownEvent that does not work.
Is your element focused?
Can your element be focused is the question
It needs to be focusable
Which is a boolean on visualelement iirc
Renaming a subasset - when I select the asset the name is updated but the name isn't updated in the project view until I force a recompile. So far I've tried a combination of ``` serializedProperty.serializedObject.ApplyModifiedProperties();
serializedProperty.serializedObject.Update();
AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
edit: Looks like if I change folder in project view and back again, it updates.. hmm
No my element is not focused will try setting the focus to it
@minor herald just to be extra clear, there's a property called focusable that you need to set to true (rather than calling .Focus() or something)
Yeah I saw the focusable property
Hello! I Want to publish a mobile Game on google play But I got a few problems with sign app, if u want to help me text me and i will give more information about this problems. Thanks
Setting the visual element to focusable = true worked
Thanks π
Hello, i want to publish a mobile game on google play and i encountered some issues with signing app (keystore). When i try to build the project i get the errors shown below. I really don t know what to do, i checked every thing and same, the paths are correct
not sure if right channel, if not remove please or ping me.
Does someone know why MaterialUI theme in rider looks like that?
@ruby kraken Not the right channel, go the Slack at unitydevs.slack.com and ask for citizenmatt, he works for JetBrains
Is VS Code borked on Unity 2019.3?
gotcha
yes it is
My Visual Studio isn't autocompleting anything? Miscellaneous files. How can I fix this?
This is not the right channel (it's for creating editor extensions) but:
in Unity make sure Edit > Preferences > External Tools > External Script Editor has Visual Studio set correctly
@gloomy jolt
Thanks!
hey, so I'm trying to write code that auto-docks instantiated windows, here's my method
` public static void DockTab(this EditorWindow rootWin, EditorWindow dockWindow) {
var hostViewFieldInfo = rootWin.GetType().GetField("m_Parent", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField);
var hostView = hostViewFieldInfo.GetValue(rootWin);
var addTabMethodInfo = hostView.GetType().GetMethod("AddTab", new Type[] { typeof(EditorWindow), typeof(bool) });
var parameters = new object[] { dockWindow, true };
addTabMethodInfo.Invoke(hostView, parameters);
}`
it works, but there's a resulting bug that breaks the functionality. after docking there appear two be two instances of the window (one docked, one undocked), but after doing a check for open windows unity only recognizes one instance as being open -- so if I close either one, the other says 'failed to load'
anyone have any idea wtf is happening?
please tag me if you do; I had to write this tool because an old now-deprecated library I'm using has bugs I need to use this as a workaround for for my game, so this is holding up my progress and once I fix this damn bug I can get back to work!
Currently my root visual element scales the height of the visual elements I add to it.
When I add a UIElement.Box with a height of 150px the height when it is added is around 50px.
Does anyone know how I can resolve this?
Here is a gif of it happening
Hey Vertx, I tried setting up an asmdef
So like this I could check if the package is there
And when I look at the inspector of my scripts, they indeed have my asmdef marked as 'definition file'
but now I get these errors
"The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Rendering' (are you missing an assembly reference?)"
Basically what I want is for the scripts in my folder to only compile IF the com.unity.render-pipelines.universal package is installed AND the version is >= 7.0.0
I see you're on mobile, so I want to mention that there is no hurry at all π
You still need the reference to the universal assmdef files too, and wrap the relevant code in that define so it doesn't compile without the pipeline.
What do you mean?
in the 'Assembly Definition References' section?
Which ones do I need to reference? There are a whole bunch
Whichever ones contain the code you care about
Alright!
And so I should just wrap my whole script, top to bottom in that 'UNIVERSAL_RENDERER' define I created then? If I don't want the script to compile unless the universal package is in the project
Yup, #if. I think Cinemachine is a good example of this with their post processing integration
Will take a look!
And thank you, after adding the necessary references, compiler errrors are gone π
UI Elements question - does anyone know of a callback for a ToolbarMenu opening/being clicked?
It's super hacky but using MouseCaptureEvent for now π§
I don't know off hand, but I would personnally investigate the source code for it
Otherwise said, I'd open ToolbarMenu in the reference source and see what is there
ToolbarMenu has a PointerClickable manipulator on it
so using a MouseDownEvent on the control should be functionally equivalent
When I tried a MDE it didn't fire - but perhaps I needed to force the bubbling or something
Sorry, apparently its a PointerDown event?
btw do you know the difference between Pointer vs Mouse?
PointerDownEvent
Not a clue, this is literally the moment I became aware of its existence
I think, it looks like, the pointer events are an abstraction of Mouse/Pen input
hmm yea.. not sure why you'd ever want MouseDownEvents in that case really... but anyway, unfortunately PointerDownEvent with/without TrickleDown doesn't detect anything
I have my Android phone with Unity Remote. I've set it on any android device but it won't start when I press play
How could I open the package manager window by script?
Execute the menu item?
I am starting to work on a more complete Graph editor + data structure, that extents the UIElements Graph view.
But I am not sure if it would be better to make a base, that you would copy the code of, and add the functionality that you need to it directly. Or to make a framework, that you would extent to add the functionality you needed.
Any thoughts on what would be easier to work with?
Heyo, anyone knows a way to save prefab with nested prefabs in runtime?
As far as i understand loaded prefabs are being unpacked in runtime, so what i need is to somehow pack that instance back into prefab along with its nested prefabs - modify it in runtime and then save it as a new prefab (with same nested prefabs)
Prefabs don't exist at runtime, but you can convert gameobjects into prefabs using the PrefabUtility functions just fine if it's Editor code
There's slides from a talk about prefabs pinned to this channel that describe some of the PrefabUtility functions for doing that sort of thing
so if you'd like to bind in another window to different objects then you need to call bind yourself
@severe python Thanks! This solved it and it's much cleaner than querying each field every time!
root.Query<BindableElement>().ForEach(x => x.Bind(new SerializedObject(this)));
why does OnPostprocessAllAssets get called twice for the same object imported?
once when the asset is createdonce when the asset is created
then again when the project is saved
both times the asset is in the importedAssets list
Does anyone know why my rootVisualElement scales down my nodes when I add multiple nodes to the rootVisualElement
Online documentation of UIElements isn't really helping
This is the code I use to add the node to the rootVisualElement of my editor window
public void Draw(VisualElement root, ContextualMenuPopulateEvent evt)
{
nodeRoot = new VisualElement();
box = new Box();
box.style.width = 150;
box.style.height = 200;
root.Add(nodeRoot);
}
Your rootVisualElement has a style on it
that style has a FlexBox and that is what is organizing your elements
All elements by default have some styles on them, so you should understand those defaults in general so that you understand the default behavior
btw, @severe python know of any good examples of getting used to UIElements? last time I tried it was to bind some imgui stuff to it to create a card editor - but it's been a while since I've done it lol
honestly, no, not anything super basic
A good place to get started is to build UIElements Inspectors however, since a few things are done automatically (the binding system setup)
There is this video in the sticky, but it looks a bit older, https://www.youtube.com/watch?v=CZ39btQ0XlE
UIElements is a new retained mode UI framework for Unity, available now as a public API for Unity 2019.1. In its current form, itβs a tool that makes it easier for you to extend the Unity Editor. In-game support and visual authoring will come in future releases.
β‘οΈLearn more ...
Thanks Twiner I will see what I can find about FlexBox
A lot has changed code wise
I know I'm being all self promoting, but with VisualTemplates in theory yuo don't need to write much, if any code
its all just UXML and USS
and if you use UIBuilder it should be simpler
however, you don't really have to write much code regardless
mostly just adding behavior to controls like buttons
but you can bind to object properties as along as the binding system is setup
@severe python is this something for the asset store or just an open project you're working on for now?
just an open source project
that I keep throwing at people and Unity
because DataTemplates should be part of UIElements out of the box
and their templates are not data templates
it might be broken atm
If you want to use it though, its MIT Licensed
I think I need to commit some stuff
Binding to and dealing with Arrays in SerializedProperties is a fucking pita
their ListView control is dumb because it forces you into doing a bunch of stuff in code that should just be a referenece to a template in the UXML
and it should handle binding
it does neither
i just tried to load your examples project and the latest 2020 build is throwing all sorts of weirdness at me with the packagemanager, saying i dont have privileges to the packages and the code (just shoved in assets folder) can't find the entities package so im about to decide if its worth investigating further or if this build is just hosed.
uhm
Create an EmptyProject, import VisualTemplates via the Package Manager
then load Visual Template examples by cloning it under your assets folder
that should work
if not I probably need to commit some shit
i think maybe its this build, because in Hub the default templates all fail to create a new project; ill try to remember how to download a specific older version and give that a try.
uh, last time I built it was on 2020.1a19 I think
the project is setup for 2020.1.a17 in my hub
so thats what it actually was
Hey, I am new to Unity (I have a few years of coding experience now).
And wanted to ask what Classes I'd need to create something in the Direction of Terrain.
(Like a new 3D object I can add into a scene, maybe also with a similar way of adding neighbors)
And also, would this be the correct channel for that kinda stuff? Or would general-code be better?
if you're asking about making terrain, you may try the #πβart-asset-workflow Channel, if you're talking about making a custom implementation, this channel may be appropriate, or #π»βcode-beginner
but you may start here
https://learn.unity.com/search?k=["q%3Aterrain"]
I don't want to create Terrain perse
discord doesn't like that link
More into the direction like something I could add here.
And adding custom tools for those things like the terrain has for example.
Like I am not looking to do anything project specfic, but just learning the internal of Unity and creating tools that might be useful for the future.
Ah, I think I found the name of what I am searching. Basically I want to create new Behaviours
Would that still go into #π»βcode-beginner or is this place the right one? I am not sure yet whether it's extending the editor or just works like most other objects.
Oh, ok nevermind, finding the name of that stuff seems to have been enough. I can figure out everything else on my own, thanks anyway ^^
That would be this channel just to be clear
Those are MenuItemAttribute that you can place on MonoBehaviors, or in the case of ScriptableObjects you can use the CreateAssetMenuAttribute
if I have a dictionary defined like this [SerializeField] private Dictionary<string, Mesh> dictionary;
This is not a valid operation Instantiate(dictionary[item.ToString().ToUpper()]);? It does not seem to do anything
I don't think you can instantiate a mesh like that.
Isn't Instantiate just for GameObjects/Prefabs? (I am still a noob with unity, but I hope I understood that part correclty)
@severe python just saw your link to visualtemplates, do you have any docs or samples?
looking to learn what problem it solves and how
if you could give quick rundown that works too
@slender juniper you might actually be right. I think i just assumed it would cast implicitly to a gameobject with a meshcomponent
If you navigate up I have an example project
Its solves the problem of picking a visual layout template based upon the data type its bought d to
Bound to
VisualTemplatesExamples is heavily doc commented
I havent made any markdown documentation really however, if your familiar with unity editor coding its built off that obviously so just start from the editors and view the results
However it may be broken atm
Currently trapped doing computer repairs so I cant fix it atm
ah i see it now
ty Twiner
looks good
Hello! Does anyone know if there's a way to get find all of the projects that Hub shows?
I'm currently parsing AppData\Roaming\UnityHub\logs\info-log.json to find out what has been opened recently, but there must be a file somewhere else with the actual list in it?
IIRC there is a registry key
Computer\HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x\RecentlyUsedProjectPaths-*
FindObjectsOfTypeAll should find it iirc
that seems terrible
That returns true if the tab is hidden, unfortunately
i.e. if the window is docked with other tabs, and another tab is active, it still thinks its true
Perhaps if you get the root element of hte window
There is some way to get whether it's visible
Hmm maybe
If I have a Prefab A and then creates a Prefab Variant named AB, is there an API that allows me to ask "Get me all prefab's that has A as their root/parent prefab" and then it returns AB?
@unborn bluff If it exists, it would be here
https://docs.unity3d.com/ScriptReference/PrefabUtility.html
Is it possible to not give a VisualElement a flex direction and have it spawn on a given position for example spawn an element on the mouse position?
you'll just need to set its position type to absolute
position: absolute | relative
you do this via USS
Thanks again! @severe python
I really like how UIElements works but I just wished there was a bit more documentation and examples for itπ
Its mostly just CSS honestly, so most of that documentation applies
Yeah I never worked with CSS so that does not help
the underlying visual element code is different obviously, but you can ignore it most of the time till you start doing more powerful things
yeah, getting your head wrapped around selectors is tough at first
its a bit of a cliff
once it clicks it will make much more sense
In a meta file, what does the field fileID represent?
you know, a specification for the asset meta files would be dope
Depends on the asset
For scripts in a dll it's some md4 hash of the script name + namespace
While the guid refers to the dll
If your script is in the asset database then the file Id is a constant value while the guid refers to the asset
I'm not sure how it works for others assets though but I'd imagine the same
@waxen sandal what about prefabs? How does fildID relate to those? Anywhere i can read up on these things?
UI Elements - struggling to prevent the scroll wheel from scrolling the scrollview. Any thoughts? I've tried adding a WheelEvent callback to the scrollview and stopping propagation amongst other things. Source here - https://github.com/Unity-Technologies/UnityCsReference/blob/master/Modules/UIElements/Controls/ScrollView.cs
you just want it to never scroll with the scroll wheel?
or is it more complicated?
basically trying to mimic behaviour of the built-in timeline - scroll wheel zooms instead of scrolling up and down
ohh
you know what I'd do
I'd subclass ScrollViewer
though no, that doesn't really work
but you could copy the code and replace the functionality in OnScrollWheel
yea... can't subclass because the method isn't accessible
it's probably less hassle just to manually track and set the scrollOffset .. maybe I'll leave some feedback in the hope they support it
Unity still displays a poor understanding of UI frameworks sadly
well lets back up
You have a SCrollViewer in your layout, why
because you want a zoom scroll functionality?
well the source does have the note // TODO: Same behaviour as IMGUI Scroll view so I assume more work is planned
You want behavior that already exists in the GraphViews
what's GraphViews? π
I see.. well.. this is almost identical to Timeline - just not quite close enough to be able to use Timeline itself
so 2 way scrolling & clipping
zoom to cursor and dynamic time labels etc is all working fine and was quite quick to set up
but you can't prevent the scroll while zooming?
ECS based Tweening tool with animations as assets
Get the scrollers, and disable them
wtf
// Set availability
horizontalScroller.SetEnabled(contentContainer.layout.width - contentViewport.layout.width > 0);
verticalScroller.SetEnabled(contentContainer.layout.height - contentViewport.layout.height > 0);
hmm but I want them useable still
just disable them when you start the zoom, and then enable them when the zoom completes
tbh, I'm guessing at this point
I'd probably build a custom control for this myself
appreciate the thoughts
this won't be released for months yet so I'll try my luck with posting feedback on the forums and move on for now I think
nods
There also appears to be a bug with binding that I can't get to the bottom of as well.. need to make a small project to repro π₯Ί
whats the issue?
or what is the symptom
it may be relted to issues I've had in some circumstance
Also, they are supposedly introducing a new binding system because they don't like the current setup
and It seems they may be abandoning SerializedProperties based upon some of the road map for UIElements
it looks like a post processing effect to me, but we don't really have any context here
hmm the issue is related to calling BindProperty on PropertyFields - I check the binding paths after a delay and they're fine but then in the property drawer I check their binding path after a delay and they're all set to the last one created. Except for occasionally. π
from what I understand PropertyDrawers are still a problem with UIElements in general
I see
bare in mind, that could be out dated
I was reading about it a few months ago, so it coul dbe fixed by now
I personally have avoided using BindProperty, and instead use Bind on entire object / view trees
I recall having much trouble with it
yea unfortunately I can't in this instance - ideally I actually want to draw the property using the property drawer without binding it to a particular asset...
but anyway... I'm about to face two more issues I wonder if you have thoughts on? haha
- marquee selection - there's nothing built-in you know of is there?
yea, click, drag, draw rect, select clips within rect region - I can obviously do it all manually but just checking before I do
- 'binding' fields to multiple serializedProperties - similar to CanEditMultiple or whatever that attribute is called - I assume that (quite reasonably) I would need to do not bind to anything and handle all of the chang events manually
oooh
no, there is nothing like that which exists, you'd have to make it, but it should actually be pretty trivial
there is a function for checking hit points and you can just create an element with position:absolute;
Log the start click position, and then set the Width/Height of the element to the difference in start mouse position and current mouse position
there may actually be an element overlap check
well, I should say, I'm not aware of that kind of tool existing
it seems like something that'd exist in Graphs
as far as multiple targets go
I have no idea
I never understood how that works
Thanks for thoughts π
oh actually hit points is probably silly
you could just find all the elements taht are selectable in the tree, and then check if they are contained or however it is you want to handle it
yea that's cool, should be straight-forward and I think there is an overlap method I can use
hmmm... would this be the right channel to ask a question relating to making custom PlayableAssets for the Timeline?
whats the best way to get a scriptable object reference into an editorwindow by searching it in the assetdatabase?
it will be used at runtime as well so i should probably put it in resources
its a collection of letters that generates a 3d mesh
private void Awake()
{
var asset = AssetDatabase.FindAssets("Letters")[0];
_lettering = AssetDatabase.LoadAssetAtPath(asset, typeof(Lettering)) as Lettering;
}
was thinking something like this in the editor window
What you are doing with it does not matter. Resources is never the answer.
If you can reach it at runtime, it means you must have a way to reference them before building
Unfortunately, AssetDatabase is Editor only
well for editor window that is fine, when I use it at runtime I need to reference it somewhere in a monobehaviour
I have a dictionary in the SO and a function to make a combined mesh. I just cant seem to find the right syntax to load from the assetdatabase
oh nvm I found it
FindAssets returned an id, not a path
i really wish there was something similar to assetdatabase for runtime
just something that lets you get assets through strings
i know strings blech but they make it so easy
without having to hook up direct references in some proxy object
And you will end up with thousands of issues you 'never expected' because of this poor design
if you really wanted, you could use consts and a seperate lookuptable that converts string to GUID, to prevent typos and moved file issues
dunno what other downsides there are
Resources is bad but it's not because of strings imo
it's because it's basically a shitty 0.001 version of an assetbundle without the benefits of real assetbundles
Resources is bad mainly because of memory.
ya
i wrote my own resources class that is basically just a dictionary with string lookups to assets baked during build
but assetdatabase.findassets is slow and it runs every time you hit play so would be nice if there was proper unity support
addressables seem like something that might solve it, but then every asset you load will be asynchronous so you end up having to go through callback hell or poll until loaded
how do I deal with that inconsistent line endings ? i know its fine and all but it does annoy me
VS > File > Advance options
Set the line ending
oops, that coulda been #π»βcode-beginner , it happened in an editor window and my brain didnt deduce it wasnt editor relevant xD
aight thx
weird, I dont see an advanced options in the dropdown
there are so many options there i didnt know about
what the hell
oh god, so amny options, which should it be on?
nvm that was encoding that was huge
there we are, tyvm
this script took me way too long, but it was quite fun to do xD
This is the way to go π
Quick question, any way within a CustomPropertyDrawer to press TAB to go to the next field?
Not really, instead it adds a tabulation to the current... TextField...
...Is that my problem? Should it not be TextField? Whoops
You never stated TextField
Yeah I think that's the issue
Not an issue
Well, it still does the [press tab] > [add tabulation to the text]
Which is not what I want in my case
You can catch the event before the TextField
Why is it that when I draw with a CustomPropertyDrawer, if the Property is inside an array, the "distance" between horizontal elements increases?
Case in point: Above a variable, and down below a List
The way I calculate those widths it is by using "position.width * 0.5f" and then adding or subtracting something... Is it because of that?
we need code
Guess this is the best place to ask about package manager questions? The thing I'm trying to do has to do with custom editors.
For some reason, target in PostProcessEffectBaseEditor is marked as internal, but I need to use it in my effect editor. Is there a way to modify packages from the package manager?
Of course, in instances where I'm trying to access something internal, I always second guess, should I be doing this? But there's no other way to do what I need to do, and target is marked as public in Editor.
you cannot modify packages. You haven't explained what you want to actually do
You can always use reflection to get the value of an internal property
Also, a cheat way of doing it without reflection is using the FindProperty function they provide and then property.serializedObject.targetObject
making a custom editor script for an effect. I want to serialize an enum and change some of the parameters when the enum is changed depending on which value is chosen. but it looks like that cheat worked. not a fan of "cheats", but I feel much better about that than introducing Reflection. thanks for the help, guess I've got to think outside of the box more
@quiet solstice you can either use reflection or change the package to have internals visible to your code
Using UIelements but also in other cases I sometimes use "EditorGUIUtility.Load" to load things like .uss files, .uxml files and icons.
Using a path variables like asset/textures/tex1.png or something
But so when someone messes with the project hierarchy, this can break things.
What would be a better way of loading .uss and .uxml files that does not rely on a path?
Should I just use references?
I barely ever touch that interface tbh. I don't really understand its limits when it comes to inspectors, property drawers, and editor windows. Doing it via the assetdatabase works in all conditions
Yeah, I need to add that lol
There is a license file in your project stating MIT
in the NUtilities repo
so you're good π
Ah cool, there's a few packages of mine where I've missed it
When I try to open a script my unity freezes?
@gloomy jolt Please do not cross-post
This channel is also for extending the editor and has nothing to do with your question
Given a SerializedProperty is possible to determine if it belongs to an Scene (its gameobject is inside an scene) or if it belongs to a prefab (it's gameobject is in a prefab file [not confuse with a prefab instance, which can be either in an scene or another prefab]) and get that scene or prefab file?
Is there any way to access selected item in Project window inside Editor Script?
The Selection class?
Noticed this one, so far I am able only to get scene elements out of it
oh got it activeObject works, thanks
Hey so, though this would be a better chat to ask about my problem, which is that a FloatField keeps resetting to its original value https://gyazo.com/5fdc7fb041cd4dc569102d6c02f445fb
this is the code for that part of the script var region = worldController.regions[selectedRegionIndex]; region.height = EditorGUILayout.FloatField(region.height);
.height is not changed anywhere else than here
except from the inspector where its also changeable
(code is in OnGUI method)
@worldly charm is that a serializable value?
or readonly? what is that height property
this. I made the setHeight function for testing but not used so I could remove that if not needed
the regions[] is a array of TerrainTypes
have you tried it with an integer not in the struct?
cuz i ve not yet seen this approach with structs
or maybe try making it a class?
Oh shit yeah, changing it to a class actually fixed it
probably structs are not serialized, classes are. not sure why or how thats a thing xD
so yeah, dont use structs for serialization xD @worldly charm
gotcha lol
Struct are handled by Unity. Don't remember since when, but it is.
In your case, this is because you are setting a struct's field, and you forgot to reassign the region after
@worldly charm
@burnt dove SerializedProperty does not imply you are working on an Object. If it does, there is API that let you know if you are on a Prefab or instance of it, or none.
what parameter is additem expecting there?
AddItem(GUIContent content, bool on, MenuFunction2 func, object userData);
either a void Func()
or void Func(object obj)
cant you pass in a lambda?
but i woudlnt be able to convert the object sent to a list right
you can
regions is an array of Region right?
but i woudlnt be able to convert the object sent to a list right
What do you mean?
well, you can
how
just wrap your callback with new GenericMenu.MenuFunction2(callback)
dont know what you mean
menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(callback), regions);
?
wait, what is callback?
public void Callback(List<Region> regions) { }
or does it need to be (object regions)
yes, it must be object
alright and then how do I make it into a List<Region> ?
you just cast the argument variable to it
thank you
Is there any way to have elements with Prefab preview in custom Editor Window? i.e. is there any 'PrefabField/View" available?
you mean if you have an object field taht it shows the prefab in a preview? @whole steppe
I would basically like to recreate Project window, that is mixed with some aditionall controls
try setting the width and height of an objectfield in the custom inspector
if that doesnt work you can get the prefab assets preview render and show that
ok will try that, thank you
How can I get the path where something is being stored inside Unity Editor?
Imagine I have this:
Assets/base.prefabAssets/base variant.prefab-> which is variant ofAssets/base.prefabAssets/scene.scene
scene.scene has 3 gameobjects inside:
base instance-> an instance ofbase.prefabbase variant instance-> an instance ofbase variant.prefabgameobject-> a common gameobject
This is what I want to do when I execute this method in a SerializedProperty vs what I get.
- Open scene.scene and execute method in any serialized property of gameobject or children. Got
Assets/scene.scene. Correct. - Open scene.scene and execute method in any serialized property of base instance or children. Got
Assets/scene.scene. Correct. - Open scene.scene and execute method in any serialized property of base variant instance or children. Got
Assets/scene.scene. Correct. - Open base.prefab and execute method in any serialized property of it or children. Got
null. ExpectedAssets/base.prefab - Open base variant.prefab and execute method in any serialized property of it or children. Got
Assets/base.prefab. ExpectedAssets/base variant.prefab
This is my code, any idea?
public string GetWhereIsStored(SerializedProperty property)
string path = null;
UnityEngine.Object targetObject = property.serializedObject.targetObject;
if (PrefabUtility.IsPartOfAnyPrefab(targetObject))
{
GameObject root = PrefabUtility.GetOutermostPrefabInstanceRoot(targetObject);
if (string.IsNullOrEmpty(root.scene.path))
path = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(root);
else
path = root.scene.path;
}
else
path = ((Component)targetObject).gameObject.scene.path;
Debug.Log(path);
I would suggest you to try all the methods in PrefabUtility, because there are a lot of them, and who is doing what is blurry (to me)
I am actually doing that but no luck
For example, if you open a prefab file in the scene viewport PrefabUtility.IsPartOfAnyPrefab(targetObject) doesn't recognices it as a prefab. Is seems that that method (and all others) only works for instances.
Impressive, PrefabStageUtility.GetPrefabStage((Component)targetObject).gameObject).prefabAssetPath seems to work like a charm. Thanks
would this be the right place to ask about getting an external editor working with unity? trying to get vscode to work and its giving me problems my other pc didnt give me.
@young island it's not the place, probably #π»βunity-talk, but is it just intellisense?
omnisharp seems to be missing a file
and idk why
FAILURE: Could not locate 'C:\Users\myuser\.vscode\extensions\ms-vscode.csharp-1.21.11\.omnisharp\1.34.11\.msbuild\Current\Bin\Microsoft.Build.Tasks.Core.resources.dll'.```
How can I extract a sub asset from an asset file? AssetDatabase.ExtractAsset only works from materials embedded in model assets
Just noticed I can do
AssetDatabase.CreateAsset(Instantiate(selection), newPath);
AssetDatabase.RemoveObjectFromAsset(selection);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
@burnt dove LoadAllAssetsAtPath?
I want to create a precompiler script, is there any way to execute it without attaching a monobehaviour to the scene or creating a menu/editor?
@ivory crater There's the InitializeOnLoad attribute
woh thank you ^^
when making an FSM, do I use delegate functions or unityevents? what do you feel are the benefits of either?
additionally, are delegates serialized like unityevents? or should i just make derived unityevents with parameters?
Delegates aren't serialized
So if you care about serialization you gotta use unity events
given the states of the FSM will be SO i do need to be careful about it
wa thinking to be able to make it work using just C#
so i dont depend on unity, and i can use it outside of unity
hmm. unityevents do not support return values...
Lemme chekc if I have an implementation that does
I don't but I think it could be converted fairly easily
I found a way around it since I am using xnode for the visual editor for the FSM
I needed to output the state of the behaviour so i just wrapped the event in a function
Hey guys, i'm using VS Code as editor and everytime i start a new project i can't get Intellisense(?) to work, usually after 1/2 restart of VS Code and / or Unity it works but it don't look like atm
Like i would expect the usual window to open and list the methods and components of the Input class
Wrong channel
Does SerializeAttribute do something in ScriptableObject?
Hi all, I have made an editor script that manipulates with a prefab instance in my scene. But after making modifications through my custom editor and entering play mode those changes disappears and are totally gone, even after returning to edit mode. However, if I unpack the prefab and do the same changes my changes are persistent throughout play/edit mode. Would anyone know why I lose these changes, but only if the instance is a prefab?
Headsup! This issue is ONLY present for one of my fields and that field is a List<ISomeInterface> where I am using the new attribute: [SerializeReference]
It could potentially be related to this bug: https://issuetracker.unity3d.com/issues/cannot-override-type-of-serializedreference-fields-in-prefab-instances?_ga=2.150978612.326270132.1581851612-1599025493.1566285874
To reproduce: 1) Open the attached project and scene 2) Select Polymorphic Prefab in the hierarchy 3) Change Derived Class 1 to some...
And another bug report here. https://forum.unity.com/threads/broken-references-for-prefabs-with-serializereference-fields.827727/ Nevermind my question, it seems like that their are some issues with Prefabs and SerializedReferences.
@burnt dove I don't think you have to have it but i often do put it on the class automatically
Ok
I have the mouses position in screen space, but for the life of me I cannot figure out how to convert it to gui/current editor window space. I thought GUIUtility.ScreenToGUIRect(...) would do it, but it doesn't seem like it does much of anything.
Any ideas?
When you manipulate the content of a prefab's .meta file is there some specific way to ensure that the changes are saved to disk? My current attempts have failed so far and it seems like it simply reset back to basic when i close/open unity
I am using PrefabUtility.SavePrefabAsset(sourceRootPrefabB); but I am not sure if that is the one I should be using.
Anyone know of any resource that can help me get a better understanding on how the prefab system works on a .meta file level?
@unborn bluff You mean you are writing to the meta file, but Unity overwrites it eventually?
I honestly don't know exactly what is happening - That is why I am looking for more resources to understand it properly. I am trying to change the linking references among prefabs so, as an example, Prefab C references Prefab B instead of Prefab A. I do this by opening up Prefab C and replace Prefab A GUIDs with Prefab B GUIDs. This also works to a certain extend and my Prefab C succesfully reference Prefab B instead of Prefab A however, my unique changes, only applicable on Prefab C is gone from within the editor. But if I open up Prefab C again I can see those unique changes are still present in the .prefab file, but not in the editor.
So in short:
- Prefab C inherits from Prefab A
- Add a sphere to Prefab C
- Replace Prefab A GUIDs in Prefab C with Prefab B GUIDs
4: Prefab C now references Prefab B, but the sphere is gone.
You can try either saving any changes there might be in memory before modifying the .prefab file or unload the changes before modifying, using Resources.UnloadAsset
How does Resources.UnloadAsset work with this? My prefabs are not related to the Resource folder in any way?
Unity decided to put runtime asset management stuff into Resources.
There might be an AssetDatabase method that does the same thing
Could you elaborate on that? What do you mean by that? That the "Assets" folder is a Resource folder in disguise for editor time stuff?
No, Resources is just a confusing name for the class
Oh
It happens to match the name of the Resources magic folder
And happens to have methods related to that
But also has other unrelated methods
Alright, noted - But how do you think it works in my situation again? If I invoked Resources.UnloadAsset prior to saving the asset, wouldn't I lose the reference?
I can't think of any reason why Unity would overwrite the changes you make unless there are some unsaved changes in memory.
That's why I suggested trying to save before modifying or unload in-memory changes before modifying.
Its a tad more strange than that I believe - The sphere is still present in Prefab C, but simply minimizing the editor and returning back to it will make it disappear.
So the .prefab file is never modified after you modify it?
My hunch is that it somehow relates to the PrefabLibrary, but I can't find any information about this library.
No
After I have done my GUID replacements, I simply minimize the editor and the Sphere disappear.
Are you modifying any .meta file for this? Your original question mentions .meta files, but it sounds like you're just replacing GUIDs inside the .prefab file.
Yeah, I am sorry about that, I actually mis-stated what I did. I don't touch the .meta file at all. I only touch the .prefab file.
Sorry for the confusement
anyone know if Bolt or Playmaker can be used to write editorwindows? or if there is a visual scripting solution to making custom editor tools?
@unborn bluff Are you able to recreate the same bug if you manually replace the GUIDs? Are multiple instances of the original GUID getting replaced or is it just one?
I can try and do it manually just to make sure. I am replacing multiple instances of the same GUID in a single .prefab.
Yeah, manually replacing the GUID also makes it disappear
Are you sure that the prefab your replacing it with has all the same properties as the original?
In PrefabInstance, there's m_Modifications which has all the modifications. Most of the original base prefab's GUIDs are in there. I'm seeing things like:
m_Modifications:
- target: {fileID: 2711930948762089810, guid: df42e6bc6b121c44892ef68f81e29c76,
type: 3}
propertyPath: _offset.y
value: -0.188
objectReference: {fileID: 0}
That fileID is the ID of the component in the original prefab
So you probably have to replace that too, unless the prefab you're replacing it with is also a variant of the original prefab.
Here is an example of my Prefab C: https://pastebin.com/1xDSbEXB
Notice that there is an object called "Sphere", but none of the GUIDs or FileIDs related to Sphere is modified. The only GUID replacements which happens are after the line: --- !u!1001 &1018047463815447383
In short, I am replacing all instances of GUID 9484ab42cded34ef2a1d991e6e05f49d
I'm assuming if you search for fileID: 400000 in Prefab A, you'll find something like
m_Component:
- component: {fileID: 400000}
400000 is the ID of a Transform component in Prefab A that Prefab C is overriding some values in.
I assume Prefab B doesn't have a Transform component with the id 400000
So the prefab file becomes invalid, because it's trying to override values of a Transform component that doesn't exist in Prefab B
So your idea is that Prefab C becomes invalid and simply boost out Sphere? But I can make changes to Prefab B and those changes are reflected in Prefab C.
I just tried deleting all the Modified fields from Prefab C and it doesn't change anything.
I don't know if this changes anything, Prefab A is technically an FBX file, but if I am not mistaken Unity treats it in a similar way like a prefab.
I'm trying to recreate this bug
I am on a bike and on my way home. Ill ping you when I get online again.
I still think this is due to a wrong fileID. I couldn't recreate it in a quick test, but that's with Prefab A and Prefab B are identical, so they have identical file IDs.
What about
Transform:
m_CorrespondingSourceObject: {fileID: 7660554750686849776, guid: 82705d16fc71da1488d80eb3dbc63d5a,
type: 3}
which I see at the bottom of my prefab variant. Maybe you need to replace the fileID there.
Yeah, that is a possible suspect
Yep, if I change that to something different, then it doesn't add the new game object
My explanation is that if something goes wrong when deserializing the base prefab, then it skips the next steps, which probably includes applying modifications and added/removed game objects/components.
In UIelements I have this toolbar
They are toggles
And I want the different buttons (toggles) to be selectable, but not all at once, only 1 at a time
Right now I use this code
But the issue is that once I press the support toggle, I want to set the other toggles to 'false', but then their respective callbacks are triggered and the support toggle gets unchecked again
How should I approach this?
@lucid hedge Toggle.SetValueWithoutNotify()?
That seems to work!
Really cool, thank you very much π π
Although it seems kind of buggy, will test some more
Is SetValueWithoutNotify supposed to work with the new UIElements system @short tiger ?
i have tried everything from serialize field to a custompropertydrawer
it is just tooo complicated for me
our should i use serialized property ?
Oh no, please do not call Resources.LoadAll in a GUI method! Initialise that puppy in OnEnable
Draw them with PropertyDrawers with serializedProperty
you'll need to create new SerializedObjects out of them to be able to get their contents
(something you should do in OnEnable)
The alternate method would be to get editors for them (Editor.CreateCachedEditor) and draw the appropriate editors.
But that's probably unnecessary with this few properties
Hey guys. I am having an issue with creating my custom Unity package. I've been following Unity's tutorial on this topic and managed to pack and compile scripts, but for some reason my custom packages do not show in Project inspector. Could someone please give me a hint on what could possibly cause the issue?
What Unity version?
I've been having the same issue
They might've introduced a bug somewhere
We're on 2019.2 but it seems fixed in 2019.3
@earnest minnow
They have modern UI, it must be .3 or 2020
I'm on 2019.3.1 @waxen sandal
Lemme update and I'll see
Mine work fine, so perhaps it's empty or the package.json is saying it wants to be hidden or something
I believe I've explicitly set the package to be visible in the .json
I would remove the type, I'm suspicious about what a module is/how it could be displayed
Thanks!
@visual stag This type property was supposed to be used with dependsOnType hiding mode, but seems like there is something wrong with it in the end. Anyways, my issue is solved, thank you very much!
Does anybody know what Unity uses to draw this toolbar?
I'm trying to draw a similar toolbar (with the icons on the right)
@lucid hedge EditorGUILayout.InspectorTitlebar
Yeah you're right
that draws the toolbar
but I didn't explain properly, what I want to know is how they draw the icons on the right
because I'm doing this
to draw a foldout like this
and instead of the 3 dots on the right, I would like the question mark like in the toolbar of the mesh renderer
Editor uses this EditorGUIUtility.s_EditorHeaderItemsMethods
The BeginFoldoutHeaderGroup does take an extra GUIStyle called "menuIcon" but I'm unsure on how to pass an icon there..
I'll take a look mikilo
So like this
this "EditorStyles.foldoutHeaderIcon"
makes it so the "3 dots" icon shows up
hmm
Looks kind of blurry but it's working
sexy
That's why I draw everything myself. I never touch [Editor]GUILayout
yep
I am messing around in a nested .prefab and I wish to understand how this nested prefab reference its parent prefab. I know the GUID can be found in the .meta file of the parent prefab, but I can't seem to locate the fileID. Where is that stored?:
You need to use internal stuff
@onyx harness i assume that response was for @lucid hedge ?
Nope, you
Oh alright, so the fileID isn't located somewhere?
In a browsable text file or anything?
FileID can be found in the Library metadata. Or by calling some API.
@unborn bluff This is the code I use to retrieve the FileID handling different Unity versions.
@onyx harness thank you, I will surely give that code a try. Where in the Library is the FileID stored? In the artifacts folders?
On my end I have this:
But Artifacts seems to be the new name
(I work with Unity 2017.4, that's why)
Interesting, also, related to the code that you linked how is fileID different from LocalFileIdentifier? I found that AssetDatabase have the following function AssetDatabase.TryGetGUIDAndLocalFileIdentifier : https://docs.unity3d.com/ScriptReference/AssetDatabase.TryGetGUIDAndLocalFileIdentifier.html
Artifacts appears in 2019.3.
This method appeared in 2018.1. And is suppose to do a similar job.
But back in the time, this method was only returning an integer as FileID. Which is factually wrong. They fixed it with a long few versions after.
Or maybe I am confusing with Unsupported.GetLocalIdentifierInFile which was returning an integer instead of a long.
Alright, that makes sense.
Unsupported.GetLocalIdentifierInFile appeared first in Unity 4.
While Unsupported.GetLocalIdentifierInFileForPersistentObject appeared in U2019.1.
I'm talking a lot of about versions, but because I have to support older ones. If you are not impacted, stick to the latest
@unborn bluff Thanks to you, I just realize that Artifacts is fundamentally different than metadata. There are no more .info to provide the FileId.
Well, we must rely on API then
How come? Because everything is packed into binaries now?
Also, where do you read up on stuff like that? I can't really seem to find much information about it.
Yep, except if you know the protocol used behind, I don't have time to reverse engineer this =X
You don't. I read stuff randomly on the internet, I dive into things, discover stuff, a lot are random and curiosity
Fair enough, I am trying to get an understanding of how the .prefab files work and what all the fields such as m_SourcePrefab or m_CorrespondingSourceObject represents and how fileID relates to everything.
They've gone through a bunch of it in the Asset Database 2.0 talks lately
GUID is the unique identifier of the asset. FileId is the unique identifier of the entity in the asset.
I should probably watch them then
what are these Asset Database 2.0 talks? where can I find them
searching for stuff on the unity blog is pointless eh?
And I just discover that: https://docs.unity3d.com/2019.3/Documentation/ScriptReference/GlobalObjectId.html
Oh
Oh neat, does that mean all GameObjects have a persistent ID we can reference?
@unborn bluff When diving into prefab, you will stumble a lot into fileId:1150000.
Look up this one, and you will understand more: https://docs.unity3d.com/Manual/ClassIDReference.html
oh my
Oh thank you @onyx harness that just answered a bunch of questions I had.
I was not aware of this entire section of the manual
If you want to know more about FileId, read this guy's investigation, it's a wonder:
https://forum.unity.com/threads/yaml-fileid-hash-function-for-dll-scripts.252075/#post-1695479
is there a format specification for asset bundles?
can't tell, I don't know much about AssetBundles
@severe python @unborn bluff https://youtu.be/VF-Qe-0zXlc is one of them I think
The release of the new Asset Database provides a solid foundation for further speeding up asset imports. Learn about the improvements in the way Unity handles very large projects and discover some of the upcoming features directed towards making the asset pipeline more extensi...
Also not sure if this one had some of that info in it... https://youtu.be/S2P9n5U9xVw, I forget, I'm out and going off what I've watched
how can i record an undo operation in a custom editor window ?
Use the Undo class
to record the whole window ?
@waxen sandal im using change scope to see if a field was changed, but at this point its already to late to record the undo operation
I'd suggest to use serializedproperties and serializedobjects
So you don't have to handle it yourself
huh never though to use it in editor window
no dice
can't create SerializedObject
public class WindowVars : Object
{
public WindowVars() { }
public int textureSizeIndex = 0;
}
and
private void OnGUI() {
if (vars == null) vars = new WindowVars();
var svars = new SerializedObject( vars );
}
error:
ArgumentException: Object at index 0 is null
UnityEditor.SerializedObject..ctor (UnityEngine.Object obj) (at ...
π€ ... i don't rly undo in the custom editor window * , one of those times ...
is it possible to use something like InitializeOnLoad for editor window ?
Sure
i got it working after 20 attempts but i have a feeling it can be done simpler:
[InitializeOnLoad] public class TestWindowBootstrap
{
public static int scriptSaveCount = 19; // temp
static bool Dead = true;
static TestWindowBootstrap()
{
if ( TestWindow.instance != null ) return;
TestMono.onValidate += TestWindow.OpenWindow;
AssemblyReloadEvents.beforeAssemblyReload += Annihilate;
//EditorApplication.update += Terminate;
Debug.Log("Test Bootstrap " + scriptSaveCount);
}
static void Annihilate()
{
//if (Dead || !EditorApplication.isCompiling) return;
if ( TestWindow.instance != null ) TestWindow.instance.Close();
//EditorApplication.update -= Terminate;
AssemblyReloadEvents.beforeAssemblyReload -= Annihilate;
TestMono.onValidate -= TestWindow.OpenWindow;
Debug.Log("Test Dead " + scriptSaveCount );
//Dead = true;
}
}
class TestWindow : EditorWindow
{
static new GUIContent title = new GUIContent("Test" + TestWindowBootstrap.scriptSaveCount );
public static TestWindow instance;
[MenuItem("Window/Test")]
public static void OpenWindow()
{
Debug.Log("Open window" + TestWindowBootstrap.scriptSaveCount );
if (instance != null) instance?.Close();
var window = GetWindow<TestWindow>();
window.titleContent = title;
instance = window;
}
private void OnDisable()
{
//TestMono.onValidate -= OpenWindow;
}
// ...
}
@waxen sandal
Aren't you allowed to have a static constructor on the EditorWindow?
not sure , i did make a separate class for that
yes it is possible
i feel good π
@steady crest I got bored https://github.com/JurjenBiewenga/SerializedFunc
Why do you need that if ( TestWindow.instance != null ) return;? @tough cairn
@onyx harness i don't know how it works under the hood so i added this line in case the static variable reference was some how left over
InitializeOnLoad guarantee you the class is being triggered during the very first frames
After any domain reload, your code is being cleared from memory
and you restart from the beginning
Since the new system, you have to hook into some API to be triggered when a "false" domain reload occurs
the thing is that this code above will result in multiple editor windows being opened in the same time - all the old once will show "Failed to locate " or something like that , and some would also have some strange behaviours so i figured old code ( from previous compilation ) is still present
@onyx harness
that's why i force close the windows
GetWindow shouldn't do that
I feel this line does not work :
static new GUIContent title = new GUIContent("Test" + TestWindowBootstrap.scriptSaveCount );
i removed it
I feel like you expected this title to be assign on any new window, but what is scriptSaveCount? Do you increment it?
yea each time i save and watch it recompile
to see the debug logs and the window titles
Hello, I am working on making a Graph, using the UIElements GraphView.
I have been using the VFX Graph, and the Shader Graph as examples to go off of.
The Shader Graph uses Json to serialize its data in to a .shadergraph file. But the VFX Graph, doesn't. This is what it does
public static T CreateNew<T>(string path) where T : UnityObject
{
string emptyAsset = "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!2058629511 &1\nVisualEffectResource:\n";
File.WriteAllText(path, emptyAsset);
AssetDatabase.ImportAsset(path);
return AssetDatabase.LoadAssetAtPath<T>(path);
}
I am not exactly sure how to reproduce what it is doing. If I am right, it is writing the YAML for a VisualEffectResource class/object (It inherits directly from UnityEngine.Object) to a file. But for the life of me I cannot figure out how to get the YAML like that for my own class/object.
I don't think there is any public api for that
is it possible to cast a none physics ray and get a collision color pixel from it ? i was looking into making a ortho camera and changing the orthographicSize to something of a 1x1 pixel
A none physics ray?
You can get the uv coord of the hit and then look it up on the texture
Reflect into InternalEditorUtility.ReadScreenPixel(Vector2 pixelPos, int sizex, int sizey)[0]; if you don't mind it being the displayed color and not the one directly on an object
@visual stag will that work for X amount of cameras or only for the main camera ?
im planning to have 1000's of those
looking for something that will behave like a 1x1 camera that got a position and a rotation
essentially i need to know how unity handles the camera behind the scenes - i get it that the display size is dynamic and can be resized in real time - would be helpful to know how to make a custom light rays capturer sensor
not physics based - but rather how the light is calculated for any object in scene *
That method will only read a pixel from the screen
if you're doing it 1000's of times, I have no idea what's best π
Does anyone know how I can change the spacing between label and text input field on a TextField Visual Element in the UIBuilder Editor?
I believe you can either add a style to override the minWidth or set the label on the text input field to be empty and add a Label field before it.
Thanks I will just make the label field empty
@gloomy chasm Where did you start with using the GraphView, I tried to get started with it, but i was totally confused about what to od
@severe python I started with the ShaderGraph source, and just tried to reimplement it. It is a lot simpler that the VFX graph. Though I did have to spend several days looking at the source to understand what it was doing. And it seems to do some things that GraphView already does...
The basic idea is this. You need to start by inheriting from GraphView, it needs a style that makes it expand to fill the space, because it doesn't do that automatically.
It uses things called Manipulators, for doing 'special' actions like dragging content AddManipulator(new ContentDragger());.
There are some actions that you listen for like nodeCreationRequest, and graphViewChanged, that are your main way of interacting with the graph.
Of course you need a data structure for your nodes, and graph.
There is a lot, I guess just look at the ShaderGraph if you want to learn?
I plan on putting my graph on GitHub once it is done. With full comments and, info on how to use it, and everything.
Would be nice if Unity Technologies would put out some info on utilizing the GraphView :/
Yeah, definitely! It has been horrible trying to learn it from ShaderGraph.
thats basically what stopped me previously, I tried digging through the source, and really hated doing so
so I gave up and just made my own solutions for what I was working on, which just ended up being a hierarchical graph
I was considering writing a blog or something about how to do it. But it is so much info, I think having a well documented Github would be easier and more helpful.
And why is the GraphView still in 'Experimental'?
any other way of doing this? the property field is a sprite variable.
being able to edit a Sprite property through costume editor?
What do you mean? There are lots of ways to do.
can you suggest me one? I just want to change the value of variable newBulwark.Icon through property field
it's underlined red cuz the EditorGUI.property() returns a bool
If I remember correctly, EditorGUI.Propertyfield automatically sets the property. There is no need to assign the value like that.
if that was the case i wouldn't have tried what im currently doing.
i even have the serializedObject.ApplyModifiedProperties()
but it doesn't work
What is icon? Is it a public field? A Property? A private field?
Okay, that looks fine. Though you don't need [SerializeField] on public fields. Unity already serializes them.
oh ok. was just making sure
Yeah, I get it. So is the field showing up, but you just can't set the value?
yes
Can you show the editor script?
Hmm, yeah that should be working as far as I can tell...
everything else works except just for the Icon field
newBulwark.Icon = (Sprite)EditorGUI.ObjectField(new Rect(400, 7, 150, EditorGUIUtility.singleLineHeight * 5), serializedObject.FindProperty("Icon").objectReferenceValue, typeof(Sprite), false); this worked XD
Try updating your rider integration
I'm not sure if this is the right place to talk about this. I'm working on a mod which will be a map making system for a game (Just for peoples comfort, I'm in regular talks with one of the Developers about this project, and he has said "zero reservations, that would actually be great to see" in response to me asking if he had any concerns or reservations about the project)
I'm trying to make it so I can reference existing assets from the game so they can be used in custom maps, but I want and am required to prevent those files being included in the asset bundles for the custom maps.
I'm having trouble working out how to solve this. Users are expected to know how to extract the game's assets, so I'm figuring I can set things up so that users just reference the extracted assets, and then I do some "magic" to turn those real references into a path reference that is populated at runtime from the games actual assets.
If my understanding of the situation is right, in order to do this I would need to setup my own system for constructing asset bundles, and replace things temporarily before the bundles are created.
Is my understanding of the situation correct, and is this approach feasible?
Alternatively, is there a better way to approach this issue that I'm not considering?
In your package manager there should be a package named Rider or something
Update that
oh yea
thank you
you saved my life
umm
never mind
now i have much more errors
i am using unity 2019.3.0a8
Is there a way to have native plugins for editor only not get copied into the build? Assets/Editor/Plugins doesn't work.
Build does not embed Editor.
Yes but I can't get the editor to discover [DllImport] loaded DLLs outside of the Asset/Plugins folder which is embedding, isn't it?
@bold siren you are not using the SO and SP correctly. Your Update() is not at the right place.
well its working fine, i dont know what you mean
for the applyModifiedProperties() to work?
Working fine does not imply you use them correctly.
then what's the suggestion?
You assigned fields directly on the 2 first fields.
Then you tried to update through a SerializedProperty.
Then Update & Apply.
Update() will refresh the representation of the object into the SerializedProperty. Meaning it will look into its target and update its data.
At this point, your Name & Description will get refreshed.
Your Icon was modified through the SP, before the Update(). If I am not wrong, it will be discarded.
Usually, you should stick to one path, not using both worlds (through SO with PropertyField, or IMGUI)
Switch PropertyField with ObjectField and set the Icon.
And get rid of SerializedObject.
@bold siren
Or, just use SO, but stick to it
I see. thanks for clarifying!
Just note that, if you use both ways, you will stumble on issues like the one above. And if you don't understand how it works internally, it will just become a headache
noted
So I was recently introduced to the Shader Graph editor in Unity. Funny enough, I was in the middle of building a custom graph editor for a type of asset in my game when I found it. The Shader Graph does literally everything I need my custom graph editor to do- has searchable types of nodes with specific inputs and outputs that process information in some way, has global constants/properties that can be fed into nodes, and is easy to use. The problem, is I need something like this that I can use generally. As in, not for shaders specifically.
Is there some way I could highjack the Shader Graph infrustructure to do this for me?
Are there any general purpose addons you know of that works closely to the Shader Graph?
Other suggestions? Shader Graph is a perfect example of what I need.
This kind of thing
@vernal lake I found this video a while back https://www.youtube.com/watch?v=7KHGH0fPL84&feature=youtu.be
Might be what your looking for(It's uses the GraphView Api to build a dialog graph)
In this tutorial we are going to create a SUPER SIMPLE node based dialogue system with the ability to branch story lines. We gonna create the main setup and make our graph entirely functional in this episode.
In the next episode, we gonna add save&load system for nodes and ga...
thats a superb introduction
Hmm, GraphView? Iβll have to give it a watch when I have time. May be just what I need. Thanks!
If you want something like ShaderGraph, GraphView is what ShaderGraph is built ontop of, as well as the VFX Graph
Actually, I'm going to go drop that video into resources
Yeah, watching the first 5 or so minutes of that video, I believe this is exactly what I need. Thank you! Itβs surprising difficult to find this if you didnβt know it existed.
Yeah I found it on the unity subreddit page.
After I made my dialog editor with IMGUIπ
π
Anyone know of any material at all re UIElements Usage Hints?
Learn to use MVVM style design with WPF then apply that understanding to how to use UIElements
After you write a databinding framework
it already exists
UIElements with editable fields are derived from BindableElement
so you can do a lot with that already, then add on the fact that you can manually bind elements, that gets you a bit further
UIElements lakes Data templates unfortunately, which i build a solution for In VisualTemplates, but its currently broken
with scroll scope
with out scroll scope
i want it to match the window size
using GUILayout and EditorGUILayout
how to prevent scroll scope from allowing child IMGUI to overflow ?
Set a maxwidth/width on your layout
doesn't work
using(var scope = new GUILayout.ScrollViewScope( scroll, GUILayout.MaxWidth( Screen.width ) ))
It means one of your nested layout is requesting this width
or you requested it yourself
show the code
Hey, I know this is a reach, but anyone happen to know if there is a way to get UIElements into an inspector in Unity 2018.3?
I know it predates CreateInspector
and that you can't use GetRootVisualContainer();
I just really don't want to write some imgui code right now lol
I'd even been fine with it being some kind of reflective approach
hmm
There is definitely ways, I just can't remember as I've not used it for ages
its so much better now, I'm just working ina context where I can't be on 2020.1
though, I'm trying to make that happen π
anyways, in stating that I realized I can check out the 2018.3 C# source and probably find a way
Totally. I mean, I've put kittens into every window (even toolltips) before, anything's possible with reflection and UI Elements ;P
I'm in love with UIElements, I cannot lie, I've been a huge fanboi over WPF, but UIElements in many ways is just better
can UIElements draw ontop of IMGUi?
Yep
so all I really need to do is find the root visual element via an editor context
by editor context you mean an Editor?
yeah
is there a reason for 18.3 and not 4 btw?
working on a stage editor for a game built in 2018.3
If you get the Inspector window then it has a rootVisualContainer that's internal
There's a static List<InspectorWindow> GetInspectors() method that you could use to get that.
Then you can look at the tracker property on the InspectorWindow, and ActiveEditorTracker's Editor[] activeEditors property to see whether your editor is in that
there's probably a better way but that's what it's led me to π
yeah that seems reasonable
@onyx harness
var max_w = GUILayout.MaxWidth( Screen.width );
var lbl_w = GUILayout.Width(style_label_width);
using( new GUILayout.ScrollViewScope( scroll, max_w ) )
{
using ( new GUILayout.HorizontalScope())
{
GUILayout.Label( "Lightmaps folder", lbl_w );
GUILayout.Space(5);
if (GUILayout.Button(preview_folder, EditorStyles.textField) )
{
// ...
}
}
}
@tough cairn whats the question?
@tough cairn What is style_label_width?
float
but based on what?
