#↕️┃editor-extensions

1 messages Β· Page 55 of 1

minor hound
#

Try re-importing it πŸ™‚

distant vortex
#

thats how i noticed the error

#

by reimporting

#

is that a problem on my editor's side?

#

im using vscode

minor hound
#

Try what NFMynster said, regen your c# project

distant vortex
#

im sorry, can you explain how to do it?

#

suggestions on the web say to choose vscode again

#

by browsing

minor hound
#

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

distant vortex
#

right

#

ill try thanks

#

i can see its some omnisharp problem

#

because tmpro doesnt work too

minor hound
#

The error is a generation problem so it might fix it, report back πŸ™‚

distant vortex
#

Well, i swtiched to visual studio 2019

#

reimported the package

#

and now it works

#

im scared of switching to vscode now

#

πŸ˜„

minor hound
#

Haha, you can always switch again back to vs2019 πŸ˜‰

severe python
#

vs2019 is better

#

πŸ˜„

#

runs away before the debate begins

minor hound
#

I write my code on paper and scan it in

distant vortex
#

genius

muted pelican
#

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.

lucid hedge
#

What's the difference between using

#

#if UNITY_EDITOR

#

and

#

if (Application.isEditor)

visual stag
#

One does not get compiled if the preprocessor argument doesn't exist

#

The other does

lucid hedge
#

Do you have an example of when I should use one of those instead of the other?

visual stag
#

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

lucid hedge
#

Ah that makes sense

visual stag
#

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

lucid hedge
#

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 πŸ™‚

ivory crater
#

what does asdmdef and assmdef means?

lucid hedge
#

Assembly Definitions

ivory crater
#

ahh ok ok

onyx harness
#

Asdmdef does not exist. Vertx meant 'asmdef' I guess

visual stag
#

Look, mobile phones aren't the best

ivory crater
#

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

onyx harness
#

That's why I clarified, we're just humans after all

severe nacelle
#

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?

shadow violet
#

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")

visual stag
#
using(new EditorGUILayout.VerticalScope("box")) {
  ...
}```
#

(obviously cache the guistyle)

willow wind
#

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();
shadow violet
#

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))
                        {
...
}
sterile steppe
#

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

karmic cliff
#

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

waxen sandal
#

You get passed thet serialized property in your ongui method

karmic cliff
#

Yes, but do I just... cast it somehow? I am not clear about how to change it

waxen sandal
#

Read up on serializedobjects and serializedproperties

#

It's too much to just explain

karmic cliff
#

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

waxen sandal
#

Yes

#

But you can get a long by doing serializedproperty.longValue

karmic cliff
#

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

waxen sandal
#

The description is just shit

karmic cliff
#

Got it

waxen sandal
#

It's probably because a long counts as a SerializedPropertyType.Integer

karmic cliff
#

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

waxen sandal
#

That should work just fine

onyx harness
#

@sterile steppe yes.

sterile steppe
#

Thank you

karmic cliff
#

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?

visual stag
#

PropertyAttribute

#

not Attribute

karmic cliff
#

... 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;

visual stag
#

Yes

#

PropertyDrawers don't work on arrays/lists

karmic cliff
#

... Guess that's my problem then

#

What's a solution or workaround? Just make a class then?

visual stag
#

Yep

karmic cliff
#

I tried to be smart about it. Guess it ain't happening. Thanks for the help.

visual stag
#

just put the node positions in a #if UNITY_EDITOR block

#

or keep them as separate data

gloomy chasm
#

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.

severe python
#

you want to inject something into the slider field?

gloomy chasm
#

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. πŸ˜›

sand spindle
#

How can I get the Debug.Log output in the visual studio debugger even when Unity is frozen due to a resource hungry code?

onyx harness
#

You open the Editor.log and listen to it

sand spindle
#

So I can not check it out in real time?

visual stag
#

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

hollow spruce
#

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

waxen sandal
#

Just don't make it public or serialized?

#

Or use hide in inspector

dim walrus
#

Yeah scriptable objects don't need to be assets

onyx harness
#

@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.

stark geyser
#

@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?

onyx harness
#

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

stark geyser
#

The stuff that is not used at runtime and not in Resources would not be built in.

onyx harness
#

Inspector can not inspect something that does not derive from Object

#

You can hook into Selection to be aware when the selection changes

ashen wyvern
#

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 πŸ˜•

split bridge
#

FYI for those using UI Builder, looks like loads of great fixes & improvements in 0.10.1 released a couple days ago

severe python
#

@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

covert quarry
#

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

waxen sandal
#

Wrong channel

covert quarry
#

Where should I ask it then?

waxen sandal
#

You're going to have to provide more information though

#

Since it's possible to determine why it's happening atm

vestal sand
#

can I ask help about polybrush here?

waxen sandal
#

If you're developing polybrush then yes, otherwise no

rugged herald
#

has anyone had the misfortune of trying to work with the Chromecast unity plugin lately?

visual stag
#

@rugged herald Do not cross-post. This channel is for extending the editor, not for questions about plugins

rugged herald
#

aren't plugins editor extensions?

visual stag
#

Sure, if you were making one that modified the Unity Editor yourself then this would be a relevant question.

rugged herald
#

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

visual stag
#

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.

rugged herald
#

my bad... i shouldn't disturb the crickets in here...so busy my text just flew right by

rich marlin
#

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

waxen sandal
#

Are those items using a custom propertydrawer?

#

If so then you're probably not setting yourheight correctly

rich marlin
#

They are yeah

#

How would I go about getting the correct height

simple cove
#

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<>())

#

nvm my monologue then πŸ˜„

twilit flume
#

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?

near wigeon
#

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?

visual stag
#

@cosmic dagger this channel is about extending the Editor, not general questions

vestal sand
#

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

simple cove
#

@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)

versed flower
#

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

grand portal
#

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?

waxen sandal
#

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

grand portal
#

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

waxen sandal
#

I've got no clue

grand portal
#

I mean, i can access that with rootVisualElement.Query<UnityEditor.UIElements.FloatField>("LenghtThreshold").First().value but that sucks

#

There must be a nicer solution

severe python
#

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

minor herald
#

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.

waxen sandal
#

Is your element focused?

severe python
#

Can your element be focused is the question

#

It needs to be focusable

#

Which is a boolean on visualelement iirc

split bridge
#

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
minor herald
#

No my element is not focused will try setting the focus to it

split bridge
#

@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)

minor herald
#

Yeah I saw the focusable property

vapid kiln
#

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

minor herald
#

Setting the visual element to focusable = true worked
Thanks πŸ˜„

vapid kiln
#

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

opal needle
#

hey

#

I'm looking for a simple way to make sandy islands

#

like smooth single objects

ruby kraken
#

not sure if right channel, if not remove please or ping me.
Does someone know why MaterialUI theme in rider looks like that?

onyx harness
#

@ruby kraken Not the right channel, go the Slack at unitydevs.slack.com and ask for citizenmatt, he works for JetBrains

long storm
#

Is VS Code borked on Unity 2019.3?

visual stag
#

doubtful

long storm
#

gotcha

brittle sorrel
#

yes it is

gloomy jolt
#

My Visual Studio isn't autocompleting anything? Miscellaneous files. How can I fix this?

visual stag
#

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

gloomy jolt
#

Thanks!

tropic zenith
#

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!

minor herald
#

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?

minor herald
lucid hedge
#

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 πŸ™‚

visual stag
#

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.

lucid hedge
#

What do you mean?

#

in the 'Assembly Definition References' section?

#

Which ones do I need to reference? There are a whole bunch

visual stag
#

Whichever ones contain the code you care about

lucid hedge
#

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

visual stag
#

Yup, #if. I think Cinemachine is a good example of this with their post processing integration

lucid hedge
#

Will take a look!

#

And thank you, after adding the necessary references, compiler errrors are gone πŸ™‚

split bridge
#

UI Elements question - does anyone know of a callback for a ToolbarMenu opening/being clicked?

#

It's super hacky but using MouseCaptureEvent for now 😧

severe python
#

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

split bridge
#

When I tried a MDE it didn't fire - but perhaps I needed to force the bubbling or something

severe python
#

Sorry, apparently its a PointerDown event?

split bridge
#

btw do you know the difference between Pointer vs Mouse?

severe python
#

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

split bridge
#

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

gloomy jolt
#

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

lucid hedge
#

How could I open the package manager window by script?

onyx harness
#

Execute the menu item?

gloomy chasm
#

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?

steel crystal
#

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)

visual stag
#

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

grand portal
#

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)));

left gate
#

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

minor herald
#

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);
}
severe python
#

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

split mural
#

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

severe python
#

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)

topaz heath
minor herald
#

Thanks Twiner I will see what I can find about FlexBox

severe python
#

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

topaz heath
#

@severe python is this something for the asset store or just an open project you're working on for now?

severe python
#

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

topaz heath
#

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.

severe python
#

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

topaz heath
#

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.

severe python
#

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

slender juniper
#

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?

severe python
slender juniper
#

I don't want to create Terrain perse

severe python
#

discord doesn't like that link

slender juniper
#

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 ^^

severe python
#

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

steady crest
#

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

slender juniper
#

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)

scenic elbow
#

@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

steady crest
#

@slender juniper you might actually be right. I think i just assumed it would cast implicitly to a gameobject with a meshcomponent

severe python
#

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

scenic elbow
#

ah i see it now
ty Twiner
looks good

ocean geyser
#

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?

waxen sandal
#

IIRC there is a registry key

#

Computer\HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x\RecentlyUsedProjectPaths-*

ocean geyser
#

oh nice! thank you!

#

got it, that's perfect

#

πŸ”₯

left gate
#

How can know if an editorwindow is open and visible

#

(it does not need to have focus)

waxen sandal
#

FindObjectsOfTypeAll should find it iirc

left gate
#

that seems terrible

left gate
#

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

waxen sandal
#

Perhaps if you get the root element of hte window

#

There is some way to get whether it's visible

left gate
#

Hmm maybe

unborn bluff
#

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?

short tiger
minor herald
#

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?

severe python
#

you'll just need to set its position type to absolute

#

position: absolute | relative

#

you do this via USS

minor herald
#

Thanks again! @severe python

severe python
#

after that you can use any of the other position values to set its location

#

np

minor herald
#

I really like how UIElements works but I just wished there was a bit more documentation and examples for itπŸ˜…

severe python
#

Its mostly just CSS honestly, so most of that documentation applies

minor herald
#

Yeah I never worked with CSS so that does not help

severe python
#

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

unborn bluff
severe python
#

you know, a specification for the asset meta files would be dope

waxen sandal
#

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

unborn bluff
#

@waxen sandal what about prefabs? How does fildID relate to those? Anywhere i can read up on these things?

waxen sandal
#

No clue

#

I'd assume the guid is the prefab and the file Id are the subassets

split bridge
severe python
#

you just want it to never scroll with the scroll wheel?

#

or is it more complicated?

split bridge
#

basically trying to mimic behaviour of the built-in timeline - scroll wheel zooms instead of scrolling up and down

severe python
#

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

split bridge
#

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

severe python
#

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?

split bridge
#

well the source does have the note // TODO: Same behaviour as IMGUI Scroll view so I assume more work is planned

severe python
#

You want behavior that already exists in the GraphViews

split bridge
#

what's GraphViews? πŸ˜„

severe python
#

zoom to cursor

#

you know, VFX Graph, Visual Scripting Graph, ShaderGraph

split bridge
#

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

severe python
#

but you can't prevent the scroll while zooming?

split bridge
#

yea πŸ™‚

severe python
#

interesting looking tool you're building

#

uhm

split bridge
#

ECS based Tweening tool with animations as assets

severe python
#

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);
split bridge
#

hmm but I want them useable still

severe python
#

just disable them when you start the zoom, and then enable them when the zoom completes

split bridge
#

I think the scroll happens before the zoom... but I like the idea

#

will check

severe python
#

tbh, I'm guessing at this point

#

I'd probably build a custom control for this myself

split bridge
#

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

severe python
#

nods

split bridge
#

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 πŸ₯Ί

severe python
#

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

amber jackal
severe python
#

and It seems they may be abandoning SerializedProperties based upon some of the road map for UIElements

amber jackal
#

what are those white lines blocking my view?

#

It only happens in 2d view

severe python
#

it looks like a post processing effect to me, but we don't really have any context here

split bridge
#

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. πŸ™‚

severe python
#

from what I understand PropertyDrawers are still a problem with UIElements in general

split bridge
#

I see

severe python
#

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

split bridge
#

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

#
  1. marquee selection - there's nothing built-in you know of is there?
severe python
#

I'm not sure what you mean by marquee selection

#

like scrolling selection?

split bridge
#

yea, click, drag, draw rect, select clips within rect region - I can obviously do it all manually but just checking before I do

#
  1. '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
severe python
#

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

split bridge
#

Thanks for thoughts πŸ™‚

severe python
#

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

split bridge
#

yea that's cool, should be straight-forward and I think there is an overlap method I can use

arctic wyvern
#

hmmm... would this be the right channel to ask a question relating to making custom PlayableAssets for the Timeline?

steady crest
#

whats the best way to get a scriptable object reference into an editorwindow by searching it in the assetdatabase?

onyx harness
#

AssetDatabase implies it is saved in the project.

#

Is it?

steady crest
#

it will be used at runtime as well so i should probably put it in resources

onyx harness
#

Never do that

#

I mean, except if it is for your own need.

steady crest
#

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

onyx harness
#

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

steady crest
#

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

scenic elbow
#

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

onyx harness
#

And you will end up with thousands of issues you 'never expected' because of this poor design

scenic elbow
#

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

onyx harness
#

Resources is bad mainly because of memory.

scenic elbow
#

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

steady crest
#

how do I deal with that inconsistent line endings ? i know its fine and all but it does annoy me

onyx harness
#

VS > File > Advance options
Set the line ending

steady crest
#

aight thx

#

weird, I dont see an advanced options in the dropdown

onyx harness
#

Might be hidden, you need to add it

steady crest
#

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

onyx harness
#

The post explains it very well

#

Good πŸ™‚

steady crest
#

this script took me way too long, but it was quite fun to do xD

onyx harness
#

This is the way to go πŸ™‚

steady crest
#

string -> 3dmesh of letter object thorn into a mesh combiner

#

fun πŸ˜„

karmic cliff
#

Quick question, any way within a CustomPropertyDrawer to press TAB to go to the next field?

onyx harness
#

It's all handled automatically by IMGUI

#

Is it not working?

karmic cliff
#

Not really, instead it adds a tabulation to the current... TextField...

#

...Is that my problem? Should it not be TextField? Whoops

onyx harness
#

You never stated TextField

karmic cliff
#

Yeah I think that's the issue

onyx harness
#

Not an issue

karmic cliff
#

Well, it still does the [press tab] > [add tabulation to the text]

#

Which is not what I want in my case

onyx harness
#

You can catch the event before the TextField

karmic cliff
#

Why is it that when I draw with a CustomPropertyDrawer, if the Property is inside an array, the "distance" between horizontal elements increases?

#

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?

onyx harness
#

we need code

quiet solstice
#

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.

visual stag
#

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

quiet solstice
#

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

feral karma
#

@quiet solstice you can either use reflection or change the package to have internals visible to your code

lucid hedge
#

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?

lucid hedge
#

Thank you!

#

Why do you prefer that over using references like this?

visual stag
#

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

lucid hedge
#

Okay!

#

And just to be sure, the license on the piece of code you shared is MIT?

visual stag
#

Yeah, I need to add that lol

lucid hedge
#

There is a license file in your project stating MIT

#

in the NUtilities repo

#

so you're good πŸ™‚

visual stag
#

Ah cool, there's a few packages of mine where I've missed it

gloomy jolt
#

When I try to open a script my unity freezes?

visual stag
#

@gloomy jolt Please do not cross-post

#

This channel is also for extending the editor and has nothing to do with your question

burnt dove
#

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?

whole steppe
#

Is there any way to access selected item in Project window inside Editor Script?

waxen sandal
#

The Selection class?

whole steppe
#

Noticed this one, so far I am able only to get scene elements out of it

#

oh got it activeObject works, thanks

worldly charm
#

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)

steady crest
#

@worldly charm is that a serializable value?

#

or readonly? what is that height property

worldly charm
#

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

steady crest
#

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?

worldly charm
#

Oh shit yeah, changing it to a class actually fixed it

steady crest
#

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

worldly charm
#

gotcha lol

onyx harness
#

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.

worldly charm
#

Huh alright

steady crest
#

what parameter is additem expecting there?

worldly charm
#

AddItem(GUIContent content, bool on, MenuFunction2 func, object userData);

onyx harness
#

either a void Func()
or void Func(object obj)

steady crest
#

cant you pass in a lambda?

worldly charm
#

but i woudlnt be able to convert the object sent to a list right

onyx harness
#

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?

worldly charm
#

public List<Region> regions;

#

i want to pass that

onyx harness
#

well, you can

worldly charm
#

how

onyx harness
#

just wrap your callback with new GenericMenu.MenuFunction2(callback)

worldly charm
#

dont know what you mean

onyx harness
#

menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(callback), regions);

worldly charm
onyx harness
#

wait, what is callback?

worldly charm
#

public void Callback(List<Region> regions) { }

#

or does it need to be (object regions)

onyx harness
#

yes, it must be object

worldly charm
#

alright and then how do I make it into a List<Region> ?

onyx harness
#

you just cast the argument variable to it

worldly charm
#

thank you

whole steppe
#

Is there any way to have elements with Prefab preview in custom Editor Window? i.e. is there any 'PrefabField/View" available?

steady crest
#

you mean if you have an object field taht it shows the prefab in a preview? @whole steppe

whole steppe
#

I would basically like to recreate Project window, that is mixed with some aditionall controls

steady crest
#

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

whole steppe
#

ok will try that, thank you

burnt dove
#

How can I get the path where something is being stored inside Unity Editor?
Imagine I have this:

  • Assets/base.prefab
  • Assets/base variant.prefab -> which is variant of Assets/base.prefab
  • Assets/scene.scene

scene.scene has 3 gameobjects inside:

  • base instance -> an instance of base.prefab
  • base variant instance -> an instance of base variant.prefab
  • gameobject -> 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. Expected Assets/base.prefab
  • Open base variant.prefab and execute method in any serialized property of it or children. Got Assets/base.prefab. Expected Assets/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);
onyx harness
#

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)

burnt dove
#

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.

onyx harness
#

Have you try PrefabStage?

#

or its utility PrefabStageUtility?

burnt dove
#

No, I will give them a look

#

Thanks

onyx harness
#

To know who belongs where, it's a mix of few APIs

#

Which leads to a mess

burnt dove
#

Impressive, PrefabStageUtility.GetPrefabStage((Component)targetObject).gameObject).prefabAssetPath seems to work like a charm. Thanks

young island
#

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.

visual stag
young island
#

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'.```
burnt dove
#

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();
onyx harness
#

@burnt dove LoadAllAssetsAtPath?

ivory crater
#

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?

short tiger
#

@ivory crater There's the InitializeOnLoad attribute

ivory crater
#

woh thank you ^^

steady crest
#

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?

waxen sandal
#

Delegates aren't serialized

#

So if you care about serialization you gotta use unity events

steady crest
#

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

steady crest
#

hmm. unityevents do not support return values...

waxen sandal
#

Lemme chekc if I have an implementation that does

#

I don't but I think it could be converted fairly easily

steady crest
#

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

dense cobalt
#

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

waxen sandal
#

Wrong channel

burnt dove
#

Does SerializeAttribute do something in ScriptableObject?

unborn bluff
#

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]

waxen sandal
#

@burnt dove I don't think you have to have it but i often do put it on the class automatically

burnt dove
#

Ok

gloomy chasm
#

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?

unborn bluff
#

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?

short tiger
#

@unborn bluff You mean you are writing to the meta file, but Unity overwrites it eventually?

unborn bluff
#

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:

  1. Prefab C inherits from Prefab A
  2. Add a sphere to Prefab C
  3. Replace Prefab A GUIDs in Prefab C with Prefab B GUIDs
    4: Prefab C now references Prefab B, but the sphere is gone.
short tiger
#

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

unborn bluff
#

How does Resources.UnloadAsset work with this? My prefabs are not related to the Resource folder in any way?

short tiger
#

Unity decided to put runtime asset management stuff into Resources.

#

There might be an AssetDatabase method that does the same thing

unborn bluff
#

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?

short tiger
#

No, Resources is just a confusing name for the class

unborn bluff
#

Oh

short tiger
#

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

unborn bluff
#

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?

short tiger
#

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.

unborn bluff
#

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.

short tiger
#

So the .prefab file is never modified after you modify it?

unborn bluff
#

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.

short tiger
#

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.

unborn bluff
#

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

north marsh
#

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?

short tiger
#

@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?

unborn bluff
#

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

short tiger
#

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.

unborn bluff
#

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

short tiger
#

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

unborn bluff
#

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.

short tiger
#

I'm trying to recreate this bug

unborn bluff
#

I am on a bike and on my way home. Ill ping you when I get online again.

short tiger
#

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.

unborn bluff
#

Yeah, that is a possible suspect

short tiger
#

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.

lucid hedge
#

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?

short tiger
#

@lucid hedge Toggle.SetValueWithoutNotify()?

lucid hedge
#

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 ?

fleet remnant
#

how can i display the stuff in the ResourceStorage class in my custom editro

fleet remnant
#

i have tried everything from serialize field to a custompropertydrawer

#

it is just tooo complicated for me

fleet remnant
#

our should i use serialized property ?

visual stag
#

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

earnest minnow
#

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?

waxen sandal
#

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

visual stag
#

They have modern UI, it must be .3 or 2020

waxen sandal
#

2019.3.0f6 works for me

#

Possible regression or old 2019 version

earnest minnow
#

I'm on 2019.3.1 @waxen sandal

waxen sandal
#

Lemme update and I'll see

visual stag
#

Mine work fine, so perhaps it's empty or the package.json is saying it wants to be hidden or something

earnest minnow
visual stag
#

I would remove the type, I'm suspicious about what a module is/how it could be displayed

earnest minnow
#

@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!

lucid hedge
#

Does anybody know what Unity uses to draw this toolbar?

#

I'm trying to draw a similar toolbar (with the icons on the right)

onyx harness
#

@lucid hedge EditorGUILayout.InspectorTitlebar

lucid hedge
#

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

onyx harness
#

Editor uses this EditorGUIUtility.s_EditorHeaderItemsMethods

lucid hedge
#

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

brittle sorrel
#

sexy

onyx harness
#

That's why I draw everything myself. I never touch [Editor]GUILayout

lucid hedge
#

Yeah but how does Unity draw it so crisp lol

#

Looks good I guess

onyx harness
#

yep

unborn bluff
#

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?:

onyx harness
#

You need to use internal stuff

unborn bluff
#

@onyx harness i assume that response was for @lucid hedge ?

onyx harness
#

Nope, you

unborn bluff
#

Oh alright, so the fileID isn't located somewhere?

#

In a browsable text file or anything?

onyx harness
#

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.

unborn bluff
#

@onyx harness thank you, I will surely give that code a try. Where in the Library is the FileID stored? In the artifacts folders?

onyx harness
#

But Artifacts seems to be the new name

#

(I work with Unity 2017.4, that's why)

unborn bluff
onyx harness
#

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.

unborn bluff
#

Alright, that makes sense.

onyx harness
#

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

unborn bluff
#

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.

onyx harness
#

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

unborn bluff
#

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.

visual stag
#

They've gone through a bunch of it in the Asset Database 2.0 talks lately

onyx harness
#

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

severe python
#

what are these Asset Database 2.0 talks? where can I find them

#

searching for stuff on the unity blog is pointless eh?

onyx harness
unborn bluff
#

Oh neat, does that mean all GameObjects have a persistent ID we can reference?

onyx harness
severe python
#

oh my

unborn bluff
#

Oh thank you @onyx harness that just answered a bunch of questions I had.

severe python
#

I was not aware of this entire section of the manual

onyx harness
severe python
#

is there a format specification for asset bundles?

onyx harness
#

can't tell, I don't know much about AssetBundles

visual stag
tough cairn
#

how can i record an undo operation in a custom editor window ?

waxen sandal
#

Use the Undo class

tough cairn
#

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

waxen sandal
#

I'd suggest to use serializedproperties and serializedobjects

#

So you don't have to handle it yourself

tough cairn
#

huh never though to use it in editor window

tough cairn
#

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 ...

waxen sandal
#

You shouldn't inherit from Object

#

ScriptableObject is better

tough cairn
#

ah SettingsProvider is what i was looking for

#

it is a scriptable object as well

tough cairn
#

is it possible to use something like InitializeOnLoad for editor window ?

waxen sandal
#

Sure

tough cairn
#

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

waxen sandal
#

Aren't you allowed to have a static constructor on the EditorWindow?

tough cairn
#

not sure , i did make a separate class for that

#

yes it is possible

#

i feel good πŸ™‚

waxen sandal
onyx harness
#

Why do you need that if ( TestWindow.instance != null ) return;? @tough cairn

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

onyx harness
#

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

tough cairn
#

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

waxen sandal
#

GetWindow shouldn't do that

onyx harness
#

I feel this line does not work :
static new GUIContent title = new GUIContent("Test" + TestWindowBootstrap.scriptSaveCount );

tough cairn
#

i removed it

onyx harness
#

I feel like you expected this title to be assign on any new window, but what is scriptSaveCount? Do you increment it?

tough cairn
#

yea each time i save and watch it recompile

#

to see the debug logs and the window titles

gloomy chasm
#

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.

waxen sandal
#

I don't think there is any public api for that

tough cairn
#

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

waxen sandal
#

A none physics ray?

#

You can get the uv coord of the hit and then look it up on the texture

visual stag
#

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

tough cairn
#

@visual stag will that work for X amount of cameras or only for the main camera ?

#

im planning to have 1000's of those

steady crest
#

im planning to have 1000's of those

tough cairn
#

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 *

visual stag
#

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 πŸ˜›

minor herald
#

Does anyone know how I can change the spacing between label and text input field on a TextField Visual Element in the UIBuilder Editor?

split bridge
#

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.

minor herald
#

Thanks I will just make the label field empty

severe python
#

@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

gloomy chasm
#

@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.

severe python
#

Would be nice if Unity Technologies would put out some info on utilizing the GraphView :/

gloomy chasm
#

Yeah, definitely! It has been horrible trying to learn it from ShaderGraph.

severe python
#

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

gloomy chasm
#

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'?

severe python
#

shrugs

#

I mean UIElements was experimental still when ShaderGraph got "released"

bold siren
#

any other way of doing this? the property field is a sprite variable.

#

being able to edit a Sprite property through costume editor?

gloomy chasm
#

What do you mean? There are lots of ways to do.

bold siren
#

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

gloomy chasm
#

If I remember correctly, EditorGUI.Propertyfield automatically sets the property. There is no need to assign the value like that.

bold siren
#

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

gloomy chasm
#

What is icon? Is it a public field? A Property? A private field?

bold siren
#

public field

#

public Sprite Icon

#

thats how I declared it

gloomy chasm
#

Okay, that looks fine. Though you don't need [SerializeField] on public fields. Unity already serializes them.

bold siren
#

oh ok. was just making sure

gloomy chasm
#

Yeah, I get it. So is the field showing up, but you just can't set the value?

bold siren
#

yes

gloomy chasm
#

Can you show the editor script?

bold siren
gloomy chasm
#

Hmm, yeah that should be working as far as I can tell...

bold siren
#

everything else works except just for the Icon field

oak grotto
#

yo

#

i have this error

#

when i open unity

#

any ideas how to fix it?

bold siren
#

newBulwark.Icon = (Sprite)EditorGUI.ObjectField(new Rect(400, 7, 150, EditorGUIUtility.singleLineHeight * 5), serializedObject.FindProperty("Icon").objectReferenceValue, typeof(Sprite), false); this worked XD

waxen sandal
#

Try updating your rider integration

severe python
#

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?

oak grotto
#

@waxen sandal

#

whats rider integration?

waxen sandal
#

In your package manager there should be a package named Rider or something

#

Update that

oak grotto
#

oh yea

#

thank you

#

you saved my life

#

umm

#

never mind

#

now i have much more errors

#

i am using unity 2019.3.0a8

sour pumice
#

Is there a way to have native plugins for editor only not get copied into the build? Assets/Editor/Plugins doesn't work.

onyx harness
#

Build does not embed Editor.

sour pumice
#

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?

onyx harness
#

@bold siren you are not using the SO and SP correctly. Your Update() is not at the right place.

bold siren
#

well its working fine, i dont know what you mean

#

for the applyModifiedProperties() to work?

onyx harness
#

Working fine does not imply you use them correctly.

bold siren
#

then what's the suggestion?

onyx harness
#

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

bold siren
#

I see. thanks for clarifying!

onyx harness
#

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

bold siren
#

noted

vernal lake
#

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.

minor herald
#

@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...

β–Ά Play video
severe python
#

thats a superb introduction

vernal lake
#

Hmm, GraphView? I’ll have to give it a watch when I have time. May be just what I need. Thanks!

severe python
#

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

vernal lake
#

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.

minor herald
#

Yeah I found it on the unity subreddit page.

After I made my dialog editor with IMGUIπŸ˜‚

vernal lake
#

πŸ˜…

split bridge
#

Anyone know of any material at all re UIElements Usage Hints?

severe python
#

Learn to use MVVM style design with WPF then apply that understanding to how to use UIElements

waxen sandal
#

After you write a databinding framework

severe python
#

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

tough cairn
#

i want it to match the window size

#

using GUILayout and EditorGUILayout

#

how to prevent scroll scope from allowing child IMGUI to overflow ?

waxen sandal
#

Set a maxwidth/width on your layout

tough cairn
#

doesn't work

#

using(var scope = new GUILayout.ScrollViewScope( scroll, GUILayout.MaxWidth( Screen.width ) ))

onyx harness
#

It means one of your nested layout is requesting this width

#

or you requested it yourself

#

show the code

severe python
#

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

visual stag
#

There is definitely ways, I just can't remember as I've not used it for ages

severe python
#

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

visual stag
#

Totally. I mean, I've put kittens into every window (even toolltips) before, anything's possible with reflection and UI Elements ;P

severe python
#

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?

visual stag
#

Yep

severe python
#

so all I really need to do is find the root visual element via an editor context

visual stag
#

by editor context you mean an Editor?

severe python
#

yeah

visual stag
#

is there a reason for 18.3 and not 4 btw?

severe python
#

working on a stage editor for a game built in 2018.3

visual stag
#

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 πŸ˜›

severe python
#

yeah that seems reasonable

tough cairn
#

@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) )
        {
            // ...
        }
    }
}
steady crest
#

@tough cairn whats the question?

onyx harness
#

@tough cairn What is style_label_width?

tough cairn
#

float

onyx harness
#

but based on what?