#↕️┃editor-extensions

1 messages · Page 73 of 1

onyx harness
#

For what purpose? o_o

gloomy chasm
#

Like I said, for making a pins bar. Like the bar on the bottom ("Error List", "Output") and the left ("Toolbox").

#

Could do ones on the left and right without too much trouble, but doing one on the bottom with a header would make it pretty bulky.

civic river
#

Am I missing something obvious? Extending Editor has UI elements support but EditorWindow does not

#

there's none of the UITK callbacks you need

visual stag
#

in the Editor Window you just add to the rootVisualElement

gloomy chasm
#

In OnEnable

gloomy chasm
#

PSA: Don't remove the sibling of rootVisualElement or your computer may very well bluescreen, lol.

civic river
#

Really? That sounds like a very mean bug

#

lol

#

@visual stag Yeah, the rootVisualElement I can add to but there's no callbacks supported like the editor has.

        public override VisualElement CreateInspectorGUI()
        {
            return base.CreateInspectorGUI();
        }

Editor window is missing these

gloomy chasm
#

Yeah, it's not great. I mean I didn't test it again, but the project was empty so I think it should happen every time. I reported it with the suggestion that it close the editor window or simply not be able to be removed.

#

@civic river

private void OnEnable()
{
  rootVisualElement.Add(new Label("My Label"));
}
#

rootVisualElement is a property of EditorWindow

civic river
#

OnEnable has race conditions with initialziation

gloomy chasm
#

It can be any where, the important part is rootVisualElement

#

You can add/remove stuff from it at any time.

civic river
#

there's no way to know when it's safe to add/remove stuff though

#

it doesn't give a callback when it's done constructing

#

like the editor does

visual stag
#

I am confused, I don't have any race conditions

gloomy chasm
#

What exactly are you having trouble with?

civic river
#

If I do something like this

        private void GenerateMiniMap()
        {
            var miniMap = new MiniMap{anchored = true};
            var spawnCoord = graphView.contentViewContainer.WorldToLocal(
                new Vector2( graphView.contentViewContainer.layout.width - 20, 45));
            Debug.Log(spawnCoord.x);
            miniMap.SetPosition(new Rect(spawnCoord.x, spawnCoord.y, 200, 140));
            graphView.Add(miniMap);
        }
#

graphView.contentViewContainer.layout.width isin't constructed yet OnEnable

#

so you have to just guess when it's created

#

graphView.schedule.Execute(ConstructGUIAfterRepaint).StartingIn(100);

gloomy chasm
#

When are you calling the method?

civic river
#

OnEnable

gloomy chasm
#

I mean after or before your graphView stuff? And is it a different window?

civic river
#

this is OnEnable for the editor window

spring geode
gloomy chasm
#

@civic river Is GenerateMiniMap() being called in the same script that you are constructing your graphview?

civic river
#
        private void OnEnable()
        {
            graphView = new BaseGraphView
            {
                name = "Coffee Behaviour Graph"
            };
            graphView.StretchToParentSize();
            rootVisualElement.Add(graphView);

            graphView.schedule.Execute(ConstructGUIAfterRepaint).StartingIn(100);
        }
gloomy chasm
#

So where is GenerateMiniMap being called in relation to that code?

civic river
#

it's in the execute call

#
        private void ConstructGUIAfterRepaint()
        {
            GenerateToolbar();
            GenerateMiniMap();
            GenerateBlackboard();
        }
gloomy chasm
#

You should be able to call it directly there, with no need for the schedule execute

civic river
#

the values are (Nan, Nan) for the size OnEnable

#

It calls OnEnable too early

gloomy chasm
#

You mean graphView.contentViewContainer.layout.width is Nan?

civic river
#

yeah for the OnEnable call

#

it doesn't resize till the next frame

gloomy chasm
#

Would not going so deep work? (I don't remember the API for it so I honestly don't know)

civic river
#

nothing gets initialized until the next frame I stepped through with the debugger

#

and maxSize is some rediculous nonsense value for some reason on the editor window

gloomy chasm
#

I am about to go to bed, so I can't look through it right now. But I would say if you haven't already look at the shader graph, or vfx code to see how they do it.

civic river
#

are those open source?

gloomy chasm
civic river
#

I didin't know that was an option lol

#

well that's a super great resource

#

cheers

gloomy chasm
#

Yeah, it has been great. Warning though, as far as I can tell, a lot of the shader graph code was written while the graph API was still new, so things have changed and it does some things it self that the graph api does now. Also the vfx graph and shader graph implement things really differently.

#

I find the shader graph easier to read and follow in general, bit less complex.

civic river
#

it looks like they just rig an event to it

#

graphView.RegisterCallback<AttachToPanelEvent>(OnEnterPanel);

#

seems simple enough

pale geyser
#

is it possible to just receive 1 mousemove event per frame in UI Elements (in an inspector?)

#

i'm using these callbacks to add the event (added in a VisualElement constructor after loading the container from UXML):

        shapeContainer = root.Q<IMGUIContainer>(name = "ShapeContainer");
        shapeContainer.onGUIHandler += OnGUI;
        shapeContainer.RegisterCallback<MouseDownEvent>(HandleMouseDown);
        shapeContainer.RegisterCallback<MouseMoveEvent>(HandleMouseMove);
        shapeContainer.RegisterCallback<MouseUpEvent>(HandleMouseUp);```
#

each event also calls my OnGUI for the IMGUIContainer function at least twice, resulting in it being run up to 100 times each frame

#

ah calling event.StopPropagation() seems to have fixed it

mild reef
#

hey guys, How do I show a field to drop an enum class into?

waxen sandal
#

What?

south fox
#

From what I understood this person wants to create a field in a custom editor/inspector window. This field should accept enum files...

onyx harness
#

What is an enum file? What are not in Unreal X)

south fox
#

It's a file that contains an enum I assume

#

Doesn't sound too weird too me. Such an input does sound weird to me though

mild reef
#

I created a script that just has this: public enum Direction{X = 0,Y = 1,Z = 2}

onyx harness
#

You need to read about DragAndDrop

mild reef
#

And I want to be able to allow only the enum scripts to be used...

whole steppe
#

Mikilo you were right

#

The list lost his reference because i was drawing it every frame

#

100%

onyx harness
#

XD

#

i was drawing it every frame
Because you were "allocating" one every frame 🙂

civic river
#

Anyone have some insight how I can solve some UI elements issues. The alignment of my first element seems to be ignored(?) I don't really know what's going on here. And when there's too many elements trying to expand it just dies horribly

gloomy chasm
#

@civic river For the too many elements expanding thing, I think you need to look at your styling on the parent of those elements. Not sure what is going on with the rest of it.

#

Have you tried looking at it with the UI Toolkit debugger window?

civic river
#

yeah I didin't find anything that looked compelling

#

there's some sort of hidden margin on the first element that isint inherited but I can't seem to find out what it is

#

can you explain a bit about the styling thing?

#

I don't really understand the style sheets at all

#

If I create an empty foldout the alignment is fine... I just don't get it

gloomy chasm
#

I've done it, I have gone too deep. I broke unity (the project loads like this and it is not possible to open windows)

onyx harness
#

Hahahaha

#

Just reset the layout, should be fine

gloomy chasm
#

How?

#

I can't access the layout options 😛

#

Oh, under window. That worked.

onyx harness
#

If the whole UI is not responding, go there:
C:\Users\{USER}\AppData\Roaming\Unity\Editor-5.x\Preferences\Layouts

#

and remove the LastLayout.dwlt

gloomy chasm
#

Cool, but yeah, it works. What I had done was remove the Toolbar, but it seems it removed the dock view as well for some reason. I mean, it had totally broke the editor when I removed the toolbar so I had to close and reopen the editor to get it to look like that.

onyx harness
#

Because a lot of things are linked intrinsically, and they don't expect to be null

gloomy chasm
#

Well, yeah.

onyx harness
#

And when you closed Unity Editor, obviously they saved the layout

#

Don't remove Unity stuff, hide them.

#

0 height, 0 width, or stuff like that

gloomy chasm
#

I am not surprised. I am mostly just playing around seeing what can be done. Sadly that doesn't work for the toolbar, and when adding ui elements to it, if they have rounded corners they seem to just be all white for some reason.

#

At least if they are a child of the rootVisualElement.

onyx harness
#

Strange, don't have this issue

gloomy chasm
#

Are you using the root or the IMGUIContainer?

onyx harness
#

It is integrated in the root

#

and drawing using an IMGUIContainer

gloomy chasm
#

Ah, I'm using VisualElement controls, I bet that is why.

mild reef
#

Hey guys, anyone know how I can get the actual Rect position of a button and not it's relative position?

#

GetLastRect does not give me the actual position within the EditorWindow...

onyx harness
dense abyss
#

Having trouble where changing Text Mesh Pro text options, like color, etc is effecting all Text Mesh Pro elements in the UI. What caused them all to be linked together?

onyx harness
dense abyss
#

Oh i thought extensions means not built in features

onyx harness
#

This channel is specific for extending Unity Editor

dense abyss
#

I am not sure I know the word extension. Like in for Google Chrome, and Edge, it means a feature provided by an outside programmer

onyx harness
#

This channel's description targets very specifically Editor and things you could write to extend.

#

Yes, kinda

#

"Outside" is optionnal, but it's really just about extending your Unity Editor

dense abyss
#

oh its for creating new extensions, not using existing ones, I see

onyx harness
#

Yep

dense abyss
#

got it!

onyx harness
#

Good luck

tulip plank
#

I'm having a hard time finding out how to/if there is a way to create a prefab from an existing prefab, then modify that independently without adding it to a scene. Is there a way to do this? All of the PrefabUtility stuff seems to require adding it to a scene before modifying it.

marble oriole
#

Anyone know how to save the ScriptableObject tied to an inspector? Created / drawing with CurrentInspector = Editor.CreateEditor(Current);

#

Then trying to save it by marking Current as dirty, and calling SaveAssets / Refresh on the AssetDatabase, but not working.

stray hemlock
#

@marble oriole modifiying a scriptableObject instance in project through a serializedObject seems to save the values.

#

Used it in a settings provider

marble oriole
#

@stray hemlock yeah not sure what was going on, kept working in the area and it seems to be working fine now?

stray hemlock
#

Lol cool

#

Can anyone suggest a way to undo data local to an editor window.
By that I mean some field used only in editor window
Using UI Toolkit if u wanted to know that

full vault
#

qq

#

how i can change this icon

#

to this sprite

#

that icon == Sprite value

onyx harness
#

Change the icon when the asset is being created.

frozen cove
#

Hi guys I'm looking to create a custom slider inside a PropertyDrawer.
I want to get rid of the value display at the end which comes as standard when using EditorGUI.Slider.
Any ideas how to only show the slider component?

#

Tag me if you reply 🙂 cheers

onyx harness
#

EditorGUI.Slider? @frozen cove

frozen cove
#

Yeah, that's what I'm using and I get the result above,

onyx harness
#

shit

#

I'm colorblind

#

XD

frozen cove
#

ooooh sorry 😦 ermmm

onyx harness
#

I see thx

frozen cove
onyx harness
#

Have you tried

#

reducing the width?

#

Try 90 @frozen cove

frozen cove
#

ok...

onyx harness
#

I think it is trigger at width > 55 + EditorGUIUtility.fieldWidth

frozen cove
onyx harness
#

If you want to know, the code executed is this one EditorGUI.DoSlider(Rect position, Rect dragZonePosition, int id, float value, float sliderMin, float sliderMax, string formatString, float textFieldMin, float textFieldMax, float power, GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent)

frozen cove
#

yeah I'd pulled the source code and it half scared me to death

#

creating it from a texture2D etc 😳
I'm hoping to not have to take that route.

onyx harness
#

I think I have not much hope for hiding this one

#

It doesn't have options to hide it

frozen cove
onyx harness
#

Have you tried GUI.Slider?

frozen cove
#

yeah it's a tricky one..
I just tried drawing the other field over the top of the slider field part, visually it looks correct, however the click input is now trying to access the slider, not my float

#

I havent.. will take a look now

mild reef
#

Hey guys, anyone know of a way to get all the indexes of a unityevent?

onyx harness
#

What is an index in there?

frozen cove
frozen cove
#

@onyx harness Legend!
target.range = GUI.HorizontalSlider(rangeRect, target.range, target.min, target.max);

mild reef
#

@frozen cove Yes...

#

I want to get the those indexes...

#

@onyx harness That doesn't give me access to the indexes?

onyx harness
#

Sorry but indexes mean nothing to me

#

On your UnityEvent you have GetPersistentEventCount()

#

This will give you the total, but what then?

frozen cove
#

beat me too it :)
UnityEvent.GetPersistentEventCount();

#

@mild reef ^

mild reef
#

Thanks guys...I needed it to see if I can adjust the layout between gui depending on how many in the unityevent box so it doesnt overlap other gui...

onyx harness
#

Lol, this is very far from needing the indexes

#

Getting the height of a UnityEvent is more appropriate

mild reef
#

Sorry, I meant the count...for now...

#

Ok thanks I will try that...

#

@onyx harness Actually, how do I get height lol?

onyx harness
#

How do you draw?

mild reef
#

EditorGUI.PropertyField(new Rect(guiDefaultPosition.x + 110, guiDefaultPosition.y, 160, 20), serializedObject.FindProperty("MenuAction"));

onyx harness
#

Get the SerializedProperty

#

Then use EditorGUI.GetPropertyHeight()

mild reef
#

Perfect thanks!

onyx harness
#

Does this one solve your earlier question?

frozen cove
#

On a custom PropertyDrawer I'm using the following code:

EditorGUI.BeginChangeCheck();
float newRange = GUI.HorizontalSlider(rangeRect, target.range, target.min, target.max);
if (EditorGUI.EndChangeCheck())
    target.range = newRange;

This works for setting the value.
However the MonoBehaviour with the custom PropertyDrawer doesn't have OnValidate called.
How can I force OnValidate to be called?

onyx harness
#

Not sure, but maybe because you modified the target directly, instead of the SerializedObject

#

The change is not reflected

frozen cove
#

I had to because the GUI.HorizontalSlider doesnt take the SerializedObject

onyx harness
#

Invalidate the Serialized Object

frozen cove
#

You guided me to the right solution! ...

#
EditorGUI.BeginChangeCheck();
float newRange = GUI.HorizontalSlider(rangeRect, target.range, target.min, target.max);
if (EditorGUI.EndChangeCheck())
    range.floatValue = newRange;

(Last Line) range is my serialized property 🙂

tough cairn
#

@onyx harness hey

onyx harness
#

Yes?

tough cairn
#

do u know how to update scene gizmos ?

#

from within onInspectorGUI

#

force exec sceneView.repaint

onyx harness
#

Didn't you just write it?

tough cairn
#

it won't work

#
bool repaint = false;

void OnEnable() => SceneView.duringSceneGui += OnSceneGUI;
void OnDisable() => SceneView.duringSceneGui -= OnSceneGUI;
void OnSceneGUI(SceneView sv)
{
    //var script = ( MapData3D ) target;
    //sv.drawGizmos = true;

    if( repaint )
    {
        sv.Repaint();
        repaint = false;
    }
}
onyx harness
#

Gizmos is drawn upon OnGUI, no?

#

what is expected from the update?

tough cairn
#

I set repaint = true in OnInspectorGUI when a value is changed

onyx harness
#

Hum... i read this is the wrong way of doing

tough cairn
#

OnSceenGUI gets exec'd only when focused ?

onyx harness
#

Because duringSceneGui will only be triggered on the SceneView repaint, isn't it?

#

which will just repaint a 2nd time due to your Repaint

tough cairn
#

ah ye

#

SceneView.currentDrawingSceneView was returning null

#

guess ill capture it on the sceneGUI and use the ref instead

onyx harness
#

I guess it is null because when you use it, you are in a OnGUI or something and not a scene repaint

#

Those are very contextual

#

The name is not "lastDrawingSceneview" but "current"

#

There are equivalent for Inspector and others

tough cairn
#

context menu yield only SceneView.currentDrawingSceneView

#

anyhow i used the ref

#

seems to do the trick 🙂

#
void OnSceneGUI(SceneView sv) => view = sv;

public override void OnInspectorGUI( )
{
  using( var change = new EditorGUI.ChangeCheckScope() )
    // ... 
    if( change.changed ) view?.Repaint();
onyx harness
#

If it works, it works 🙂

tough cairn
#

exactly lol

onyx harness
#

But there is a better way

#

wait

tough cairn
#

k

onyx harness
#

SceneView.lastActiveSceneView

tough cairn
#

nope

onyx harness
#

Doesnt work?

tough cairn
#

it won't update

#

:<

#

only when focused it will

#

( mouse over scene )

onyx harness
#

Resources.FindObjectOfTypeAll(typeof(SceneView))

tough cairn
#

nope

#

same

#

its ok dw

onyx harness
#

Hum... this last is very surprising

tough cairn
#

that what i tried btw :

if( change.changed )  ( (SceneView) Resources.FindObjectsOfTypeAll(typeof(SceneView)).FirstOrDefault() )?.Repaint();
onyx harness
#

This is my most reliable way of finding any Object

#

Ok ok, I'll keep that in a corner of my mind

tough cairn
#

it is not null tho

onyx harness
#

Oh

#

Hum... strange then

tough cairn
#

im getting out (UnityEditor.SceneView) as log

onyx harness
#

So what is not working then?

tough cairn
#

it works

#

only when focused

#

so i change the slider and it won't repaint

#

but when using void OnSceneGUI(SceneView sv) => view = sv; it does forces it to repaint for some reason

#

idk

onyx harness
#

Strange

tough cairn
#
var val = (SceneView) Resources.FindObjectsOfTypeAll(typeof(SceneView)).FirstOrDefault();
//Debug.Log( val );
if(change.changed) val.Repaint();
#

vs

#
if( change.changed ) view.Repaint();
#

oof..

#

that one also stopped working

#

D:

onyx harness
#

Restart

tough cairn
#

yep now ( 2/3 ) works lol

#

broke:
if(change.changed) SceneView.currentDrawingSceneView?.Repaint();
work:
if(change.changed) catched_view_ref?.Repaint( ); ( from OnSceneGUI )
if(change.changed) ( ( SceneView ) Resources.FindObjectsOfTypeAll( typeof( SceneView ) ).FirstOrDefault( ) )?.Repaint( );

onyx harness
#

But what doesnt work?

#

What is the expected result?

tough cairn
#

1st

#

i move a slider and a gizmo cube size is changed

#

on OnDrawGizmosSelected

#

guess ill use OnSceneGUI instead :/ ?

onyx harness
#

(FYI Resources.FindObjectsOfTypeAll<SceneView>())

mild reef
#

Is there a way to hide the static methods in the UnityEvents inspector and only show the dynamic ones?

onyx harness
#

You must reimplement the drawer

mild reef
#

@onyx harness Is that response for me?

onyx harness
#

yes

mild reef
#

SerializedProperty property = serializedObject.FindProperty("unityEventPropertyField"); EditorGUI.PropertyField(new Rect(guiDefaultPosition.x + 110, guiDefaultPosition.y, 160, 20), property);

#

I have this, where should I start?

onyx harness
#

Either you redraw the whole UnityEvent manually

#

Or you reimplement a PropertyDrawer

#

Which will also need to redraw the UnityEvent manually

mild reef
#

Not sure what you mean by redraw...

onyx harness
#

Using EditorGUI/GUI to mimic what Unity have done for UnityEvent

mild reef
#

So create my own UnityEvent GUI?

onyx harness
#

Yes exactly

mild reef
#

Sounds like too much work lol, I'll figure something out...

onyx harness
#

Oh yeah, if you have no idea how to do that, it becomes much more difficult

tough cairn
#

do float[ , , ] get serialized ?

onyx harness
#

This a multi-dimensional array, nope

tough cairn
#

uhh time for a index shift hax

#

just dropping it here if anyone would need this ( i hope it works ... )

/// <summary> Convert 3D index into 1D </summary>
public int Index3D1D( Index3 index ) => index.z * ( x * y ) + index.y * x + index.x;
/// <summary> Convert 1D index into 3D </summary>
public Index3 Index1D3D( int index ) => Index3.Floor( index % x , index / x, index / ( x * y ) );

( where this . x,y,z is the grid size )

marble oriole
#

Out of curiosity, is there any drawback to putting assets (scriptable objects, prefabs, etc) in Resources, but not loading them? I put some in there for my game editor, but never load them in the actual game.

onyx harness
#

Very bad

gloomy chasm
#

@onyx harness that isn't an answer. :P
@marble oriole The only drawback is that they would be included in the build of the game, meaning it would unneededly increase the size of it. I think that if a Resources folder is inside of a Editor folder, it will not be included, or maybe the other way around, could be wrong though.

marble oriole
#

Got it, thanks @gloomy chasm , that makes sense. I'll look into moving it elsewhere. Early enough in development that it's ok to do small refactors 🙂

onyx harness
#

@marble oriole Having those folders embedded in build is one thing, having them loaded in memory while the user is never gonna use them is way worse

#

Because Resources are loaded at startup, which increases loading time for nothing.

marble oriole
#

Because Resources are loaded at startup, which increases loading time for nothing.

This is what I was wondering about.

onyx harness
#

Could be nothing, negligeable, but bad practice

patent river
#

Does anyone here use vscode for writing scripts?

#

Intellisense stopped working

visual stag
patent river
#

I ended up figuring out by reading all those pesky error messages

#

It was only a matter of finding the correct installs

#

Thanks anyways

stray hemlock
#

Guys what would be the best way to have an undoable field in an editorwindow which shows data local to the editor window, I mean like its not binding data from some other object but rather its just a private float field or something in the editorwindow class.

civic river
#

Heya, I can't seem to find how to make a (UI toolkit) visual element resize to fit it's content container

#

My css goto resize does not seem to exist in unity CSS land

civic river
#
.charImgStyle {
    height: auto;
    position: absolute;
    -unity-background-scale-mode: scale-to-fit;
    width: auto;
    flex-direction: column;
    flex-shrink: 1;
    flex-basis: 100%;
}

Just doesn't seem to do the trick

#

goal is to keep the apsect ratio the same but keep the content completely in view

visual stag
#

Have a play with the UIElements debugger

#

it's much easier to get things working and see the bounds of the rects you're dealing with

civic river
#

Yeah I tried playing with pretty much every setting I could think of, it seems like pretty much none of the settings do anything

#

absolute position might not be resizeable maybe

#

I can set up similar things in UI builder and it seems to resize them fine

#

but yeah add absolute position and it seems to be a buzz kill

#

🤔

#

I've conceded to just making a mouse drag manipulator

#

this css stuff is too much for my smooth brain

gloomy chasm
#

@civic river Sorry for the late reply. flex-grow: 1 should do for you.

lofty seal
#

not sure if this is the correct section for this but I really need some help with setting up snippets for unity in vsc

#

I installed the extension and the instruction say I need to pop this command in the command palette: ext install kleber-swf.unity-code-snippets to install the extension

#

but when I try to do so I just get this

#

does anyone know how to fix this?

inner folio
#

I want to draw handles, but in the same way the unity label icons are rendered.

I tried faffing about with the sceneview camera's cameraToWorld and inverse matrices, but somehow I can't get to the right behaviour.

The ">" in each of these should at some time be the endpoint for a spline that goes to another object.

#

These are drawn with "Handle.Label" right now, with newlines (because I can't space the lines myself correctly - this is part of my problem)

#

Nuuuu.

tough cairn
#

is Handles.DrawAAPolyLine broken ?

#
var top_right = view.camera.ScreenToWorldPoint( screenSize ); 
var bottom_left = view.camera.ScreenToWorldPoint( Vector3.zero );

Handles.color = Color.red;
Handles.DrawAAPolyLine( 2f, Vector3.zero, top_right );
        
Handles.color = Color.green;
Handles.DrawAAPolyLine( 2f, Vector3.zero, bottom_left );

Handles.color = Color.white;
Handles.DrawAAPolyLine( 2f, bottom_left, top_right );
#

ah... ok it doesn't like z shifts , fixed by adding this :

bottom_left.z = top_right.z = 0f;
deep wyvern
#

So I have a horizontal layout group with 2 elements and the second one is a small button. So far everything is fit nicely. But if I change the second element to a vertical layout group because I want 2 small buttons on top of each other it adds a lot of padding to the second element. Why is that and how do I change that?

gloomy chasm
#

@deep wyvern To be honest, I'm not sure, especially without seeing the code.

onyx harness
#

I guess using GUILayoutOption.ExpandWidth(false) might help @deep wyvern

deep wyvern
#

@onyx harness I think thats what I was missing. Used a different workaround for now. Thanks!

whole steppe
#

Hello , i was wondering , why is the reorderable list so laggy when i add a good amount of items to the list.

onyx harness
#

Might depend

#

How much is "good amount", how heavy is your GUI

#

And of course, I'm not sure ReorderableList is well optimized

whole steppe
#

40 items is maximum then it takes like 2-3 seconds until the gui reacts

#

i just disabled the custom editor script and everything works very fast so it must have to do with the custom editor/reorderable list

#

what do you mean with "how heavy is the Gui" Mikilo

onyx harness
#

How heavy is your DrawElement?

#

What do you draw

whole steppe
#

let me show

#

not much to be honest

onyx harness
#

Sorry, but you are not qualified to state if it is much 🙂

#

on top of that, you have a GetPropertyHeight right?

#

And I think I can say yes, this is heavy

#

40 elements, multiply by 5., 200 elements minimum in a single Editor

whole steppe
#

allright. i will see what i can do there. thanks

#

And i have to add double the size actually :/

#

items have a few more fields

steady crest
#

how do I detect the available width of an editorwindow, adjusting for the scrollbar if its present?

onyx harness
#

Hardcore

#

Use GUILayout.Space() and get last rect, to extract the width

#

Or something similar

#

Or go deep and dive into GUIView and clipping

steady crest
#

eep

#

I assumed it would be rather simple, given I can see it happening in the inspector for default inspectors xD

onyx harness
#

You talk manually or using Layout?

steady crest
#

im using layouts

onyx harness
#

usually you don't even need to handle

#

Why do youask?

steady crest
#

cuz I made an editor grid view

#

and the scrollbar is being drawn on top of it

#
        public static void CreateGrid<T>(this List<T> data, Vector2Int size) where T: Object
        {
            if (data == null || data.Count == 0)
            {
                return;
            }
            
            var width = Screen.width - 45;
            for (var i = 0; i < size.x * size.y; i++)
            {
                if (i % size.x == 0) GUILayout.BeginHorizontal();

                data[i] = EditorGUILayout.ObjectField(data[i], typeof(T), false,
                    GUILayout.Height(Mathf.Floor(width / (float)size.x)), GUILayout.Width(Mathf.Floor(width / (float)size.x))) as T;
            
                if (i % size.x == size.x - 1) GUILayout.EndHorizontal();
            }
        }
onyx harness
#

You're not using layout then

#

Layout with Width/Height is not exactly layout

steady crest
#

yeah ok, thats a good point

onyx harness
#

Just before going into BeginHorizontal

#

Draw an invisible line

#

Or just GetRect with full expand width

steady crest
#

hmm

#

GetRect with full expand width

#

im not sure I understand what that means GUILayoutUtility.GetRect(GUIContent.none, new GUIStyle());

onyx harness
#

Me neither

#

XD

#

Add an option to get expand on Width

steady crest
#

this sets the value to the width and after it just decides to set it to 1 somehow
var width = GUILayoutUtility.GetRect(GUIContent.none, new GUIStyle()).width;

#

guess its the repaint and layout event being annoying

onyx harness
#

You must use it from a Repaint

#

Never layout

steady crest
#

ah

onyx harness
#

Sorry wrong word, you must use the width from Repaint only

steady crest
#
        private static float width = 0;
        public static void CreateGrid<T>(this List<T> data, Vector2Int size) where T: Object
        {
            if (data == null || data.Count == 0) return;
            
            if (Event.current.OnRepaint())
            {
                width = GUILayoutUtility.GetLastRect().width - 10;
            }
            
            Debug.Log(width);

            for (var i = 0; i < size.x * size.y; i++)
            {
                if (i % size.x == 0) GUILayout.BeginHorizontal();

                data[i] = EditorGUILayout.ObjectField(data[i], typeof(T), false,
                    GUILayout.Height(Mathf.Floor(width / size.x)), GUILayout.Width(Mathf.Floor(width / size.x))) as T;
            
                if (i % size.x == size.x - 1) GUILayout.EndHorizontal();
            }
        }
#

@onyx harness is it literally redrawing after the scrollbar is there and thinking it fits on there making it jitter like that lol

onyx harness
#

Sorry it is not suppose to be like that

#

The "width ="

#
Rect r = GUILayoutUtility.GetLastRect();
if (Event.current.OnRepaint())
{
    width = r.width - 10;
}
``` @steady crest
#

More something like that

#

oh wait...

#

You must draw something before using GetLastRect

#

Or it will give you the rect of the last thing

#

and I don't know what it is

steady crest
#

Would that be something above it in the inspector or could it be some other random ui element?

#

The last thing drawn above it is a horizontal group with a slider and a button

onyx harness
#

I really have no idea, it depends of you code

#

Well should be fine

steady crest
#

The available width if I log it is just constantly changing between x and x-15 which would be the width of the scrollbar

onyx harness
#

What is if (Event.current.OnRepaint())?

#

type == EventType.Repaint?

#

Why don't use your GUILayout.MinWidth()?

#

And skip the whole complexification

steady crest
#

From what j found on the docs they should be equivalent

#

Oh y actually minwidth should do it

onyx harness
#

Or ExpandWidth(false)

#

Or something like that

steady crest
#

Gonna be some trial and error to find the right layout stuff rly

onyx harness
#

And pre-detect if you are bigger than the (width-15)

steady crest
#

Probably a good idea, ima try it in a few different ways. Interestingly each of the types has one of those boolean checks

#

I dont know why they exist if you can just check the enum types, but they do

civic river
#

Hey frens, more UI elements confusion from me. I don't know why this TemplateContainer exists in my editor window, it is created malsized and seems to be the default container for the rest of the XML document.

#

If I resize the template container in the debugger it works as expected

#

But I'm not really sure why that's a neccesary step

#

Is their some way I can get rid of it?

#

(also is this a bug that should be reported or am I just dumb)

whole steppe
#

I am trying
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceSynchronousImport & ImportAssetOptions.ForceUpdate);
But it doesnt seem to have the same effect

tough cairn
#

what's the relation of the scene view camera position to its draw size ? so i figured out by trial and error that the view.cameraDistance is proportional to 1 unity unit when its value is 1 and a cube will occupy the smaller size of the screen completely , when its value is 2 the cube size will be at 50% , etc , but i can't seem to see how to calc the position

... ahh nvm i'll use sceneView.camera.WorldToScreenPoint

tribal skiff
#

how would I make rect that contains multiple rects, basicly something like

short tiger
#

@tribal skiff In that picture, the red rectangle is a little bigger than it needs to be, right?

tribal skiff
#

um... its just for better looking i think

mild reef
#

Whats the best way to draw EditorWindow changes without overloading and crashing Unity?

waxen sandal
#

??

mild reef
#

So crickets?...

waxen sandal
#

No crickets, just no a comprehensible question

tough cairn
#

how to make serializable asset reference in scriptable objects ?

#

( i want it to have something like public List<Object> references;

gloomy chasm
#

@tough cairn I don't quite understand what you mean. But if you want that field to serialize, you should be able just put [SerializeReference] on it.

tough cairn
#
[System.Serializable]
public class GridTileSettings : ScriptableObject
{
    [System.Serializable]
    public struct TileData
    {
        public int width;
        public int height;
    }

    public List<Object> references;
    public List<TileData> tiles;
#

now when i do cs [SerializeReference] public GridTileSettings settings; in a MonoBehaviour it won't serialize

gloomy chasm
#

Won't serialize as in assigning a GridTileSettings asset to the field will not save the value? Or as in the field it self does not show up in the MonoBehaviour?

tough cairn
#

the last one

#

ah nvm

#

i think i have some other problem

#

one sec

#

yep it wasn't creating the object to begin with lol

#

    public static GridTileSettings Create( string prefix )
    {
        var data = ScriptableObject.CreateInstance<GridTileSettings>();

        var path = "Assets/" + prefix + "_" + (typeof(GridTileSettings).Name.Replace(" ", "") + ".asset");

        AssetDatabase.CreateAsset( data, path );
        AssetDatabase.SaveAssets();
        EditorUtility.FocusProjectWindow();
        // Selection.activeObject = data;

        return data;
    }
#

and i call it on :

    void OnEnable()
    {
        if( tileSettings == null ) 
        { 
            var scene_name = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

            tileSettings = GridTileSettings.Create( scene_name );
        }
    }
gloomy chasm
#

Nice. Just so you know, ScriptableObjects don't need System.Serializable attribute on them.

#

So did you get it working then?

tough cairn
#

i see

#

( still trying )

#

yep all good

#

was missing a #endif 🤨

gloomy chasm
#

lol, well glad you got it to work. Also, Unity supports polymorphic serialization for fields of the ScriptableObject type, so [SerializeReference] is not needed there 🙂

tough cairn
#

yep i noticed that , was throwing random stuff at it since it didn't work

#

thanks

gloomy chasm
#

Yeah, I figured that may the case (I do that too), but thought I would make sure.

viral dune
#

hi, are there any way to implement particlesystem.minmaxcurve to a custom editor ?

#

or any minmax curve in general

mild reef
#

has anyone here reflected a method and used invoke in OnGUI? I think it is crashing Unity for me constantly. I need to figure out why...

waxen sandal
#

That works just fine

onyx harness
#

Log, log, log

whole steppe
#

Is there any soloution for my problem. As soon as i have more than 20 items drawn it lags very hard. 5-6 seconds delay and more

#

i am using a reorderable list

#

maybe using a Changecheck codeblock. no clue if that would help 😉

untold frost
whole steppe
#

Would be really nice if someone has a working soloution for me. I can not publish this asset like that.

waxen sandal
#

Use the profiler to see what's taking long?

#

Might just be too many elements at once

#

Or too many findproperties etc

#

Pre calculate your rects

whole steppe
#

That sounds good. Thank you.

waxen sandal
#

Could also add expanders to the individual items to reduce the amount of items being drawn

onyx harness
#

I already told you thing, but you don't seem to listen

waxen sandal
gloomy chasm
#

Is there a way to draw the content of a editor window inside of another? I feel like there was, but now I can't find it for the life of me.

onyx harness
#

It's a tricky intent

#

EditorWindow are not supposed to be drawn inside one another

#

The state might be unpredictable

#

Depending on the EditorWindow

#

But technically, calling OnGUI should suffice

gloomy chasm
#

Alright, will give that a try, thanks. I am trying to draw an inspector inside of a custom window.

onyx harness
#

This is not EditorWindow X)

#

Inspector is just a pile of Editor

gloomy chasm
#

Well, I tried to just loop through the components and create an editor for each, but that broke, so now I am trying this 😛

onyx harness
#

You are doing something wrong then

#

Of course, there are many tricks in Inspector you have to handle to mimic it correctly

#

But this is the way

#

Drawing InspectorWindow in a EditorWindow is kinda dangerous

#

You need to perfectly handle its state, like enabling/disabling, focus, blur, etc.

#

There is only one drawback I know when mimicking via Editor.
Sometime the GUI requires the window to be specifically an InspectorWindow. There you are doomed.

whole steppe
#

Mikilo i just scrolled up and i can not see any tips you gave me to optimize the code.

#

I already told you thing, but you don't seem to listen
@onyx harness

onyx harness
#

Do you want me to code for you?

#

I stated too heavy GUI.

#

You said "not much"

#

If you never used the Profiler, the first move must be there

#

Navi is right

#

Check first

#

(Btw you used GUILayout in your drawer)

whole steppe
#

true

onyx harness
#

Profiler with Deep Profile

whole steppe
#

ok. i will inspect the code.

onyx harness
#

I don't know what is your aim about Editor scripting, but if you want to go deeper, farther, whatever, you need to know how to deal with the Profiler

#

One day or another, you'll have to face it

whole steppe
#

well i think this is the day.

#

hey Mikilo

onyx harness
#

Yes sir?

whole steppe
#

I'm use the Unity: 2018.4.28f1 @onyx harness

#

And i'm download the new Unity Collab @onyx harness

onyx harness
whole steppe
#

I Need TeamMembers @onyx harness to help me work on TheSwampForest

onyx harness
#

What is this? I don't even know what it is @whole steppe

#

I guess I will be of no use on this matter

whole steppe
#

Well i'm use the new Scene Fusion on Unity 2018 @onyx harness

gusty plume
#

Hi there. Has anyone come across a problem when embedded Unity icons are missing? I'm using Hub 2.4.1, Unity 2020.1.7f1.
Tried reinstalling the editor, didn't help.

onyx harness
#

Lol, what have you done to your Unity

waxen sandal
#

That just looks like a shitty drawer

#

Rather than missing icons?

#

Oh wait I'm looking at it wrong

#

They probably just renamed them?

gusty plume
#

Were do they store those icons? In a dll somewhere?

onyx harness
#

Nope, built-ins in the installation folder

#

unity_builtin_extra, default, editor, etc.

gusty plume
#

Thanks. Will investigate further

tribal skiff
#

hello! i want to know are the editor custom inspectors to get better looking stuff is good even if i am doing a game alone?

plucky cedar
#

vscode is showing errors that worked when i last opened project

#

WorldGenerator definately exists

#

i just cant get it to work

civic river
#
        [Preserve]
        public new class UxmlFactory : UxmlFactory<Listy, UxmlTraits> { }
   
        [Preserve]
        public new class UxmlTraits : VisualElement.UxmlTraits
        {
            readonly UxmlStringAttributeDescription foldout = new UxmlStringAttributeDescription { name = "FoldoutText", defaultValue = "Foldout" };
            ////
        }
        
        private readonly Foldout foldout;
        public string FoldoutText //name = "FoldoutText" links directly with this field
        {
            get => this.Q<Foldout>("ListFoldout").text;
            set => this.Q<Foldout>("ListFoldout").text = value;
        }

Hey guys, sorta dumb question but I haven't stumbled on an answer if anyone's aware of one. Unity automagically names your field in the UIE builder/XML based on the field name you've declared, but the name doesn't appear to be mutable so it looks really horrendous but other fields don't look nearly as bad. Is their some way to change the display name for the UIE?
Here's an example of what I mean

frank gale
#

Hello, I am wondering if anyone knows how to properly make UnityEvents shown on the Inspector, using EditorScripts, It looks like a simple PropertyField won't do the job, the elements shown just doesn't respond with clicking

#

I have encountered this before, but on ReorderableList, which I can cache it as a private variable, however I find little info on how to properly "cache" this.

visual stag
#

you need to Apply your scriptable object when changes are made

frank gale
#

Ah yes, I forgot that part

#

Thanks

calm thistle
#

Hello ! I'm trying to replace '@' with '/' in the AnimationClip's internal name, and it works great on asset creation/move :

#

Problem is it doesn't work when I'm just renaming assets. Here is the code :

#

I tried a bunch of solutions (SerializedObject, AssetModificationProcessor, ForceReserializeAssets, GetPostprocessOrder) but none of them work. Any idea ?

burnt dove
#

Why each time I modify a gameobject's component in the inspector the component is serialized several times? I just put ISerializationCallbackReceiver and a Debug.Log("Hi") and I noticed that the message is logged 15 times when I modify the component... not 1

waxen sandal
#

Is it in a custom editor?

#

Maybe it's just a shitty editor

burnt dove
#

Is it in a custom editor?
@waxen sandal Yes, but actually it uses DrawDefaultInspector + one button

shrewd remnant
#

How to limit character in EditorGUILayout.IntField

#

?

waxen sandal
#

I'd just check the input after and round it but not sure if there's an official way

onyx harness
#

There is, but it's a pain in the ass

#

You need to toy with TextEditor

shrewd remnant
#

@onyx harness I i did that to achive so far

#

after all working well

cinder wave
#

Hello Guys! Any idea why my Project Preferences show um like that? How can i fix it?

#

show up*

uncut snow
onyx harness
#

@uncut snow EditorApplication.hierarchyWindowItemOnGUI

uncut snow
#

thx^^

charred kettle
#

Sorry if this is not the right channel. How can I get a scrollbar on the inspector window? I have many elements in my 'indices' component but I can't scroll down to see all of them

waxen sandal
#

It should just be there

#

Is that a custom editor?

charred kettle
#

it's not

onyx harness
#

You have a bigger issue

#

All your Editors are slightly cropped

waxen sandal
#

Yeah something is fucking with your editor

charred kettle
#

Fixed. it was the imported project that caused this

deep wyvern
#

Is there a way to find all references to an instance of a SO ?

onyx harness
#

NG Asset Finder Free

#

Or lookup through files

deep wyvern
#

I wanted to do it via script

#

So I can have a button in my inspector that makes a popup to show where it is being referenced

onyx harness
#

No API available

deep wyvern
#

yeah I figured this is going to be a ride ^^

onyx harness
#

I provide an API in NG Asset Finder, but it's not quite direct and straightforward

#

You have to implement some stuff to scan

deep wyvern
#

@waxen sandal If I understand correctly that would get me every object of the type of SO that I am looking for?

waxen sandal
#

More or less

#

Should just try them and see if that's good enough for you

onyx harness
#

Not at all

#

It collects dependencies

#

You are looking for references

#

Exactly the opposite

deep wyvern
#

yeah

#

I tried it and it only got me the script and the instance so its not what I am looking for

barren elk
#

very basic but related none the less, how would i get the worldspace position of the editor camera? i've gotten the rotation just fine, but the position is a rect?

#

very basic but related none the less, how would i get the worldspace position of the editor camera? i've gotten the rotation just fine, but the position is a rect?
@barren elk solved, SceneView.lastActiveSceneView.camera.transform.position;

frank gale
#

Hey there, is there a way I can make use of PropertyField to draw my own UEventFloat that derives from UnityEvent<float>?

#

Oh never mind, just add [Serializable] on top of the class

waxen sandal
#

Anyone ever ran into this while starting a coroutine right after starting Unity?
Couldn't extract exception string from exception of type StackOverflowException (another exception of class 'NullReferenceException' was thrown while processing the stack trace)

#

In a DelayCall of course

#

It hits that on the first yield

shadow parrot
#

is there any way to swap assets and keep properties, i have this game and I want to swap this cube out for a car model, can I do that? and how

solid parrot
#

ReleaseAllScriptCaches did not release all script caches!
Does anybody know why this pops up when I open the editor?

Sometimes it appears, sometimes it doesn't, but regardless, the project I'm working on runs fine. Still--I can't help but feel that my project is fucked in some way.

mild reef
#

Does anyone know why GetWindow creates a new instance of the window even though the description of GetWindow says it will look for an instance first?

#

This only happens if the window is docked...

queen cliff
#

hi

#

anyone knows the difference between IMGUIcontainer and VisualElement?

visual stag
#

VisualElement is just the base container

#

and IMGUIContainer draws IMGUI content

deep wyvern
#

Did something change in 2020 that you cannot pass in a enum serializedProp into a prop field anymore?

#

Nvm I just had some super weird VS bug

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

tired basalt
#

Anyone knows how can I check if a gameobject is a prefab or not?

onyx harness
tired basalt
#

Oh I'm dealing with nested prefab btw

onyx harness
#

Why do I even waste my time answering

tired basalt
#

stray hemlock
#

Its regarding a problem with Undoing a propertyfield

stray hemlock
#

Plssssss

craggy latch
#

At some point (no idea when) Undo.RecordObject stopped working for me. I have no idea what could be causing it but it just doesn't record the action now. No error or anything. It just... doesn't do anything. Any ideas?

plucky cedar
#

i need to run some code when the unity editor is saved.

public class SaveHandler : UnityEditor.AssetModificationProcessor {

    public delegate void Notify();
    public event Notify UnitySaved;

    public static string[] OnWillSaveAssets(string[] paths) {
        
        string scenePath = string.Empty;
        string sceneName = string.Empty;

        foreach (string path in paths) {
            if (path.Contains(".unity")) {
                scenePath = Path.GetDirectoryName(path);
                sceneName = Path.GetFileNameWithoutExtension(path);
            }
        }

        if (sceneName.Length == 0) return paths;

        return paths;
    }
}```
#

that unfortunately is static, so i cant add the event that i made at the top of the class

#

is there a non static alternative or a workaround?

#

i need to call a method in a editor script when the project is saved

#

ping me please

waxen sandal
#

Make your event static?

plucky cedar
#

then you cant add listeners

#

from other classes

formal thistle
#

Can somebody lead me trough how to make a game like Scrutinized or Welcome to the game 2

deep wyvern
#

So if I use Resources.FindObjectsOfTypeAll it seems to find every object in the scene but only assets from the project folders if I have selected them once during the session. Is there a way around it so I can find all objects regardless of having selected them before?

chilly stone
#

@deep wyvern AssetDatabase methods

deep wyvern
#

what does this mean "In Editor, this searches the Scene view by default. If you want to find an object in the Prefab stage, see the StageUtility APIs." ? What the stageUtility being used for? and what exactly IS "prefab stage"?

onyx harness
#

When you edit (open) a prefab

#

The prefab you see resides in a Prefab Stage

obsidian thunder
#

i set the prefab as dirty with EditorSceneManager.MarkSceneDirty(prefabStage.scene)
how do i force-click the 'Save' button from script?

waxen sandal
#

That's against like all UX principles

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

waxen sandal
crude horizon
#

hello guys, today is my first day doing Editor Scripting, I made a small editor but can align things properly in it

#

How do I align all the options on the red line?

#

Like the first option

vapid scarab
#

anyone have any ideas on how i can embed the unity animation preview window into my own custom editor?

onyx harness
#

@crude horizon show us some code

crude horizon
#
EditorGUILayout.BeginHorizontal();
        GUILayout.Label("GameObject containing Text Component(s)", GUILayout.Height(20));
        go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Match Color", GUILayout.Height(20));
        matchColor = EditorGUILayout.Toggle(matchColor);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Match Size", GUILayout.Height(20));
        matchSize = EditorGUILayout.Toggle(matchSize);
        EditorGUILayout.EndHorizontal();

        if (!matchSize)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Font Size", GUILayout.Height(20));
            fontSize = EditorGUILayout.FloatField(fontSize);
            EditorGUILayout.EndHorizontal();
        }

@onyx harness This is how I arranged everything

vapid scarab
#

or any pointers on how to make a similar functional preview window appreciated too

onyx harness
#

I advise you to use label from ObjectField and Toggle

#

instead of drawing the label yourself

crude horizon
#

Sorry I didn't catch you

onyx harness
#

Methods ObjectField(), there are many overloads

#

Use the one providing a label

#

and use EditorGUIUtility.labelWidth to adjust the width of the label

crude horizon
#

Can you write me one small example?

onyx harness
#

ObjectField("GameObject containing Text", go, typeof(GameObject), true)

crude horizon
onyx harness
#

Yep, that's the way

crude horizon
#

The text hides below

#

tho

onyx harness
#

labelWidth, like stated above

crude horizon
#

oh ok

#

EditorGUIUtility.labelWidth comes at the end right?

onyx harness
#

no no, before

#

it sets the width

#

the right way

#

1/ Is to save it to a variable.
2/ Set your intended width.
3/ Draw.
3/ Restore the width

crude horizon
#

Gotcha

#

thnx alot

gloomy chasm
#

In UIToolkit, how do you have an element that doesn't affect vertical layout but still expands horizontally?

#

I want basically to make a background out of several elements.

uncut snow
#

Hi, is there any way to convert a single binary saved scene to text based scene ?

snow bone
#

i'm trying to validate a variable and want to show a message in the inspector when it fails, how can i do this please? google isn't throwing me anything useful

#

OnValidate doesn't seem to be overrideable in an Editor script

shy bough
#

is there an equivalent of the AssetPostProcessor but for when assets are deleted from the project?

#

nevermind - found it ... AssetModificationProcessor

onyx harness
#

Hey @visual stag, sorry to ping you, but can I DM you?

visual stag
#

Sure

plucky cedar
#

i have a mesh that i want to paint in the editor, how would i do that

#

i already have the collision detection and raycasting from the editor, i just need the actual mesh painting to work

barren moat
#

What's the idiomatic way to manage cached data that is derived from project assets. I would like to create assets within the Library/ folder as Unity does, but I'm not sure what the best way to go about this is. Should I just be calling AssetDatabase.CreateAsset(myCache, "Library/MyExtensionName/MyCache.asset")?

onyx harness
#

Yes

wispy delta
onyx harness
#

Looks nice

wanton kindle
#

what's the recommended way of handling multi-selectable VisualElements? Ideally there'd be something like a custom pseudo-class, but it doesn't seem like that's possible...

waxen sandal
#

Is there a way to remove a file created in the library folder with InternalEditorUtility.SaveToSerializedFileAndForget?

onyx harness
#

AssetDatabase?

#

Save To Serialized is useful for assets outside the project, since Library is inside, there's no use @waxen sandal

#

And SaveTo is kinda dangerous if you don't grasp correctly it's behaviour

waxen sandal
#

CreateAsset doesn't work in Library, perhaps in newer versions but I'm on 2018.4

onyx harness
#

Sounds strange

waxen sandal
#

So I assume other things don't work either

#

I don't recall ever seeing assetdatabase working outside of assets/packages

onyx harness
#

AssetDatabase works at the root project level

#

Assets is just one folder inside

#

That's why you have to prefix all your paths with 'Assets/'

#

Because you can write to ProjectSettings and others

waxen sandal
#

That doesn't explain the error I get 😛

onyx harness
#

Which error?

waxen sandal
#

Don't have the project open atm, will let you know in a bit

waxen sandal
#

@onyx harness

Startup failed: UnityEngine.UnityException: Creating asset at path Library/test.asset failed.
  at (wrapper managed-to-native) UnityEditor.AssetDatabase.CreateAsset(UnityEngine.Object,string)```
#

with AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<ModifiedReferencesData>(), "Library/test.asset");

onyx harness
#

Let me give it a try in 2018.4 as well

onyx harness
#

@waxen sandal looks like you are right! Creating seems forbidden, while loading is fine

waxen sandal
#

Interesting...

#

The fuck Unity

#

Ah well, I'll just keep my SaveToSerializedFileAndForget

onyx harness
#

SaveToSerialized will create an Object that will survive domain reload! Be careful with it

waxen sandal
#

Thanks 👍

chrome dock
#

Trying to piece together how to make custom editor, and I can't seam to figure out how to make EditorGUILayout.Toggle clickable to change the class's boolean property "controlsEnabled"

[CustomEditor(typeof(PlayerController))]
public class PlayerControllerEditor : Editor { 

    public override void OnInspectorGUI() {
        PlayerController controller = (PlayerController)target;

        if (controller.controlsEnabled) {
            EditorGUILayout.Toggle("Controls Enabled", controller.controlsEnabled);
        } else {
            EditorGUILayout.Toggle("Controls Disabled", controller.controlsEnabled);
        }
    }
}
iron coyote
#

Trying to piece together how to make custom editor, and I can't seam to figure out how to make EditorGUILayout.Toggle clickable to change the class's boolean property "controlsEnabled"

[CustomEditor(typeof(PlayerController))]
public class PlayerControllerEditor : Editor { 

    public override void OnInspectorGUI() {
        PlayerController controller = (PlayerController)target;

        if (controller.controlsEnabled) {
            EditorGUILayout.Toggle("Controls Enabled", controller.controlsEnabled);
        } else {
            EditorGUILayout.Toggle("Controls Disabled", controller.controlsEnabled);
        }
    }
}

@chrome dock
shouldn't it be:
controller.controlsEnabled = EditorGUILayout.Toggle("Controls Enabled", controller.controlsEnabled);

onyx harness
#

The return

#

You don't use the return

chrome dock
#

That does work, and somewhat make sense. (I am very new to custom editors)

onyx harness
#

Don't worry it's all fine

#

We all started somewhere

iron coyote
#

Yeah it's a bit confusing. Took me hours to figure it out the first time too lol

chrome dock
#

and I have to eventually get to the point to use a reorderable list of inherited classes 😓

#

but gotta start small with the easier scripts that could use an editor overhaul

chrome dock
#

I keep getting an error on

if (controller.controlsEnabled) {

Saying
“Mismatched types in GetValue - return value is junk. UnityEditor.SerializedProperty:get_vector3value()”

It works as expected in editor, but throws an error afterwords

iron coyote
#

Um... is controlsEnabled a boolean?

chrome dock
#

yes

iron coyote
#

I wonder if your controller is being destroyed before oninspectorgui is being called, I'd try adding if(controller != null) before and see if that fixes it

chrome dock
#

I am just utterly confused. I slapped that around the entire oninspectorgui right after controller = (PlayerController)target, and the error stopped. I removed that if statement, and the error doesn't come back... (Yes, it was saved before doing if(controller != null) when originally giving error)

iron coyote
#

Well, there's a lot of things that /could/ be wrong, but off the top of my head the two major issues could be the old script was cached and unity didn't update it after the save, or there was an instance of the old script running that shared the same memory as the new one and when you updated the script with the if statement unity killed that instance

sturdy lynx
#

[Header("Insert_Thing_Here")]

vestal sand
#

How do I change Alpha of a TTMPRo text using LeanTween?

drifting forge
#

I tried assigning a new BG color style with GUIStyle bgColor = new GUIStyle(); bgColor.normal.background = EditorGUIUtility.whiteTexture;
But it didn't do anything

remote yarrow
#

UIToolkit pros ... have you found a way to find out the size (especially "height", but width would be great too) of text elements in UIToolkit / UIElements?

...the obvious method (MeasureTextSize) is useless when building UI (not documented, but according to a Unity forums post: it only works AFTER you've displayed the UI).

In UnityUI this was fiddly but worked - is that the best workaround, to generate UnityUI objects and use them to calculate size instead?

waxen sandal
#

Look at the source?

remote yarrow
#

Um. It's native code. How do I see the source?

#

OK, so ... using UnityUI instead of UIToolkit actually works - but you have to guess a font + font-size (I don't know how to read the default font + font-size in UIToolkit, but if you try to read them back from a plain Label you get null data):

TextGenerator textGen = new TextGenerator();
        Font unityFont = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).font; 
        TextGenerationSettings generationSettings = new TextGenerationSettings()
        {
            font = unityFont,
            fontSize = 14,
            fontStyle = FontStyle.Normal,
            lineSpacing = 1f,
            pivot = Vector2.zero,
            scaleFactor = 1f,
            horizontalOverflow = HorizontalWrapMode.Overflow,
        };
        float labelHeight = textGen.GetPreferredHeight(""+item.cssPadding.top, generationSettings);
#

If anyone knows how to read the current / default / global stylesheet info, I could update that to have correct values, but ... I can't find a way to access them (I've just re-read the full UIToolkit docs again, and done a lot of google searches, but nothing)

zinc kelp
#

weird question maybe, but is there a way to have two different project windows (where you view files etc.) that aren't linked together in the editor?

#

I wanna be able to view my scenes at all times, but if create two project windows and double click an item they both sync up

onyx harness
#

yes

zinc kelp
#

how would you go about that?

onyx harness
#

Lock them

#

or lock one of them

zinc kelp
#

oh wow, that was easy

#

thanks 🙂

chrome dock
#

I finally got to the point of using the baked in (still lack of documentation) ReorderableList, but i’m a bit unsure on this new (to me) EditorGUI. Every tutorial ive found tells me to use EditorGui.PropertField, but for one variable I need a TextArea. Is it ok to use them, or is there some issue with doing so like it not connecting to the variable to update from editor?

visual stag
#

You could use a PropertyField and just add a [TextArea] attribute to your field

chrome dock
#

oh, ok

chrome dock
#

that definite;y seams to work.

One other question. I have class Dialogue (Which is used on its own) that I created a custom editor for (which has a reorderable list), and then I have DialogueAction, which uses Dialogue class as a property. I have been searching on google, but maybe the words I am using aren't the right ones. But how do I use the existing editor for Dialogue in my DialogueAction so that I don't have to repeat all the ReorderableList stuff again (and update all places its used from one source)?

chrome dock
#

I could go back to what I was doing before, where i just made DialogueAction require Dialogue to be on gameobject with [requirecomponent] and automatically grab it on awake, but i kinda want to have it all in one nice panel if possible.

(I kinda need to have it in same panel, because in future, I need to implement a similar feature, for a reorderablelist that can use multiple classes that originate from Action- which will have to run the classes in order)

remote yarrow
#

I'm not quite sure I follow (I have no idea what all your class names mean) but - have you looked at Custom Property Drawers? Sounds like that's what you're looking for (they have a lot of ... um ... "design flaws" ... so they don't quite work the same as everything else, most of which I consider "bugs", but most people have now memorized the differences + workarounds for the differences, so ... we just suck it down these days :))

#

(and for the most part they work great, to be clear. It's just there are edge cases that work badly)

drifting forge
#

ahhhh

#

this editor extension stuff can be so frustrating

onyx harness
#

What exactly?

drifting forge
#

Im displaying a grid of buttons. And trying to surround if with beginScrollview, but when the buttons get too big, it expands my element

#

ill make a screenshot

#
    {
        GUIStyle textureButtonStyle = new GUIStyle() { margin = new RectOffset(1, 1, 1, 1)};

        int widthCount = _voxelPalette.width;
        int heightCount = _voxelPalette.height;

        subTextureSelectionScroller = EditorGUILayout.BeginScrollView(subTextureSelectionScroller);

        int buttonSize = 128;
        
        GUILayout.BeginHorizontal(GUILayout.MaxWidth(380));
        for (int x = 0; x < widthCount; x++)
        {
            GUILayout.BeginVertical(GUILayout.MaxHeight(230));
            for (int y = heightCount - 1; y >= 0; y--)
            {
                if (GUILayout.Button(_subTextures[x + y * widthCount], textureButtonStyle, GUILayout.Width(buttonSize), GUILayout.Height(buttonSize)))
                {
                    int id = x + y * widthCount;
                    _voxelPalette.voxelTypes[_selectionGridIndexVoxelTypes].textures[_selectedSubTextureSide] = id;
                    UpdatePreviewObject();
                    HideSubTextureSelectionWindow();
                };
            }
        
            GUILayout.EndVertical();
        }

        EditorGUILayout.EndHorizontal();

        GUILayout.EndScrollView();
    }```
onyx harness
#

I suggest you go manual

#

Instead of GUILayout, use GUI for the buttons

drifting forge
#

for that i need to specify a rect though, dont i?

onyx harness
#

Or, you can try to put a flexible space at the end of each row

drifting forge
#

i dont know why this type of editor extension is so complicated to understand

#

i worked with the experimental grid feature a few months ago

#

and it was completely different

#

but so much better

onyx harness
#

Layout is not the easiest to tackle

#

stay with it then

drifting forge
#

lol actually maybe I should

#

i didnt think about that because when just looking to make editor extensions, every tutorial tells me to use this stuff

onyx harness
#

use what? GUI Layout?

#

it's the old stuff

#

but still working

drifting forge
#

yee it works pretty good

#

but the layouting is haaard

onyx harness
#

not really

#

but I understand it can drive people crazy

drifting forge
#

in the new thing, every element is a flex box

#

which is so handy and easy to understand

#

but maybe thats me because I use them in webdevelopment too

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

Stick with it then 🙂

foggy birch
#

One message removed from a suspended account.

onyx harness
#

then give more details

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

So this code works right?

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

Print the output

#

Try with very simple case

#

Make sure it works the way it should for simple stuff

foggy birch
#

One message removed from a suspended account.

onyx harness
#

Print it

#

Load, save, load, look if the output remain the same

foggy birch
#

One message removed from a suspended account.

onyx harness
#

🙂

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

Domain reload you mean

#

or compilation

foggy birch
#

One message removed from a suspended account.

onyx harness
#

yeah because restart I hear restarting a process, which in this case nothing survive 🙂

foggy birch
#

One message removed from a suspended account.

onyx harness
#

Oh you meant persistent then

#

Sorry, wording is a bitch, but they have precise definition to avoid confusion 🧙

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

Where do yall save your project and preference settings? I can't figure out a good way to do it without hardcoding in the path. :/

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

EditorPrefs, SessionState & Local AppData for global stuff

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

gloomy chasm
#

Oh yeah, that is cool. Didn't know it was a thing!

onyx harness
#

It's a reliable way to store data that must survive for the process lifetime

#

Nothing very special about it

gloomy chasm
#

What about Project settings? What do you do for those?

onyx harness
#

Data :

  • for plugin-level : use ProjectSettings (or AppData for global)
  • Editor/EditorWindow/PropertyDrawer-level : EditorPrefs
  • SessionState anywhere you need data that doesnt last but must survive domain reload
foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

I try my best to stay away from those, as it bothers users

#

But I'm a publisher, needs are different I understand

gloomy chasm
#

I will assume it is me just not getting it. But I want things to be stored per-project, so like they are included on github and stuff. I don't quite understand how one would do that.

foggy birch
#

One message removed from a suspended account.

onyx harness
#

Anything under root is supposed to be in the depot

#

ProjectSettings as well

foggy birch
#

One message removed from a suspended account.

onyx harness
#

Yes yes, it is a good place

gloomy chasm
#

What do you do @onyx harness if you don't put things in the ProjectSettings folder? Or do you?

onyx harness
#

I use InternalEditorUtility.LoadSerializedFileAndForget to load an asset in the AppData

foggy birch
#

One message removed from a suspended account.

onyx harness
#

I use it for global yes that's correct

remote yarrow
#

but maybe thats me because I use them in webdevelopment too
@drifting forge Not just you. Flexbox is literally 30 years ahead of Unity's own layouting systems (Unity's layout architecture was already 10+ years behind the idnustry standard when they first implemented it :))

foggy birch
#

One message removed from a suspended account.

remote yarrow
#

Uh ... or you could read the context. Ruby was saying that they thought Unity's new layout - UIToolkit - was easier to understand than the old one. I agree. I've been writing IMGUI editors for Unity since 2013 and I can do it in my sleep now, but I still recommend people use UIToolkit instead for inspectors.

drifting forge
#

i got lead down a completely new path of editor making now

#

found out there is a UI builder package

#

lowkey orgasming

foggy birch
#

One message removed from a suspended account.

drifting forge
#

just need to find out how I can insert some sort of selectable list

remote yarrow
#

What about Project settings? What do you do for those?
@gloomy chasm There's a lot of options here. There's a long forum thread about it. Depends what kind of project-settings you want to store, and what you're going to do with them :). For editor-extensions ... I tried all the clever stuff, and it all failed sooner or later (edge cases in Unity, things that are poorly integrated), so now I do:

  1. ScriptableObject with all the per-project settings
  2. Write code to prevent there being more than one copy of that file
  3. For Editor: auto-detect it at startup but NEVER use Resources.FindObjectsOfTypeAll (it's fundamentally broken for this, even though lots of people try to use it for this). Have to do more of a manual search using the Editor-only APIs
  4. For runtime: Fresources.FOOTA is fine.
gloomy chasm
#

@remote yarrow For using ScriptableObjects. How do you find them? Because of course, the user can move them.

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

I making a thing where the user can make collections of assets.

#

So I need to save each collection and all the assets in that collection. This is for editor only.

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

No, I store the asset GUIDs, not the actual assets or their paths.

#

I just need to know where a single ScriptableObject is located that stores all the collections.

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

What do you mean?

#

Oh, do you mean like how you set the scriptable render pipeline asset in the project settings?

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

I never thought of that. Now I am blanking on how you access Project settings data... :/

remote yarrow
#

You can't reference it in projectesettings because projectsettings has no persistence - you have to write your own code to de-persis

#

What I do at the moment is a combination of Object.Find methods - hang on, I'll dig out a recent example

#
public static List<MySettings> findAllPossibleProjectSettings
        {
            get
            {
                string[] guids = AssetDatabase.FindAssets( "t:" + nameof(MySettings) ); //FindAssets uses tags check documentation for more info

                List<MySettings> @return = new List<MySettings>();
                for( int i = 0; i < guids.Length; i++ )
                {
                    string path = AssetDatabase.GUIDToAssetPath( guids[i] );
                    @return.Add( AssetDatabase.LoadAssetAtPath<MySettings>( path ) );
                }

                return @return;
            }
        }
#

...a lot of trial-and-error went into that, and some bug reports submitted to Unity for e.g. "FindAssets" is currently undocumented and doesn't work unless you know the magic strings (I had to go in the Unity source to find them)

#

(but there's now a thread in the forums where unity team has given their input and asked for feedback on how we'd like it to behave in future, so I'm optimistic the API will get improved soon)

gloomy chasm
#

Oh, that isn't too bad ( I mean besides that it is a property and not a method :P
). Something like that is probably what I was going to do. Good to know I was on the right track!Thank you.

foggy birch
#

One message removed from a suspended account.

remote yarrow
#

you still need to handle what to do when it finds more than one result 😉 (I wrote a popup dialog that "strongly encourages" the user to delete one of them, since results are undefined otherwise)

foggy birch
#

One message removed from a suspended account.

remote yarrow
#

Ah! When you said Project Settings I thought you meant the feature in the editor, not the magic folder 🙂 - sorry!

gloomy chasm
#

No, I meant just in general. You answered exactly what I was asking! 🙂

foggy birch
#

One message removed from a suspended account.

remote yarrow
#

I would avoid using ProjectSettings folder because it has the same problem as all the other "smart" solutions: I fear it fails with core Unity features. Off the top of my head: isn't it impossible to have an AssetStore asset that has files in that folder? (because the assetstoretools package won't let you upload from it)

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

remote yarrow
#

I don't know. But I also can't find docs on the ProjectSettings folder, so that immediately makes me suspicious of it 🙂

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
remote yarrow
#

Last updated 4 days ago. That's probably an update from my bug report.

gloomy chasm
#

I mean I know I have used FindAssets before. And at least some of those docs were there.

remote yarrow
#

Off the top of my head: in source code there were 4-5 magic strings. I do not see 4 strings documented on that page.

foggy birch
#

One message removed from a suspended account.

gloomy chasm
#

What sort of magic strings?

remote yarrow
#

these "t:", "name:" etc

#

they control how FindAssets works

#

They cause Unity to instantiate an internal class that has some very useful methods on it that let you directly control what's being searched for

#

Off the top of my head: there's one for "include/exclude prefabs", and one for "only include assets, do NOT include scene objeects (or vice versa)"

#

If you feel it's fully documented, then great. I don't.

gloomy chasm
#

That is because it uses the same search that the project window uses

onyx harness
#

Last updated 4 days ago. That's probably an update from my bug report.
@remote yarrow lol are you being serious?

remote yarrow
#

Off the top of my head: it's not exactly the same, it uses the same internal hidden class, but it uses it slightly differently.

#

(but go dig in the source to see for yourself)

#

@remote yarrow lol are you being serious?
@onyx harness Honestly? When someone starts with swearing at me and calling me a liar? I lose interest fast.

#

If I cared ... I'd dig out the Unity bug reprot with Unity's repsonses, and we coudl go through in precise detail exactly what was missing. But ... see above comment. I don't really care.

onyx harness
#

"t:" was there since the beginning, when you type "t:AnyMonoBehaviour" in the Hierarchy, it behaves exactly the same, the doc is clear

#

Woah...

#

Liar?

remote yarrow
#

You're welcome to ignore me and e.g. use "Resources.FindObjectsOfTypeAll", because a lot of people believe it works (people who haven't tested it)

onyx harness
#

Da fuck you are talking about, i never talked about that

#

And we already had this discussion on the publisher forum

foggy birch
#

One message removed from a suspended account.

stark geyser
#

@whole steppe This is a channel for extending Unity editor. You can find VS and VS Code installation instructions in #💻┃code-beginner pinned on top right.

onyx harness
#

I have no idea how to automatically change icons for ScriptableObjects/Scripts depending on current theme
@foggy birch Not easy task

#

You must go through a SerializedObject

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx harness
#

Oh I see, my bad, I thought you were talking about changing a Script's icon

foggy birch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

fading monolith
#

I'm not sure if this belongs here so apologies in advance, but I've been trying to code a custom editor based off tutorial, and it's not drawing anything on screen
https://hastebin.com/ugurugoxub.csharp

#

there should be a circle around the red cube to indicate the viewRadius

fading monolith
#

ping me if you have a solution :P

gloomy chasm
#

@fading monolith ui in OnSceneGui is not capitalized, it needs to be.

#

So it should be private void OnSceneGUI() {}

fading monolith
#

Oh thanks!

#

that fixed it xD

#

I kinda knew it had to be a typo because it was exactly the same as the tutorial

#

So how would I make this rotate with the object it's attatched to?

gloomy chasm
#

I think changing from using the vector forward to using the target's transform.forward should do.

fading monolith
#

oh nice, and to keep the angle centered on the front of it?

stark geyser
#

Generally you can recognize Unity's reserved methods names being blue colored in VS.

fading monolith
#

fixed it xP

primal chasm
#

If a Serialized Property is of an int value how do I get a reference to that value to pass into EditorGUI.IntField
I'm trying to make a PropertyDrawer that will change the names of a generic int[] from Element0 to what I want it to say. I made the attribute already and can change the names using EditorGUI.ObjectFiled but that doesn't work since they are ints

    {
          try
        {
            var elementProperty = property.GetArrayElementAtIndex(0);
            int someX = 0;  
            int pos = int.Parse(property.propertyPath.Split('[', ']')[1]);
            EditorGUI.IntField(position, new GUIContent(((ArrayNameAttribute)attribute).elementNames[pos]),someX);
            
        }
        catch
        {
            EditorGUI.ObjectField(position, property, label);
        }
    }```
#

I need someX to be the actual reference to the int[x]

#

The renaming works fine. EditorGUI.IntField use to EditorGUI.ObjectField but that made the Inspector have an spot to drag an Object which didn't work

onyx harness
#

You have a member intValue in SerializedProperty

primal chasm
#

Yeah I tried this:

            EditorGUI.IntField(position, new GUIContent(((ArrayNameAttribute)attribute).elementNames[pos]),property.intValue);```
#

And it does generate text boxes to put in ints.. It starts out as 0 then if i type 10 and hit enter. . it instantly changes back to 0

onyx harness
#

because you never assign it

#

IntField returns an int.

primal chasm
#

weird then why does it take a property.intValue to assign to.. if I have to do the assigning 🙂

onyx harness
#

Wrong statement

#

it takes the intValue as argument

#

It's an integer, which implies a value type

primal chasm
#

Oh i see

onyx harness
#

🙂

primal chasm
#

So it keeps displaying the current value

onyx harness
#

Show me the change

primal chasm
#

Yeah that works correctly now

            property.intValue = EditorGUI.IntField(position, new GUIContent(((ArrayNameAttribute)attribute).elementNames[pos]),property.intValue);```
onyx harness
#

Good job

primal chasm
#

Is there way to get the type that a property is. So i could switch on it and have EditorGUI.FloatField, or EditorGUI.Toggle as approperiate

#

if its an int, float, bool whatever

onyx harness
#

propertyType

frank gale
#

Hello there, is there a way I can mark a PropertyField as ReadOnly?

visual stag
#

ReadOnly as in the field in the inspector is not editable?

frank gale
#

Yep

visual stag
#

Is this UIToolkit/UIElements or IMGUI

frank gale
#
EditorGUILayout.PropertyField(config.FindPropertyRelative("size"), new GUIContent("Font Size"));
visual stag
frank gale
#

Thanks

humble hinge
#

do you guys know if it would be possible in a simple way to somehow reuse the unitys prefab environment scene thing for other stuff? i mean creating a custom tool/extension, that could grab any gameobject (not necessarily a prefab), temporarily move it/isolate it into a seperate mini-scene to do some work and then just return it back to the normal scenes environment?

#

with emphasis on 'simple' here, so possibly existing unity API that would allow for this (one they already use for prefab workflow)?

waxen sandal
#

It's called prefabstage

#

Not sure if the api is generic yet but that was their plan iirc

frank gale
#

What is a good way of drawing a plain sprite in the OnInspectorGUI()?

waxen sandal
#

GUI.texture?

frank gale
#

That works... but I am looking for an auto layout option

#
if(sprite.objectReferenceValue != null) GUILayout.Label(((Sprite)sprite.objectReferenceValue).texture);
#

Currently I am casting the objectReferenceValue into Sprite, but the Texture property of a sprite is the whole texture sheet it belongs to, rather than the specific cut...

#

Guess I need to find a way of slicing that whole texture sheet and re-assemble the pixel back into a separate texture

blissful burrow
#

okay the heck

#

EditorGUILayout.PropertyField( x, GUIContent.none ); is usually my strat for making a labelless field

#

but for some reason it's not working in this context, I get an invisible label with a fixed width that I can still drag my mouse over to change values

#

anyone know what might be the reason?

onyx harness
#

remove the label ?

blissful burrow
#

what?

onyx harness
#

Use the override without a GUIcontent

blissful burrow
#

using the one without GUIContent will add the default label

onyx harness
#

Isn't that the right way of doing labelless?

#

oh ok

blissful burrow
#

no, usually it works by shoving in GUIContent.none

#

but in this case I get an invisible label that is still interactable and is taking up space

onyx harness
#

Did it happen suddenly? or after a Unity version change?

blissful burrow
#

no, it's in a specific situation where it doesn't work

#

nothing changed temporally!

#

I wonder if it's the indent level that might be messing it up

#

yep! that was it

#

indent level is applied to all GUILayout.things it seems

onyx harness
#

Good job

blissful burrow
#

I had them in a horizontal layout so things got fucky

waxen sandal
#

IndentLevle is only applied to editorguilayout things iirc

#

Which is really annoying since buttons don't have an EditorGUILayout equivelant

frank gale
#

Oh I found it

#
GUILayout.Label(AssetPreview.GetAssetPreview((Sprite)sprite.objectReferenceValue));
onyx harness
#

Good job

frank gale
drifting forge
#

is it bad practice to use the "Update" function for editor windows?
I'd like to continuisly check if 1 field is set, and depending on wether it has a value or no value, enable and disable other elements.

#

(I'm on the new UIElements stuff now, so - not working with OnGUI function)

onyx harness
#

Not at all

#

But your intention might be wrong, be careful

#

For checking enable stuff, rely on events instead