#↕️┃editor-extensions

1 messages · Page 67 of 1

lean vault
#

i think it was the mirror button idk

#

idk it was near edge loop thing

#

anybody even active?

lean vault
#

k now im at like 200 errors

flint escarp
#

Hi guys, Im having a problem with CustomPropertyDrawer:
I have a abstract class BaseProvider and a class Provider<T> : BaseProvider.

I also have a abstract class BaseElement : MonoBehaviour, it has a public List<BaseProvider> providers.
Then there's a component which derives from BaseElement and has a public Provider<bool> testProvider

I've declared a CustomPropertyDrawer(typeof(BaseProvider), true), it works for the list declared in BaseElement, but the field on the component isn't showing up

pale geyser
#

anyone know how to go about binding a list/array to a custom VisualElement (and detecting changes to it)?

#

currently attempt is this hacky thing, but surely this isn't how i'm meant to do it (and it doesn't update when the list changes): cs public class InspectorList : BindableElement { public override void HandleEvent(EventBase evt) { if (evt.eventTypeId == 38 && !string.IsNullOrWhiteSpace(bindingPath)) { var type = evt.GetType(); //for event type 38/setting the serialized object, it's SerializedObjectBindEvent which is internal SerializedObject obj = type.GetProperty("bindObject").GetValue(evt) as SerializedObject; array = obj.FindProperty(bindingPath); UpdateList(); } base.HandleEvent(evt); }

pale geyser
#

So i've got a bit further (still using that hacky thing to bind, but it seems to work fine). The issue i'm having now is using this code: https://hatebin.com/fqdjkatmhr , when I update the list by clicking the add or remove buttons, the property fields get recreated empty. The UXML is just <InspectorList name="HitList" binding-path="meleeHits" />

#

the log shows that the SerializedProperty is working as expected.. but the new PropertyField(property) seems to be creating an empty property field?

#

but only when i refresh it sometime after it was bound

#

Ah nvm I got it.. I needed to do propertyField.Bind(property.serializedObject); after creating it

austere adder
#

Does anybody know a way to quickly trigger a domain reload using a script?
I set Domain Reloading to off and it could be helpful when debugging to have a button that I can press that will trigger a domain reload

onyx harness
#

@austere adder

public static void    RecompileUnityEditor()
{
    BuildTargetGroup    target = Utility.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
    string                rawSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(target);
    // Force Unity Editor to recompile.
    // Thanks to darbotron @ http://answers.unity3d.com/questions/416711/force-unity-to-recompile-scripts.html
    PlayerSettings.SetScriptingDefineSymbolsForGroup(target, rawSymbols + "a");
    PlayerSettings.SetScriptingDefineSymbolsForGroup(target, rawSymbols);
}
#

For the button

austere adder
#

thanks!

austere adder
#

looks very useful

onyx harness
#

Yes?

#

😄

austere adder
#
[MenuItem("Tweaks/Recompile",priority = 0)]
static void Recompile() 
{
    UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
}

I found in the link from your code snippet a one liner solution. I'm probably going to use NG Hub for more complex tools but right now a simple menu item is enough

onyx harness
#

This method appeared very lately

#

Since 2019.3

#

If you work on recent versions, yeah take whatever suits you

austere adder
#

yeah

placid jackal
#

Hello guys! I have a question. Does is there any kind of check to Editor.target can be equals as root object from hierarchy?
What I want to achieve is : I have 2 objects with the same scripts ( child and parent ), and with editor script there is 2 scripts attached to both of them, + they have a button. I want button to be pressed only from root gameobject ( parent )

waxen sandal
#

transform.root is a thing right?

placid jackal
#

yes but

waxen sandal
#

Use hastebin to post code

placid jackal
waxen sandal
#

Well target is a monobehaviour so you just get the transform from that

placid jackal
#

I cant, because its not monobehavior

waxen sandal
#

What's tool then

placid jackal
#

its Editor.target

#

Tool this is my custom script

#

Oh i get

#

what you mean

#

stll didn't help

full vault
#

how i can draw gizmo in Editor script?

waxen sandal
#

You don't, you use handles

#

Idk if it works for editors

full vault
#

how i can enable/disable it?

lean vault
#

how can i play a sound when something = true?

hot crane
#

Anybody know if there is documentation on accessing the hide/visibility scene hierarchy through script?

real ivy
#

Anyone uses async/await in editor context?

waxen sandal
#

Nope

stark geyser
#

It was a nice way to manage animation without coroutines. But now there's a package for the Editor Coroutines.

visual stag
#

await's great, I wonder if it'd be easy enough to hook into Unity's editor update loop so you could yield back there similar to UniTask

real ivy
#

Im just starting but that's only bcoz i need to use AngleSharp, which uses it (at least in the example, so might as well learn it)
Just wondering what are ur use cases? Is it really just a more "proper" coroutine?

I tried EditorCoroutine, and i dont mind coroutine in general except for the fact it can't return unless u do the Action<Image> callback stuff.
Actually, i dont really mind that either.

So basically the other question is, why await/async over coroutine?
(This is getting further from editor specific...)

lucid hedge
#

Is there a way to change Unity built in preferences by script?

onyx harness
#

what is a built-in preferences?

lucid hedge
#

I just mean like these

#

the preferences I didn't add myself

#

if I know the key, can I just do EditorPrefs.SetInt(key, value);

#

?

#

I'll go check the registry to see the key

onyx harness
#

The classe used is UnityEditor.PreferencesProvider

#

Which is internal

#

Almost all the things used is in PreferencesProvider

#

So yes to answer you, you can do it by script. @lucid hedge 🙂

lucid hedge
#

Okay

#

Specifically I wanted to change the shader variant limit and it seems they use this key

#

So I'll do some testing

onyx harness
#

If it works, it works

waxen sandal
#

Can't you load them as a serializedobject?

onyx harness
#

Settings are not objects

#

Some might

#

But most are displayed manually

austere sun
#

how can I conditionally hide an array in the inspector?

waxen sandal
#

Write an editor that does the check

austere sun
#

I tried making an attribute for it, but the drawer gets the entries of the array rather than the array itself...

waxen sandal
#

Yep...

austere sun
#

so if it is impossible with an attribute, how else do I do it then?

waxen sandal
#

An editor

#

Not a property or attribute drawer

austere sun
#

is this a unity limitation or a c# limitation?

waxen sandal
#

??

austere sun
#

the fact that attributes apply to entries of the array rather than the array itself

waxen sandal
#

You gotta pick either of the methods, Unity picked for elements

onyx harness
#

Unity's limitation/design

austere sun
#

that sucks

onyx harness
#

From Unity 4.2 or around

waxen sandal
#

Sucks for you maybe, is great for someone else

austere sun
#

sure

onyx harness
#

that sucks
@austere sun You're not alone, I feel it sucks too 🙂

austere sun
#

so basically a 'drawif' attribute it useless since I need to write custom editors for classes that have arrays anyways

#

and there's no generalization that I can do?

onyx harness
#

or you would need to wrap the array in a class

#

Much uglier, and makes the PropertyDrawer works

austere sun
#

hmmm

#

that might actually not be a terrible idea

#

I constantly hit walls like this when working with unity for some reason

onyx harness
#

It's sad they didn't provide an option to select between entries and the array

austere sun
#

yea

waxen sandal
#

Well now you have a drawer for it

#

So you can fix it

#

I wonder if you can inherit from List<T> and do a drawer as well

#

Since it's not directly a list

vast needle
#

Hi, does anyone know whether or not it is possible to disable 3rd party CreateAssetMenu? Ideally I would like to hide it completely.

#

The most obvious solution is to remove it from code. But the code might be precompiled into a DLL. Second problem with that solution is future updating.

#

Is there any other way?

onyx harness
#

@vast needle Not sure it will work, but check UnityEditor.Menu

#

It literally has a method RemoveMenuItem()

zenith holly
whole steppe
#

Anybody using UIElements?

#

I wanted to know, how do you make a ListView expand with it's number of child elements?

vast needle
#

@onyx harness I love you man!

onyx harness
#

Did it work?

vast needle
#

@onyx harness I could not test it yet. I just managed to find out its internal. I will give it a go tomorrow with some reflection magic

#

There is also a question of when to call it.'

onyx harness
#

Anytime

#

Isn't it public? At least in 2019.4

vast needle
#

@onyx harness It is internal in 2019.4.3f1

rotund dune
#

How do I get my UI Editor to work for child objects? Eg.

[CustomEditor(typeof(item))]```
Then the Inspector class would apply it to childs of ``item``, rather than just ``item`` itself?

For context, I'm making a dropdown selection for the type of ``item`` it's going to be (the component gets replaced by the child of the base class)
rotund dune
#

Overloading would be for methods, right?

waxen sandal
#

Constructors can be overloaded as well

onyx harness
#

Add ', true' after 'item)'

rotund dune
#

Constructors can be overloaded as well
Hmm. This particular class isn't derived from the Editor, but derived from MonoBehaviour (since it's a component). Perhaps maybe a misunderstanding due to the lacking context. Thanks for trying though.

Add ', true' after 'item)'
Worked perfectly. Thank you.

waxen sandal
#

When you apply an attribute to a class you create an instance of that type

#

Thus invoking the constructor of that type (In this case CustomEditor)

#

Thus you need to invoke one of the constructor overloads which enables the custom editor for derived classes as well

#

Which is what you're doing by applying Mikilo his suggestion

rotund dune
#

Ooh, ok! I understand now. Thank you

rotund dune
#

How would I go by with "invoking" the constructor?

#

With your approach

waxen sandal
#

Literally the same as you're doing now

rotund dune
#

Hmm, excuse my newbie knowledge.

#

I'll have to research Invoking and attributes.

onyx harness
#

@onyx harness It is internal in 2019.4.3f1
@vast needle Just tested it in 2019.4.0f1, and it worked surprisingly perfectly

vast needle
#

@onyx harness but it was internal, right?

onyx harness
#

Yep, the method yep

vast needle
#

Btw thx for testing it

#

where did you call it? I mean - in some InitializeOnLoad callback?

onyx harness
#
var m = typeof(Menu).GetMethod("RemoveMenuItem", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
m.Invoke(null, new object[] { "Assets/Create/Shader" });
#

I tested it throught a MenuItem

#

I didnt try with InitializeOnLoad, might work differently, since it is the first frame

#

But you can call a delay from it, should work

vast needle
#

Ok, I will give it a go. I hope I can fully automate it.

onyx harness
#

should not be an issue

onyx harness
#

You can't paste big chunk of code

wanton monolith
#

All my searches lend me to questions posted in 2011-2012

#

Has unity ever introduced a feature that allowed you to change the default folder a specific type of asset gets created in?

#

Specifically creating a script through a gameobject?

#

Or maybe creating an animator or an animation through the animation window

onyx harness
#

Unity never implemented such thing

#

But it's not hard to implement

wanton monolith
#

i am just disappointed because that should be a thing already

waxen sandal
#

I don't anyone really uses it tbh

steady crest
#

why should that be a thing.

#

you can set it up but its workflow and project specific so there rly is no point

waxen sandal
#

You should be able to change it

#

There's no reason it should be in the root if all your scripts are in some asmdef

placid jackal
onyx harness
#

Nope

#

It must be a C# Type

keen pumice
#

Looking for confirmation, (hoping I’m wrong):
Some types can be displayed directly (using and returning an instance of the object), with GUI and EditorGUI functions like IntField, FloatField or BoundsField.
But there is NO built-in method to display these types as an array or List, WITHOUT using a SerializedProperty. Is this correct? ? (I can roll my own, or create a temporary SerializedProperty, which is fine, just wanted to confirm this is necessary before I do so.)

onyx harness
#

Displaying an array is a bit boring, but completely fine and doable without SP

#

You can even use UnityEditorInternal.ReorderableList if you are lazy

waxen sandal
#

Even if it's a bit boring, everyone just seems to implement a shitty array

#

While the Unity array has a bunch of small features that make it easier to work with

keen pumice
#

Yes, this IS about being lazy! I don't want to do it it I dont have to 🙂
hmm.. Unable to find official docs on ReorderableList 😦

waxen sandal
#

There are none

#

That's why it's in UnityEditorInternal

#

IIRC Aras is putting effort into getting it into Unity 2020

keen pumice
#

hmm,, all the examples I'm finding for it.. DO use a serialized property.. should I keep searching for a variant that doesn't?

waxen sandal
#

Oh yeah ReorderableList is pretty reliant on serialized property iirc

onyx harness
#

Lol

#

not at all

#

It just displays element of a list

#

Just that

#

Ok ok, it can rely on SO & SP

#

But it is just a wrap

keen pumice
#

test 123

waxen sandal
#

456

onyx harness
#

789

waxen sandal
#

0-=

keen pumice
#

hmm, I pasted in some code and my post vanished.. odd

waxen sandal
#

Ah yes

#

Use hastebin

keen pumice
waxen sandal
#

Ah yeah

#

If you click on the line number you can link the specific line

keen pumice
onyx harness
#

Dont post big chunk of code, or you will be temporarily banned

keen pumice
#

thanks guys! helpful as always ❤️

onyx harness
#

I find it much faster to use VS or ILSpy/dnSpy to lookup stuff

waxen sandal
#

If you have an ide open yeah 😛

severe python
#

its only a matter of time before you can do that stuff on github I'm pretty sure

#

they already have it for typescript

onyx harness
#

I saw it for PHP

#

Most of the type I just need the definition, not the whole implementation, which make the an IDE ideal, but yeah you need one around

real ivy
#

In editor, how to save Texture, but as Sprite?

var bytes = ((DownloadHandlerTexture)www.downloadHandler).texture.EncodeToPNG();
File.WriteAllBytes(path, bytes);

Something goes between there.
Do i save the Texture, do Sprite.Create, then do AddObjectToAsset to the texture?

onyx harness
#

Nope you just need to set the asset as a Sprite

real ivy
#

How do i do that other than selecting all texture then in inspector change to Sprite in the dropdown?

feral otter
#

i dunno where else to ask this question but is 2020.1 supposed to have so many loading times?

onyx harness
#

Do you have more specifics?

feral otter
#

it doesn't usually show hold on every time i modify a script

shadow moss
#

I'm populating a Tilemap, and I'm creating Tiles via ScriptableObject.CreateInstance. I then set the sprite to the tile, and then set the tile in the tilemap

#

I'm targeting Windows, and of course, this is inside an editor script. Does anyone know what could be wrong?

#
Tile tile = ScriptableObject.CreateInstance<Tile>();
tile.sprite = sprite;

var position = new Vector3Int(0, 10, 0);

var importedTileTransform = goTilemap.GetTransformMatrix(position);

goTilemap.SetTileFlags(position, TileFlags.None);
goTilemap.SetTile(position, tile);
goTilemap.SetTransformMatrix(position, importedTileTransform);
goTilemap.SetTileFlags(position, TileFlags.LockAll);

goTilemap.RefreshAllTiles();
#

sprite is not null either

cunning depot
#

I have VS as my editor in unity I have 2 editors for work one is VS and one is atom in unity I have VS as the editor but it opens Atom rather than VS help m

shadow moss
#

Okay, regarding my problem above, I added a SpriteRenderer to check if it even displays, and it does

shadow moss
#

Gah, I'm not seeing the problem here

austere sun
#

can I find the default implementation of the OnGUI method for property drawers somewhere?

onyx harness
#

dnSpy and good luck

#

or ILSpy

#

or Unity Reference source code

onyx harness
#

Why UI?

austere sun
#

because it has to do with ui

onyx harness
#

Hum... I will help you

#

Because you are very far from the truth XD

austere sun
#

lol rip

onyx harness
#

Do you have a particular property drawer in mind?

#

Cuz I won't show you the code of every PD

austere sun
#

there are multiple? 👀

onyx harness
#

There is a PD for many things yeah

austere sun
#

I just want to mimic that nested stuff

onyx harness
#

Is that an enum?

austere sun
#

no im not talking about the enum specifically

onyx harness
#

SpecialLayer is of a certain Type, right?

austere sun
#

yes

onyx harness
#

This Type is serializable

austere sun
#

yes

onyx harness
#

SerializedObject (SerO) will wrap it and provides you a SerializedProperty (SP)

#

From the SP, you can easily draw it

austere sun
#

maybe I need to give more context

onyx harness
#

By defining a PropertyDrawer for the Type above.

#

Please do

austere sun
#

but it's quite a story

onyx harness
#

go straight to the point

austere sun
#

okay so I'm trying to make an attribute so that certain fields only get drawn when a condition is met (ie. an enum in the class instance has a particular value)

onyx harness
#

Use this

austere sun
#

does that work for arrays?

onyx harness
#

Hum... Can't tell

#

Don't remember

#

But i should work for your Type which is a class

#

not an array

#

isn't it?

austere sun
#

yes but I want it to behave differently when its part of an array

#

wait let me show a screenshot

#
using UnityEngine;

[CreateAssetMenu(fileName = "New Test", menuName = "Test/Test")]
public class TestObject : ScriptableObject {
    public TestThing testThing;
    public TestThing[] testThings;

    [System.Serializable]
    public class TestThing : IDrawConditioned {
        public Foo foo;
        [DrawIf("foo", Foo.Sliding)] public Bar bar;
        [DrawIf("foo", Foo.Static)] public Sprite sprite;
        [DrawIf("foo", Foo.Animated)] public Sprite[] frames;
        [DrawIf("foo", Foo.Sliding)] [DrawIf("bar", Bar.Alpha)] public string hi;
        [DrawIf("foo", Foo.Sliding)] public float speed;
        public bool always;

        public enum Foo {
            Animated, Sliding, Static
        }

        public enum Bar {
            Alpha, Beta, Gamma
        }
    }
}
#

how it looks in the array currently is exactly what I want

#

except of course still keep the functionality of hiding things

onyx harness
#

As expected, it half works on array

austere sun
#

yours you mean?

onyx harness
#

Yep

austere sun
#

with 'half' you mean you still see count and the name?

#

cause I had that issue earlier today

onyx harness
#

To deal with array, you either need to write an Editor, or wrap the array in a class

#

Exactly

austere sun
#

but the array works

#

do you want me to share my drawer?

onyx harness
#

In your case, you already wrapped your array in a class

austere sun
#

no I didnt

onyx harness
#

Isn't TestThing the wrapping class?

austere sun
#

no

#

that is just an arbitrary class

onyx harness
#

of shit I misread your pictures above

#

You wrote a PD that flatten the class

austere sun
#

uh... ? 👀

#

what do you mean by flatten?

onyx harness
#

Members of a class are supposed to be foldable

austere sun
#

oh like that

#

yes

#

which is what I want for when it is an element in an array, but not when it is not

onyx harness
#

"You want it to be foldable like so" (everything is showing),
"except of course still keep the functionality of hiding"
So... Do you want to hide or show? I'm quite confused

austere sun
#

in that screenshot all fields of TestThing are shown

onyx harness
#

Oooooh, you are talking about flattening the Class in an array, but keep the parenting when not in an array

austere sun
#

while in the screenshot before that (when it was part of an array) only the fields that should be drawn were drawn

onyx harness
#

Show me your PD then

austere sun
#

yes exactly

onyx harness
#

It's suppose to be easy

austere sun
#

sorry for being confusing 😅

onyx harness
#

You have a propertyPath

#

If the path contains an "array member", you flatten

#

end of the story

austere sun
#

the drawer is > 2000 chars

onyx harness
#

Just gave you the solution

#

Try it and come back

#

Good luck

austere sun
#

no it is not as simple as that

#

I know how to detect when it is in an array or not. I don't know how to make the foldout work

onyx harness
#

Please be very explicit

#

I'm getting confused

#

Which foldout?

#

Because you got few

austere sun
onyx harness
#

I see 2 foldouts

austere sun
#

showing \🔽 Test Thing

onyx harness
#

How did you manage to flatten in this one?

austere sun
#

because in the current implementation, it draws it like this (indentlevel 0 and no 'Test Thing' label nor an arrow)

#

that one has both a TestThing and a TestThing[] field

#
    public TestThing testThing;
    public TestThing[] testThings;```
#

the first three fields shown there (Foo, Frames, Always) are part of the testThing field

#

but they're not indented under a Test Thing label

#

am I making sense or am I only making things worse?

onyx harness
#

but they're not indented under a Test Thing label
@austere sun They are not?

#

I would have said they are

austere sun
onyx harness
#

Yep, in this case, they are flatten and I see the indentation is wrong

#

But in your other picture, under the Test Thing label, they are indented

austere sun
#

yes because that layout is what I want to mimic with my current drawer when it is not in an array

onyx harness
#

Line 89, add a check to know if it is in an array.
If yes:
get properties right under.
Else:
Keep as is

austere sun
#

oh so you mean instead of defaulting to the array drawing, instead default to the normal drawing?

onyx harness
#

If I'm not wrong, you gathered the "props" by looking up the fields.

austere sun
#

yes

onyx harness
#

All your drawings are suppose to have the parent fold

#

I dont even see how you flattened it

austere sun
#

the property that gets passed in the InitializeProps method is of type TestThing

#

so then the props are all the fields of a TestThing instance

onyx harness
#

Oh yeah...

austere sun
#

and then in OnGUI I loop over the props and draw a prop iff it should be drawn

onyx harness
#

oh so you mean instead of defaulting to the array drawing, instead default to the normal drawing?
@austere sun So basically, yes

#

If you detect that TestThing is not in an array, you just default drawing

austere sun
#

but the default drawing won't suffice

onyx harness
#

How come?

austere sun
#

that'll ignore the DrawIf attribute

onyx harness
#

Oh you would like the DrawIf

#

XD

austere sun
#

yea xD

onyx harness
#

Ok ok

#

Line 19, insert the drawing of "property" if not in array.
It has an "isExpand"

#

And update your GetPropertyHeight accordingly

whole steppe
#

XD

onyx harness
#

Don't laugh

#

We will address it soon 🙂

austere sun
#

but what is "the drawing of \"property\""

onyx harness
#

You have your TestThing which lies in argument "property"

austere sun
#

yes

onyx harness
#

EditorGUI.PropertyField

austere sun
#

ah

onyx harness
#

and of course, the last argument as false

#

(to not draw children)

#

I'm not sure 100%

#

but if you used my ShowIf attribute given above

#

Your code would have been much smaller

#

As PropertyField would handle hiding automatically

austere sun
#
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        this.InitializeProps(property);

        EditorGUI.BeginProperty(position, label, property);
        int y = 0;
        if (!property.propertyPath.EndsWith("]")) {
            EditorGUI.PropertyField(new Rect(position.x, position.y + margin + CalculateYPos(0), position.width, EditorGUIUtility.singleLineHeight), property, label, false);
            y++;
        }

        foreach (var propName in this.propsOrder) {
            SerializedProperty prop = this.props[propName];
            if (this.ShouldDrawProperty(prop)) {
                EditorGUI.PropertyField(new Rect(position.x, position.y + margin + CalculateYPos(y), position.width, EditorGUIUtility.singleLineHeight), prop, new GUIContent(prop.displayName), true);
                y += this.GetPropertyLineHeight(prop);
            }
        }

        EditorGUI.EndProperty();
    }``` so like this?
#

but yours doesn't work correctly for arrays

onyx harness
#

Yes

#

Doesn't matter, since you are overriding the drawing of TestThing yourself

austere sun
onyx harness
#

What is confusing you is this:
ShowIf would apply on members of TestThing.
not TestThing itself

austere sun
#

but I need to change the height method as well, but not sure to what

#

no I know that

#

oh wait

onyx harness
#

I wait

austere sun
#

As PropertyField would handle hiding automatically
what do you mean by that?

#

how does it automatically handle hiding

onyx harness
#

What is confusing you is this:
ShowIf would apply on members of TestThing.
not TestThing itself
This

austere sun
#

oh yeah but the problem is that attributes on fields that contains an array apply to the entries of the array rather than the array itself

onyx harness
#

But this attribute is not on array fields, but on members of the array fields

#

shit you edited XD

#

Oh yeah I forgot you had the member "Frames"

#

Forget it

austere sun
#

yeah xD

onyx harness
#

To be honest, I really hated Unity for that shitty 180° turn

#

And still do

austere sun
#

what turn?

#

that it applies to array elements?

onyx harness
#

I don't know who the fuck made this insane mistake and not let us an option to handle it

#

Yes

austere sun
#

I agree

onyx harness
#

They changed the design around Unity 4.2

#

And even apologies in the changelog...

austere sun
#

I'm not sure how I need to change the height method

#

And even apologies in the changelog...
so they know it's bad and still did it? weird

onyx harness
#

well the height method would be the same as ongui

#

They just wrongly coded it and fixed it...

#

So freaking sad

austere sun
#

OMG I GOT IT WORKING! 😄

onyx harness
#

🙂

austere sun
#

thank you so so so so much for your time!

onyx harness
#

UI had nothing to do with your issue XD

austere sun
#

I mean that's more about how they structured that repo that im unfamiliar with

onyx harness
#

GUI maybe

#

In the mean time, I hope you will optimize your PD

#

Because yours is insanely heavy

austere sun
#

I'm open for suggestions 🙂

#

I just don't really think it can get much better

onyx harness
austere sun
#

it was a pain to get it to this state

#

yeah that was for debugging purposes

onyx harness
#

If you work on a laptop or light desktop, or a lot of elements in your array

#

you will definitely feel it

austere sun
#

what's a lot of elements?

onyx harness
#

You need to cache EVERYTHING once

#

If the array has dozen and dozen of entries

austere sun
#

actually more than once because of how sucky unity is

#

it probably happens once every frame

onyx harness
#

Just a few scroll

#

and you might feel it

#

give it a try

#

put 20 elements

#

and scroll it

austere sun
#

20 is butter still

onyx harness
#

XD

#

Ok put 100

austere sun
#

100 is a bit laggy, but not too bad tbh

onyx harness
#

Just the thing that you need to understand

#

PropertyDrawer are generated by the Editor, which is done by the Inspector in your case

austere sun
#

I'd say 100 and scrolling is 45 fps

onyx harness
#

Every single frame, you will InitializeProps

austere sun
#

yea I know that

onyx harness
#

This can be put in cache

austere sun
#

oh?

onyx harness
#

InitializeProps can be done just once

#

A part of it

austere sun
#

oooooh

#

that sounds very promising

onyx harness
#

You need to cache the properties and their conditions

#

When you GetPropertyHeight (Which is called right before OnGUI)

#

You check all the conditions and calculate the height

#

From it, you can populate the list of props to display for OnGUI

#

OnGUI you just render

#

End of story

austere sun
#

oh so you're saying only keep the InitializeProps call on GetPropertyHeight?

onyx harness
#

Yep

#

This is one step only XD

#

Don't forget what I wrote around

austere sun
#

around what?

onyx harness
#

Caching the props, conditions

austere sun
#

I'm beginning to become a bit slow (it's 1:15am)

onyx harness
#

Populating the OnGUI in GetPropertyHeight

austere sun
#

Caching the props, conditions
like in a static dictionary?

onyx harness
#

So Initialize() runs once and after you only check what you gathered already

#

no no, don't use a static for that

#

as I explained above

#

PropertyDrawers are generated by Editor

#

If you have many TestThings

#

You will have many PD

#

Maybe static can work, if you know things are not going to change

#

But since you are saving the SerializedProperty in there

#

It won't work

austere sun
#

I am half following half confused

onyx harness
#

forget it XD

#

You made it work

#

I'm off to bed too

austere sun
#

is Initialize() a method called by unity?

onyx harness
#

No no Initialize() was a short for your InitializeProps()

austere sun
#

forget it XD
that's not how I work 😝

#

I'm really curious to know how to avoid making new property drawers each frame though

#

can I message you tomorrow about this?

onyx harness
#

no no no XD

#

This is not what I explained

#

Yes

#

you can

austere sun
#

alright cya tomorrow then. gn o/

#

thanks again for the help 👌

waxen sandal
#

So apparently if you have ExecuteInEditMode and an OnDestroy then OnDestroy gets called after the unserialized state is thrown away upon entering playmode 🙄

queen wharf
#

I want to make a private variable in one of Unity's types serializedfield but I have no idea where to start, I've been told I need to use reflection

#

Can anyone assist me?

real ivy
#

Hmm im still not able to do this.

Basically im doing a download image of many files (hence why im making an editor script)
I use the async UnityWebRequest, works
Texture2D is saved to project, done
Then i wanna save it also as sprite. I do this immediately after File.WriteAllBytes

aimp.textureType = TextureImporterType.Sprite;

Line 2 gets nullref bcoz line 1 couldnt find it. Ok then
So also added AssetDatabase.ImportAsset(path); and await Delay(1000) (this is such a hack...)
But same nullref.
So how exactly do i know when an asset is imported, or when can i actually do AssetImporter.GetAtPath(path); ?

waxen sandal
#

You want to make a field that's not serialized in a class you don't control serialized? @queen wharf

#

Does the type of the field even support serialization?

queen wharf
#

I believe thats correct yes

#

and also yes

waxen sandal
#

What type is it?

queen wharf
#

GameObject

waxen sandal
#

And what field?

queen wharf
#

Sorry, might be a tad ignorant, GameObject is the field?

waxen sandal
#

That's the type, not the field

queen wharf
#

Then I'm unsure

#

Would the correct answer to your question be Tile?

waxen sandal
#

That's already serialized

queen wharf
#

Ah, sorry, I mean make it public then?

#

currently I have to be in debug to access it

waxen sandal
#

You mean you want to see it in the inspector

queen wharf
#

Yes, sorry for misusing a term

waxen sandal
#

You'll need to create a custom editor that shows it

#

You probably want to base it of off that

queen wharf
#

I see, I'm not unfamiliar with C# but im completely new to this stuff

#

where should I start in having any idea how to do this

queen wharf
#

I see, thanks

#

so the end result would be the exact same as my current unity except when im looking at a Tile in the inspector it will show the type i want?

waxen sandal
#

It depends 😛

queen wharf
#

Could you elaborate?

#

Wanna make sure I'm not doing the wrong thing haha

waxen sandal
#

Often it's either not easy or possible to replicate it a 100% since they might use internal APIs

queen wharf
#

Reading this guide

#

I still don't know how to access the tile variable im looking for

#

i understand most of this stuff, but it relates to making a new thing, and not editing an existing thing

waxen sandal
#

Yes there's no documentation on editing an existing thing

#

It relies on your own knowledge

#

I'd just try to copy that class that I linked

#

Change the class name + namespace

#

And see what errors your run into

real ivy
#

Ok got it to work
But this is what i mean tho.
I changed the type like so:
aimp.textureType = TextureImporterType.Sprite;
And now it's different than how normal Texture2D asset type changed to Sprite. This one is a single asset without that subchild sprite asset

#

Compared to this (normal Sprite asset)
So, does Unity actually create a Sprite sub-asset and parent it to the Texture2D asset, when changing type to Sprite in editor?

visual stag
#

just changing that doesn't apply it

#

I would use scriptable serializedobject to modify that field, apply that, and then reimport the asset

#

the sub asset is created by the importer when the asset is imported

waxen sandal
#

SerializedObjects?

visual stag
#

yes, sorry

waxen sandal
#

Happens, they're very confusing

real ivy
#

It seems the most correct way is to do SpriteImporter : AssetPostprocessor.OnPreprocessTexture override rather than guessing when after/before WriteBytes/.Refresh/.ImportAsset etc

mossy wave
#

Hey everyone, dose anyone know if you can add bones to things in proBuilder?

real meadow
#

So I tried to figure out how to add a menu option to the context menu in the hierarcy but I can only find really old answers and they don't seem to work ._.

using UnityEditor;
using UnityEngine;

public class PrefabContextMenu : EditorWindow
{
    [MenuItem("CONTEXT/GameObject/Replace Prefab", false, 0)]
    public static void ReplacePrefab(MenuCommand command)
    {
        Debug.Log("test");
    }
}

What do?

clear hollow
#

I think that last number passed to MenuItem specifies position in the menu. But the "sorting values" of each menu item is spaced out quite a bit, so some guesswork is needed to get the right number. Try passing something huge like 1000 and see if your menu item moves to the bottom of the menu. Then try values in the middle till you figure out the right value

real meadow
#

Well isn't it strange that it doesn't appear at all?

#

Wouldn't 0 be at the top?

clear hollow
#

oh I see, yeah not sure.

waxen sandal
#

Shouldn't matter

real meadow
#

Hm okay

clear hollow
#

Did you try it and did it work? If not I have another idea

real meadow
#

Didn't make a difference, yea

#

I put the class in my Editor folder as well

clear hollow
#

it's accepting a parameter. The examples I'm looking at don't accept a parameter

#

...but now I see others that do.

real meadow
#

You see my problem, yes?

#

😛

clear hollow
#

you could also try adding the menu item to a different menu, just to be absolutely sure that it is able to appear, just now where you want

#

not*

real meadow
#

Well if I remove the "CONTEXT" part and only go with GameObject, it does appear in the menu, though it also appears in the GameObject menu in the top-left

#

Which isn't very conducive to its function because it's context specific

waxen sandal
real meadow
#

If you read through the conversation here you'd find that this supposed "fix" does not fix it.

#

[MenuItem("GameObject/Test9", false, 0)]
static void testFunc9(){
}
This just makes it appear in all GameObject menus

#

I want it to only appear in the hierachy when I right-click a gameobject

tulip plank
#

I'm curious if anyone has any tips on stepping through / debugging UI Elements code to see why, for example, a mouse click is not being handled in the way you expect.

#

In my case I essentially have a custom Button that is embedded in a Foldout header, but when I click the button, it causes the Foldout to expand/contract. I want the Button to block clicks from going through to the Foldout header underneath.

real meadow
#

Does any of you know how to use this method: EditorGUIUtility.GetObjectPickerObject() ?
I don't really understand how to use the Object that it returns to get the GameObject that was picked with this:

[MenuItem("GameObject/Replace GameObject", false, 0)]
public static void ReplacePrefabCall(MenuCommand command)
{
    currentPickerwindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
    EditorGUIUtility.ShowObjectPicker<GameObject>(null, false, "", currentPickerwindow);
}

public void OnGUI()
{
    if (Event.current.commandName == "ObjectSelectorUpdate" && EditorGUIUtility.GetObjectPickerControlID() == currentPickerwindow)
    {
        currentPickerwindow = -1;
        ReplaceObjects(EditorGUIUtility.GetObjectPickerObject());
    }

    if (Event.current.commandName == "ObjectSelectorClosed")
    {
        currentPickerwindow = -1;
    }
}

private void ReplaceObjects(Object pickedObject)
{
    GameObject[] selectedObjects = Selection.gameObjects;
    if (selectedObjects != null && selectedObjects.Length > 0)
    {
        // how to use pickedObject ??
    }
}
tulip plank
#

(Sorry, I don't know the answer to your question, OmniOwl)

#

I'm thinking that I will need to clone the UIElements source code and copy the Clickable / PointerClickable / etc. manipulators into my project, rename them slightly, and use them so that I can step through the code and see why my clicks aren't handled the way I expect.

split bridge
#

@tulip plank if you go to about and type ‘internal’ magically a ui toolkit (aka ui elements) event debugger will appear in I think Window->Analysis

#

I realise that legit sounds like I’m making it up but I’m not 😂

tulip plank
#

Okay I'm about to possibly look like a fool...

#

whoa, "developer mode: on"

split bridge
#

It’s still not easy to track down issues with events (I totally failed to even using this tool) but it might help

tulip plank
#

Very cool, I'm taking a look. My other option was to just create my own versions (via copying from reference source) of each of the manipulators, etc. that I needed to debug.

split bridge
#

Well you certainly mostly can - just copy the package into your project’s packages folder

tulip plank
#

Oh I was wondering that, yeah... would it conflict with the... non-package library, though?

split bridge
#

If it detects a local project version it uses that instead of the one centrally cached

tulip plank
#

Oh interesting, I wasn't aware of that.

split bridge
#

Yea - really nice 👍

tulip plank
#

Oh, another maybe-dumb question: If I look for the reference source online, it says it's for Unity 2020.something. How do I find the 2019 version (which is what I'm using)?

#

Oh nevermind, clearly I can select the branch in GitHub

shadow moss
#

Does anyone know of an open source sprite packer?

weak spoke
mighty oasis
#

Anyone know why AssetModificationProcessor.OnWillMoveAsset ain’t being triggered??

mighty oasis
#

i think restarting unity fixed it for those who encountered the same issue

snow bone
#

when i do a EditorGUILayout.BeginVertical(); how do i get the position, so that I may draw a control using a Rect()?

#

nvm, it's just position

idle anvil
#

any of you know how to make this work? ```cs
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;

[CustomEditor(typeof(SkinsChanger))]
public class SkinsChangerEditor : Editor
{
private VisualElement _RootElement;
private VisualTreeAsset _VisualTree;
// This function is called when the object becomes enabled and active.
void OnEnable()
{
_RootElement = new VisualElement();
_VisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("skinChangerEditor.uxml");
}
public override VisualElement CreateInspectorGUI()
{
return _RootElement;
}
}```

the uxml:xml <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:VisualElement class="Title"> <Style src="SkinsChangerEditor.uss" /> <ui:Label text="Skins Changer" /> </ui:VisualElement> <ui:VisualElement> <Style src="SkinsChangerEditor.uss" /> <uie:PropertyField label="Momoo Flat C"> <uie:ObjectField label="Momoo Flat C" binding-path="momooFlatC" /> </uie:PropertyField> </ui:VisualElement> </ui:UXML>

and USS:css .Title { font-size: 32px; justify-content: space-around; -unity-text-align: middle-center; border-left-color: rgb(126, 126, 126); border-right-color: rgb(126, 126, 126); border-top-color: rgb(126, 126, 126); border-bottom-color: rgb(126, 126, 126); border-bottom-width: 4px; border-top-left-radius: 20px; border-top-right-radius: 20px; background-color: rgb(233, 138, 138); }

#

that is how far i managed...

#

pretty sdure i did something wrong 🤔

idle anvil
#

multi-object editing not supported... probably due to the fact this script is in the prefab mode?

#

is this where it should be for _VisualTree.CloneTree(_RootElement);?

#

oki

#

but still not working...

#

same message for "multi-object editing not supported"

#

i just figured why i did it wrong....

#

i changed it to this: ```cs
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
using System;

[CustomEditor(typeof(SkinsChanger))]
public class SkinsChangerEditor : Editor
{
const string resourceFilename = "SkinsChangerEditor";
public override VisualElement CreateInspectorGUI()
{
VisualElement customInspector = new VisualElement();
var visualTree = Resources.Load(resourceFilename) as VisualTreeAsset;
visualTree.CloneTree(customInspector);
customInspector.styleSheets.Add(Resources.Load($"{resourceFilename}-style") as StyleSheet);
return customInspector;
}
}```

#

it worked but....

#

it's gone

idle anvil
#

oh well, i tried

#

going to bed now

turbid harness
#

Hey, So I'm making a vr parkour shooter thing and after making a indoor level in probuilder and testing it, my character doesn't jump anymore when on the floor, only on slopes, do Ontriggerenter methods not do well with rooms were the faces are flipped inward?

flint vapor
#

Hello, is possible to override unity gameobject context menu actions, like copy, duplicate etc. I don't like the fact that when I duplicate something name "something1" I get "something1(1)" and I would like to get the normal "something2". I want to achive this using a context menu for the gameobject. The issue is that the static function is never called when I click "duplicate" . cs [MenuItem("GameObject/Duplicate %d", false, priority = -100)] private static void DuplicateGameObject() { Debug.Log("heii I am called"); foreach (GameObject gameObject in Selection.gameObjects) { string name = gameObject.name; int number = 0,i = name.Length - 1; // "Hospital" while (i >= 0) { bool isNumeric = int.TryParse(name.Substring(i), out var numberTest); Debug.Log(name.Substring(i) + " " + isNumeric); if (!isNumeric) break; number = numberTest; i--; } Debug.Log(number); number++; string duplicatedName = name.Substring(0,i + 1) + number; Transform parent = gameObject.transform.parent; GameObject duplicatedGameObject = Instantiate(gameObject, parent, true); duplicatedGameObject.name = duplicatedName; } }

visual stag
#

that way you can rebind it in the shortcuts settings

#

just as you can rebind the default one

#

But I think duplication probably isn't as simple as that

#

and also affects many other items across Unity

#

and just remove it via that

idle anvil
#

back, i tried again that ui builder but it appeared it's not working.....

#

that is the result

#

and it's annoying that it didn't display anything...

idle anvil
#

i did drag the script myplayer in the gameobject it became invisible as a result

#

i found that really weird

teal timber
#

I want to set a hotkey for a custom EditorTool. Couldn't find it in the shortcut editor so I created a menu item that does the switching, and that showed up in the regular shortcut editor and it works ... except in the script I switch by just doing Tools.current = Tool.Custom; which only works because I only have one custom tool right now. Couldn't find a way to specify which one specifically to switch to, is that even exposed in the API? (Or am I missing something re: just directly setting a shortcut for a specific custom EditorTool without the [MenuItem] script middleman?)

shrewd kindle
#

Has anyone ever made a unity test that includes ink (https://www.inklestudios.com/ink/)? We're trying to bring on new programmers for our team, but we're having a difficult time coming up with a unity test that incorporates ink

woven knot
#

Is there a way to rename components with an addon

#

When I have 5 colliders on an object it’d be nice to name them so I know which is which

idle anvil
onyx harness
#

When I have 5 colliders on an object it’d be nice to name them so I know which is which
@woven knot I developped such a feature in one of my prototype tool (NG Flow Inspector)

#

If you would like to give it a try get NG Tools Free

#

It's in there

shrewd kindle
#

@idle anvil we already have it added in our Unity build, right now we're trying to bring on programmers that know how to build custom functionality for the integration

idle anvil
#

ah that, there is a github for it, i think

#

it's best to wait a little because the team have something new to be announced

#

also, they have official discord server

waxen sandal
#

I kind of doubt that plugin is big enough to have people skilled in it that are looking for a job

frigid pendant
#

I'm trying to modify the MemoryProfiler package (the new stuff, not the old plugin by the same name) to call some code in Assets/ but it gives the "name 'foo' does not exist in the current context". Both the profiler code and the code I'm trying to call are in Editor/ folders. Is it at all possible to do this or am I out of luck?

waxen sandal
#

You probably need references in the AsmDef

frigid pendant
#

Which means the code I'm trying to call also needs to be in an assembly, right?

waxen sandal
#

In an AsmDef yes

idle anvil
#

i honestly have no idea what is the meaning of it....

waxen sandal
#

You got an extension on your resources.load

#

So it can't find it

idle anvil
#

ah?

#

is that so?

#

even though it's this way:cs public override VisualElement CreateInspectorGUI() { VisualElement customInspector = new VisualElement(); var visualTree = Resources.Load("Assets/Resources/Scripts/Editor/Skins/SkinsChangerEditor.uxml") as VisualTreeAsset; visualTree.CloneTree(customInspector); customInspector.styleSheets.Add(Resources.Load("Assets/Resources/Scripts/Editor/Skins/SkinsChangerEditor.uxml") as StyleSheet); return customInspector; }

rain wolf
#

Sorry if this is wrong chat, but I'm using a Cinemachine Free Look camera that I only want to rotate if the player is holding down an input. In other words, I need it to continue "Follow" and "Look at" at all times but only rotate around situationally. Is there an option so I can script this or am I using the wrong kind of camera?

brave moon
#

How you guys make enum showed in inspector that I can switch value of it? atm im using

   EditorGUILayout.PropertyField(AItype, new GUIContent("AI type"));

but I cannot change the value of it from inspector, it stays same.

waxen sandal
#

Did you apply?

restive lantern
#

is there a way to find all Texts at editor time from prefabs and scenes then change all the text components to TMP?

waxen sandal
#

Find all GameObjects in the AssetDatabase and check if them or their children contain a Text component

restive lantern
#

hmm let me try ty

waxen sandal
#

Wrong channel

warm ridge
#

what is the right channel tho

#

It is an extension, isn't it

waxen sandal
#

Sure but this channel is about developing your own extensions

#

Not using them

warm ridge
#

I see, sorry m8

waxen sandal
#

No worries

#

You probably have the highest chance on the forums

warm ridge
#

thank you

vast geyser
#

Hi Guys, anybody know how to load this waveform texture from the imported audio ?

waxen sandal
#

I'd look at the decompiled code

vast geyser
#

decompiled code?

visual stag
#

the source code to the C# side of the editor is pinned to this channel

vast geyser
#

ooh

deep wyvern
#

I am trying to make an int matrix of a scriptable object editable in the inspector. So far so good but the values keep resetting when I click play and I have no idea why. Am I missing something obvious here?
https://hatebin.com/zysjizyfqu

waxen sandal
#

Don't use target

#

Use SerializedProperties

deep wyvern
#

how would that work with a matrix

real ivy
#

How can i make a string list popup? Using EnumField or something else?

#

I used to do this in IMGUI:

animationAttacker.intValue = EditorGUILayout.Popup("Animation Attacker", animationAttacker.intValue, animationListArray);
uneven spindle
#

hi how to use opengl es3 instead of 4.5 in the editor i tried alot but its not working

sonic kraken
solar basin
#

is it possible to make an attribute and have a custom inspector for every class with that attribute?

#

like [CustomInspector] public class MyClass : Monobehavour { }

#

i have multiple classes that i want to have the same inspector and i don't want to recreate an editor class for each one

split bridge
#

@solar basin in your inspector either [CustomPropertyDrawer(typeof(blah), true)] or [CustomEditor(typeof(blah), true)] - i.e. the second param should do what you want

waxen sandal
#

Yeah should use a shared base class

solar basin
waxen sandal
#

I don't think you can do that

#

But you can make a CollectionAuthoring base class and write an editor/propertydrawer for that

#

And then make your ItemCollectionAuthoring inherit from CollecitonAuthoring

solar basin
waxen sandal
#

??

solar basin
#

removing mistakes

onyx harness
#

Yes you can for a whole class, just not a MonoBehaviour

solar basin
#

how

#

@onyx harness

onyx harness
#

Just remove MonoBehaviour 😄

#

And mark the class Serializable

solar basin
#

ah

onyx harness
#

Use the attribute like it was a normal one

#

on the field

gloomy chasm
#

I found these in the 2020.1 patch notes. Both are very nice imo!

onyx harness
#

TypeCache was kinda buggy for me, but they are interesting API nonetheless

gloomy chasm
#

Oh really?

onyx harness
#

yep, it did not want to work after a compilation, during the very first frame

#

Bug reported of course, but lost my attention since then

gloomy chasm
#

Ah. Well if it works I think it would be real handy.

onyx harness
#

I guess they fixed it since

#

Should be fine

#

give it a go 🙂

#

In my tests, it was interestingly faster

gloomy chasm
#

Editor: Introduced PreviewSceneStage. Implement custom stages by inheriting from this class. Finally! 😄 I remember trying to do this my self, had to use reflection and stuff and it still didn't work right.

silver spruce
#

genarTheDevheute um 16:47 Uhr
Tried to install "Localization" Package from unity... getting this error "Library\PackageCache\com.unity.localization@0.7.1-preview\Editor\Settings\LocalizationEditorSettings.cs(376,24): error CS1061: 'BundledAssetGroupSchema' does not contain a definition for 'BundleNaming' and no accessible extension method 'BundleNaming' accepting a first argument of type 'BundledAssetGroupSchema' could be found (are you missing a using directive or an assembly reference?)
" Any ideas ?

snow bone
#

I've got some BeginHorizontal/EndHorizontal, in between, I just write text, however when I start the 2nd block, i have a large vertical space inbetween the blocks, any idea?

#
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space(60);
if (GUILayout.Button("Use this Directory"))
{
  AssignDirectory(gameDirs[0]);  //has no visual oputput
}
EditorGUILayout.Space(100);
EditorGUILayout.EndHorizontal();
GUILayout.Label("This line is lower than it should");
onyx harness
#

EditorGUILayout.Space does it even exist? O_o

snow bone
#

it's applying space after the button

#

otherwise the button fills the width

onyx harness
#

What version of Unity?

snow bone
#

seriously, it wouldn't work if it didn't exist

#

unity 5 obviously......

onyx harness
#

We never know, often people in here does not even realize it is not even compiling

snow bone
#

please don't ask me questions for noobs

onyx harness
#

Do I know you?

#

Do you expect anybody in this channel to know anybody's skill?

snow bone
#

it's to do with the Space fn, but what's the alternative

onyx harness
#

For your information, EditorGUILayout.Space appeared in 2019.3

snow bone
#

i'm at least using that version then

onyx harness
#

Next time, stay polite and dont expect us to be god gifted and read into your mind

#

Just use GUILayout.Space and you are good to go

snow bone
#

use a custom space fn you wrote above?

onyx harness
#

Nope nope, the function I showed you is the one implemented by Unity

#

That's why you see a 60px height spacing

snow bone
#

soon as I add the Space() it adds vertical space in the horizontal block

onyx harness
#

Because the 2nd argument of GetRect is height

#

Because you are using EditorGUILayout.Space

#

Are you sure I should talk to you like an expert?

snow bone
#

appologies, there are a lot of people who expect anyone who asks questions here to be noobs

onyx harness
#

No worry. We need to measure people behind their questions, to adapt our solutions/advices/tips

snow bone
#

the normal responses i get are jsfg, which i've already done

onyx harness
#

jsfg? O_o

snow bone
#

GUILayout.space works fine

onyx harness
#

🙂

snow bone
#

now i feel like a noob, lol

onyx harness
#

Don't worry, Unity implementing Space as a square is already making them noob

#

I will never get how they think/work...

snow bone
#

thank you

#

have you got a EditorGUILayout.BeginHorizontal(); EditorGUILayout.EndHorizontal(); around your button?

#

the post was deleted, meh

#

is there a way to specifcy the location of the BeginHorizontal relative to the height?

#

i've got some controls that add or remove a line above it, causing the dialogue to jump up and down & not sure how to fix it

onyx harness
#

You mean the space between a block BeginH and the one above?

#

Space() is a good way to insert space

#

You just need to remember if you are horizontally or vertically drawing

snow bone
#

i've got a begin/end block above it, that is not always dispalyed, sometimes adding a space of 20 vertically

#

won't the space also be relative to what's added above it?

onyx harness
#

Yep

#

Always when you are rendering with the Layout API

snow bone
#

i can just add an else condition to add a space instead if nothing is displayed i guess

#

out of curiosity, is there perhaps a way that i can specify the vertical position of a beginHorizontal with a Rect perhaps?

onyx harness
#

Yep

#

Use Space() to define the offset or space.
Then use GetRect with the right style and options

#

Or simply go Space() with the height you want, and draw using EditorGUI and not EditorGUILayout, but this implies that you "master" GUI

snow bone
#

yeah, mastering gui is a stretch

#

are you talking about EditorGUILayout.GetControlRect?

onyx harness
#

This one is a good pick

#

But this one is made for a nice & good display of "controls"

#

Like TextField, Float, Int, string etc...

#

I tend to use GUILayoutUtility.GetRect() for better control

snow bone
#

thank you, i'll read up on that

onyx harness
#

This last doesn't take into account the margin space and other stuff

#

Which is good or not, it depends on what you to display

torn zephyr
onyx harness
#

The code provided is not sufficient to help you unfortunately

#

And moreover, I guess you are using Odin

#

Maybe something is messing up over there

torn zephyr
#

What other code do you need?

onyx harness
#

You dont override GetPropertyHeight, I would say the default height is 16 pixels

#

Maybe your MB Grass is having attributes, or anything that can bug the UI

torn zephyr
#

Just removed Odin, no other attributes in project

onyx harness
#

Show us Grab then

torn zephyr
#

Grab?

#

Now it's just not showing anything : /

onyx harness
#

Grass sorry

torn zephyr
#

?

onyx harness
#

the MonoBehaviour

torn zephyr
#

Oh

onyx harness
#

Strange

#

Just override GetPropertyHeight in your PD to return 16F

#

Should work

torn zephyr
#

Hum, ok

onyx harness
#

lol

#

Your PropertyDrawer

#

You are using EditorGUILayout

torn zephyr
#

Yeah

onyx harness
#

You can't use those

torn zephyr
#

Blah

#

Why not? Never understood which is which

onyx harness
#

EditorGUI is for manual drawing

#

EditorGUILayout is for automatic drawing

#

PD provides you a position (Rect), to draw in

torn zephyr
#

That's what I gathered

#

Hum, ok

onyx harness
#

With this position, you need to use EditorGUI

torn zephyr
#

Makes sense why it's off then

onyx harness
#

Because if you use the Layout, you are going to draw in the layout world, which would be at the very top of your window

torn zephyr
#

Could I swap this to a custom editor or something, and keep using GUILayout? I'm confused on the differences there

onyx harness
#

Unfortunately no

#

PropertyDrawer only provides a Rect

#

So, you are suppose to work with Rect manually

torn zephyr
#

Hum, ok. Thanks

onyx harness
#

But you can use GUILayout.BeginArea to switch from manual to automatic

#

To easy your life

torn zephyr
#

Ah, haven't heard of that one. Will look into it. Thanks

onyx harness
#

But in reality, you might encounter futur bugs

#

BeginArea is nice, but truly, it can bring disasters upon you

#

🙂

#

I warned ya

torn zephyr
#

Yeah, sounds about right

mighty oasis
#

is there a way to clone a scriptableobject?

brave moon
#

Hey anyone got time to help me?
I have this waypoint script but I havent manage to fix it the way that when Im making new point by pressing button it would update positions that it would always take last position from last point + offset position.

So simply what I want is that it would spawn correct place when I have moved parent object.

mighty oasis
#

where's the waypoint.cs code?

#

@brave moon

brave moon
#

well there is no really code in it but sure:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Waypoint : MonoBehaviour
{
  public int waypointCount;
  public  List<Transform> Waypoints = new List<Transform>();
  public GameObject Point;
  public float Radius = 1;
}

visual stag
#

just make the position you track be local

#

and transform it to world space if you want to

#

using TransformPoint

brave moon
#

erhm.. okay?

mighty oasis
#

i'm confused as to what you want actually

#

so say i had my first waypoint at 0, 0, 0

#

i move it to 1, 0, 0 and press create waypoint

#

what's supposed to happen?

brave moon
#

like I said, I want created point always be created from last point + offset.

#

these created points are children of gameobject what holds the script.

#

so if you move your parent object and try create point, it will spaw in wrong place.

visual stag
#

you're using world position, just use local, it will fix all your issues

brave moon
#

So I put it like:
lastPosition = point.transform.localPosition; ?

mighty oasis
visual stag
#

yes, and then set it using local position too

brave moon
#

Welp, I can tell you sure that it wont work but lets give it a try.

mighty oasis
#

if it doesn't work you need to explain exactly what you want to happen a bit better

brave moon
#

I dont know how I can explain it any better.

  • When ever I press '' create waypoint " button, it makes new Point and makes it child of this game object.
  • When making new point I want it always spawn from last point + offset. no matter how much I move Parent object, it should always spawn from last point + offset.

I will try now that localposition what vertx mentioned but I doubt it will works since I have tried it before.

mighty oasis
#

what is the offset?

brave moon
#

that "lastPosition" vector

mighty oasis
#

just give me the scenario that i was trying to understand with

brave moon
#
  • new Vector(0,0,5)
mighty oasis
#

you have your first waypoint at 0, 0, 0 on the parent game object

#

you move it to 1, 0, 0

#

you press the button

#

what's supposed to happen?

brave moon
#

did you move child (point) or parent?

mighty oasis
#

this is a root gameobject with the waypoint component

#

no child yet

brave moon
#

well no matter did you move parent or child self, next point must spawn from that last point + offset

mighty oasis
#

give me numbers man

brave moon
#

you see FIRST point gets created from parent position

mighty oasis
#

you move it to 1, 0, 0

#

what happens

brave moon
#

next Point gets created from last point

mighty oasis
#

when you press the button again

brave moon
#

I already said

mighty oasis
#

like specifcally...

brave moon
#

next point must be created from last point what already exists

mighty oasis
#

does it get created at 0, 0, 0

#

does it created at 1, 1, 0

brave moon
#

and now I shall show your "localPosition" result

mighty oasis
#

cuz i dont understand what you mean by last point + offset

#

offset means nothing to me

#

you have a gameobject "A" at 0, 0, 0

#

you press the button.... it makes it at 0, 0, 0

#

"B" at 0, 0, 0

#

you move A to 1, 0, 0

#

it creates C where

#

etc etc

brave moon
#

[Press button] > Create Point > Set position of it to Parent
[Press button again] > Create Point > Set position of point to earlier point + offset position

mighty oasis
#

Give me some vector positions in your example

brave moon
#

you dont need that vector x)

mighty oasis
#

Ok never mind

#

Good luck

brave moon
#

I dont understand why in earth you need vector numbers

#

Its all about positions

mighty oasis
#

so i know what the heck you mean

brave moon
#

it doesnt matter in what coordinate that object is in numbers

mighty oasis
#

i know it doesnt

#

i just need to understand what the heck you're talking about

brave moon
#

Jesus..

mighty oasis
#

i dont think you're understanding why i'm asking for the vectors

#

it's because offset is relative

brave moon
#

Parent object in 0,0,0
Press button > Create Point to SAME POSITION AS PARENT SELF 0,0,0
Press button again > Create point to SAME POSITION AS EARLIER POINT SELF + Offset position ( 0,0,5) 0,0,5

I move parent to 5,0,0
Press button again > Create point to SAME POSITION AS LAST POINT SELF + offset position (0,0,5) 5,0,10
etc.

#

ant localpositionin didint work.

mighty oasis
#

So you want it to always go on top of where the parent is

#
  • 0,0,5
brave moon
#

not top of parent, what I meant that next point what gets created will be set to same position as last point + that 0,0,5.

mighty oasis
#

But you said you moved the parent to 5, 0, 0 and the result is 5, 0, 5

brave moon
#

seems I made typo there

#

5,0,10

visual stag
#

local position would work fine

brave moon
#

but it doesnt work

visual stag
#

you'd just need to initialise your weird first offset - which I assume you're doing in your current implementation

brave moon
#

It is possible that lastPosition needs get reseted because it throws weird positions for points when they are created

#

So I dont honestly know what to do with this

mighty oasis
#

sorry I still don’t understand what you want to happen. Sounds like vertx knows

#

What you can do instead of keeping a last position vector is to reference the last point created

visual stag
#
Vector3 newLocalPosition = Waypoints.Count == 0 ? Vector3.zero : Waypoints[Waypoints.Count - 1].localPosition + offset;
newWaypointTransform.localPosition = newLocalPosition;
Waypoints.Add(newWaypointTransform);```
#

just something like that

mighty oasis
#

So Waypoint lastPoint

#

And then do: point.transform.position = lastPoint.transform.position + offset ;

#

Same idea vertx had. Minus the list

brave moon
#

😫

mighty oasis
#

?

brave moon
#

my brain hurts, im too sleepy to think.

mighty oasis
#

Yea take a break

loud vortex
#

You just need a reference for previous and next waypoint in your waypoint script.
Then you go like:

Waypoint currentWaypoint;
void CreateWaypoint()
{
     Waypoint newWaypoint = Instantiate(prefab, currentWaypoint.position + offset, currentWaypoint.rotation) as Waypoint;
     currentWaypoint.nextWaypoint = newWaypoint;
     newWaypoint.previousWaypoint = currentWaypoint;
     currentWaypoint = newWaypoint;
}
fossil lake
#

Does anyone have a use for a multi-platform build script?

ivory marsh
#

i hope you understand:>

#

never mind

digital briar
#

hi guys i got a issue with my Debug tools , its supposed to take all the created scenes but it don't want to ```cs
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
class DebugTools : EditorWindow
{
string SceneName;
[MenuItem("Window/Scene Opener")]
public static void ShowWindow()
{
GetWindow(typeof(DebugTools));
}

void OnGUI()
{
    
    //SceneName = EditorGUILayout.TextArea(SceneName);

    foreach (SceneAsset scenes in Resources.FindObjectsOfTypeAll<SceneAsset>())
    {
            if (GUILayout.Button("Open Scene : " + scenes.name))
            {
                EditorSceneManager.OpenScene(scenes.name);
            }
    }
}

}```

onyx harness
#

dont want to what?

#

Take all the created scenes?

#

@digital briar

digital briar
#

@onyx harness yes

onyx harness
#

Because Resources doesn't know them yet

#

You have to load them all

#

@digital briar

#

Then only, Resources will ackknowledge them

digital briar
#

oh so i load them in a array

#

ok thx

waxen sandal
#

You should use AssetDatabase to find them

onyx harness
#

It is also a finer solution

digital briar
#

so i use AssetsDatabase with LoadAssetAtPath?

#

@waxen sandal do you know what is a filter? whats thats mean

#

because i've tried like thats : string[] Scenes = AssetDatabase.FindAssets("",new[] {"Assets/Scenes"});

#

but i don't understand the filter

onyx harness
#

try "t:scene"

digital briar
#

ok thanks

#

now it's giving weird number

onyx harness
#

the GUID

#

You convert the GUID to its path

#

using AssetDatabase

digital briar
#

ok thx

#

hmm

#

i find it

graceful gorge
#

Hi, I've been trying to put together a polymorphic property drawer of some sort that I need for work. It's been an absolute nightmare. My current solution is to serialize the objects to Json strings along with their types, it seems it works so far (I've thought that several times though). Now I'm having more problems with the drawer itself.

    {
        var collection = ((objectInstances)EditorHelper.GetTargetObjectOfProperty(property)).objects;
        var buttonRect = new Rect(position.x, position.y, 150.0f, position.height);
        if (GUI.Button(buttonRect, "test"))
        {
            collection.Add(new baseObj());
            property.serializedObject.Update();
            Debug.Log("added object to list");
        }
        Debug.Log(collection.Count);
        for (int i = 0; i < collection.Count; i++)
        {
            Debug.Log("drawing object " + i);
            var instance = collection[i];
            
            var userTypeChoice = (objType)EditorGUILayout.EnumPopup(instance._type);
            if (instance._type != userTypeChoice) Debug.Log("request new object type");

            switch (instance._type)
            {
                case objType.none:
                    
                    break;
                case objType.first:
                    break;
                case objType.second:
                    break;
                case objType.deep:
                    break;
                default:
                    break;
            }
        }
  
        
    }```
#

It does the expected stuff, I can add an object to the list and the enum popup works. Until you close that inspector. When you reopen it only draws the button and throws "ArgumentException: Getting control 1's position in a group with only 1 controls when doing repaint" . I've looked around and it is suppose to happen because OnGUI is called several times a frame and changes to the number of controls makes it loose it. But using the debug message, it seems the code steps through it three times in the exact same way so I don't know how it loose one of the controls (without mentionning that drawing the added object inspector when it's added to the list should trigger the error, but doesn't)

#

Am I missing something important here ?

digital briar
#

why my message is not here

graceful gorge
#

I've seen flicker in and out several times

digital briar
#

me too

waxen sandal
#

Because you need to use hastebin to post code

onyx harness
#

You can't paste big chunk of code, dont repeat or you will get an auto temporary ban

digital briar
#

oh

waxen sandal
#

Just a mute I think

onyx harness
#

@graceful gorge Dont use EditorGUILayout in PropertyDrawer

graceful gorge
#

Yeah i just noticed it

#

It removed the exeption, still doesn't doesn't draw the list object

digital briar
waxen sandal
#

What doesn't work

#

Does it give an exception

#

Does it not find the object?

digital briar
#

well i've tried to convert it to string but it's not working and i know why but how can i convert the var to a EditorSceneManager scene

onyx harness
#

It removed the exeption, still doesn't doesn't draw the list object
@graceful gorge Maybe because you did not adapt GetPropertyHeight?

digital briar
#

@onyx harness if you are talking to me , yes the list is working and the name contains the path

#

wait

#

i'm stoopid

#

um no i doesn't work

graceful gorge
#

@graceful gorge Maybe because you did not adapt GetPropertyHeight?
@onyx harness it's a popup, it's not linked to any property directly, unless I misunderstand you. It also manages to draw it just fine when you add the object to the list for the first time

waxen sandal
#

Really need more context on both your issues, what exactly is failing

#

We're just guessing at potential issues here

onyx harness
#

@onyx harness it's a popup, it's not linked to any property directly, unless I misunderstand you. It also manages to draw it just fine when you add the object to the list for the first time
@graceful gorge I'm sure you missed my point, and I would bet it was previously an illusion

#

He is right, show us some code

graceful gorge
waxen sandal
#

@onyx harness is right, you need to override GetPropertyHeight on your PropertyDrawer

onyx harness
#

https://hastebin.com/raxijatize.cpp That's the whole thing
@graceful gorge Yep, this is what I thought. Without overriding GetPropertyHeight, your PD would always be 16px as height

#

I guess, your field objectInstances was the last of your MonoBehaviour?

graceful gorge
#

it's stored in a scriptable object but yeah

onyx harness
#

Oh yeah I should have thought about it

#

Because with "Add Component" at the bottom, you would have seen it, the issue

#

So you just need to override GetPropertyHeight

graceful gorge
#

You are absolutely right, I put the button at the bottom and now it straight up doesn't display anything. I'm going to implement an override I suppose I need to add the heights of all the stuff I'll display? Still kind of baffled that it initially worked. You both have been a really big help, you can't imagine

waxen sandal
#

Yeah just add everything together

#

You can use EditorUtility.SingleLineHeight

#

Be sure to account for potential expanders and stuff

onyx harness
#

Still kind of baffled that it initially worked.
@graceful gorge Told ya, an illusion 🙂

graceful gorge
#

Worked like a charm

brisk crest
#

Hi, I'm trying to Instantiate a specific prefab on my project folder into the scene using a editor window.

In the documentation the example for PrefabUtility.InstantiatePrefab() Instantiates the selected GameObject on the Scene, but I don't want to select it, and just instantiate it from it's known path.

So far I'm stuck trying to use AssetDatabase.LoadAssetAtPath() to get the reference object, whatever I try, it seems to return null everytime, so I can't instantiate.

anyone know the correct way to do it?

onyx harness
#

this is what I'm doing
@brisk crest you forgot the extension '.prefab'

brisk crest
#

@brisk crest you forgot the extension '.prefab'
@onyx harness Ohh, that seems correct... I didn't noticed that, but I solved it overthinking it and using Find Assets to get the GUIDs Path, and then converting the GUID to AssetPAth XD

onyx harness
#

If it works, it works

brisk crest
#

Lol I added the .prefab and deleted the other method and it does work XD thanks 🙂

fallow adder
#

Hi!
What happened to ProjectFilesGenerator in Unity 2020.1?
It is not triggering any builds anymore. I'm using Visual Studio 2019.
Is it something to do with the new VS extension on the package manager?

waxen sandal
#

Idk what that api is but there's a built in api

fallow adder
#

Yeah, thanks 🙂
A took a look into the code and found that too.

#

And sidenote, this OnGeneratedCSProject can return string, so you can entirely replace csproj contents.

waxen sandal
#

Oh that's the one I meant to link 😛

#

There's also one that returns a bool to say if you "completed" the generation somewhere iirc

fallow adder
#

Ah, cool.

onyx harness
#

OnPreGeneratingCSProjectFiles
OnGeneratedCSProject
OnGeneratedCSProjectFiles
OnGeneratedSlnSolution

austere sun
#

if I have a scriptableobject that has Sprite[] frames and float duration properties, can I then show a preview of the animation in the inspector?

onyx harness
#

Done manually, yes

austere sun
#

what do you mean by manually?

onyx harness
#

You draw a sprite using GUI.DrawTexture

mighty oasis
#

anyone know how to autosize editorgui labels?