#↕️┃editor-extensions

1 messages · Page 80 of 1

civic river
#

Agreed, was trying to eliminate as many possibilities as I could though. Test proj shows I probably screwed something up on write somewhere

onyx harness
#

Clearly

civic river
#

Was not clear, it broke on version update with no code changes ;p

wispy delta
#

importer is not null and successfully casts to MonoImporter.
importer.GetScript() is returning null which makes it impossible to figure out what class is being compiled (perhaps because it hasn't compiled yet 🤔 )

patent pebble
#

Can a Generic Menu be used with the MenuItem attribute?
I'm trying to show a context menu when clicking on a menu item on the top bar of Unity
But it doesn't seem to show anything

[MenuItem("Details/test")]
public static void Menu()
{
    GenericMenu menu = new GenericMenu();
    menu.AddItem(new GUIContent("TestName"), true, ToggleMenuFunction);
    menu.AddSeparator("");
    menu.AddItem(new GUIContent("All"), false, ShowAllDetails);
    menu.AddItem(new GUIContent("None"), false, HideAllDetails);
    menu.ShowAsContext();
}
#

maybe Generic Menus can only be used inside the OnGUI loop?

#

the documentation doesn't say anything about only using it in OnGUI exclusively, but shows the example using them in OnGUI() 🤔

#

oh nevermind, the source uses an event in ShowAsContext(), so I guess not

#

Another question, can I somehow control the order of the Menu Items on the main Unity bar?

zealous goblet
#

public MenuItem(string itemName, bool isValidateFunction, int priority);
you intrested in priority?

patent pebble
#

priority only works for setting the orders of MenuItems that are submenus within another MenuItem

#

it doesn't seem to affect the main Unity topbar

zealous goblet
#

well. my best guess is they are ordered in same order unity validates and loads scripts. checked couple times that in same file MenuItem remain in same order they presented in script. so probably easiest way to control it is placing MenuItems in one big script and order it there :D

#

or use that bizzare menu to control order of loading scripts.

#

also i think unity will place user menus anyway before "Window"

patent pebble
#

that's why I'm asking

#

since they are all handled internally, maybe someone knows a way of manipulating that with reflection or maybe with a publicly available utility class

#

I'm checking on InternalEditorUtility but it doesn't seem to have anything

zealous goblet
#

well. i dont know. also unity guidelines telling me "dont create new MenuItem categories and use existed one" so i never looked for this.

patent pebble
zealous goblet
#

oh where it is. it is in "Submission Guidelines" for asset store.
4.3.1

patent pebble
#

oh, I see
4.3.1.a Editor extension file menus must be placed under an existing entry. If no existing menus are a good fit, you can place it under a custom menu titled "Tools". This keeps the editor clean and organized.

#

I thought it could cause some internal conflict or something, but it seems to be mainly for keeping the top bar clean

onyx harness
#

This guideline is for public stuff.
For your own use, you do whatever you want

zealous goblet
#

though they make sense when you do it in your own stuff. couple times i looked up to toolbar and saw junkyard.

onyx harness
#

It's all up to you to not mess with yourself

dim slate
#

@wispy delta sorry a little late, I don't know if it'll help but maybe you can use [RuntimeInitialization] or whatever it's called and make sure the function runs after the assemblies are loaded?

severe python
#

Can Presets be setup to not include certain fields?

main snow
#

What would be the best way to have multiple editor UI buttons for a class on the same line? Or rather, what would be a user friendly way to handle lists better than the default editor?

currently using GUILayout.Button

visual stag
#

multiple things on the same line? use a HorizontalScope
or Begin/End Horizontal

#

want to draw a better list?
make a ReorderableList. They're kinda annoying to set up (and they're basically default in 2020+ now), but they're the way to do it

ebon citrus
#

is there a way to add my own prefab to the create button like how cinemachine adds its own camera can I add my own game object?

waxen sandal
#

Just make a menu item that's in there then just instantiate a gameobject

twin dawn
#

and the old array thing for T[] arrays?

#

I got a reorderable list for a proprety that I simply am drawing with EditorGUILayout.PropertyField(inputs);

#

actually now that I'm looking, that field is an array

#

so maybe everything is just a ReorderableList now?

main snow
#

Anyone know how to make it so that a reorderable list works with drag and drop?

I have the class called light controller, which I can drag in the normal list in the editor, but drag and drop doesn't do anything in the reorderable list.

Kinda have a hunch that there's something not right in the drawelementcallback

 LightControllersList.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    var element = LightControllersList.serializedProperty.GetArrayElementAtIndex(index);
                    var elementRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
                    element.objectReferenceValue =EditorGUI.ObjectField(elementRect, element.objectReferenceValue, element.GetType(),true);
                };```
waxen sandal
#

It works by default but only when you click outside the element iirc

main snow
#

doesn't seem to work like that either

gloomy chasm
main snow
#

like, drag from the hierarchy to the list, an object with a component of that type

#

it works if I drag into the normal list view, but not in the reorderable one

plucky nymph
#

Hey all, quick (hopefully easy) question: Im new to UIElements, making an extension using the GraphView API. Im adding some new elements to the mainContainer of a Node, and they are all stacking vertically (screenshot for example).

I would like the enum and the integer field to be on the same line (as they are a single skill check). Any advice?

#

Code for reference:

    public void DrawSkillCheck (DialogueNode nodeCache, SkillCheck _check)
    {
        var ve = new VisualElement();
        var skillEnum = new EnumField(_check.Type);

        skillEnum.RegisterValueChangedCallback((A) =>
        {
            var newType = (Stat.Types)A.newValue;
        });
        var skillTarget = new IntegerField();
        ve.Add(skillEnum);
        ve.Add(skillTarget);
        nodeCache.mainContainer.Add(ve);
    }
gloomy chasm
plucky nymph
#

And ... you're an instant legend!

#

Never thought my horrible css skills would be needed in Unity 😛

gloomy chasm
#

Haha, glad I could help. I don't mind if you @ me if you have any more questions 🙂

plucky nymph
#

Thank you!

#

If you dont mind an instant followup @gloomy chasm , how would you go about stretching those two elements to fill that line? Currently they're huddled at the left hand side.

Looking at options, im seeing flex basis (but that only changed height??), and flex grow/shrink which im unsure about

visual stag
#

if you use the UIElements debugger (right click on the inspector tab and it should be in there) you can have a play with it very quickly

#

flex grow should be the one

plucky nymph
#

oh, didnt even know that existed haha. Thanks 🙂

visual stag
#

I always get confused so messing about with it until it works generally helps 😄

plucky nymph
#

What value IS flex-grow though? Pixels? Percent? Doesnt say in any of the docs

#

Because no matter what I do to it nothing changes haha

visual stag
#

I usually just set it to 1

#

I think (this is off the top of my head) it's a normalized value that describes how much of the remaining space in the container that the item will use

#

0, it won't expand to take that space, 1 it will take all of it

plucky nymph
#

Ha! Got it. Yep, you're right 🙂 I, however, am a numpty, and was applying flex-grow to the container. Applying it to the individual field made it work

dim slate
#

Is UIElements the new way to build Editor tools? Or at least display them

waxen sandal
#

It's what Unity wants you to

dim slate
#

The way you say that makes me think I should avoid it a little longer

waxen sandal
#

Apparently it's not that bad in 2019.4 and 2020.1 but last time I used it, it was still kind of cumbersome with shitty docs

#

Some people here do like it though

visual stag
#

I do a 2/3 IMGUI, 1/3 UIToolkit, but I try to do as much UIToolkit when it comes to building tools for release just because I'd rather they be maintainable in that way. For stuff internal for projects, IMGUI rules, it requires minimal setup, and most of what is 'normal' is both easy and fast to create.

#

For anything that's a lot of complex nested/scrolling content like node graphs I would never do IMGUI 😛

dim slate
#

Got any good tutorials on that stuff Vert? I've been reallyyy loving editor scripting but so much is just undocumented

graceful gorge
#

Speaking of poorly documented Editor stuff. Anyone has a good source to learn to use TreeView? The examples Unity gives seem pretty convoluted

waxen sandal
#

Ugh, I hate Unity not returning the right property height for fields that collapse unto multiple lines (e.g. vectors)

waxen sandal
#

I should tweet at aras

#

Get him to fix it

graceful gorge
#

Do they even do fix to MGUI anymore ?

waxen sandal
#

They might

civic river
#

Docs are still just as shitty but UITK itself is quite good

severe python
#

I find UITK to be so much better than IMGUI to work with that I make a point to make it work well enough in 2018

fiery canopy
#

Quick question.

Is there a way to pass data into a property drawer within a editor script?

For example I want a popup inside my property drawer to be populated based on the field from a different serialized property.

severe python
#

You can always acquire the SerializedObject from a SerializedProperty via its serializedObject field.
At which point you can find the other serialized property on that object.
However since its a property drawer, there is no guarantee that the serializedObject is the type you expect

#

So this isn't exactly a robust design since the property drawer should stand on its own

#

This may be ok depending on your projext, and if you're using a Property Attribute to trigger the PropertyDrawer it means it will only come up when intentionally used

fiery canopy
#

OK I sort of understand what you are saying but how would that allow me to populate data into the popup field that my property drawer is trying to draw?

fiery canopy
#

OK I have gotten the data out of the serialized property that I need now I just have to figure out how to pass it to the property drawer 🤔

fiery canopy
#

Ah I was thinking of doing that since I can get the serialized property type. I wish Unity had better documentation when it came to using this stuff.

waxen sandal
#

I don't think you both are talking about the same thing

onyx harness
#

@fiery canopy Your PropertyDrawer is generated based on a specific field (Which might have a custom attribute?)

#

Use this custom attribute to target another field to be populated with

fiery canopy
#

Oh I didn't realize that could be done

#

Oh OK I think I misinterpreted what you were saying @onyx harness

The field that I am trying to use doesn't have custom attribute it is just an int value.

What I am trying to do is have the property drawer draw a popup field instead of the int field it would draw without it.

And populate the popup with string data from an array.

onyx harness
#

you need a custom property attribute

fiery canopy
#

Wait so I have to put the Property Attribute on my int variable to make that work?

#

I thought that was only for MonoBehaviors?

onyx harness
#

yep

#

Hum no

#

Attribute can be marked on almost anything C# thing

#

You need a CustomPropertyAttribute on your int field

#

then write your own PropertyDrawer

civic river
#

Is it possible to override unity's default CSS styles using an inherited style? It seems like if I supply anything other than an inline style unity's defaults will take precedence

#

For example, here despite me supplying my own CSS selector unity's defaults still take precedence:

fiery canopy
#

@onyx harness I kind of got it working but the thing is for the Attribute it is expecting a constant value. So if I want to for example change said value I can only do it through the Custom Property Attribute

#

Oh nevermind I didn't realize you could use Attributes without having to set parameters

fiery canopy
#

@civic river You should be able to override the defaults. You just have to make sure you use the correct names in your CSS file

civic river
#

It has the style their loaded in the SS, but you can see it's priority 4 and being overriden by all of the unity styles

#

Mine is the BaseNode style and unity's are the others

#

I'm not really a css guy but I'd think unity styles would have the lowest priority

#

but it seems to be the inverse

gloomy chasm
#

It should have the lowest priority...

civic river
#

Is this a bug then?

#

For ex:

.port.typeString {
    --port-color: rgba(200, 200, 200, 0.5);
}
#

You can see unity has a higher priority than me]

#

I'm having the same issues with many of the property field CSS as well

fiery canopy
#

I don't know I have never encountered Unity overriding custom CSS

#

But it could also be the values you are using for your color

#

Try

--port-color: rgba(0.2,0.2,0.2,0.5);
civic river
#

unfortunately no styles are overrideable from this css class

#

I can only create new style options that are not provided by unity's port.output and port.typeString

#

I can apply this same color to other css elements and it applies fine,

#
.unity-toolbar {
    background-color: rgba(30, 30, 30, 0);
}

.unity-button {
    background-color: rgba(0, 173, 181, .5);
}

.unity-button:hover {
    background-color: rgba(0, 173, 181, .88);
}
#

these all apply

#

I'm unsure what the difference maker is

fiery canopy
#

That is weird

#

looking at those numbers those shouldn't even show up because in the first case the alpha is 0 and the others it is close to 0 so you should barely see any color

civic river
#

the alpha is 0..1 but the rgb is fine as 0-255 or 0..1

#

I am guessing it's how it is in regular CSS but unsure

fiery canopy
#

🤔

#

Well I'm not sure then

#

hold on let me check something

#

Quick question is what you are trying to do have to deal with graph view by any chance?

civic river
#

This port example is graph view, but almost all of the UITK property fields have similar problems

fiery canopy
#

Oh OK

#

once my project loads I can see what is going on

#

Ah I thought I used rgba for my colors but I used hex values like this

background-color: #006600;
#

Also I think I don't even bother changing the alpha when using hex but I don't see why you wouldn't be able to

civic river
#

weirdly it doesnt seem allowed to supply alpha

#

with hex

#

but css seems consistent with that /shrug

fiery canopy
#

OK yeah changing the unity generated properties works for me when I change the color of the graphview nodes background color

#

let me see if changing the port color works

#

So it seems when I change the background color for the port in the graphview it doesn't change

#

I also tried changing the port color in the ui debugger and it doesn't change which is odd 🤔

civic river
#

anything else unity overrides

#

it is the same problem as the port color

#

I looked at unity's css files

#

and there's no indicator that they have different priority

fiery canopy
#

odd

#

I wonder why that is? 🤔

civic river
#

it certainly makes it very inconvenient, maybe this is not the intended behaviour

#

or maybe there's some obvious CSS solution that I'm just not aware of

#

xP

fiery canopy
#

So I did some digging and it seems you have to go even further down the hierarchy if you want to change the color of what the connection port is.

civic river
#

Does that change the edge color correctly?

#

I think the edge relies on the --port-color

fiery canopy
#

No that chances the actual port connection graphics color

#

let me see what changes the edge color

civic river
#

looks like no

fiery canopy
#

So changing the edges background color is possible but not the line graphic for it seems like

civic river
#

yeah, the color matches the port always I think

fiery canopy
#

Wait what did you change to get it to work?

civic river
#

inline style

fiery canopy
#

no I mean which style?

civic river
#

--port-color

fiery canopy
#

Ah ok

civic river
#

--port-color: rgba(200, 200, 200, 0.5);

#

^

#

it's just a matter of having high enough priority to override unity's style

#

I will have to ask about this !important on the forum

#

maybe not implemented.

fiery canopy
#

Ah OK that is something I will have to look into because when I tried changing the port color inline style in the UI Debugger it wouldn't even let me

civic river
#

yeah I had to make my own port class to change the inline style

#

;p

#

this is why I ask

#

because it's incredibly inconvenient

#

I don't want to have to also make my own property drawer classes >.<

fiery canopy
#

Yeah that is a pain most of the time.

But in most cases if you look at the UI Debugger and look for what you need to change if it can be changed in the debugger then you can just add the relevant tags to your CSS file

civic river
#

yeah, it seems like 50% of the time it works but other times the style does not seem setup correctly maybe

#

having access to this !important thing seems like... uhh.. a solution

fiery canopy
#

Indeed it does

I would like to know why it wasn't implemented

#

To be honest I think they are waiting because we still don't have animations for UI Toolkit

civic river
#

I am very new to all this CSS stuff, but I like UITK enough to deal with these problems because the many edge cases I have to solve are still less painful than the old editor-gui solution for me xD

fiery canopy
#

Lol yeah

proud ember
#

Is it expected that CompilationPipeline.RequestScriptCompilation(); does not make the Unity Editor recompile scripts when EditorSettings.enterPlayModeOptionsEnabled is true?

civic river
#

Compiling would result in reloading the domain... but whether or not that's expected is debatable yeah.

#

I could maybe see why there's a safeguard against it

proud ember
#

Yes, I would also expect the domain to reload, which would still maintain the EditorSettings.enterPlayModeOptionsEnabled purpose. I am curious to know if there is an actual reason for this not working, or maybe if it is just a case that was overlooked by the Unity devs

civic river
#

Might be an overlooked case, probably worth filing a bug report either way as it's a pretty specific case

#

I'd at least expect CompilationPipeline.RequestScriptCompilation(); to give a warning if it did nothing because of the play options

plucky nymph
#

Any ideas as to why this would show up white, and not its actual color? Can change using debug toolkit to correct value (which is what is there).

sl_v.style.backgroundColor = new StyleColor(new Color(43, 43, 43, 1));
#

Background is see through on auto, so its definitely making a change, just not to the correct color

onyx harness
#

What is 43, what is 1? The scale.

plucky nymph
#

ahhh wrong rgb, thanks all

visual stag
#

it's amazing how things just work when you read the docs 😛

plucky nymph
#

I am trawling the docs rn

visual stag
plucky nymph
#

Got thrown off by IStyle and StyleColor tbg

#

*tbh

muted zealot
#

Hi there! I'm using ScriptedImporters to import our own file format. I have some importer settings and try both with the default editor and a custom made ScriptedImporterEditor but the inspector ignore entirely Custom Property Drawer for the fields. It's quite a big issue as they are necessary for us in this case. Any idea why? Tried with 2020.1 and 2020.2, similar issue

waxen sandal
#

Show code

muted zealot
#

What part? It's quite straightforward. There is a ScriptedImporter, with serialized fields in it (so like public int m_Something for instance) with an attribute on it to use a custom property drawer (for instance, I have one which instead of the int, will display a dropdown box showing all elements from a database to pick one, but only its unique ID (int) is stored).

Then when I select the asset , the inspector does display my fields, but not using the custom property drawer (that drawer works perfectly fine in the usual inspector on scripts, or in Editor Windows, etc..)

#

Amusingly, builtin properties, like [Range(x, y)] work fine

waxen sandal
#

Your editor needs to inherit from ScriptedImporterEditor and need to apply to the importer class

muted zealot
#

Yes, like I said, it works fine for simple things, the only issue is some custom property drawers not working

waxen sandal
#

What property drawers

muted zealot
#

Custom ones, which work fine in a usual inspector

waxen sandal
#

You mean your imported object has fields that have propertydrawers for it?

#

Or your importer has fields that has custom propertydrawers?

#

What does your scriptedimportereditor look like

muted zealot
#

My importer, funny enough if the imported objects has fields like that, it works fine ! It's only in the importer that it doesn't

#

It's really basic, nothing fancy

waxen sandal
#

What's m_IDReferences

muted zealot
#

A List<IDReference>, which is a struct containing multiple int

#

and these ints have a PropertyAttribute on top of them to use CustomProperty drawers

waxen sandal
#

Seems all correct

#

I'd debug what Unity is trying to select for the drawer

#

Aka, step into whatever propertyfield is doing

muted zealot
#

Where does that happen? I would expect it to be in EditorGUI.PropertyField, don't have the symbols for that though

waxen sandal
#

Rider and VS should be able to debug into it using decompilation debugging

muted zealot
#

I'll give it a try with VS, thanks

waxen sandal
#

Is your propertydrawer UITK?

muted zealot
#

No, just old school editor

waxen sandal
#

Yeah you should be all good then

vernal quartz
#

Hey guys, i am trying to make a patcher in a editor tool for my fbx files/maps etc i am just wondering is there anything in unity that records the import time? so i can cross reference and patch up for my other devs if needed

waxen sandal
#

Think it's in the logs

vernal quartz
#

when u say logs u mena?

waxen sandal
#

The editor logs

fiery canopy
#

Quick question When you call Repaint() on an custom inspector does that reinitialize the entire inspector? Or does it just redraw it only?

severe python
#

is it possible to have fields that serialize in the editor but dont' serialize for builds?

#

I have these references that I want to exist only in the editor

twin dawn
severe python
#

That appears to cause problems in builds unfortunately

twin dawn
#

that directive makes the compiler completely ignore that code when building for a target that is not the unity editor

severe python
#

It doesn't end up excluding the referenced assets from the build is the issue

civic river
#

@severe python
I've had luck wrapping a partial class in #if UNITY_EDITOR but I'd check if it works for your purpose in build, I have a sneaky suspicion that removing fields in some cases will causes deserialization problems at runtime.
https://hatebin.com/gawueffbjs

#

In terms of references, maybe unity doesn't care if the field is compiled out and is doing static analysis on the existing codebase, not the compiled codebase, if that's the case you probably need to look towards addressables or something similar.

visual stag
#

it does cause some issues, I would avoid it as I've seen posts by Unity employees saying it's not good. Unity complains a little during the build process (though it doesn't actually seem to affect anything) - and also I've seen IL2CPP stack traces get screwed up, unsure if that's related to the same issue though

waxen sandal
#

^

grim vine
#

is there a way built-in way to import MeshColliders from a model or do i need to implement an AssetPostProcessor?

ebon citrus
#

is there any way to edit code from inside the editor?

#

for free?

waxen sandal
#

Probably not

ebon citrus
#

ok

grim walrus
#

Anyway to replicate the drag/drop that Unity does for game objects for fields?
Id like to assign a field by being able to drag an asset on it, and then it does what it needs to get said value (like unity dragging the object pulls the component)

Right now I have an object field and a string field overlapping each other

waxen sandal
grim walrus
#

oh so it was the event stuff thought that'd be for scene view FeelsChromosomeMan

#

thanks, got that running

severe python
#

Yeah I just need to strip references to assets I dont want in the build pre build and need to figure out how to handle that in a generic fashion

fiery oasis
#

Does anyone know how to fold/unfold a transform in the hierarchy through code?

gloomy chasm
fiery oasis
candid linden
#

I made something that puts the prefab variant icon in the bottom right to make it more clear it's a variant

#

is this built in Unity or does it have to be custom

glad dagger
#

If i start using bolt in 2020 or 2019 (asset store version), will upgrading to the package manager version in the future cause class name change issues or something?

vale granite
#

gots the big problem bois, I downloaded this project from github and updated the project, but when I open the project im getting tons of library errors. I also just added it to unity collaborate. Here are a few:

#

Library\PackageCache\com.unity.collab-proxy@1.3.9\Editor\UserInterface\Bootstrap.cs(23,20): error CS0117: 'Collab' does not contain a definition for 'ShowChangesWindow'

#

Library\PackageCache\com.unity.collab-proxy@1.3.9\Editor\Models\Providers\Collab.cs(110,22): error CS1061: 'Collab' does not contain a definition for 'RevisionUpdated_V2' and no accessible extension method 'RevisionUpdated_V2' accepting a first argument of type 'Collab' could be found (are you missing a using directive or an assembly reference?)

#

Library\PackageCache\com.unity.collab-proxy@1.3.9\Editor\Models\Providers\Collab.cs(114,22): error CS1061: 'Collab' does not contain a definition for 'ErrorOccurred_V2' and no accessible extension method 'ErrorOccurred_V2' accepting a first argument of type 'Collab' could be found (are you missing a using directive or an assembly reference?)

#

If you can help me that would be epic

gloomy chasm
modest ledge
#

Not sure if this is the right channel, but couldn't seem to find one that fits my question except maybe this one. I'm getting a console error when installing 2D SpriteShape from the Package Manager. I have uninstalled and reinstalled the package from the manager, the console errors go away when it is uninstalled; but come back when it is installed. Not sure what the exact problem is, but it does not appear to be on my end. My playtests work fine and everything seems to be working. Could this just be a problem with 2D SpriteShape? I do see where the error is coming from in the script, but I don't want to mess with it.

wispy delta
#

Is it possible to draw an editor within a reorderable list? The only draw functions I'm finding are for within a layout, not a rect

wispy delta
#

I've got a list of serialized objects and think it would be slick to draw the inspector for the selected element within the list. looks like unity doesn't recalculate element height after clicking so I can't dynamically change the height of an element to add space for an editor, making my previous q moot 😦

gloomy chasm
wispy delta
#

So I've created the editor and it draws nicely outside the list but my understanding is that the layout for a reorderable list is precalculated, so I can't draw anything that uses GUILayout or EditorGUILayout within the drawElementCallback since the layout will be placed below the list

twin dawn
#

THere's a callback I think for getElementSize or something

#

that you can use in addition to drawElementCallback - IIRC

#

I've used it before but I forget the name

visual stag
#

you can override the height per element of a reorderable list- but the problem is that drawing the editor, layout is unknown as far as I know

#

because it's just a call to OnInspectorGUI or whatever, and that just goes straight to user code, right?

#

which is going to use Layout to draw

wispy delta
visual stag
#

so unless you manage to get the layout to properly allocate/calculate there, (mikilo might know) it won't work

wispy delta
#

but that's one of two problems, the latter is that I can't find a way to draw an editor without it being done via layout which puts it at the end of the list gui

#

(sorry @visual stag reading your messages now, just wanted to clarify some stuff)

#

yes as far as I know, you're right. gotta find workaround for layouts and elements not getting resized at the right time

wispy delta
#

obviously i should just make my own take on a ReorderableList class. i'm sure that's not beyond my skill level 🤡

plucky nymph
#

Can anyone point me to directions on adding an item to an EditorWindow context menu? I understand I can add a GenericMenu to an item, but trying to add to the actual windows menu instead of an element

waxen sandal
#

Implement UnityEditor.IHasCustomMenu on your window

plucky nymph
#

ah thanks!

earnest trench
#

Hey guys how do i validate when player press this maximize button in code?

plucky nymph
#

Anyone have any feedback on how stable Editor Coroutines is rn? I know its in preview, just interested as to its usability. Project isnt commercial so I can deal with some screwiness

waxen sandal
#

How do I force an editor to draw with a specific width?

onyx harness
#

Have you try to wrap it?

waxen sandal
#

Wdym wrap it?

#

I just put in a group to position it but it's trying to render wider than my group is wide

onyx harness
#

Around BeginArea Horizontal/Vertical layout

waxen sandal
#

Oh interesting, BeginArea works but Group doesn't

#

Cheers

onyx harness
#

If I'm not spreading shit, Clip/Group are culling/clipping the drawing area.

#

While Area really starts a new layout pipe/stack

#

You can see that when you ungroup an EditorWindow at the very beginning and start drawing in neighbor windows 🙂

waxen sandal
#

Ah makes sense

plucky nymph
#

Anyone know of a way to change a nodes title text color? Changing the label color attribute in the debugger works, but inline code like:

node.titleContainer.style.color = newColor;

Doesnt do anything. Ideas?

waxen sandal
#

UITK?

plucky nymph
#

... I do not know what that is sorry. A tool kit?
That being said, I think I was actually referencing the wrong VE. I think I should be modifying a Label thats a child of the container

waxen sandal
#

UI Toolkit

#

The "new" xml based UI solution

plucky nymph
#

Oh, UIElements? Im new to it sorry, havent fully absorbed various terms

waxen sandal
#

UIE got renamed to UITK

plucky nymph
#

... well that is information that is going to make my googling a lot better

#

how the hell did i miss that

waxen sandal
#

It's only going to make it worse most likely

#

At least you'll only find recent things

plucky nymph
#

Yeh doubly interesting, because I normally restrict to "The past year" anyway

hazy umbra
#

Hello guys, I have one quick question when I create a custom VisualElement where should I create sub elements ? If I do it in the constructor nothing happen

gloomy chasm
hazy umbra
#
public class TestElement : VisualElement
{
    public TestElement()
    {
        Label testLabel = new Label();
        Add(testLabel);
    }
}``` I'm actually doing this and I can't find my label, even in the debugger I don't have anything under my Element
#

and i'm generating a mesh inside and I can see the mesh but no label even when I add text to them csharp private void GenerateVisualContent(MeshGenerationContext obj) {}

plucky nymph
#

Make sure you add it to the container too.

So standard workflow for me atm is

VisualElement myElement = new VisualElement();
Label l = new Label("Test");
myElement.Add(l);
rootVisualContainer.Add(myElement);
hazy umbra
#

I don't have anything else than this.Add(); because it derive from a visual element, I'm not trying to do an EditorWindow

gloomy chasm
hazy umbra
#

Well, I managed to do it but I had to create my elements inside the init function of this csharp public new class UxmlTraits : VisualElement.UxmlTraits {} to ba able to generate some elements

sudden pulsar
#

https://gyazo.com/df8e7abc2a65ef98ca86e5e9ca234ae3
Any idea why this is happening?


        label= new GUIContent(label.text + "\tVector2: " + property.vector2Value);
        EditorGUI.BeginProperty(position, label, property);
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
``` (I think this is the relevant code)
In the inspector
#

The vector2 thing is getting cut off. Just curious if there's something obvious I'm missing :P

#

oh wait

onyx harness
#

PrefixLabel will provide you a rect that is an editor label, which is relying on the labelWidth

#

You can see that it cropped like X & Y

#

You can trick it by increasing the width manually

sudden pulsar
patent pebble
#

Is it safe to commit changes for the repository while the Unity project is still open?
I've gotten into the habit of closing Unity and then committing the stuff to GitHub...

onyx harness
#

Yes

patent pebble
#

Does closing Unity change some meta files or something like that?

#

oh ok

onyx harness
#

But having you asking this question requires a more appropriate explanation

patent pebble
#

I'm not very experience with repositories, I just have a basic understanding of them to be able to use them on a surface level

onyx harness
#

This question is not about repository, but Unity Editor understanding

patent pebble
#

true

onyx harness
#

The Assets folder is not suppose to change unless you apply modifications.
Like almost all other folders, except Library, which is used to build your project

#

When you commit, just make sure to save the project and it should suffice 99% of the time.

waxen sandal
#

Save Project/Saving scenes might change some assets which Unity asks you to do when you close

onyx harness
#

The last percent is for plugin/script/hook that execute some work when closing.

#

Which is, in my knowledge, extremely rare.

waxen sandal
#

It should be extremely rare

onyx harness
#

Nobody does that.

patent pebble
waxen sandal
#

Every 10 minutes? amateur

patent pebble
#

@onyx harness thanks for the explanation 🙂

#

you've saved me precious minutes every time I want to commit changes

waxen sandal
#

If you're using perforce then I suspect there might a bug when you switch streams and Unity does something while it's happening

#

Which makes your files go into a changelist you can't easily access

patent pebble
#

I just use GitHub

waxen sandal
#

No worries then

onyx harness
#

There is a sad and I feel its kinda stupid from Unity.
Most of the time people will "Save" (Ctrl+S) thinking it will save the project, but it only saves the current Scene.

onyx harness
patent pebble
onyx harness
patent pebble
#

I remember reading somewhere that the Project should auto-save whenever something is changed, but I don't know how accurate is that or if it's true at all

onyx harness
#

"should" is harsh, maybe an option to toggle it perhaps

#

Unreal has an auto-save

waxen sandal
#

Unity claims that you should never need to use Save Project but that's bs

onyx harness
#

I won't go into this path of ranting about Unity Editor

#

⛑️

patent pebble
patent pebble
wispy delta
#

Is there an editor dialog popup that has a toggle field for "remember decision" instead of this awfulness?

With EditorUtility.DisplayDialog you can only remember your decision if you select yes. You can't say "no, and remember my decision." I also can't pick the text displayed for the "Do not show this again" option. It's so long and ugly lmao

visual stag
#

I'm not familiar with it, but you can always do this manually with EditorPrefs/SessionState

wispy delta
#

good to know, thanks 🙂

I guess it'd be important to have some way to show a toggle in a popup dialog, since without it I'd have to show two popups: the first which lets the user make a decision, and the second which lets the user say if they want their decision to be remembered.

I'm guessing there's not a way to define my own gui for one of these native dialog windows? I guess I could make my own PopupWindow, but it wouldn't be quite the same

visual stag
#

I do not think you can

plucky nymph
#

I think this is what you're looking for

hazy umbra
#

I don't know if it's the correct place for this question but I was wondering. With the classic UI (canvas, text, TMP, button, ...) we had to split our ui smartly to avoid having to re render everything each to something changed in the UI, is it still the case with the new UIToolkit ?

gloomy chasm
fiery canopy
#

Anyone know why PropertyField doesn't work in UITK?

I tried using it and apparently it shows up in the debugger but when I look at the style value it is set to 0, and when I set it to anything other than 0 it still doesn't show up.

#

Also this is for a Custom Editor Window

#

I have tried for a Custom Inspector and everything works fine

#

Oh I figured it out I wasn't binding the field to a object

cyan totem
rare surge
#

Hey guys it is possible to make own search window for EditorGUI.ObjectField? I use generic typed scriptableobject and it shows everything in the list. However I managed with own code to filter out what types I want to see (in this example int types). I did it with popup but would like to replace the search window.

whole steppe
#

Hey peeps, how can I access the animation clips in an animator controller via editor code? The Animation Clips field is always empty

candid linden
#

How do I do a bulk reimport of the asset database?

gloomy chasm
candid linden
#

Oooo, maybe it's AssetDatabase.Save @gloomy chasm

#

Basically I'm editing a bunch of objects at once which I've loaded using AssetImporter.GetAtPath

#

will AssetDatabase.Save save these objects?

gloomy chasm
patent pebble
#

Is there any situation where we would use
SerializedPropertyType.ArraySize
instead of just using directly
SerializedProperty.arraySize
The first one would require to access a sub-property of an array using SerializedProperty.FindPropertyRelative("Array.size")
Am I missing something? Why would someone ever use the size sub-property? 🤔

#

The second one even seems to account for multi-object editing, which is a plus

#

digging on the source code, they seem to mostly use SerializedProperty.arraySize.

#

and SerializedPropertyType.ArraySize only for PropertyFields, clipboard and prefab stuff

waxen sandal
#

It's for when you iterate over a serializedproperty that contains an array, one of the elements will be the array size

patent pebble
#

so i guess for example if I wanted, for some reason, to draw collections in a custom inspector but hiding the size field so the user can't change it manually

#

or things like that i guess

waxen sandal
#

Yep, it makes it pretty easy to fake arrays by just iterating over the sp

patent pebble
#

ah yeyeye gotcha. Thanks for the info @waxen sandal 😊

waxen sandal
#

There's some more fun things you can do

#

If you have a class that you want to draw with a custom foldout, you can skip the first element and draw your own foldout instead

patent pebble
#

takes notes 📝 👀

cloud wigeon
#

Is it possible to add categories to the Unity shortcut system from C#? I am adding shortcuts to a custom tool and it would make it easier to find them.

patent pebble
#

What are the implications of choosing between the Api Compatibility Level of .NET Standard 2.0 and .NET 4x ? (In the context of editor extensions)

Context:
I'm making extensions that use the Microsoft.Win32.Registry assembly and apparently that is only available on .NET 4x.
The original project I used to make the extensions had the .Net Standard 2.0 selected and I could for some reason still access the Registry assembly.
But after upgrading to the latest 2020.2 version of Unity I can only get that assembly by switching the API Compatibility to .NET 4x, otherwise i get errors

Concerns:
Unity says a bunch of things regarding this topic, while I understand them on the surface, I don't truly understand the potential implications of those things:
Only use the .NET 4.x when you require functionality that is not available in .NET Standard 2.0. The .NET 4.x profile includes a much larger API surface, including parts which may work on few or no platforms.


- .NET Standard 2.0 reduces the size of your final executable file. The .NET Standard 2.0 profile is about half the size of the .NET 4.x profile, so use the .NET Standard 2.0.
- .NET Standard 2.0 has better cross-platform support, so your code is more likely to work across all platforms.
- .NET Standard 2.0 is supported by all .NET runtimes, so your code works across more VM/runtime environments (e.g. .NET Framework. .NET Core, Xamarin, Unity).
- .NET Standard moves more errors to compile time. A number of APIs in .NET 4.7.1 are available at compile time, but have implementations on some platforms that throw an exception at runtime.```
A Unity employee said: ```The recommended solution when trying to use an API that is part of the .NET Framework, but not part of .NET Standard 2.0 is to change the Api Compatability .NET 4.x rather than adding assemblies such as Microsoft.Win32.Registry.```
#

Questions:

  • Why did my original project had access to the Registry class on .Net Standard 2.0? (I had imported some external tools to that same Unity project, maybe one of them imported references to that assembly?
  • Should I just switch to .NET 4x and forget about importing DLLs manually?
  • If I only use the .NET 4x API features for editor extensions, how will that affect my runtime code and builds?

*sorry for the very long post, I have near zero experience in dealing with this .NET stuff 😓

brittle wharf
#

.NET Standard will have better compatibility if you are building for systems other than Windows.

#

Or if you switch to .NET 4.x you may use an object or method that isn't supported on another system.

craggy kite
#

If you're building a normal Unity game, you can get away with .NET Standard 2.0

You only really need .NET 4.x if you need more advanced reflection / domain loading and modification features. And you should only need those if you're building more of an app or something that integrates with certain kinds of desktop features.

visual stag
#

Or if you want a pleasant coding experience with modern language features

craggy kite
#
  • some external dlls that aren't unity specific or built against newer versions of .NET (Core or Standard) tend to included more windows-specific things like Registry. You may be able to find an alternative if you just need a key/value store
  • If you have the dll that has the Registry somewhere under Assets/, you should be able to access it and include it in your project without needing to manually import it in code.
  • if you have a .NET 4x API featureset for editor extentions, but don't want to force a project to use .NET 4.x, you should be able to include specific DLLs with your editor tooling directories and keep the rest of the project .NET 2.0.

It's been a while since I messed with this stuff in a project so Your Mileage May Very

patent pebble
#

hmmm, I see

#

however I'm still conflicted with them recommending to switch to .NET 4x instead of just importing new DLLs by ourselves

#

and for example I just tried importing the Registry dll on an empty project and i get this conflict:
Library\PackageCache\com.unity.ide.visualstudio@2.0.5\Editor\VisualStudioInstallation.cs(57,38): error CS0433: The type 'RegistryKey' exists in both 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

#

I don't know why it's not letting me just use my imported Registry dll when using the .Net Standard 2.0 API compatibility level

#

mscorlib.dll is only used for the .NET 4x API compatibility level

#

with other external libraries there's no issue, but it's weird that they force use to switch from .NET Standard 2.0 to .NET 4x instead of letting us override assemblies 😓

#

I tried building an empty project using both compatibility levels and with .NET 4.x the build size is actually smaller (48.7 MB) than with .NET Standard 2.0 (50.8 MB)
which seems to contradict what the Unity docs say... (though the executable files are exactly the same size)
.NET Standard 2.0 reduces the size of your final executable file. The .NET Standard 2.0 profile is about half the size of the .NET 4.x profile, so use the .NET Standard 2.0.

#

well, I guess I'll just do as they recommend and switch my projects to the .NET 4x profile,

#

I've seen workarounds online such as modifying the csproj files, but that's pointless since Unity rebuilds those files anyways.
And some other shenanigans like setting some parameters to override references in assembly definitions and whatnot, but those may also cause conflicts with Unity's API compatibility levels...

#

I've also seen people had similar issues in the past couple years and Unity employees deeming them as bugs, reporting them as bugs , getting fixed and then the "bugs" getting reintroduced in newer versions of Unity 😅

whole steppe
#

Whenever I try to open a script from Unity to Visual Studio, the following error pops up. I'm not entirely sure what it means.

dusty comet
#

could anyone help me create an editor for scriptable objects?
My idea is having a scriptable object called Ingredient and have all ingredients in that windows

whole steppe
#

I don't think I do. Let me check.

tepid yew
#

Yes, the one on the left should install what you need.

#

It will optionally install Unity Hub so uncheck that.

patent pebble
#

My idea is having a scriptable object called Ingredient and have all ingredients in that windows
could you elaborate more?

dusty comet
#

I was just giving details of what I think

#

I will send a little sketch if that is fine

#

Probably what I would aim for is having a list of all ingredients that were created and a button to create a new one

#

then this could be sorted or by rarity or by name

whole steppe
#

@tepid yew What do I do after that?

tepid yew
#

I think that's all it takes. You might restart Unity and VS. Open a project in Unity and the either open a script or create a new one. Then double-click it to open VS and edit it.

#

Let Unity launch VS. Edit your files there, save them, and when you switch back to Unity it will compile your changes.

patent pebble
whole steppe
#

I got the same error message.

dusty comet
#

I made a very little editor but this is more advanced at least for me, I want to get better at this since this is a very powerful tool

patent pebble
#

it all depends on the complexity of your tool and the intended use

whole steppe
#

I'm getting close to just uninstalling VS and reinstalling it at this point. tired_of_yall

tepid yew
#

Is that the latest version? (2019)

whole steppe
#

Yes.

tepid yew
#

I guess a reinstall won't hurt. I'm not sure what the problem might be.

whole steppe
#

can anybody give me lessons

#

please

tepid yew
visual stag
whole steppe
#

ok

whole steppe
tepid yew
#

I'm pretty sure that all you need are .NET and the Unity package (which basically just installs a particular version of .NET framework.)

whole steppe
rough veldt
dusty comet
#

@patent pebble sorry for bothering but have you seen a video of someone that did a custom editor for a character?

patent pebble
#

a custom editor for a character that is very vague. You wouldn't usually make a single custom editor for an entire "character", unless you have a very simple character. You'd make custom editors for components or scriptable objects

#

unless by "editor" you mean a tool for handling and editing whatever data relevant to your character

dusty comet
#

I remembering that I saw a video and maybe you had seen it, I wanted to see how they did it and try to see how I could have done mine

#

I have looked for it but I can't find it

patent pebble
#

no idea, good luck with your search 👍

dusty comet
#

Oh found it, it is from unity

idle anvil
#

i made lot of search but i couldn't find the right information about that part, what i'm trying to find is what is the right type for RuntimeAnimatorController, do you know how or where to find the right information about it?

#

it's for an objectfield with the help of ui builder

waxen sandal
#

Can you clarify

idle anvil
#

i mean: when i click the objectfield in my script, i get a list of everything, what i want is to find the specific type like RunAnimatorController when i select one of these objectfield

waxen sandal
#

Ah

#

Isn't it just AnimatorController?

idle anvil
#

even when i put only AnimatorController

#

it's really frustrating when there is only vague information about how to do it

#

especially in the documentations

waxen sandal
#

UnityEditor.Animations.AnimatorController?

#

Also why is Obejct still in there

idle anvil
#

i will try

#

thx! it worked!

waxen sandal
#

I'm not sure what format that string is supposed to be in but assuming it's using type.GetType then your input is saying UnityEngine.Object in the UnityEngine.AnimatorController assembly

idle anvil
#

that unityengine.object was found from the documentation about binding path

#

which i was able to figured it out

#

however, i had no idea what is the right information related to animatorcontroller

#

hum

#

i noticed that it only select animatorcontroller instead of runtimeanimatorcontroller...

#

because in my list, there is also OverrideController as files

waxen sandal
#

Try UnityEngine.RuntimeanimatorController and nothing else in teh type field

idle anvil
#

hum

#

i have an idea, i will test something

waxen sandal
#

Typo

idle anvil
#

typo?

#

oh

#

i see!

waxen sandal
#

Try UnityEngine.RuntimeAnimatorController, UnityEngine

idle anvil
#

ah this time it worked

#

thx!

west fog
#

@idle anvil No reaction gifs/off topic embeds.

idle anvil
#

ok

sage crater
onyx harness
#

IMGUI or UIToolkit

waxen sandal
#

Which part are you having trouble with?

sage crater
onyx harness
#

Yes

sage crater
waxen sandal
#

No

#

IMGUI is GUI/GUILayout, UITK is the new UI system (previously UIElements)

sage crater
#

Oh you mean built in EditorGUILayout

#

well I know about that but I couldn't manage to make that fancy elements in that UI. For example those toggles . How about those?

waxen sandal
#

Custom guistyle

#

Or just draw 2 different images based on a bool

onyx harness
#

I suspect they must exist natively

sage crater
onyx harness
#

Since I saw Services using it

sage crater
onyx harness
#

Yeah, pretty lame & basic one 🙂

sage crater
#

True. Does that sliding toggle have a specific name of it?

waxen sandal
#

I think services is not an editorwindow

#

It takes ages to load so I feel like it's some web view or something

onyx harness
waxen sandal
#

I haven't checked what it actually is but I'm skeptical it's a normal window

onyx harness
#

I agree, I remember something like that too

sage crater
waxen sandal
#

@onyx harness do right click and you'll see it's a browser

sage crater
#

Perhaps I will go with gui skin option. Thank you for advice

onyx harness
#

U2020?

onyx harness
sage crater
#

One more question, how to enable disable a part of code based on toggle like I have seen this thing in some assets that when you turn on toggle of some feature, unity starts to compile and its probably compiling the code of feature you enabled. So how to achieve that?

sage crater
onyx harness
#

I guess it might change the defines

sage crater
waxen sandal
onyx harness
#

shit wrong answer

waxen sandal
#

Thought so

waxen sandal
onyx harness
waxen sandal
#

Ah they rewrote it then

sage crater
#

Any example of its use? What I am trying to achieve is that I am making an asset that has an editor window that can provide an easy setup to multiple ad networks or a mediation network. User can turn on which ad network he wanna use. So I was thinking to let unity compile either admob or FBAN code only if toggle is turned on. Hope it makes it clear

onyx harness
#

Yeah, because the Web container is no more later

waxen sandal
#

Oh that's harder, since you don't control the code

onyx harness
#

Toggle pure plain code, or toggle assemblies?

sage crater
onyx harness
#

Well we can't tell without seeing it

waxen sandal
#

Probably because they control the code

sage crater
#

Turned on advertising, unity is compiling

sage crater
waxen sandal
#

Ah nevermind, they support third party plugins

#

But it's likely that they're just removed and adding the code

sage crater
#

Yeah I guess its like they remove/add or enable/disable code. I basically wanna achieve same thing

waxen sandal
#

Then just delete some directories when it's disabled

sage crater
#

for third party plugins we have to download on our own

#

Its just like they add code to show ads from that ad network

#

like if you turn on google ads, it will put the code that handles bringing an ad on the screen

waxen sandal
#

Without knowing more about that plugin we can't really know what it's doing

sudden pulsar
#

Anyone know what the size range slider is for the Tree-Shape-Size is called?

#

oh nvm

patent pebble
#

How do I make it so my external files can be defined as a custom asset type? I want them to recognized by Unity's features like searchbars and whatnot.

First time dealing with assets, I'm creating a text file to store some JSON but I just did it in a crude manner with File.WriteAllText and then just AssetDatabase.Refresh to make it appear on the project window.
I suspect this is not the most robust approach 😅

#

Right now Unity sees the file's asset type as a DefaultAsset, I'd like to have control over that

waxen sandal
#

Scritpedimporters

patent pebble
sudden pulsar
#

Hello was the debug label :P

#

oop wait-

#

first has an accuracy of .01, 2nd has an accuracy of the lowest log 10, divided by 1 (so 1) and last is .01 b/c default is 0-100, and 0 log10 is 100- (it's actually NaN, but it then treats it as if it's a 1)

#

I'm just rather happy, so sorry if I'm bein weird :P

severe python
#

For an editor tool are there any conventions are modifying files not managed as assets in the project, such as project settings, or the manifest.json file in the packages folder?

onyx harness
#

The manifest might not be considered as an asset, but any other yes

lament eagle
#

Hi, I am wondering if it is possible to implement my own custom directory in editor. e.g. view whats inside a 7z file without having to decompress it

gloomy chasm
lament eagle
#

e.g. if there were a 7z file in the assets folder be able to access it as a directory like a normal folder.

gloomy chasm
onyx harness
#

Unfortunately, it might work only one level

lament eagle
#

Yeah, I am looking into it now. I have found out how to edit the project window so its go well so far 😄

onyx harness
#

The other approach is just to write an Editor for compressed files

#

And do it in the Inspector, instead of Project

lament eagle
#

That is my fallback option. I am going to end up doing it for something like 20 different file types so it makes sense to do it in the project window(at least to me it does).

onyx harness
#

Sorry to break it down for ya, but the Inspector makes more sense :)

waxen sandal
#

There's some APIs on AssetDatabase to add an extra dir (assuming similar to Packages) but no clue how that works in reality

onyx harness
#

Which one?

waxen sandal
#
    [GeneratedByOldBindingsGenerator]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void RegisterAssetFolder(string path, bool immutable, string guid);

    [GeneratedByOldBindingsGenerator]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void UnregisterAssetFolder(string path);
#

Nice embed

onyx harness
#

Oh from 2018! Never noticed

#

Nice catch

#

(I think I can genuinely say you are the very first user using the embed 😄 congrats!)

waxen sandal
#

🥳

severe python
#

Thats a really cool embed, and frature, I have uses for that myself

onyx harness
#

@waxen sandal Well I'm sorry, apparently you are 2nd nonetheless! 😄

waxen sandal
#

rip

earnest trench
#

Hey guys how do i validate when player press this maximize button in code?

onyx harness
#

There is no callback as you might hope

#

But you can check that by verifying the size of the main view with the resolution, and make some approximation

patent pebble
#

What's a good way of storing data for simple editor extensions?

I'm making a tool that needs to keep track of a couple of file names, and I need that data to be tied to the project.
I thought of using EditorPrefs since the tool is very small and simple... but EditorPrefs are global across every project

#

is it bad practice to use the EditorPrefs for project-specific data?

onyx harness
#

Nope

#

Use it use it

patent pebble
twin dawn
patent pebble
#

Yeah, but I like the seamless aspect of the Editor Prefs

#

and while my data is mostly project-specific, it could benefit from sharing small pieces of it

#

I'm still designing it, but seems like that's the case

twin dawn
#

I don't know your tool - but you should consider what happens when a project is worked on by multiple people

#

and how EditorPrefs won't be shared between them

patent pebble
#

this tool is only for myself

twin dawn
#

ok then it doesn't really matter 😄

#

do whatever you like

patent pebble
#

but if it was for multiple seats, I'd like so each person could set up their own

twin dawn
#

👍

patent pebble
#

I'm making a tool that lets you specify custom text file templates for scripts, shaders and other text files

#

so I store keys for the names of the templates, those can be reused by multiple projects

#

and I store a key for a "project ID", which defines what templates a specific project uses

#

probably not the best design, but seems to be fine for what I need

#

If I keep extending this tool I will probably do a more robust design, probably with scriptable objects or json files

#

but for now EditorPrefs seem fine

#

what seems to fit well with the EditorPrefs is the fact that they are shared across every project, so I won't need to import new templates for every project whenever I create a new one

waxen sandal
#

Fyi, editorprefs isn't saved per project

patent pebble
waxen sandal
#

Ah I missed that 😛

patent pebble
#

Is there any Unity API that can give me a callback for when I edit a file outside of Unity?
For example if I edit a custom JSON text file outside of Unity on the notepad

waxen sandal
#

Yeah it'll be imported

#

But no guarantees when it happens when Unity is closed

#

There's also one that happens on save asset

#

AssetModificationProcessor

#

static string[] OnWillSaveAssets(string[] paths)

patent pebble
#

hmmm

patent pebble
waxen sandal
#

I just have no idea whether Unity will call your code when importing changed assets upon opening

#

Nor do I rely on it in my code

patent pebble
#

hmmm I see. I can live with that. As long as it's consistent while Unity is open i'll be happy

waxen sandal
#

Ehh, I just figured out that I'll have to check whether it works when opening Unity

#

Well, I guess I could away with not doing it but it would be better

onyx harness
#

He is talking about outside file, implying outside Unity project?

patent pebble
#

I'm not on my work station, otherwise i'd test its behaviour

onyx harness
#

Well Unity will never talk about it then

#

It is not in its scope

patent pebble
#

really?

onyx harness
#

Like if you edit a file in your D:/

#

Why will Unity react to it?

patent pebble
#

big sad 😓

waxen sandal
#

I'm reading it as a file in the unity project but edited using a 3rd party tool rather than somethign in Unity

onyx harness
#

It only react to stuff aftr your root

#

This is what I thought

#

but he just confirmed the opposite

patent pebble
#

I'm confused now

waxen sandal
#

The file is in Assets right?

#

But you're editing it with notepad

onyx harness
#

If the file (inside the project) has been modified, Unity will import it yes.

patent pebble
#

yeah it's a file that exists inside the unity project, but needs to be edited by external tools, eg: the Notepad

#

it's a non-native file though, can I get away with not implementing a scripted importer?

#

or do I need to do that in order to get Unity to recognize and do auto-reimports and all that?

onyx harness
#

Just use OnWillSaveAssets and do whatever you wanna do from there

#

Like Navi mentionned earlier

#

If the file is not recognized, it is suppose to act like a "default asset"

#

Still an asset

patent pebble
#

ah right right

#

@onyx harness @waxen sandal thanks both of ya! 😊

onyx harness
#

As a test, just create a file ending with .foobar

#

Look at the logs

#

Edit the file.

#

Look at the logs again

#

You should see Unity importing it

patent pebble
#

ok, not at work pc right now, but I'll do that to check when I get the chance

waxen sandal
#

Just checked, it'll also call your importer when it's changed when Unity was closed

tough cairn
#

how to call slow updates for editor script ? i remember there was something that would get refreshed 10 times per second or something like that , any one knows ?

waxen sandal
#

OnInspectorUpdate

tough cairn
#

found it OnInspectorUpdate

#

yea lol thanks

#

any ideas how to make it Editor accesible as well ?

#

seems to be used for Window

waxen sandal
#

Nop

tough cairn
#

:< back to haxs

drifting forge
#

is the current version of ui builder broken?

#

i just freshly installed the package and im getting 276 errors

#

ah fuck I'm on 2019 lts

agile void
#

so editor code doesn't compile in the build right? As in there is no need to wrap it in #if UNITY_EDITOR

twin dawn
#

Well

#

Unless it's entire files in the editor assembly

#

If you have parts of runtime files that are editor only, wrap it

quaint zephyr
#

Hey guys. I have a ScriptableObject that I want to use to persist my data.
I check if it exists using AssetDatabase.LoadAssetAtPath<AppData>(dataPath). If it doesn't, I AppData appData = CreateInstance<AppData>(); and then AssetDatabase.CreateAsset(appData, dataPath);
Now, when I use the data from there it works, when I change the data on the UI, it changes it to the SO. And even persists between play/edit sessions. However, when I exit the editor and load it back up...the data is reset to default. How can I get it to persist across editor sessions?

#

Oh i got it to persist between editor sessions. Before AssetDatabase.SaveAssets(); line I added EditorUtility.SetDirty(appDataAsset); And it works. But is that supposed to be like that? I mean convention?

patent pebble
#

@quaint zephyr
SetDirty: Unity uses the dirty flag internally to find changed assets that must be saved to disk.
SaveAssets: Writes all unsaved asset changes to disk.

#

my understanding is that if you don't mark objects as dirty, Unity doesn't know if it has to save them to disk

quaint zephyr
#

I'm of course wrapping them in UNITY_EDITOR directives.

patent pebble
#

I mean, that's just a design or architecture decision

#

as far as I know, you can mark objects as dirty from anywhere

quaint zephyr
#

Ok. Thanks.

patent pebble
#

whether that's a good practice or not, I can't say. I'm not the most experienced in this topic. Somebody else may be able to give you a better answer

quaint zephyr
#

Yeah I have two modes. Production mode saves all the SO to json format on the persistentPath. And Development mode saves all SO directly into my assets folder so I can view the entire structure live and change it on the go.

patent pebble
#

I mean personally I like to keep things decoupled as much as I can

#

if your MonoBehavior component should be responsible for handling the data persistence, that's fine

#

that depends on your particular situation

#

I would probably separate the concerns there, if your component doesn't care about how, why, or where the data is saved and stored, maybe you can just make the component send a notification so an external system can handle the data saving

#

it all depends, can't answer that question for you

#

I'm not a big fan of using UNITY_EDITOR and including Editor-only code in my runtime code, but I see a lot of people using it

waxen sandal
#

^

dim prairie
#

is there a way for me to apply a certain set up that I want for an array, and then update it to where the array instances function like the setup? I can't really explain it well; im adding comments to my script so i can show what im talking about

#

im learning and testing, so please pardon the noobiness and tell me if i need to send anymore screenshots

waxen sandal
#

Sounds like you want to make a propertydrawer for the type that is in your array

dim prairie
#

i believe so? is that a variable I can make or just what that's called?

waxen sandal
#

A propertydrawer lets you define how to draw a field of a specific type (or the elements in an array)

#

And you need an attribute on the propertydrawer class [CustomPropertyDrawer(typeof(targetType))]

#

Then you can draw your gui in public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) and you need to define the height of your drawer in public float GetPropertyHeight(SerializedProperty property, GUIContent label);

dim prairie
#

thanks for pointing me in the right direction! i literally spent hours both searching and trying random stuff

waxen sandal
#

You can't use GUILayout in serializedproperties by the way

#

And it's recommended to use SerializedProperty for everything

waxen sandal
#

@visual stag Can you take care of that?

visual stag
#

@mortal hinge do not post off topic content - consider this a warning (the bot cannot DM you the warning formally)

waxen sandal
#

Thanks

graceful gorge
waxen sandal
#

Whoops

#

Meant can't there

#

Sorry about that

#

@dim prairie fyi

dim prairie
#

Noted. I also found a video explaining it also

#

Next time I’m on unity, I’m gonna make some form of unholy abomination of a mixture of the editor and drawer inspector fun 😄

pastel osprey
#

Does anyone know an API point that happens before default hotkeys are dealt with? I need to capture key presses and consume the events before editor hotkeys.

Its for an EditorTool so I tried EditorTool.OnToolGUI. I also tried duringSceneGUI. Both happen afterwards

onyx harness
#

But I'm not sure it can intercept the event before Unity executes

waxen sandal
#

The github link is wrong

#

And it links to docs while it's an internal field

onyx harness
#

The doc link is fine, since it targets the Type. But yeah the github is wrong, I don't how why it points to the layout

waxen sandal
#

I'd argue there shouldn't be a docs link if it's internal but 🤷‍♂️

onyx harness
#

It's because when both Type & Member are public, I provide 2 links

#

Like this

#

and of course the 2nd does not link correctly XD

waxen sandal
#

😂

#

I was talking about the page and not the embed though

#

Which in this case also points to editorapplication

onyx harness
#

Not the most intuitive, but consider the 2 things, 2 separated entitties

waxen sandal
#

Ohh you can press on the name, I was just pressing on the icon

onyx harness
#

And the link issue is fixed. Now investigating why GitHub is so wrong

waxen sandal
#

Good work as always

pastel osprey
#

Thanks so much! Works great 😄

onyx harness
pastel osprey
#

However, I havent yet found out how to unassign it 😛

waxen sandal
#

Chances are you're overwriting it using that code

#

So you could just set it to null

patent pebble
#

is this still true about JsonUtility?
Serializing/deserializing arrays and lists as top-level elements is not supported right now. It's on the to-do list...

#

Should I just give up on JsonUtility and get accustomed to JSON.NET or Newtonsoft to save me some pains?

onyx harness
#

The trick is to wrap the string with {}

patent pebble
#

@onyx harness so basically just instead of top level I need to wrap everything?

onyx harness
#

yep

#

{"list":[]}

severe python
#

I wouldn't recommend trying to use json.net in unity

#

It works, but sometimes it doesn't, so you have to deal with quirks regardless

patent pebble
#

I assume i need to do the same with my objects? wrapping them into classes before serializing to JSON?

onyx harness
#

I had this discussion a year ago with the Unity engineer behind the serialization

#

My opinion? They will never implement X)

severe python
#

Yeah its a little annoying

onyx harness
patent pebble
severe python
#

Exaclt, with jsonutility you have a rule set you're already used to

#

Or perhaps more importantly, is consistent across unity, where external libs won't be

#

You'll have this quirk, unity obviously deals with it too, just look at Packages/manifest.json

patent pebble
#

I'm a bigger fan of consistency, even at the expense of having to do some boilerplate stuff

#

I'd rather spend a small amount of time automating something to save me time from doing boilerplate, instead of having to face massive headaches and wastes of time figuring out if the library I imported is going to work or not, and digging through docs and forums to figure out what to do to make it work

#

specially in my situation, making indie games and simple tools for my own workflow

dim prairie
#

and im back

#

is it possible to display variables based on an enum selection in a PropertyDrawer? I know i can in an Editor

severe python
#

Has anyone tried to extend the package manager?
I want to setup some custom registry sources that require some special handling...
The more I say the less I think the idea is feasible, but I'm building my own manager and its basically the exact same thing except it loads data from an extensible set of sources which will handle everything except the actual management of package.json files and putting the files in the right locations.
It seems like it should be possible to actually extend the package manager itself, but the documentation isn't exactly helpful

#

there is a IPackageManagerExtension but what it doesn't isn't clear at all

gloomy chasm
severe python
#

yeah, the issue Is I don't really get what the purpose of this extension class is

#

I suppose what I should really do is setup a scoped registry

#

Meaning like, host a scoped registry within unity that translates the registries I want to add

gloomy chasm
severe python
#

oh this is almost exactly what I want to do

#

oh this is jsut showing me all kinds of cool stuff, like OpenUPM

gloomy chasm
#

Do you happen to know if there is any easy way to get a grid view with the ListView? I want a grid like in the project browser, but I want to be able to have the reusable items/performance like what the ListView has.

severe python
#

AFAIK grids are still a real problem

#

In the sense that Unity doesnt' create support to build a grid

#

I suppose making a Grid control might be considered design breaking though

gloomy chasm
#

I got a grid working pretty easy with just row and wrapping.

#

But that doesn't work with a listview of course

severe python
#

Are you trying to make a data table?

gloomy chasm
#

Not really, I am trying to make a 'asset library' window that sort of mimics the Project Browser, but it is just for making like collections of assets and stuff. Allow for organizing assets without changing their file location.

severe python
#

If you can evaluate how many items per row there can be then you can group the backing data into rows for a ListView

#

Honestly though this is a problem I've faced in WPF and it gets pretty hard

gloomy chasm
#

Yeah, I was thinking of that, but when resizing horizontally, all the items would need to be looped over again :/

severe python
#

I'm confident you could be smarter than looping over all the items, but yeah it's non-trivial in general

#

this is a place where Retained mode loses to imgui, virtualization is trivial with imgui

#

track the starting point, calculate the space available vs the size of the items, and render only that which fits in the screen looping from the tracked index forward

#

you can theoretically do the same in retained

#

if you accept that your reverse scroll might be somewhat invalid and have to figure out how to fudge the edges of the scroll

gloomy chasm
#

Yeah, I was just thinking that could be a way to do it.

severe python
#

This is how I do my virtualization in imgui for my tool, but thats a much simpler setup admittedly

#

its not effectively a virtualizing wrap panel

#

Also, don't feel bad, this is actually a fairly hard problem in general it seems

gloomy chasm
#

Hey @severe python do you know if there are any callbacks or anything for when the layout changes? Specifically I want the horizontal layout.

severe python
tepid sorrel
#

Hello, not sure im in the good channel tell me if not i will change, i have this problem :

#

Someone now can i solve that ? i need to add a using no ?

whole steppe
#

What Variable are you trying to declare

#

Show le code

twin dawn
#

You can't instantiate UnityEngine.Random (it's static), but you can with System.Random

gloomy chasm
severe python
#

thats way more performant than the crapy list setup I built just now

#

looks solid

gloomy chasm
#

It was actually pretty easy to do. All that is is the ListView basically (thus the good performance)

#

But what I did was make a custom class that implements IList that that makes rows for the items and set that as the source for the ListView

 public struct GridRow<T>
    {
        public List<T> items;
        public int sourceIndex;

        public GridRow(int sourceIndex, List<T> items)
        {
            this.sourceIndex = sourceIndex;
            this.items = items;
        }
    }

    public class GridCollection<T> : IList<GridRow<T>>, IList
    {
        [SerializeField] private List<T> _items = new List<T>();
        [SerializeField] private int _perRowCount = 5;

        public GridRow<T> this[int index] 
        {
            get 
            {
                int startIndex = index * _perRowCount;
                return new GridRow<T>(startIndex, _items.GetRange(startIndex, Mathf.Min(_perRowCount, _items.Count - startIndex))); 
            }
            set 
            {
                for (int i = 0; i < value.items.Count; i++)
                {
                    _items[value.sourceIndex + i] = value.items[i];
                }
            }
        }
}
#

I'm going to be honest, I feel very clever and smart for coming up with this xD

#

Btw @severe python there is a GeometryChangedEvent which is sent after layout events. I use it to do a simple evt.newRect.Width / _itemWidth to get the number of items per row.

#

I just gotta see if I can override/disable some of the default behavior of the ListView to get it to actually function with selection, hover, arrow key etc.

severe python
#

I need to try using ListView again, I didn't like it before, but my templating control has problems

quaint zephyr
#

Does anyone know how I can assign a Converter for a key on a Dictionary<key, value>? I'm using Newtonsoft.Json

prisma pike
#

Has anyone run into issues with choosing a sorting layer from the dropdown? I'm trying to assign objects to different sorting layers and literally nothing happens when I select a different sorting layer. It just continues to say Default

visual stag
#

do you have custom code drawing the dropdown?

prisma pike
#

No

#

This is just in the editor itself

visual stag
#

This channel is about extending the editor, general editor stuff is still #💻┃unity-talk

prisma pike
#

Thank you

snow pebble
#

trying to make a custom editor window, i have this code but it comes out blank when i open it:

    public class FourierEditor : EditorWindow
    {
        private WaveFieldSettings _waveFieldSettings;

        [MenuItem("Window/Spectrum/Generator")]
        static void Init()
        {
            var window = GetWindow<FourierEditor>("Spectrum Generator");
            window.Show();
        }

        void OnGui()
        {
            EditorGUILayout.BeginHorizontal();
            
            _waveFieldSettings = EditorGUILayout.ObjectField(_waveFieldSettings, typeof(WaveFieldSettings), false) as WaveFieldSettings;
            EditorGUILayout.EndHorizontal();
        }
    }

What is going wrong here?

#

its pretty similar - their code worked but mine doesn't

visual stag
#

OnGui 🤔

snow pebble
#

its what their docs has

visual stag
#

no it isn't

snow pebble
#

ah god damn

gloomy chasm
#

OnGUI not OnGui

snow pebble
#

capital letters

#

(╯°□°)╯︵ ┻━┻

#

thanks !

snow pebble
#

is there no option for arrays ?

#

i can't find it in the docs

visual stag
#

There is not

snow pebble
#

that is kinda crazy

#

guess i'll have to use a wrapper of some kinda

visual stag
#

ReorderableList is nice 😄

#

just a bit tedious to use

snow pebble
#

i'll just put the array in a scriptable object and have the editor execute a function for the SO to do the job instead

visual stag
#

if it's serialized you can just use a PropertyField

snow pebble
#

hmm im a bit lost my editor creates a Texture2D and i try to assign it to my SO but it says type mismatch when the field is a texture2D

#

i don't know what means

#

seems custom editors can't generate data or images for SOs or something

visual stag
#

you're going to have to post some code

#

custom editors can do anything

snow pebble
#

When i press "Generate" gui button it calls this function:

        private void GenerateInitSpectra(WaveSpectra waveSpectra)
        {
            Texture2D texture2D = new Texture2D(Resolution,Resolution,TextureFormat.RGBAFloat,false);
            texture2D.filterMode = FilterMode.Point;
            texture2D.wrapMode = TextureWrapMode.Clamp;
            texture2D.anisoLevel = 0;
            texture2D.name = waveSpectra.Label;


            waveSpectra.SetTexture(texture2D);
        }

waveSpectra is my scriptable object.
After pressing it, the SO inspector shows this:

visual stag
#

is that a custom inspector for the SO?

snow pebble
#

thats the default inspector

#

its got the correct type too:

        [SerializeField]
        private Texture2D _initSpectrumTexture;
visual stag
#

is SetTexture just an assignment?

snow pebble
#

yup

        public void SetTexture(Texture2D texture2D)
        {
            _initSpectrumTexture = texture2D;
            _isSet = true;
        }
#

sets a flag so i don't do it twice but other than that its all it does

visual stag
#

I wonder if it's just because you haven't written the texture to the asset database

snow pebble
#

im not familiar with asset database

#

you saying it needs to be a physical asset on my hard drive first?

visual stag
#

Well, I don't know if SO's can straight up serialize assets which are not in the asset database

#

you can serialize stuff into the scene in some cases

#

but I don't know if SOs have that ability

snow pebble
#

oh so i have to save the texture as a file

snow pebble
#

thanks

visual stag
#
using UnityEditor;
using UnityEngine;

[CreateAssetMenu]
public class Test : ScriptableObject
{
    [SerializeField] private Texture2D texture2D;

    [ContextMenu("Create Tex2D")]
    public void Create()
    {
        Texture2D texture2D = new Texture2D(36, 36, TextureFormat.RGBAFloat, false)
        {
            filterMode = FilterMode.Point,
            wrapMode = TextureWrapMode.Clamp,
            anisoLevel = 0,
            name = "Texture2D"
        };
        AssetDatabase.CreateAsset(texture2D, "Assets/Texture.asset");

        Undo.RecordObject(this, "Assigned Texture");
        this.texture2D = texture2D;
    }
}```
This works. Without creating the asset it does not.
snow pebble
#

oh it has to be .asset format

#

i need to learn more about this asset database stuff

#

@visual stag does it have to be .asset or can i use any thing ?

visual stag
#

I don't think it can be anything else

#

Unity won't recognise it needs to import it otherwise

snow pebble
#

ah okay 🙂

#

nice, it worked ! Thanks dude

patent pebble
#

I'm trying to display the text of a meta file for an asset in an Editor Window

#

but can't figure out a way to load the file

#

any tips?

onyx harness
#

SerializedObject

patent pebble
# onyx harness SerializedObject

ehm... sorry but I don't get it

here's my code

_obj = EditorGUILayout.ObjectField("Select asset to inspect its Meta file", _obj, typeof(Object), false);

if (_obj != null)
{
    string path = AssetDatabase.GetAssetPath(_obj);
    EditorGUILayout.LabelField($"Path: {path}");

    Object metaFile = AssetDatabase.LoadAssetAtPath(path + ".meta", typeof(Object));
    // ...
}
#

I don't know how SerializedObject is supposed to help me 😅

onyx harness
#

From what I remember, loading a .meta wont give you anything

#

You have to load the real asset, and iterate internally using a SerO

patent pebble
#

oh, this seems to work

#
string metaString = File.ReadAllText(assetPath + ".meta");
EditorGUILayout.LabelField($"{metaString}", GUI.skin.textArea);
#

gonna try with SerializedObject

onyx harness
#

Is that serious?

#

I mean, do you want to properly display the content, or just display the content?

patent pebble
#

properly display the content sounds better

#

@onyx harness how can I load the external file so I can use it in a SerializedObject?

#

I'm very inexperienced in dealing with files and assets, and can't find much info online

#

because I don't know the proper words to search 😓

#

maybe File.OpenRead or .Open?

onyx harness
#

Load the asset using AssetDatabase.
Wrap it with new SerializedObject(asset)
Iterate over the SerializedProperty
And you might need to turn the SerO to internal mode to iterate over everything (including "hidden stuff")

patent pebble
#

oh i see

#

doesn't seem to work. i tried iterating over every property in the serialized object, but none seem to have anything to do with the meta files

#

unless I'm doing something wrong

onyx harness
#

As an example

#

Do you see the icon assigned to the asset?

#

You have no API (to my knowledge) to modify it

#

The only way I know is to go through the SerializedProperties and change it there

#

Even though you use the SerO, the SerializedProperty won't show everything (The icon is hidden)

#

You have to enable the internal mode

patent pebble
#

I tried searching online but "internal mode" gives me no results

#

nothing on the source code either

onyx harness
#
PropertyInfo        inspectorModeProperty = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
inspectorModeProperty.SetValue(serializedObject, InspectorMode.Debug);

patent pebble
#

ah right, reflection

#

I still don't think that has anything to do with the actual meta file of the asset though

onyx harness
#

Certain information in the meta can only be accessed through this technique

#

like the icon

#

Otherwise, I dont know

patent pebble
#

I think all the meta file stuff is handled in the UnityEditor.VersionControl API

#

but I'm not sure, there's virtually zero documentation on meta files

severe python
#

Anyone know why a nested ListView wouldn't execute its MakeItem and BindItem methods?

#

this is the code I'm executing that has the issue

#

I discover 2 ListViews, once in the OnRootPresenterAttach, which sets up the ListView, the packageSourceList, which correctly invokes MakeSource and BindSource

#

however, MakeSource also adds an AttachToPanelEvent which executes the OnSourcePresenterAttach, which executes basically the same code except it discovers the itemSource differently

severe python
#

Okay, this is unexpected, after reviewing the UnityReferenceSource for unity 2018.4 (I don't know if its changed since) the problem was that the ListView didn't have a height that could support adding children, which was unexpected

#

In hindsight, I guess it makes sense since its a virtualizing control

tardy sorrel
#

I'm trying to make an editor script that does this. Does anyone know what this is called?

#

Definitely looks like a treeview, but I can't tell whether this dropdown/search structure is built into Unity of whether it's particular to the localization package. I'd like to avoid making my own if I can.

waxen sandal
#

It's not

#

but it's pretty easy to do

#

Just show an editorwindow as popup iirc

#

So

ScriptableObject.CreateInstance<window>().ShowPopup();
quaint zephyr
#

I am making [MenuItem], I understand how to use them for the most part, validation, etc. But I don't know how to have them selected. Like a check mark next to the menu item.

onyx harness
#

I dont think we can

quaint zephyr
#

oh no!

tardy sorrel
#

@waxen sandal That's insightful - thanks!

quaint zephyr
#

Ok, is there a way to dynamically change the MenuItem's label then?

onyx harness
#

Nothing that I know

#

MenuItem is compile-time.

quaint zephyr
#

Ok, maybe you can throw some ideas at me? I have a few states that the app can be in while it is open in Editor (for development purposes). Currently I am controlling which state is active via a prefab in the Resources folder. (This prefab bootstraps itself to any scene when you load and takes care of all the core features, input, resource pooling, data control, etc.

I want to create something that I can control globally, like a menu item in this case, where I can I just go to "App -> Mode -> WhateverModeINeed" and it will then update the prefab in the resource folder by itself without me having to navigate my way to it. Also I would like somewhere easily accessible I can see what mode it is in without having to navigate to the prefab.

#

But since I can't "check mark" the menu item or change the label dynamically. I was wondering if you might have an idea of where else I can implement this without too much coding 😛

severe python
#

You can have toggle menu items in a GenericMenu but you'll have to figure out how you want to invoke the GenericMenu

#

You could invoke it from a MenuItem and it would be similar to having a submenu

quaint zephyr
#

I'm afraid I'm not yet familiar with GenericMenu?

onyx harness
#

I just told you about the API Menu

#

What else do you want?

#

Look at the doc first, then come back

quaint zephyr
#

Thanks

severe python
#

Your embed doc link seems to be broken mikilo?

onyx harness
#

oh crap...

#

Hum, it's not not working, just there is no doc for API Menu (I don't check if every single link is functionnal)

#

But here is the API with some comments

quaint zephyr
#

I went ahead and just "disabled" the one that is selected for validation. 😛

onyx harness
#

Gut gut

#

Here is a more recent version of Menu (2019.2)

#

As you can see, you can Add/Remove MenuItem dynamically

#

And I tested it, it works, few bugs, making not 100% reliable, but it works

severe python
#

oh man, why can't that stuff be in 2018

onyx harness
#

March is coming, LTS 2018 dropping soon 🙂

severe python
#

Meaning they are not supporting it anymore? Doesn't really matter for me unfortunately, my efforts currently are around existing games

#

Making a package manager has been a fun project though

#

Stupid word wrapping

onyx harness
#

Well, just mean publishers will be pushed to support latest stuff

#

Meaning I will drop it as soon as I can

severe python
#

I can't blame you

onyx harness
#

What are those?

severe python
#

I wish I knew lol I haven't looked to figure it out yet

snow pebble
#

any one know how to get this to update the image preview every time the image data changes:

        public override void OnInspectorGUI ()
        {
            Fourier myTarget = (Fourier)target;
            DrawDefaultInspector();

            var texture = AssetPreview.GetAssetPreview(myTarget.H0T);
            GUILayout.Label(texture);

        }

Currently its just showing a snapshot even tho the image is constantly changing every frame - i want a live preview

drifting summit
#

what does the aPI versioner do?

visual stag
#

tells you what versions have an API present

frank gale
#

Hello there, I am currently working on an editor script for the following class

#
public enum ActionType { ForegroundCleaning, CG, Sound, Null }
public enum Position { Left, Right }

public class DialogActionHolder : ScriptableObject
{
    public DialogAction[] actions;
}

public class DialogAction : ScriptableObject
{
    public virtual ActionType GetActionType => ActionType.Null;

    public virtual void Run(DialogModuleUI dialogModuleUI) { }

    
public class CGAction : DialogAction
{
    public bool shouldSet;
    public Sprite sprite;

    public CGAction(bool shouldSet, Sprite sprite)
    {
        this.shouldSet = shouldSet;
        this.sprite = sprite;
    }

    public override ActionType GetActionType => ActionType.CG;

    public override void Run(DialogModuleUI dialogModuleUI)
    {
        if (!shouldSet || sprite == null)
        {
            dialogModuleUI.CG = null;
        }
        else
        {
            dialogModuleUI.CG = sprite;
        }
    }

}

public class SoundAction : DialogAction
{
    public AudioClip audio;

    public SoundAction(AudioClip audio)
    {
        this.audio = audio;
    }

    public override ActionType GetActionType => ActionType.Sound;

    public override void Run(DialogModuleUI dialogModuleUI)
    {
        dialogModuleUI.SoundFx = audio;
    }
}

public class ForegroundCleaningAction : DialogAction
{
    public Position[] foregroundCleaning;

    public override ActionType GetActionType => ActionType.ForegroundCleaning;

    public ForegroundCleaningAction(Position[] foregroundCleaning)
    {
        this.foregroundCleaning = foregroundCleaning;
    }

    public override void Run(DialogModuleUI dialogModuleUI)
    {
        foregroundCleaning.ForEachEnumerable(dialogModuleUI.CleanAtPosition);
    }
}
#
public class DialogActionHolderEditor : Editor
{
    public override OnInspectorGUI()
    {
        
    }
}
#

I am using an array to store all the different DialogActions by their base class

#

And I am having trouble on getting the fields of each child class

#

This **DialogAction ** scriptable object was originally an interface however I can't get unity serialize it correctly

#

Afterward I change the interface into a regular class, this time the unity can serialize the class however I am unable to either obtain the reference to base class nor determine the type of children class

gloomy chasm
#

That also goes for any sort of polymorphizium.

frank gale
#

Thanks

#

Eventually write all the fields inside the base class

tardy sorrel
#

(Red box is sensitive info, disregard.)

onyx harness
#

You need to set the min/maxSize

waxen sandal
#

Chances are you're doing show then showpopup

onyx harness
#

ShowPopup is not enough to display as a borderless window

#

@tardy sorrel Also, you must create the window using EditorWindow.CreateInstance<>(). Not using GetWindow<>().

tardy sorrel
#

I did switch to CreateInstance. If ShowPopup isn't sufficient, would something else work?

waxen sandal
#

Can you show your code?