#↕️┃editor-extensions

1 messages · Page 79 of 1

gloomy chasm
#

I don't know why it did work when I had the field marked with just [SerializeField], but not on prefab variants. But does work when marked with [SerializeReference]. I would think that it would either work or not work, not this strange halfway thing. Who knows.

#

Yeah... that is true. But don't really have much choice. Only good way to do undo/redo and support prefabs.

patent pebble
#

well, that's just how Unity is with editor features, it seems in the last 2 to 3 years they've put out a bunch of half-baked features

#

looks and works nice on the surface, but once you start digging, you start running into issues

#

and sometimes it's not even that the feature is incomplete or has bugs, it's that they have it extremely poorly documented, which leads to user error

#

@raw viper please don't send private messages asking people for help 🙂 ask your question here, someone asked you to share code, but you didn't. So we can't help

#

🤷

valid wharf
#

So I have a List that's is showing up in inpsector.
how would I go about setting up an initial size of the list when the component is added into the gameobject.
coz normally => you add component, set size, list shows 4 fields.
I want to eliminate the part of setting the size.

split bridge
valid wharf
#

....

#

shit

solid thicket
#

Hey, I created a window that I want to show use ShowModalUtility, and I want it to render to the Scene window, I tried hooking to SceneView.duringSceneGui but it seems the modal is blocking Unity entirely so the editor is not updated (no calls to duringSceneGui)

#

Any idea how I can achieve this while block my other EditorWindow?

patent pebble
#

@valid wharf @split bridge by doing new List<int>(5) you are only setting the initial capacity of the list, not the actual size. To set the size of a list when you initialize it you can do public List<int> someInts = new List<int>(new int[4])

#

a list has capacity as well as size, they are different properties

split bridge
#

Good point - hopefully @valid wharf got the gist 🙂

patent pebble
#

well the size property is actually called count but yeah

#

@solid thicket as far as I know you can't render an entire window to the scene view

solid thicket
#

I don't want to do that, I just want to change SceneViews camera settings

patent pebble
#

what you can do is use GUI/EditorGUI/GUILayout/EditorGUILayout methods inside the method subscribed to SceneView.duringSceneGui with Handles.BeginGUI & Handles.EngGUI

patent pebble
#

🤷

#

if you want to show a modal window while keeping the SceneView updating you can use SceneView.RepaintAll()

solid thicket
#

I said I want to render to the scene view, I didn't saw the window itself

patent pebble
#

Hey, I created a window that I want to show use ShowModalUtility, and I want it to render to the Scene window 😅
(the SceneView is an EditorWindow)

solid thicket
#

I want it to render to

#

Nevermind, anyway I wanted to change the SceneView settings

patent pebble
#

that's just what you asked. Now what it seems you are actually trying to do is show a modal window within the screen rect the SceneView window is at

solid thicket
#

SceneView.RepaintAll() Worked!

#

Thanks!

gloomy chasm
#

How do you get an event when an asset is deleted?

patent pebble
#

these are, as far as I know, the only 2 ways of getting native info from the deletion of an asset from the Unity Editor

#

maybe there's other ways of doing it, I'm not an expert in asset management

unreal phoenix
#

Am I crazy or does the

visualElement.RegisterValueChangedCallback(ev => Debug.Log(ev.newValue));

fire when you change the label text of a textfield?

Is this supposed to happen?

gloomy chasm
neat flower
#

Hey people. Do you know if it's possible to make default array inspector to use type's default values when adding an element to array instead of copying it from the last?

#

(2020.2)

mild reef
#

Hey guys, anyone know why the EditorGUI.Popup will not show numbers or symbols when it becomes active on click?

patent pebble
#

@mild reef show code?

thin coral
#

Good day i research addressables now and want to create AnalyzeRule which shows Implicit reference too, but in examples and docs i didn't find any information which classes has this informationUnityChanHelp

gloomy chasm
#

How do I get rid of the context menu for elements in an array drawn with a custom property drawer? Or at least get a callback for when one is selected.

onyx harness
#

Catch the click?

gloomy chasm
grim vine
#

is there a way to add custom operations to the Undo? For example the undo api afaik only covers stuff like property changes, destroy and create objects. But i've had a number of instances where changes aren't registered properly because they don't fit into either of those categories.

gloomy chasm
grim vine
#

too bad

grim vine
#

Undo.undoRedoPerformed looks interesting but it doesn't provide any sort of control or context, doesn't even tell you which of undo or redo being performed. Maybe Event holds the goodies?

grim vine
#

no dice

gaunt sky
#

heyhey! anyone knows how could one create a camera out of scene/without gameobject? I'm trying to create a custom view camera to view a singular selected object/mesh in the editor

#

or hiding the objects in Narnia or some other place would be okay aswell

#

just hide them from the user

waxen sandal
#

Hideflags

gaunt sky
#

thank you!

mild reef
#

Hey @patent pebble I just saw your response. Here is the code:

#

index = EditorGUI.Popup(new Rect (guiDefaultPosition.x + 110, guiDefaultPosition.x, 200, 20), index, new string[]{"None", "Anim #1", "Anim #2"});

#

This is all that shows though when I click on it:

patent pebble
#

@mild reef I think you have to escape the # symbol

#

I don't know exactly how to do that

#

I know you can escape quotation marks with a backslash for example

"This is a string with a \"word\" in quotations"
#

that in a string will result in:

"This is a string with a "word" in quotations"
mild reef
#

Hmm, don't ever remember having this issue before weirdly...

#

But you are correct about the # symbol. I just removed it and they all show up with 1 and 2...

patent pebble
#

it says the equivalent of # is %23

#

not sure if that applies to c#

#

@mild reef try with the backslash first, \#

mild reef
#

Ok thanks...

mild reef
#

@patent pebble I got an "unrecognized escape sequence" error...

#

with #

patent pebble
#

yeah the # symbol is a weird one

mild reef
#

Ill try the %23...

patent pebble
#

if you just put a space between the symbol and the number it works

#

but I don't think there's a way of having it on a string without a space

#

"Something # 1" will work

#

but not "Something #1"

#

i'd suggest just forgetting about that symbol and use plain numbers instead

twin dawn
#

like you can use a lot of characters without needing escape sequences

patent pebble
#

@twin dawn I think the # symbol still has conflict when something goes after it without a space

#

even when doing the verbatim literal string

twin dawn
#

could be!

#

could always interpolate your # symbols in too

#
string myString = $"phone {Hash}555-555-5555";```
mild reef
#

Hey guys, I just did a skim through your posts and tried all of those and nothing works...I just reported this as a bug to Unity since there is no explanation...

#

as to why this happens when you can see it like this before it being active:

patent pebble
#

yeah nothing seems to work for the Popup in regards to the # symbol

#

probably something in their source code that treats the strings in a certain way

#

like for example doing index = EditorGUILayout.Popup(index, new string[] { "Test", "Test/1", "Test/2" });

#

will result in the menu item having a submenu

#

they probably have reserved some symbols internally for context menus and menu items and that sort of thing

twin dawn
#

Oh

#

It's related to this

#

It creates keyboard shortcuts

patent pebble
#

ooooh lol

#

I was gonna go dig through their source code

#

surprisingly they have that documented 😅

twin dawn
#

SOmething about what you said re: menus rung a bell in my brain

patent pebble
#

yeah hehe

#

@mild reef there you go, seems like you won't be able to use any of the symbols %, #, &, / in any GUI stuff that uses menu items

mild reef
#

Since what version of Unity?

patent pebble
#

probably since forever

#

the docs for Unity 5.2 already had that

onyx harness
#

Just use similar char

#

For % and &, it might be hard to find one

#

but # and / definitely have some

gloomy chasm
#

Is there a reason why a list marked with [NonSerialized] would be set to null after OnAfterDeserialze() is called?

mild reef
#

@patent pebble Very weird since this is a project I’ve never noticed that issue with before...

patent pebble
#

Does anybody know if the shader for the built-in Handle Caps is available anywhere?

#

I'm making some custom tools for the sceneview and I'd like to recreate exactly how Unity does the Handle Caps

#

Like the cones in the transform tool

waxen sandal
#

You can probably find the source somewhere in the editor

#

Or you cna just load it

#

If you can figure out hte name

#

internal/handles or something probably

patent pebble
#

@waxen sandal I saw this on the forums
The source of the Handles shader doesn't exist in the editor installation. The shader used is precompiled inside an asset bundle of default editor resources.

waxen sandal
#

In that case you can just load it

patent pebble
#

@waxen sandal so if I figure out the name, I can just load it with Shader.Find ?

waxen sandal
#

Yep

patent pebble
#

ok, I'll do some digging to see if I find what it's called

#

thx!

severe python
#

Is there a way to launch the preferred code editor via unity to a specific file?

#

I'm trying to replicate the "Edit Script" component menu option

patent pebble
#

@waxen sandal oh I seems now they just publicly release all the built-in Editor shaders.
In my old 2017 shader folder they weren't there
But in the newest releases they added the folder EditorDefaultResources with all the goodies 😋

gloomy chasm
#

@patent pebble There is HandleUtility.handleMaterial though I don't remember what it does and is undocumented.

patent pebble
#

@gloomy chasm yeah there's multiple issues with that one. It changes color (red, green blue) based on the camera direction, it fades out if any mesh is between the camera and the handle

#

and most importantly....

#

I'm not Nicholas

#

🙃

gloomy chasm
#

LOL

#

That is a great comment.

patent pebble
#

So I just downloaded the built-in shaders from their website and tweaked the one called HandlesLit

#

the Editor is probably doing other things to the way Handles are rendered, because I can't just replicate the same color, shading and fading behavior using the built-in shader. I got close enough tho

patent pebble
#

oh I'm dumb, I figured out why the weird behavior, I forgot global shader variables were a thing 🤦‍♂️

#

@gloomy chasm so yeah then technically using the HandleUtility.handleMaterial works, but it's just a pain having to make backups for all the shader variables

#

so using a new shader for my custom values saves that headache

quaint zephyr
#

Is there a plugin that can help disable editor hotkeys while you're testing in PlayMode?

marsh grove
#

I would like to create a drawing tool like extension for 2d scenes. How do i detect the input and how do i prevent accidentally selecting another gameobject?

ebon helm
#

How can I do a BeginVertical inside a specific Rect that I have calculated ?

fickle copper
#

Hello, is there a way to not draw each individual float value of a vector3/vector2?

#

So it is just the Vector3

#

Im using the GetIterator() stuff to get to every property

#
 SerializedProperty it = serializedObject.GetIterator();
            it.Next(true);

            while (it.NextVisible(true))
            {
                switch (it.propertyPath)
                {
                    case "useCustomAnimation":
                        it.boolValue = EditorGUILayout.Toggle(it.displayName, it.boolValue);
                        break;
                    case "customBridgeAnimation":
                    case "defaultBridgeState":
                        if (m_UseCustomAnim)
                            EditorGUILayout.PropertyField(it, new GUIContent(it.name), it.isExpanded);
                        break;

                    default:
                        EditorGUILayout.PropertyField(it, new GUIContent(it.name), it.isExpanded);
                        break;
                }
            }
#

Im trying to make it so that some specific properties are drawn when a boolean is true

ebon helm
#

you can place the individual values in a EditorGUILayout.Foldout

fickle copper
#

true, but i want to remove them from the editor completely as it is very reduntant to have duplicate variables imo.

#

I also realized that any custom property drawers made by Unity dont work: Here is how my Unity Event looks like:

ebon helm
#

you can check the type of the SerializedProperty and not draw it if it is a float?

fickle copper
visual stag
#

I don't think you should be passing isExpanded into the property field at all

visual stag
#

like if it's not expanded, it won't draw the children regardless afaik. I think your issue is entering children in NextVisible

#

because you draw the property and its children

fickle copper
visual stag
#

and then enter the children and draw them too

#

Just don't enter the children in NextVisible

fickle copper
#

uhm..

visual stag
#

enter it as so far to draw all of your root properties (ie. enter once) and then never enter the children again

fickle copper
#

so basically it.NextVisible(false)?

visual stag
#

yup

fickle copper
#

Would you believe me if i said that i spend about an hour figuring that out?

visual stag
#

Yeah, I've had some hard times with similar things

#

you get used to it 😛

fickle copper
#

❤️

#

ill test it to see if it draws correctly

#

And it sure does

#

Ill just have to disable the first property as its the script itself

#

Pretty sure that shouldnt be editable

visual stag
#

or just skip it, screw that field 😛

fickle copper
jagged coral
#

I'm trying to determine what the best practice is for placement of a package settings asset. Here's the scenario:

  • I have a ScriptableObject which stores the settings in my Packages/*/Editor/Default Resources/*.asset path.
  • That object has a method to load and/or create the asset file and a method to return a SerializedObject for it.
  • I have a SettingsProvider which is registering a project settings window which loads/saves and allows editing of the values in that above asset.
  • The SettingsProvider and the ScriptableObject are currently in my PackageName.Editor namespace.
  • I have code in a different namespace called PackageName which needs to load and use the settings.

Should I just include the PackageName.Editor namespace in my files which need to read the settings so I can use the ScriptableObject to load the settings? Or should I move the ScriptableObject to my PackageName namespace which is already included in the file defining the SettingsProvider? Or should I be doing something entirely different? What is the typical / recommended convention for separating editor code from non-editor code and making package-wide settings available to both sets of code?

whole steppe
#

i need help with somthing guys anyone here can help me tha'd be much appreciated

patent pebble
#

@whole steppe to make life easier for everybody on this Discord, please don't ask questions asking if anyone can help you.
Ask your question or state your problem and if someone can help, they'll answer 🙃

marsh grove
#

I have the following problem. I am trying to create a GUI for my Brush editor tool.
If I select the tool I can interact with the GUI, but once I click and draw in the scene I cant anymore.
My code:

Handles.BeginGUI();
       
            GUILayout.Window(2, new Rect(Screen.width-310, 25, 300, 0), (id)=> {
                // Content of window here
                if (GUILayout.Button(visible ? "Hide" : "Show Brush settings")) visible = !visible;
                if(!visible) return;
                GUILayout.Label("Brush Radius");
                GUILayout.BeginHorizontal();
                GUILayout.Label(radius.ToString("F"));
                radius = GUILayout.HorizontalSlider(radius, 0.00001f, 5f, GUILayout.MaxWidth(250));
                GUILayout.EndHorizontal();

            }, "Brush Config");
            
            
            Handles.EndGUI();
            // Cancel deselecting/selecting other objects 
            if (Event.current.type == EventType.Layout) 
            {
                HandleUtility.AddDefaultControl(0);
                return;
            }
            // Draw logic here
teal anchor
#

does anyone know if i can, or how to... put the lists in the area on the drop down? or at least the title?

visual stag
#

I assume we're looking at a reorderable list or a property drawer?

#

Regardless you should not use the Layout functions

#

and use the rect provided

#

and override the property height function

teal anchor
#

i'm trying to make collapsable sections to be able to add or take away sections

#

and yeah its reorderable list

civic river
#

Is their any way to run the UI elements debugger on a runtime UI document?

#

It seems like UI documents have a flipped coordinate space compared to editor windows but it's not so easy to confirm this is the case without the debugger

#

Editor Window

whole steppe
#

Guys, I'm making an editor window
How can I use the selection method

ebon helm
#

Quick question. How can I make it so that when I click on a object field to have that object be selected in the inspector?

waxen sandal
#

Double click it?

whole steppe
#

what i mean is the context in the window changes depending on the object i selected

waxen sandal
#

Selection.ActiveObject or something like that

#

Then just check the type or w/e you want to do

whole steppe
waxen sandal
#

Yeah

cloud wigeon
#

Quick question regarding UI toolkit based editor windows in 2020.2

#

In previous unity versions, I used this code to populate the hierarchy

#

However the CloneTree function appears to no longer work properly

visual stag
#

I don't think you need to do rootVisualElement.hierarchy, can't you just add directly to rootVisualElement?

cloud wigeon
#

Same error unfortunately

visual stag
#

The error does seem to be coming from the clone function, not the add

#

so it must be something weird with your uxml?

cloud wigeon
#

the weird thing is since i am using hierarchy.add it appears to be an issue within the clonetree function itself

cloud wigeon
visual stag
#

:/

cloud wigeon
#

any ideas what changed or what needs to be changed in the uxml to upgrade it?

visual stag
cloud wigeon
#

Hm I'll do a clean reimport of the project and see if this helps first

#

Might have to open a thread in the forum if not. Thanks for the help thus far! 🙂

#

The UI Builder error seems to confirm that it doesn't like one of the uxml files

#

a few other files i tested loaded just fine

marsh grove
#

anyone?

cloud wigeon
#

@visual stag It appears as if the ListView changed, mine have children and that's no longer supported

waxen sandal
#

Think I ran into that before, really annoying...

ebon helm
#

So I'm using a GUILayout.BeginArea() with a specific rect to draw some mlticolumn header stuff and I cant get my head around how to make the damn Area scrollable with .BeginScrollView

gloomy chasm
#

Sorry, never mind I just didn't read the doc comments... my bad.

gloomy chasm
#

How do you load assets local to a package? Using the normal Assets/My-Package/myAsset.asset path does not seem to work.

visual stag
#

com.thingo.package/Path/File.asset iirc

gloomy chasm
# visual stag `com.thingo.package/Path/File.asset` iirc

Yeah, I just took a look at the UI Builder to see what it does, and that seems to be it. I was wondering how to handle when actually making the package. But I think I just realized that it should be in it's own, non-Unity folder and then add it as a package to a Unity project to work on it.

visual stag
#

That's what I do

gloomy chasm
#

Makes sense. Does it need it's own solution file or anything? Or just drop a package.json file in a folder and call it a day?

visual stag
whole steppe
#

Guys, how can I add a button that when pressed adds a dropdown menu

#

I'm a bit if a beginner

waxen sandal
#

I've got a propertydrawer that is drawing array elements, for better visualization I need the rest of the array to do some calculations. I guess there's no clean way to do that except draw the whole array myself right?

ebon helm
#

ok. Does anybody know how to properly register for Undo the actions form a ColorFIeld ?

waxen sandal
#

Code?

ebon helm
#
EditorGUI.BeginChangeCheck();
data.mat.SetColor(colorProp,EditorGUILayout.ColorField(data.mat.GetColor(colorProp), GUILayout.Width(100)));

                    if (EditorGUI.EndChangeCheck())
                    {
                        
                        Undo.RecordObject(data.mat, "matTint");
                    }```
#

I do this inside a loop that goes trough a bunch of data. It sets the color on the desired mat correctly

#

nvm I was being stupid

#
EditorGUI.BeginChangeCheck();
                    tintColor = EditorGUILayout.ColorField(data.mat.GetColor(colorProp), GUILayout.Width(100));
                   
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(data.mat, "Base color change on " + data.mat.name);
                        data.mat.SetColor(colorProp, tintColor);
                    }
#

this is what needed to happen

graceful gorge
#

Hello everyone, I'm trying to setup a foldout property, it's working, except than opening the foldout lowers the header and toggle one row below where it's supposed to be. Is there a catch I need to pay attention to ? I could swore I did something similar once without issue (I pass the position that gets fed to OnGUI to the EditorGUI.Foldout call)

frank gale
#

How do you draw a line between two items? Something works line EditorGUILayout.Space

graceful gorge
#

Nope, but I just found out what happened with the help of a colleague, I just have to set the position's height to single line or the header got drawn in the middle of the Rect. (I wrongly assumed that the content was anchored to the top left of the provided rectangle)

valid slate
#

Hey guys, I've been trying to use VFX graphs to make a muzzle flash for an FPS game as I 'm struggling to make a nice looking one with unity's basic particle systems, but I can't figure out how to implement the VFX graph on click or how to implement it into my programming, does anyone know of any tutorials that show implementing VFX graphs with programming? (I've looked but can't find any with programming)

valid slate
gloomy chasm
#

Is there any way to make it so that the default constructor is called on items when they are made in an array? I have class that creates a unique ID for it self in the constructor. And the array kind of messes that up...

onyx harness
#

the only "constructor" you got is ISerializableCallback

gloomy chasm
severe python
#

Anyone know how you can invoke the script editor correctly?

#

or perhaps, even know where in the source code I could look?

#

I've been trying to figure it out, even by looking at the reference source, but I can't exactly figure out how the "Open C# project" menu item works, or double clicking on a script....

#

oh nevermind, I totally just figured it out

visual stag
#

InternalEditorUtility.OpenFileAtLineExternal

severe python
#

yep

#

man my new composable scriptable object stuff is really coming along

#

ah man

#

the top Inspector is a custom editor for a type I call ComposableObject, this is the ComposableObjectEditor, which draws each field using EditorGUI.PropertyField
and so the DependenciesDrawer gets invoked whether the ComposableObjectEditor or the normal Inspector for the ThunderstoreManifest object is used
however, if I drag and drop onto the ComposableObjectEditor's Dependencies list, it never shows the asset as droppable, even if canDrop is true
Furthurmore, it isn't droppable I can't drop it in that state and have it drop
but I can drag and drop to the normal inspector just fine
Shouldn't the DependenciesDrawer behave the same regardless?
I even added...
if(canDrop) Debug.Log("We can drop here");

Which does log when I expect it to
which suggests the visual mode should be updated

#

and suggests that I should be able to drop it, I just don't understand why this wouldn't be working here, and it definitely was working at one point...

#

Ah, I apparently need to use Event.Current.Use()

mild reef
gloomy chasm
#

Is there some way to get a event when a SerialzedProperty field has been changed at runtime? I have a TreeView that I need to call Reload() on when a value changes.

#

Also, is there some sort of callback for when the Revert item is selected from the property context menu?

waxen sandal
#

Update returns a bool iirc

gloomy chasm
waxen sandal
#

Serializedobject.Update returns a bool whether something has changed

severe python
#

So while using event.current.use solved my specific issue, something in my editor appears to be a problem for drag and drop in general

#

Is there any really good guides on drag and drop that may help me understand what problem ive created?

gaunt sky
#

okay, how do I draw a window that is 100% of the EditorWindow , not a % less, not a % more (in OnGUI)? this works somewhat but the height is not accurate at all probably new Rect(0, 0, EditorGUIUtility.currentViewWidth - 2, Screen.height - Screen.height * 0.2f - 21)

#

oh and this is janky, if I put the window on the right side of the editor there is a missing pixel column, put if I remove the -2 then it is not accurate for normal (central/in your face) window alignment

#

like Screen.width is incorrect for the editor window, BUT if I do change the editor window size in the editor, it does change Screen.width

gaunt sky
#

anyone?

#

or is the editor like a down-scaled version of Screen.width and height? I might try that tomorrow

thin fossil
#

What is the state of the art in deploying custom packages? I have an open source package ready in GitHub and looking to deploy it via package manager...

twin dawn
#

Usually for a free open source package the git URL is the way

thin fossil
#

But it seems like git URL still has problems with versioning and dependencies

#

Was thinking about using OpenUPM or npmjs or maybe even Asset Store?

whole steppe
#

Anyone know if its possible to render static imgui code in a graphview?

#

I want to make it so like 1/4 of my windows regular imgui code the rest is a graph view but can't figure out how

waxen sandal
#

IMGUIContainer?

whole steppe
#

@waxen sandal you're a god damn legend.

#

This appears to be exactly what I need!

#

Thank you very much!

#

@waxen sandal is there a way to lock it so it can't be moved? I want it to like always show up on the left side of the graph.

waxen sandal
#

wdym?

#

Are you drawing it as a node in your graph?

#

If so you should just be able to draw separate from your graph

whole steppe
#

Let me try that!

#

it was in a node

whole steppe
#

that worked

#

thank you

#

What is the method to get the width when I am trying to do imgui

#

screen.width doesn't work correctly and neither does editorwindow.windowsize.x

grim vine
#

i had issues with DPI

#

evt.mousePosition * Screen.dpi / 96f

#

that is if you're using a 4k display or above, if not i'll just fly away

waxen sandal
#

EditorWindow.position.width?

whole steppe
#

Ok im going to bed im drunk screen.width works fine. I just was doing it wrong.

grim vine
#

lol

#

I'm looking for a design pattern for event chains.

so far i've just been enabling GameObjects:
Object A does it's thing, then enables Object B
Object B does it's thing, then enables Object C.

this is done with a simple field that references the next object. It's dead simple to implement but it's also completely unmaintainable.

waxen sandal
#

Just use a list of events?

grim vine
#

put the list where?

waxen sandal
#

It depends?

grim vine
#

i suppose it does

#
public interface IEvent{
    void Next();
}
#

i could implement an interface like this along the monobehavior. But then what is "Next". Is it enabling a component? Or GameObject? could be anything. One object should have no knowledge of the next operation in the chain.

waxen sandal
#

I'd just separate your chain into a separate class that then handles the invoking and waiting for the next event

grim vine
#
public interface IEvent(){
    void Exec(System.Action next);
}
waxen sandal
#

If you really only want one class then yeah that works but that'll be annoying to set up

grim vine
#

yeah, each component needs to implement the interface

#

and i need to create an editor for the manager

grim vine
#
public interface IEvent(){
    void Exec(System.Action next);
}

public class AwaitTrigger:MonoBehavior, IEvent{
    private Action _next;
    
    public Exec(Action next){
        _next = next;
    }
    
    private void OnTriggerEnter(){
        _next();
    }
}

public class EnableObjectEvent:MonoBehavior, IEvent {
    public GameObject ThenEnable;
    
    public Exec(Action next){
        ThenEnable.SetActive(true);
        next();
    }
}

public class Eventer : MonoBehavior {
    public IEvent[] Subscribers;
    private int _position;
    private void DoIt(){
        Subscribers[_position++].Exec(DoIt);
    }
    
}
#

but yeah, i need to create monobehaviors for triggering common events like triggers. And other than that everything else needs to implement that interface which may be a hassle when i get stuff like killing mobs or player actions like jump/move

#

@waxen sandal what was your suggestion again?

waxen sandal
#

Remove that next action, make your eventhandler just iterate over the events

#

And make the eventhandler normal class

grim vine
#
public class Eventer {
    public IEvent[] Subscribers;
    private void DoIt(){
        foreach(var f in Subscribers)
          f.Exec();
    }  
}

?

#

still got the interface

#

😂

waxen sandal
#

I guess you want serialization support right?

grim vine
#

i want i can set up the chain in the editor

#

i should study about it before i start building stuff, let's see if there's any hits on the Command pattern

waxen sandal
#

In that case non unity object listeners might be harder to do

#

Might be able in 2019 with serializereference perhaps

grim vine
#

i think the serialization is adequate as is. I can see an issue with restoring the state after reloading the game

lethal helm
#

"if it doesn't exist, a new one is created in the local materials folder"

#

this is really annoying behaviour that you can't turn off by default

#

i really really really wish it wouldn't do this

#

because it gets it wrong anyway

#

under "naming" it says 'from model's material'

#

but unity always ignores the existing material and generates a new one, because the generated name doesn't actually match this at all

#

it adds all this extra bullshit based on properties of blender that are irrelevant to unity

#

i really like to manage my materials strictly so this behaviour is frustrating

#

i have an editor script here to manage the default import of models

#
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;

public class ForceExternalMaterialProcessor : AssetPostprocessor {
    void OnPreprocessModel() {
#if UNITY_2018_1_OR_NEWER
        var importSettingsMissing = assetImporter.importSettingsMissing;
#else
        var importSettingsMissing = !System.IO.File.Exists(AssetDatabase.GetTextMetaFilePathFromAssetPath(assetPath));
#endif
        if (!importSettingsMissing)
            return; // Asset imported already, do not process.

        var modelImporter = assetImporter as ModelImporter;
        modelImporter.materialLocation = ModelImporterMaterialLocation.External;
    }
}
#endif```
#

can i use this script to also modify the naming convention ?

#

and if so, how would i do that

vernal bison
#

morning all. can anyone point me in the right direction on how to write a custom property drawer for lists? requirements: it has to be a drawer (not an editor), and it needs to encompass the drawing of the entire list (my attempts so far only take over the drawing of the elements, but i want entire array control).

waxen sandal
#

DecoratorDrawer draws the whole list iirc

#

Otherwise you can't

vernal bison
#

trying now, thanks. and yeah, i found your second statement to be true

#

hmm, so switching to a decoratordrawer, the list still draws in addition to my fanciness. is there a way to tell it to not draw the property it's attached to? reading docs, it sounds like that's not how decoratordrawers work (they don't draw a property)

waxen sandal
#

You can make a wrapper around it and create a property drawer for that class

vernal bison
#

sorry, not sure i follow. are you saying instead of trying to draw only my List with a property draw, to instead create a custom drawer for the entire class?

waxen sandal
#
class ListWrapper
{
  public List<int> list;
}```
then create a PropertyDrawer for ListWrapper
vernal bison
#

oh right, yeah, i thought of that but that'll result in a lot of data loss.

#

so it sounds like taking over drawing of an entire array property is not possible without jumping through data-changing hoops. so next question would be: if i have a custom editor for the parent class of the array, is it possible to say something like "draw all elements as you normally would except for this one. let me take care of that one" instead of me having to custom-draw everything in the class.

waxen sandal
#

DrawPropertiesExcluding

vernal bison
#

lovely. that'll have to do, i guess. thanks

vernal bison
#

hey all, another random question for the masses: first time working with reorderable lists in a custom editor and everything is fine except one oddity. i actually have two lists in the class and therefore two reorderable objects. the removal behavior differs between the two. when i remove from list A, it removes the entire element from the array as expected. when i remove from the list B, it first clears the field within that element, then i have to click "-" again to remove the element itself. why would that be?

west drum
#

Is there a smarter/shorter way to do this?

AnimationClipSettings animSettings = AnimationUtility.GetAnimationClipSettings(clip);
animSettings.loopTime = true;
AnimationUtility.SetAnimationClipSettings(clip, animSettings);
twin dawn
#

Not really.

#

Use the var keyword maybe? That's slightly shorter

gloomy chasm
vernal bison
# gloomy chasm Only one property drawer is made and shared. So any 'initialize' logic would the...

it's not in a drawer because, afaict, drawers can't take over the entire array drawing. instead, it's a custom editor for the entire class, and in that class are two separate arrays of things, both of which I've overridden via reorderablelist. when i remove an element from list A, it actually deletes the entry. when I remove from list B, it only clears it out. then i need to hit remove again, THEN it removes the entry. same custom editor, similar code to run both reorderable lists, but they behave differently.

#

if that makes sense

gloomy chasm
vernal bison
#

ahh, that must be what's happening then. is there a way to bypass that behavior and just have it delete the array element?

gloomy chasm
vernal bison
#

ok, i figured as much. thanks

thin fossil
#

did anybody here already upload packages to OpenUPM? Not sure if the submission process is broken or if I just dont get it

dim slate
#

I didn't see this channel, i'm looking for any decent tutorials, paid or free that actually teach about tool building and editor extensions in unity, if you find or have anything feel free to ping me! thanks in advance

grim vine
#

@dim slate i think you need to be a little more specific

#

"tools" is a fairly broad term

#

start with making custom inspectors

graceful gorge
# dim slate I didn't see this channel, i'm looking for any decent tutorials, paid or free th...

https://youtu.be/pZ45O2hg_30 This is a course Freya Holmer ran for a game education in sweden, it's a very good primer

🔽 click for timestamps & info!

this was originally streamed as a course for students at http://futuregames.se/, who were super kind to let me both stream this live as well as upload it here! so massive thanks to the people at FutureGames!!

💖 Patreon ❱ https://www.patreon.com/acegikmo
🐦 Twitter ❱ https://twitter.com/FreyaHolmer
📺 Twitch ❱ http...

▶ Play video
dim slate
#

Thanks Basil!

graceful gorge
#

Hello, question about addressable build (this is the most specific channel I could think of for this). Is there an equivalent to IPostprocessBuildWithReport to make operation after building an updating a catalog (I'm trying to automatically upload the catalog to our backend)?

raw viper
waxen sandal
#

Because Title isn't the asset name

#

it's name

#

Probably

raw viper
#

hm how i can fix that thing

waxen sandal
#

You can probably change it in the debug inspector

raw viper
raw viper
#

?

raw viper
#

@waxen sandal

patent pebble
#

What are good ways of "hooking up" extra functionality to default Unity features?
For example:
Having a toolbar with some buttons being drawn on the SceneView by default from the moment I open Unity (and also be able to close it and open it from a menu item on Unity's top bar)

I know this can be used to achieve that https://docs.unity3d.com/ScriptReference/InitializeOnLoadAttribute.html
Is there anything else that I should learn on this topic?
Or anything I should be careful with?

#

*This isn't for a particular tool or anything, I'm just trying to learn about every way Unity can be extended

severe python
#

there are a number of methods that people have used, but none of them are particularly great

#

Thats why Gabriel has been working on a new system to manage this better

patent pebble
#

👀 tell me more

severe python
patent pebble
#

@severe python any pointers to what other people have used for this in particular? I find it sort of difficult to google info on the topic since I lack the specific vocabulary in order to do so

#

oh

severe python
#

I've honestly not done it myself

#

There are a ton of tools that have, ProBuilder has versions with such features IIRC

#

Curvy Spline does it

#

actually, I don't know why I'm saying IIRC, ProBuilder adds a button widget to the scene view

gloomy chasm
#

InitializeOnLoad is what most people use. I personally now also just get the rootVisuelElement and add stuff to that instead of messing around with IMGUI.

patent pebble
#

yeah I've used some ProBuilder for prototypes, iirc they have a small toolbar that pops on the sceneview, but I don't know if it's an Editor Window or just GUI controls hooked up to the SceneView.duringSceneGui callback

severe python
#

well you have the source code, and you know what to look for

#

so open it up in VS and do a find

patent pebble
#

oh right I should do some digging

#

maybe they have the source up on GitHub since they are now part of Unity Technologies

#

@gloomy chasm I'm not very familiar with UIElements, so I rely mostly on using IMGUI

#

but I'll look into that too

patent pebble
severe python
#

yeah unfortunately

#

the preview of overlays is available, but you'll probably have to be on the 2021.1 beta

patent pebble
#

@severe python yeah, i just took a quick glance at their developer guide and seems they use UIElements for that, which I'm not very familiar with

#

I guess I'll have to learn how to deal with it soon 😅 heh

severe python
#

UIElements is the Way

#

I've been doing a ton of IMGUI lately, and it only cements my belief

#

the one thing I have to give to IMGUI as of late, is that its completely trivial to implement virtualization

#

its just kind of a given, only render what the user can see

patent pebble
#

yeah

thin fossil
#

What would be the best way to recover static vars in an editor tool after domain reload? I know I could use EditorPrefs but is there a way to keep it in memory without writing to registry or disk?

normal jay
#

Did anyone ever use Addressables.LoadAssetAsync for editor scripting ? It doesnt resolve unless i wiggle the viewport or save the scene

#

Or any async method call in editor for that matter

ancient sable
#

Has anyone here ever used or seen any editor tool used to play and pause multiple audio clips simultaneously.

For years, I have been using Reflection to call UnityEditor.AudioUtil methods to play, pause , stop and resume audio clips but now I need to be able to play multiple clips at a time , pause or stop one or two without breaking playback for everything.

I am curious to find out if there are any editors that do this.

visual stag
#

My speculation without trying it would be to look towards the Timeline audio API.
I'm fairly sure it has audio preview, and I would assume multiple tracks

#

I think it uses AudioClipPlayable

#

you can look at the source for AudioTrack and its associated files as it's in a package

ancient sable
#

Thanks @visual stag , I will look into this. Anything's helps

grim vine
#

is there some functionality that let's me drag resize an area?

patent pebble
#

@grim vine resize what? a rect for an IMGUI control?

#

I don't think there's a built-in way of doing it

grim vine
#

yes

#

alwright

#

looking at the source again

patent pebble
#

a while ago I made a way for dragging and resizing rects in an editor window, I can share it

#

(not sure how efficient or polished it is)

grim vine
#

i can take a look

#

found something called EditorGUIUtility.HandleHorizontalSplitter

#

internal tho

patent pebble
#

@grim vine they are messy, unoptimized and not extensively tested

#

that code was just for some quick tests I did when I started learning about IMGUI, I haven't actually used them in any tool. But they seem to work

grim vine
#

alright

#

it'd be useful one way or another

daring musk
#

hello i am trying discord rp and when i start the editor it gives my this error DllNotFoundException: discord-rpc DiscordPresence.PresenceManager.Update () (at Assets/Discord-RPC/PresenceManager.cs:121)

#

and also does the discord rp count as an editor extension

grim vine
#
   void OnEnable() {
        _method = typeof(EditorGUIUtility).GetMethod("HandleHorizontalSplitter", BindingFlags.Static | BindingFlags.NonPublic);
    }

    private static MethodInfo _method;
    private static Rect HandleHorizontalSplitter(Rect dragRect, float width, float minLeftSide, float minRightSide) {
        return (Rect)_method.Invoke(null, new object[] { dragRect, width, minLeftSide, minRightSide });
    }

works like a charm 🕹️

#

@daring musk what did you install?

daring musk
#

wdym

grim vine
#

lol the github is in French

daring musk
#

lol

grim vine
#

seems the Dll exists in the repo but not loading correctly for you

#

how did you install it?

daring musk
#

i took the enitre assets folder then put it in my assets folder

grim vine
#

can you find the dll?

daring musk
#

dll?

grim vine
#

Assets/Plugins/

#

x86 and x86_64

daring musk
grim vine
#

that's it

#

both folders should contain a dll

daring musk
#

they both have a puzzel peice that is called discord-rpc

grim vine
#

ok

#

how does it look in the inspector?

daring musk
#

wdym

grim vine
#

their properties

daring musk
#

oh ok

grim vine
#

no issue there

#

try rightlick reimport 😂

daring musk
#

where is that?

#

i didnt see it

grim vine
#

on the puzzlepiece

daring musk
#

ok

#

on both?

#

i did it on both then i started the game but it still doesnt work

grim vine
#

ok

#

then i dunno

daring musk
grim vine
#

your error leads me to this line:

[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void RunCallbacks();
#

try typing discord-rpc.dll

#

or the full path

daring musk
#

type it where

grim vine
#

after dll import

#

innnn

#

/Assets/Discord-RPC/DiscordRpc.cs

daring musk
#

should i put it after all of these?

        [DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
        public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);

        [DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
        public static extern void Shutdown();

        [DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
        public static extern void RunCallbacks();

        [DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
        private static extern void UpdatePresenceNative(ref RichPresenceStruct presence);

        [DllImport("discord-rpc", EntryPoint = "Discord_ClearPresence", CallingConvention = CallingConvention.Cdecl)]
        public static extern void ClearPresence();

        [DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
        public static extern void Respond(string userId, Reply reply);

        [DllImport("discord-rpc", EntryPoint = "Discord_UpdateHandlers", CallingConvention = CallingConvention.Cdecl)]
        public static extern void UpdateHandlers(ref EventHandlers handlers);
grim vine
#

you can use ctrl+h

daring musk
#

ok

#

what should i do after i press ctrl+h

grim vine
#

discord-rpc -> discord-rpc.dll

#

if it doesn't work try discord-rpc.dll -> /Assets/Plugins/x86_64/discord-rpc.dll

daring musk
#

ok

#

it still doesnt work

grim vine
#

awesome, then i dunno

severe python
#

I have an issue I don't understad, Given this code...

        public override void OnInspectorGUI()
        {
            dataArray = serializedObject.FindProperty(nameof(ComposableObject.Data));
            CleanDataArray();
            using (new VerticalScope())
                for (int i = 0; i < dataArray.arraySize; i++)
                {
                    var step = dataArray.GetArrayElementAtIndex(i);
                    var stepSo = new SerializedObject(step.objectReferenceValue);
                    var editor = CreateEditor(step.objectReferenceValue);

                    EditorGUI.BeginChangeCheck();
                    try
                    {
                        if (DrawElementHeader(step))
                            editor.OnInspectorGUI();
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtility.SetDirty(stepSo.targetObject);
                    }
                }
        }
#

If I make edits to any field via the inspector, I the changes are not persisted

#

I copied the general setup from the Unity C# reference, but they didn't even do what I'm doing with set dirty, which I added as a troubleshooting step

#

the editor in this example is always...

    [CustomEditor(typeof(ComposableElement), true)]
    public class ComposableElementEditor : UnityEditor.Editor
    {

        public override void OnInspectorGUI()
        {
            DrawPropertiesExcluding(new SerializedObject(target), "m_Script");
        }

    }
#

I honestly feel like I must be missing something dead simple

#

ah it has something to do with DrawPropertiesExcluding

gloomy chasm
#

Is it because you are never doing serializedObject.ApplyModifiedProperties() perhaps?

severe python
#

that was my thinking, but it seems to be more complicated...

#

it looks like I needed to update the serializedobject

#
    [CustomEditor(typeof(ComposableElement), true)]
    public class ComposableElementEditor : UnityEditor.Editor
    {
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" });
            if (GUI.changed)
            {
                EditorUtility.SetDirty(serializedObject.targetObject);
                serializedObject.ApplyModifiedProperties();
                Repaint();
            }
            Repaint();
            serializedObject.ApplyModifiedProperties();
        }
    }
gloomy chasm
#

Ah, it is because you are recreating the editor each time

#
 var step = dataArray.GetArrayElementAtIndex(i);
                    var stepSo = new SerializedObject(step.objectReferenceValue);
                    var editor = CreateEditor(step.objectReferenceValue);
severe python
#

this is totally copy pasta

#

ah okay

#

so I should perhaps try to persist my editors?

gloomy chasm
#

Yep, I normally use a Dictionary<Object, Editor>

#

With the key being the objectReferenceValue

#

Or I will use the propertyPath string as the key.

#

Actually, what I would do my self is use the propertyPath as the key, and then make a class that holds both the Editor and the SerializedObject, that way you don't need to recreate it either.

severe python
#

implementation details, but yeah that was totally the issue

#

Thanks!

gloomy chasm
#

Sure thing!

severe python
#

If you look at this, there is this little rogue control going down the left side

#

I even went so far as to comment out my entire OnInspectorGUI method, and it still shows up on this type

#

If anyone has any clue, this is absolutely maddening, I have no idea where this is coming from :/

#

nevermind, turns out I had forgotten about a derived editor which had its own code, which I should have noticed because it doesn't happen in another place I have this same base inspector

visual stag
#

Use the imgui/uitoolkit debuggers to figure out what it is next time

gloomy chasm
#

Well I just learned that SerializedProperty.DataEquals(propA, propB) was a thing! I just spent like 2 hours making my own version of it and debugging it!

#

Is there a good way to see if there is a custom property drawer for a type? I guess more accurately, I want to hide the foldout of a property.

severe python
#

there is an imgui debugger?

gloomy chasm
# severe python there is an imgui debugger?

Yep, at least in 2019 you can press alt + 5, it is in window/analytics/IMGUI Debugger. I think in some older versions (don't remember how old) you have to get it off of github.

severe python
#

Sweet, that will definitely be useful

visual stag
#

If you're in internal mode it's in the window menu somewhere I'm pretty sure

#

I also have a gist to open it regardless pinned to this channel

gloomy chasm
#

LOL, I just found this comment in the Unity source for the PopupWindow // Change to private protected once available in C#.

sonic crane
#

hey, is there a way to make PrefixLabel line up with the property above?

#

it returns a rect that doesnt line up

#
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
gloomy chasm
sonic crane
#

@gloomy chasm like this?

position = EditorGUI.PrefixLabel(position, label);
position = EditorGUI.IndentedRect(position);
GUI.Label(position, coordinates.ToString());
#

because it didn't work

gloomy chasm
#
position = EditorGUI.IndentedRect(position);
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
sonic crane
#

unfortunately this did not work neither :/

#

ill restart my unity and try again

#

nope

sonic crane
gloomy chasm
sonic crane
#
EditorGUI.indentLevel++;
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
patent pebble
#

@sonic crane iirc you need to use the EditorStyles.inspectorDefaultMargins style or EditorStyles.inspectorFullWidthMargins

#

need to add either the left padding or left margin

#

or directly use the style in a group or area that encompasses your control

onyx harness
waxen sandal
#

If it's a class/struct you can just go into the children of the serialized property and draw them

#

There's a list somewhere in propertyhandler iirc

grim vine
#
new PreviewRenderUtility();

all constructors for PreviewRenderUtility throws and exception, any idea what's going on?

#
Preview scene could not be created
grim vine
#

nvm, i just restarted Unity

topaz thunder
#

Hi, i'm building a screenshots tool for a school assignment. I have an Editor script called "ScreenshotInspector" that uses OnInspectorGUI to add some extra functionality in the inspector to objects with "CameraScreenshot" script attached, all this works perfectly. When i add OnSceneGUI to "ScreenshotInspector" script and add anything like show some buttons, i can't click on inspector fields of that object anymore. If i leave OnSceneGUI blank it works normally. I can't find what causes this or how to solve it.

thin fossil
#

Is there any way to prevent the EditorGUI.LabelField from hiding its icon when the space gets to small?

waxen sandal
#

Not buy you can draw it yourself using draw texture

solid thicket
#

Hey, I have an EditorWindow that contain a ScriptableObject property, which I set on OnEnable (and It is declared SerializeField).

Everything saves great when I exit the window and open it up again, the properties are restored correctly, but when I play the game, my property seems to be null

#

Any idea what could happen? when I look at OnEnable my property is set correctly, and is not null, the next function is OnGui which there it is already null (I debugged it when I hit the play button).

By the way, I use SerializedObject to serialize the properties

thin fossil
sonic crane
#
position = EditorGUI.PrefixLabel(position, label, EditorStyles.inspectorDefaultMargins);
GUI.Label(position, coordinates.ToString());
#

@gloomy chasm btw thanks for your help attempts, I posted the things I've tested but none of them seems to work

#

could something be wrong with my unity?

#

wait it just fixed itself

position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
#

🤔

#

okay... I guess, lol

grim vine
#

is there way to add stuff to the official unity documentation?

gloomy chasm
grim vine
#

interesting

#

suppose i could make it and put it on a github page 😂

thin fossil
#

How do I add a custom menu entry to the editor windows default context menu?

#

okay found it. had to use IHasCustomMenu

carmine furnace
#

It works for what I need, but I have something weird I don't want, and I don't know much about extending the editor

#

The Dropdown attribute, for some reason I don't understand, I have to put the type of this class

#

And I don't want it, I just want to call the string

#

(Sorry for the image "spam")

gloomy chasm
carmine furnace
#

If I hardcode them, I can still calling the attribute in other class?

gloomy chasm
carmine furnace
#

It such a pity to not be reusable, but it's ok

midnight python
#

Wouldn't you be able to make a generic?

#
class DropdownDrawer<DropdownList> : PropertyDrawer
{
  [Dropdown(typeof(DropdownList), "string")...
}
abstract juniper
#

Hi guys, I was told to ask my question again here. I have a List<Material> materials. It's about 200 materials. I want to save those materials into my folder "Resources/Skyboxes". Is there a way to copy them with code?

#
    AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(obj), "Assets/Resources/Skyboxes/" + fileName + ".mat");
    AssetDatabase.SaveAssets();
    AssetDatabase.Refresh();
#

seems to do the job

#

👍

whole steppe
#

How can I run debug.line in the editor?

twin dawn
#

What's debug.line?

whole steppe
#

Sorry I'm on my phone, I ment Debug.drawline();

waxen sandal
#

Use handles

whole steppe
#

Could you elaborate/link API doc?

whole steppe
#

👍 thank you

grim vine
whole steppe
#

Can some one explain why this isint working

#

[CustomEditor(typeof(SnapPointConfigurator))]
public class SnapPointConfigurator
{
public Vector3 PointA, PointB;
void OnDrawGizmos()
{
Handles.DrawLine(PointA, PointB, 2);
}
}

waxen sandal
#

OnDrawGizmos needs to be on your monobehaviour

#

A custom editor has to inherit from Editor

whole steppe
#

When I have it set as a monobehaviour it gives me an error

#

Huhhhhh

waxen sandal
#

Well yes, custom editor can't be a monobehaviour

whole steppe
#

Than I set it to Editor and it dosent appear in my scripts

ebon helm
#

Has anyone actually worked with multicolumnheader before ?

whole steppe
#

Dont mind the url

#

but is there a way I can add items to this menu?

waxen sandal
#

What the fuck

whole steppe
#

Like function extensions

#

Its beautiful Ik

waxen sandal
#

@stark geyser I don't think this is okay

stark geyser
#

!warn 796214448301408266 Do not post offensive content on the server.

grave hingeBOT
#

dynoSuccess APEX#4607 has been warned.

whole steppe
#

Bruh

stark geyser
#

!mute 796214448301408266 3d

grave hingeBOT
#

dynoSuccess APEX#4607 was muted

graceful gorge
#

Hello. This is likely straightforward but I can't really find documentation for a problem.
I'm creating scriptable objects in an editor script, and they have a list of sprite as member. If I try to load said sprite in code and assign them, they turn into null reference after the script finishes executing(as I would expected). How do I assign a reference to a sprite asset the way I would by dragging a sprite asset on a field in an inspector ? I assume it involve using a Serialized object after of before creating my SO asset, but I can't figure out how to set it up correctly.

waxen sandal
#

Undo.RecordObject is the easy way

#

Otherwise create a serializedobject from your scriptableobject and then use findproperty/findpropertyrelative to find your array

#

Then use GetArrayElementAtIndex

graceful gorge
#

I used GetArrayElementAtIndex and an so, but I think that when I load my sprites into my script, I lose the reference to their assets, they just exists in memory. Unless I should use another option than ObjectReferenceValue on the property ?

waxen sandal
#

Show code

graceful gorge
#

sure var result = ScriptableObject.CreateInstance<LevelInfo>(); var so = new SerializedObject(result); List<Sprite> imageResults; if (remote) { imageResults = await GetImagesRemote(result, ImagesPath); } else { imageResults = GetImagesLocal(result, ImagesPath); } var prop = so.FindProperty("Images"); prop.InsertArrayElementAtIndex(0); prop.GetArrayElementAtIndex(0).objectReferenceValue = imageResults[0]; prop.InsertArrayElementAtIndex(1); prop.GetArrayElementAtIndex(1).objectReferenceValue = imageResults[1]; prop.InsertArrayElementAtIndex(2); prop.GetArrayElementAtIndex(2).objectReferenceValue = imageResults[2]; prop.InsertArrayElementAtIndex(3); prop.GetArrayElementAtIndex(3).objectReferenceValue = imageResults[3]; so.ApplyModifiedProperties(); AssetDatabase.CreateAsset(result, DestinationPath + "/" + legacyInfo.Word + ".asset"); return result;

waxen sandal
#

Ah yeah if your images are in memory only then you need to save them

#

Also, there's no need to use serializedobject if you aren't editing an existing one

graceful gorge
#

I load them from assets though, should I duplicate them?

waxen sandal
#

If they're from assets then that should work

graceful gorge
#

Strange. Maybe the error comes from somewhere else. I'll debug it deeper and see anything else is off

graceful gorge
#

yup, the image loading was silently failing

graceful gorge
#

Unrelated question, I have a property drawer that displays a dropdown list of possible completions for a string field. it works fine, however if can't be drawn outside of whatever inspector it is in (so if the list should stretch over the next component in my game object, it gets cutoff). Is there something like EditorGUI.popup that behaves like everything else in that regard?

robust wren
#

Hi, i want to add a tooltip for a menu item but i didnt found how to, is this possible?

graceful gorge
#

That doesn't seem to be easily possible (none of the default menu item have tooltips), so I assume you'd need to implement it yourself, sadly.

robust wren
#

oh well, ill try then

graceful gorge
#

Godspeed

graceful gorge
#

Already tried, but thanks :). I'm retrofitting the addressable asset reference field search popup now. it's ludicrously complex for what it does but it should work out, eventually

vernal quartz
empty shore
#

Hi, is there a way to iterate through all my textures and set the max size to 1024?

waxen sandal
#

Assetdatabase

carmine furnace
# midnight python Wouldn't you be able to make a generic?

It' seems I don't need the attribute. Instead I can make the property drawer for a serializable class in order to get the approach I need. But I having some problems because I don't understand much about extending the editor and I'm just writing without know what I'm doing 😩

#

I'm triying to send a capture but discord is trolling me

#
[CustomPropertyDrawer(typeof(SceneBuild))]
public class SceneBuildDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var elements = SceneTools.GetAllScenesInBuild();
        var sceneName = property.FindPropertyRelative("Name");

        if (elements != null && elements.Count != 0)
        {
            var selectedIndex = Mathf.Max(elements.IndexOf(sceneName.stringValue), 0);
            selectedIndex =EditorGUI.Popup(position, property.name, selectedIndex, elements.ToArray());
            sceneName.stringValue = elements[selectedIndex];
        }
        else EditorGUI.LabelField(position, "No Scenes in build");
    }
}```
#
[Serializable]
public class SceneBuild 
{
    public string Name { get; private set; }

    public SceneBuild(string name)
    {
        Name = name;
    }
}```
visual stag
#

properties are not serializable

#

so FindPropertyRelative("Name") will find nothing

carmine furnace
#

🤦‍♀️

#

Thank you so much

patent pebble
#

i've always wondered, why are SerializedProperties called that? if they are fields and not properties?

#

is that some C# terminology or something?

visual stag
#

Idk, Unity being Unity

patent pebble
#

oh, so they just decided to name it that way just because i guess...

#

when I first learned about them i was extremely confused

#

even the docs don't mention that they work with fields...

SerializedProperty and SerializedObject are classes for editing properties on objects
#

ah well.. on the SerializedObject docs it says different

SerializedObject and SerializedProperty are classes for editing serialized fields on Unity objects
#

jeez 😓

visual stag
#

you should probably report that as confusing by using the form at the bottom of the doc page

patent pebble
#

will do

#

@visual stag "leave feedback" or "report a problem on this page"?

#

oh nvm

visual stag
#

(the latter)

patent pebble
#

the "leave feedback" link just scrolls the website to the "report a problem" link 😅

severe python
#

I don't know if this is in appropriate to do, but vertx, are you familiar with the issue I mentioned as being common, I honestly didn't know where to ask the question. It seems like if it was an issue it would be a really common problem

visual stag
#

the dlls one? Not really, I don't use the asset store

#

I use packages only, and probably wouldn't publish anything on the asset store until it uses them too

severe python
#

everyone is moving over to assembly definitions and providing source access, so maybe its really just not an issue

#

oh, asset packages are package managers are fundamentally different systems aren't they

lunar oar
#

is it allowed to post questions here too?

#
Camera cam = SceneView.currentDrawingSceneView.camera;
Debug.Log("Mouse Position: " + cam.ScreenToViewportPoint(e.mousePosition));
#

if i write a editor script to turn the current mouse position into a viewport Point so it can be used to figure out where on a plane it would intersect it starts going wierd

#

in the top left corner its understandably 0, 0

#

but the bottom right isn't 1, 1 as expected

#

dragging the mouse any further out stops the position logging because it then clips into the inspector

#

even popping out the scene view doesn't fix the issue

wispy delta
#

I've got a modifier system that involves creating empty game objects with components on them and registering them with a manager (Deformable). For a while I've been using a creator window that shows all of the creatable components. When you click one of the buttons, the window handles creating an empty object with the component and registers the created component with the manager.

#

Would it be possible to get this functionality in the GameObject create menu?

#

I know how to do it manually with MenuItem, but being able to automate this would be great

#

I've already got my own attributes (which the Creator window uses to find the components). Ideally I could use that attribute data to populate the Create menu, but am unsure if this is possible

gloomy chasm
gloomy chasm
#

Yep, it should work!

wispy delta
#

Oh great! Thank you @gloomy chasm I will give it a try tomorrow

fathom kettle
#

Looking for some editor scripting assistance

waxen sandal
#

Cool

fathom kettle
#

Right now I am manually deleting tracks from many animations, and trying to automate the task. For instance I want to delete the scale tracks because it just bloats the file size.

#

Was wondering if anyone could point me towards a way to Select the properties through code so i can gain some efficiency

fathom kettle
#

or if there is a way to delete properties a different way

topaz thunder
#

hi, i have some problem with my custom inspector. when i use OnSceneGUI i can't edit my custom inspector fields. any idea why this happens?

gloomy chasm
topaz thunder
#

can i copypaste the code here?? or is it a screenshot better?

gloomy chasm
topaz thunder
#

i suppose i uploaded it correctly

#

im using OnSceneGUI at line 93 and method GUIHandles used inside that is at line 315

fathom kettle
#

So I managed to figure out a way to remove tracks/properties by using AnimationUtility.SetEditorCurve

#

BEWARE THO, deleted tracks is a PERMANENT change that cant be undone

normal jay
#

Between Destroy(AGameObject) and DestroyImmediate(AGameObject), which one should I use in a Monobehaviour that has ExecuteInEditMode

#

I'm trying DestroyImmediate because the documentation tells me so, but the GameObject isnt destroyed

#

So I tried Destroy and it worked well, but the editor log a message telling me I really should use DestroyImmediate

#

so i don't know anymore

#

nevermind

#

i'm tired

#

I was trying to destroy a component instead of the gameobject

civic river
#

Hi guys I'm wondering if anyone's tinkered around with this system before https://docs.unity3d.com/ScriptReference/ExposedReference_1.html. In the docs it mentions that ". This can be used by assets, such as a ScriptableObject" What I'd like to do is I have a graph with a blackboard, I'd like to be able to add (scene) references to the blackboard which I can then add to my objects. The ExposedReference seems like the perfect fit, except I can't actually find how to implement the system. I've tried implementing IExposedPropertyResolver, however it seems like there's no appropriate time to call ExposedReference.Resolve() for scriptable objects. It looks like if I can find a way to use the resolver in the SO I'll be set, but I just can't figure a way. Anybody tried something like this?

long pebble
#

So I'm trying to write some code to allow me to create and modify bezier curves in the editor. I'm trying to make it so I can place and position control points in the scene view like you do any typical Game Object, but I also don't want to have to write a new custom editor for any Monobehaviour that uses my BezierCurve class, which leads me to PropertyDrawers. Looking at the documentation though it doesn't look like PropertyDrawers can interact with the scene view in anyway which would require me to use a custom editor anyway, which goes against what I'm trying to achieve here. Is there anyway I can write a PropertyDrawer that will allow me to interact with the scene view to let me modify a curve, or am I doomed to write custom editors for any script that uses a curve?

#

At the very least it looks like I could use DrawDefaultInspector() to minimize work, but it's still not ideal

patent pebble
#

@long pebble why would you need to make custom editors for classes that use your bezier curve stuff?

#

if all you want is modify the curves in the scene view by dragging points around, you don't need a custom editor for that

#

unless you want to implement some other functionality

#

but in the most basic sense, all you'd need for the curve's data is an array for the points and tangents

solemn meteor
#

I'm working on a custom editor window and I need to reference a game assembly. I've added an assembly reference by selecting the Editor -> Analyzers node in the Solution Explorer and via the Project -> Add Reference menu (in VS 2019). I've also ensured the project that the assembly is tied to is marked as dependency in Visual Studio. Whenever I open the Unity Editor though, I get the following error in my project: The type or namespace name 'PathSystem' could not be found (are you missing a using directive or an assembly reference?) any idea what might be going on?

solemn meteor
#

aha! I need to do this inside of the Unity editor not VS. Please disregard

long pebble
patent pebble
#

@long pebble that's exactly why I asked if you really need to make a custom editor for it...

#

if all you need is to edit them on the Scene view you can do that with Handles, for example

#

Does anybody know how can I get a list of all my custom global EditorTools that I've added to the scene tools?

#

the Tools and EditorTools classes don't seem to have that info accessible

waxen sandal
#

The easiest way to do handles is in a custom editor though...

patent pebble
#

@waxen sandal can't he use handles in a property drawer or decorator drawer if he subscribes a method to the sceneview.duringscenegui?

#

instead of making a separate custom editor for each class

waxen sandal
#

PropertyDrawers and DecoratorDrawers don't have an entry/exit point

#

Only a gui draw method

#

Good luck subscribing and unsubscribing on that

patent pebble
#

yeah true

onyx harness
#

Trick it with static

waxen sandal
#

I mean tyou can do it, but should you

#

I don't think so

long pebble
#

I might just have to change my approach. I wanted the curve to just be a data type you could declare in a monobehaviour and the correct controls would always be there, but if I need any other scripts needs a curve I might just have it reference the game object with the curve script on it.

dim slate
#

@graceful gorge Thanks again a ton for the tip on Freya's class, Ive made a ton of progress this week thanks to that little bit of insight 🙂

severe python
#

Is there a supported way to stabilize guids generated for an asset?

gloomy chasm
severe python
#

I don't know in general, I know dlls appear to get a random guid though

#

its been a constant thorn in my side

#

its possible there is something I'm doing that causes it to be a problem

#

some part of me feels like there must be

waxen sandal
#

They're not stable

#

Or not deterministic is probably the better word

#

I replace guids for assets that I want to have deterministic guids generated based on path

nova fox
#

Anyone know if it is possible to access the Game Window and force a specific display? (Editor only)

waxen sandal
#

Probably if you get the editorwindow and then use either reflection or serializedobjects to change it

nova fox
#

Solved it. Thanks for pointing me in the right direction 🙏

private void ChangeDisplay(int index)
{
    var assembly = typeof(UnityEditor.EditorWindow).Assembly;
    var type = assembly.GetType("UnityEditor.PlayModeView");
    var window = EditorWindow.GetWindow(type);

    var displayField = type.GetField("m_TargetDisplay", BindingFlags.NonPublic | BindingFlags.Instance);

    displayField.SetValue(window, index);
}
waxen sandal
#

You can also use Resources.FindObjectsOfTypeAll to find all windows

#

GetWindow actually opens the window so that might not be what you want

nova fox
#

Oh. I did not know you can access windows from Resources.FindObjectsOfTypeAll. Opening the window is good enough for my use case.

waxen sandal
#

👍

patent pebble
#

How does OnValidate work in EditorWindows? Does it only get called when the script is loaded?

#

This function is called when the script is loaded or a value is changed in the Inspector
Since EditorWindows don't interact with the inspector, I guess the second part doesn't apply in this case

#

can anyone confirm?

waxen sandal
#

I don't think there's OnValidate in editorwindows?

patent pebble
#

and I'm able to access it on my EditorWindow scripts, it only seems to be called when the scripts are loaded

waxen sandal
#

Ah

#

Probably when you change a serializedproperty on the editorwindow

#

E.g. make a serializedobject of your window, change aproperty and apply and it'll probably fire

patent pebble
#

ooh, that would make sense

#

gonna test it, brb

#

@waxen sandal correct, you were right

#

this makes a lot more sense now, thanks for the info! 😊

carmine furnace
waxen sandal
#

Yes?

carmine furnace
#

I can with [SerializeReference], but I'm seeing if it's possible to make a nameof()

#

var sceneName = property.FindPropertyRelative(nameof(SceneBuild.Name));

#

SceneBuild.Name is the property, but I guess I cant fight against level protection XD

#

I know with properties don't work, it just that I have wrote that right now

civic river
#

@carmine furnace So this is a property within a property?

#

If I'm understanding you right you could use a recursive property finder or something to do this

carmine furnace
#

I'm going to paste again the script and the property drawer to better understand

#
using System;
using UnityEngine;

[Serializable]
public class SceneBuild
{
    [SerializeReference] private string name;

    public string Name { get => name; set => name = value; }

    public SceneBuild(string name)
    {
        Name = name;
    }
}```
#
using UnityEngine;
using UnityEditor;

[CustomPropertyDrawer(typeof(SceneBuild))]
public class SceneBuildDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var elements = SceneTools.GetAllScenesInBuild();
        var sceneName = property.FindPropertyRelative("name");

        if (elements != null && elements.Count != 0)
        {
            var selectedIndex = Mathf.Max(elements.IndexOf(sceneName.stringValue), 0);
            selectedIndex = EditorGUI.Popup(position, property.name, selectedIndex, elements.ToArray());
            sceneName.stringValue = elements[selectedIndex];
        }
        else EditorGUI.LabelField(position, "No Scenes in build");
    }
}
#

This is an example ```csharp
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

[AddComponentMenu("abutoolkit/Scenes/Scene Listener")]
public class SceneListener : MonoBehaviour, ISerializationCallbackReceiver
{
public static List<string> scenesInBuild;
[SerializeField] LoadSceneMode sceneMode;

[SerializeField] protected SceneBuild scene;

public void OnAfterDeserialize() { }

public void OnBeforeSerialize() => scenesInBuild = SceneTools.GetAllScenesInBuild();

public void LoadScene() => SceneManager.LoadScene(scene.Name, sceneMode);

public void LoadSceneAsync() => SceneManager.LoadSceneAsync(scene.Name, sceneMode);

public void UnloadScene() => SceneManager.UnloadSceneAsync(scene.Name);

}```

#

It makes a enum of current scenes in build

#

and the result of a SceneBuild is a string

#

That works, but I don't know if I can do a nameof, instead hardcode the "name" string value

waxen sandal
#

Why serializereference

#

And you can't replace it with nameof since it's not public

#

Or internal

carmine furnace
#

Because private fields, and SerializeField return a NullReferenceException:

#

But internal...let me check out

waxen sandal
carmine furnace
#

No, internal is not in the level protection

severe python
#

However the issue I was trying to solve specifically was modifying m_script references to refer to the DLL rather than the script asset, which I think I have a path forward on, which amounts to replacing the assets m_script reference before building out a UnityPackage, build the package, and then revert the reference after the build

#

it still uses the code I use to hash for the dll, but I think in my use case that will be fine

waxen sandal
#

Oh yeah I do something similar somewhere else

severe python
#

with remapping the script references? is that the basic workflow you use, and it works out?

#

I haven't had a chance to actually finish putting it together, would be nice to know if i'm basically on the right track

whole steppe
#

@waxen sandal is there a way to create a mesh that fits the terrain or obj under it in editormode?

#

im trying to make something like easy3droads but not sure how i generate a 3dmodel that is aware of textures

waxen sandal
#

@severe python yeah it works, we do it to generate asset bundle variants which are based on other bundles for things like small config changes

#

@whole steppe raycasts

#

@severe python we just copy the file and check whether it had references to the old bundle and if so we look up the guid for the new copied file

severe python
#

when you say bundles do you mean asset bundles or Asset Packages e.g. *.unityPackage ?

waxen sandal
#

We do for asset bundles but it shouldn't be any different for packages

severe python
#

Do you have to refresh the asset database after modifying the files, thats one thing I wasn't sure about

waxen sandal
#

I just use serialized properties to fix references

#

But yeah you should refresh after editing files

#

Else they might not up date

severe python
#

oh do you get the monoscript property and set it directly?

#

I don't understand how that would work tbh

waxen sandal
#

We mostly do assets but afaik it should work as long as the old script isn't missing

onyx harness
severe python
#

oh I know, I got that part, I also discovered your recovery tool

onyx harness
#

If I am not wrong, my tool has an API inside that you can directly use

severe python
#

I was actually going to ask if that works basically how I expect, you parse the yaml files and determine what likely candidates for classes are by checking their serializable fields and then making recommendations?

#

Is your tool available via the package manager somehow?

#

I don't want to take on dependencies unless their acquisition can be automated

onyx harness
#

Which unfortunately does not guarantee it will work

onyx harness
severe python
#

depends on the unity version unfortuantely

onyx harness
#

Maybe I should separate the API from view/Unity.

severe python
#

Understood, your tool does a lot of things that would be very useful for the target audience (modders) so I'd not really be against it

onyx harness
severe python
#

link doesn't work for me

onyx harness
#

oh shit

severe python
#

oh yeah, this is what i'm using

onyx harness
severe python
#

I haven't gone over everything in NG Tools, you just solve a number of issues that would be useful for a modding environment, such as missing script recovery, there is also the remote server thing, there were others but I don't recall what atm

onyx harness
#

I got contacted by a modder one day, he said he used my tool to mod, first time I heard about modding with my stuff 🙂

#

but yeah, quite handy to debug/test/visualize

severe python
#

My project is basically to setup a tool that makes it easy to setup a modding environment for "any" given unity game, which really means 2018.1+ because I don't know how to make this work without Assembly Definitions

#

There is some overlap with NG Tools, but your stuff has tons of solutions for issues that frequently come up

severe python
#

So Preface, this stuff is hacky. However, in order for you to mod a game you need to have all its required assemblies in the unity project, I pull those in as a Unity Package and create a package.json for it.
Most games end up having a Assembly-CSharp.dll and if the game includes one you need to overwrite the Assembly-CSharp.dll in the ProjectRoot/Libraries/ScriptAssemblies folder in order for its scripts to function inside unity

#

Due to this, you can't pack your mod scripts into an Assembly-CSharp, and the only way to change that that I'm aware of is to use an AssemblyDefinition, which as I understand it, is an AsmDef?

#

So I don't know if its even possible to support a version of unity that doesn't include the ability to define your assemblies explicitly

onyx harness
severe python
#

That thought actually just crossed my mind

#

I'm not sure, I think I've tried to do something like that in the past and it didn't work out

onyx harness
#

Did you think about altering the DLL? Via dnSpy or Cecil?

severe python
#

Trying to avoid that kind of thing, that seems like a maintenance nightmare to me

onyx harness
#

dnSpy is nice for manual hack

#

Cecil is the way to go for automatic (That's what Unity uses, and also I use for NG Unity Versioner)

severe python
#

yeah, I'd end up using cecil if I went down that road

#

I'd do discovery in dnspy first probably

onyx harness
#

The API is pretty solid and not too hard to grasp, I use it for discovery, not altering

#

dnSpy is funny, as you can directly write code

#

Those shits are powerful

severe python
#

oh its all the rage in the modding communites I've been in, Its a super powerful tool, but I honestly hate the way the interface setup, but there is no denying its utility

onyx harness
#

Never been into modding stuff, sounds interesting world

severe python
#

Its a million crazy hacks 😄 you always run into some special interesting problems and the constraints make for interesting programming work

#

its fun programming

cosmic iron
#

I noticed that Unity updated list to be reorderable. Is it possible to get a reference to the List and subscribe to events? i.e: onSelectCallback

visual stag
dim slate
#

I'm running into an issue with multi editing on a custom inspector, I have what feels like a fairly hacky solution in place as is and im not sure if thats whats causing the problems or if its something to do with the property drawer im using for Textures? I'm using the serializedObject and property methods which according to what few resources I've found, should handle the editing of multiple objects at once but, alas, nothing. Anyone got anything I could look into?

#

Just as a note since the object im working with is a scriptable object that I need to be able to edit both when selected and when applied to a monobehaviour I have a custom editor aswell for the monobehaviour which instantiates an editor instance of the scriptableobject inside of it

waxen sandal
#

Show code

dim slate
#

I cant show too much unfortunately however heres part of the controller, there isnt any issues with multiediting passed this point

#
public class Class{
serializedObject.Update();
        List<MaterialController> controllers = new List<MaterialController>();
        for (int i = 0; i < targets.Length; i++)
        {
            controllers.Add(targets[i] as MaterialController);
        }
        MaterialController controller = target as MaterialController;
        MaterialData data = controller.data;
        using (new GUILayout.VerticalScope(EditorStyles.helpBox))
        {
            base.OnInspectorGUI();
            using (new GUILayout.VerticalScope(EditorStyles.helpBox))
            {
                var editor = Editor.CreateEditor(data);
                editor.OnInspectorGUI();
            }
//extra stuff
        }
        serializedObject.ApplyModifiedProperties();

}
}
waxen sandal
#

Is this in a propertydrawer?

dim slate
#

The texture is, the materialdata is in an editor script

#

Ill grab the texture one sec

visual stag
#
editor.OnInspectorGUI();```
This is a memory leak
dim slate
#

You know another way to display the objects editor inside an object in scene 😅 ?

#

[CustomPropertyDrawer(typeof(Texture))]
public class TexturePropertyDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var indent = EditorGUI.indentLevel;
        EditorGUI.indentLevel = 0;

        property.objectReferenceValue = EditorGUI.ObjectField(new Rect(10, 10, 50, 50), property.objectReferenceValue, typeof(Texture), false);
    }
}
waxen sandal
#

You should use Begin/EndProperty

dim slate
#

Can I use the PropertyDrawer outside of the scene?

waxen sandal
#

I was being stupid I think

dim slate
#

Because its a scriptable object I need to be able to edit it off the object as well unfortunately

waxen sandal
#

I'm confused what you're actually trying to do

dim slate
#

Here

#

On object the controller allows me to edit stuff for materials without actually using unity's materials

#

But i also need to be able to edit the master data aswell

waxen sandal
#

Use hastebin

dim slate
#

I could do that

waxen sandal
#

Or what is it

dim slate
#

Part of it yes

#

the other part works with multiediting and is irrelevant

#

its just when I have multiple controllers in scene and attempt to change say a Colour, it picks the first one

waxen sandal
#

Yeah uhh, I don't really know if you can do that

#

Because of Editor.CreateEditor

dim slate
#

Sooo I should probably just disable multi editing?

waxen sandal
#

And Vertx is right, you should fix that memory leak by creating it in onenable and destroying it in ondisable

#

Probably yeah

dim slate
#

Alright thanks Navi

visual stag
#

CreateEditor does have a version that takes mutliple targetObjects so I assume you could make it multi-edit by properly filling that out

#

I've never tried it though

waxen sandal
#

Right, I forgot about that. Never used it either but worth a try

dim slate
#

Oh youre right vert I didnt notice that, shouldnt be hard as im already using target

#

I think im relatively close, getting a null reference on multi edit, seems its not generating the editor? ima try a few more things and see

waxen sandal
#

Maybe you need to specify the type of the editor

dim slate
#

Holy shit thanks @waxen sandal and @visual stag

#

probably not the most efficient but ill fix that later

#
private void OnEnable()
    {
        datas = new List<MaterialData>();
        controllers = new List<MaterialController>();

        if (targets.Length > 1) 
        {
            for (int i = 0; i < targets.Length; i++)
            {
                MaterialController cont = targets[i] as MaterialController;
                controllers.Add(cont);
                datas.Add(cont.data);
            }
            controller = target as MaterialController;
            data = controller.data;
            editor = CreateEditor(datas.ToArray(), typeof(MaterialDataEditor));
        }                   
        else
        {
            controller = target as MaterialController;
            data = controller.data;
            editor = CreateEditor(data);
        }
        
    }
civic river
#

Anyone know of a way to dock an editor window automagically? I'd like to launch two editor windows that are docked together

waxen sandal
#

There's a overload for GetWindow

civic river
patent pebble
#

I was designing a tool for handling game data and this question arised.
What is the generally accepted "best" way of handling reusable game data?
Prefabs or using serialization & scriptableobjects?

#

It seems like prefabs would cause a lot more work in certain situations, like big architecture redesigns

#

and serialization & scriptableobjects seem like a better choice for making custom tools and being able to edit data outside of the engine

#

the more i get into tooling and extending the editor, the more useless prefabs look...
what are you folks' thoughts on this topic?

gloomy chasm
patent pebble
#

I remember when I was learning how to use Unity years ago, that most tutorials relied on heavily using prefabs

#

so I was now wondering if prefabs are not really a good way of doing that, specially for "big" games

gloomy chasm
patent pebble
#

nothing in particular, just most of the game's data

#

like items, enemies, etc, that sort of thing

#

this isn't for a particular tool or anything, I was just wondering if prefabs are not really the way to go

#

and they are just only useful for small projects and quick prototypes

onyx harness
patent pebble
#

yeah I didn't mean they used the prefabs for holding and saving the data. I mean for using it at runtime

#

so I was just thinking that instead of having for example prefabs for different enemies with different components and such. Why not just use serialized data to construct enemy variants

onyx harness
patent pebble
#

I don't know if I'm explaining my thoughts correctly

onyx harness
gloomy chasm
# patent pebble like items, enemies, etc, that sort of thing

I personally have ScriptableObjects for items that store all the info for given item (name, price, UI icon, etc), since I need that info for inventories, and a prefab of the item when it is in world which is basically just a mesh renderer or two and maybe some collision stuff.
Enemies and other agents I normally just have as prefabs since I don't need info about them normally until after they spawn. Sometimes I will and so I will make a SO with any data about them I need.

onyx harness
#

Where you will want to separate the stuff

patent pebble
#

probably, yeah. I'm not very experienced with architectural patterns

#

i don't know, I feel like using prefabs would only be useful for cases where the instanced data needs to have slight variations from the original

#

but I'd rather just keep everything serialized and construct my game entities by using the needed data

#

maybe I'm missing something, but I feel like prefabs are mostly useless for me 😅

#

I'm reading around the forums and I think this sums what I was trying to say well:

Now you want to create a variation of the same enemy with same everything, but different stats.

You could have a prefab for each variation, sure. Now later you decide to rework how the prefab is structured, you want to change hierarchy, add scripts, colliders, many internal changes. That would mean that to maintain that enemy you would have to manually process each variation and manually make changes to hierarchy etc, this is very time consuming and error prone.
Now instead of storing variations as prefabs you can have a single prefab for the enemy, and pull the variations from scriptable objects.

Lets say scriptables only contain fields like - health, armor, speed...
You instantiate your enemy, and you inject the scriptable object in it, and enemy uses the scriptable object fields as his own.

This way you have a single prefab that is easy to maintain and data that is agnostic of the type of object you want to inject it in.```
#

@gloomy chasm I feel like that's mostly what you said, right?

gloomy chasm
patent pebble
#

yeah i think it was written before prefab variants were a thing

#

I still feel like it's better to abstract the data as much as possible from the prefabs. I feel like making design tools for simple data is more straight-forward than having to deal with it on prefabs and whatnot

#

this whole discussion is probably very obvious for most people. But my experience with architectural patterns and things like that is not very strong, heh 😅

carmine furnace
patent pebble
#

I mean, I still use them, but mostly for simple things that won't change throughout the development and don't use tons of data

#

i use prefabs a lot for static things, like environmental props and backgrounds and things the player doesn't interact with

carmine furnace
#

Me too, maybe bullets and something more without game data

#

I like the idea of have a script that has a reference to prefab and a SO for setting it (something like a factory of turrets for example)

patent pebble
# onyx harness I feel it too

Sometimes I see Unity pushing so heavily on the "official" way of doing things, that it feels like if I do something differently I'm doing it "wrong"
Maybe they shove prefabs on our faces because they are a good tool for simple things and user-friendly for beginner Unity users.

#

I feel they've been telling people to use prefabs a lot, specially since the new prefab system rework

#

they are great for prototyping, and for quick level design tho

civic river
#

Variants have been great in my experience for what was an otherwise unusable system yeah. It's still quite a specific use case but has application now

#

My guess is unity pushes prefabs because they're easy to understand and relatively user friendly for beginners, other options maybe not so much

#

SO still comprise like 95% of what I'm doing in unity engine it feels like xD

onyx harness
#

Listen to the feedback, way more reliable

patent pebble
#

yeah, whenever I'm learning a new Unity feature, or topic, my go to is googling
"should i use X"
"how to use X"
"pitfalls of using X"
etc

patent pebble
#

I know how to tap into the project window items with EditorApplication.projectWindowItemOnGUI

#

is there anything similar for that top bar? can't find anything

onyx harness
patent pebble
#

big sad 😓

onyx harness
#

If they converted to UI Element, you would able to do anything

patent pebble
#

i don't know if they'll ever rewrite all the internal editor code to make it use UI Elements

#

one can only dream of such things... 😩

gloomy chasm
patent pebble
#

oh

#

we'll see how long it takes them, hopefully it's not years 😅

gloomy chasm
civic river
#

Hi guys, I'm starting to learn addressables, the end goal for the system I'm working on is to distribute it as a package.

Here's where I'm at now, I have a system that is creating assets and I'd like them to be automatically added into an addressables catalog. I'd like to add them to specific groups automagically, but to do that those groups must exist -- so I started down the barbarian path:
https://hatebin.com/tjqqkqbqvz

This looks pretty terrible, and I don't like that this might mingle with other addressable systems. Does anyone know of a way to create a package-unique addressable bundle (The system seems like I should be able to drop something like that in place, but I can't seem to find how)? That way the addressable settings for the package are already configured and I don't need weird hacks to create the groups and etc, etc.

wispy delta
#

I've been trying to use the ScriptedImporter class to create a custom asset that Unity imports as a shader. Is this possible? I can't find a way to create a shader asset anywhere (thinking of something equivalent to MonoScript asset?)

wispy delta
#

aha I think I found it with ShaderUtil.CreateShaderAsset

wispy delta
#

ok next question (sorry) is there a way for me to detect when a MonoScript recompiles, and add a subasset to it if it's a subclass of a certain type?

I tried a AssetPostprocessor with an OnPreprocessAsset event function that checks if the importer is a MonoImporter, but the GetScript function is always returning null

#

This where I'm at, but script is always null

private void OnPreprocessAsset()
{
    // Are we importing a script?
    if (assetImporter is MonoImporter importer)
    {
        // Is there a script?
        var script = importer.GetScript();
        if (script == null)
            return;
        // Does the script have a class?
        var type = script.GetClass();
        if (type == null)
            return;
        // Is the script a C# shader?
        if (type.IsSubclassOf(typeof(SomeSpecialClass)))
        {
            // Check if script has SomeSpecialAsset as a subasset
            // and add one if missing
        }
    }
}
dim slate
#

is the object null or is the importer null?

severe python
#

Is there any way to define new templates in the Unity Hub?

#

Nevermind, I figured it out, can do it, but its not really nice and possibly not worth it

waxen sandal
#

There's no built in support afaik

severe python
#

no not really, you have to make a folder in a bunch of folders

#

Even then though, your ability to customize the template is limited, I wanted to reduce the base set of installed packages to only the things required, but that doesn't appear to be an option, its annoying having to uninstall all the Advertising and IAP crap every time I make a new project

zealous goblet
#

question. unity have labels that you can drag and change value. i want similar thing for my stuff. how to do it?

zealous goblet
#

nope. thingy to drag not appearing. i kinda checked it already. checking EditorGUI.HandlePrefixLabel now but it's not really documented

twin dawn
#

I know that might not be an option but I guess it should probably work there at least

zealous goblet
#

well. for default properties it ofc works. but i want to make bunch of PropertyAttribute's that change appearance of default drawers. for example i want int to be drawed as float but scaled with some constant. and some more complex stuff. right now it seems that mimic default implementation is easiest way.

waxen sandal
#

Show your code

zealous goblet
#

huh? it same as it CustomPropertyDrawer example. i just looking for ways to draw SerializedProperty but with fancy labels.

waxen sandal
#

IntField and FloatField should both support that

zealous goblet
#

lol i know. but i dont want field. i want label of that field.

#

also those fields is using some internal function "DoFloatField" and "DoIntField" as far i i know. not much ways to see how they are implemented.

#

lol. google tells me to get internal method through reflection and call it anyways. right.

civic river
#

Can I get a sanity check on this one? [HideInInspector] seems to break serialization.

        [SerializeField]
        public string GUID;
        [SerializeField]
        public List<RuntimeNode> outputConnections = new List<RuntimeNode>();
        [SerializeField]
        public List<RuntimeNode> inputConnections = new List<RuntimeNode>();

I have an editor window saving this to file using the asset DB, and like this it works fine.

Contrast:

        [SerializeField, HideInInspector]
        public string GUID;
        [SerializeField, HideInInspector]
        public List<RuntimeNode> outputConnections = new List<RuntimeNode>();
        [SerializeField, HideInInspector]
        public List<RuntimeNode> inputConnections = new List<RuntimeNode>();

This writes when the asset db creates the object for the first time, but is not serializing after being set dirty as expected, and as the above script does. Can I get a sanity check, this seems like a major bug.

#

I have multiple editor scripts that i had to remove [HideInInspector] from after updating to Unity 2020.2.3f1

#

they all seem to have this issue.

waxen sandal
#

It shouldn't

civic river
#

Made a standalone project trying to reproduce and couldn't

#

Must be user error

#

q-q

onyx harness
#

SerializedField and Public is redundant