#↕️┃editor-extensions

1 messages · Page 82 of 1

tough cairn
#

so that's 1st line in the error log above , would take me too much time to do the rest lol

#

if different contractor won't work i won't use it

quaint zephyr
#

This is great thank you!!

tough cairn
#
[Serializable] 
public class RelayBase : UnityEngine.Object 
{
    [HideInInspector, SerializeField] List<RelayInvoker> relay_invokers = new List<RelayInvoker>();
#

i think this is the problem

#

it doesn't want to have a default value

#

im using it like this :

[SerializeField] public RelayBase OnChange;
#

so unity should make a default object by default in the inspector as it does to all of its types , is that not so ?

gloomy chasm
tough cairn
#

without doing so it will not draw the property in inspector

onyx harness
tough cairn
#

if i remove Object it will not draw

gloomy chasm
tough cairn
#

[CustomPropertyDrawer( typeof( RelayBase ), true )]

gloomy chasm
tough cairn
#

OnGUI to draw

#

and inside it reorderableList.DoList( rect );

tough cairn
gloomy chasm
tough cairn
#

ofc , thanks

#
//var target = RelayRefelction.GetActualObjectForSerializedProperty<RelayBase>( fieldInfo, property );
//reorderableList = new ReorderableList( target.relay_invokers, typeof( RelayInvoker ) );
                
if( list == null ) list = new List<RelayInvoker>();
reorderableList = new ReorderableList( list, typeof( RelayInvoker ) );

//reorderableList = new ReorderableList( property.serializedObject, invokersList );
#

so this works obv

#

but not the 1st or the 3rd one

#

from what i can tell so far

#

i need it to be auto initialized like other things in unity

#

similar to how u just make a struct public unity takes care for this for you

#

defining the class as its suggested in the unity docs won't render it

[Serializable] public class RelayBase
#

but when extending it on Unity Object it does

#

this is what it looked like yesterday

#

( top one is Relay , bottom one is UnityEvent )

gloomy chasm
#

Relay is missing [Serializable]

#

Also, please for all that is good in this world, move the property drawer to it's own file.

tough cairn
#

yes

#

thank you 🙂

gloomy chasm
#

Also, also just so you know, unity can't serialize polymorphic without the use of the [SerializeReference] attribute on the field. So if you have a [SerializeField] private BaseRelay _myRelay = new Relay();, it will just serialize as a BaseRelay not as a Relay

tough cairn
#

so if both have [serializable] it will ?

gloomy chasm
# tough cairn so if both have `[serializable]` it will ?

No, you will need to use the SerializeReference attribute instead of the SerializeField attribute. But I would do some reading on it first.
Something to note about how unity serializes data, it serializes everything that is not a UnityEngine.Object as a value (that is why when the editor or game starts, anything that is not a UnityEngine.Object already has a value and is not null).
The [SerializeReference] attribute change that, so it serializes as a reference instead of a value.

tough cairn
#

i see

#

will need to do some more reading on this for sure , thanks for that

severe python
#

is there a way to handle style sheet differences between unity versions?

#

I'm trying to get things all together and I'm finding there are some properties that are one way in one version and another way in a newer version. I initially decided to just make multiple sheets and load different ones per version, but I get a ton of warnings even if I'm not loading the style sheet

tough cairn
#

@severe python isn't it possible to wrap the styles around conditional compilation per unity version ?

severe python
#

That'd be exactly what I want but I don't know what you're talking about?

#

Rather, I don't see anything in the documentation covering it in the ui elements developer guide

onyx harness
tough cairn
#

u can wrap anything in those regardless

severe python
#

I want unity not to scan the files so that it doesn't report warnings to the user

severe python
#

I hope you don't say code based styles :p

onyx harness
severe python
#

lol

#

I'm going to get Nitro just so I can use my guillotine emoji on you

neon anvil
#

Hello
Unity does not open my projects, I can open Unity Hub but not the Editor.
I use the latest version of Kali Linux (Graphical environment: XFCE)
Thankful😄

tough cairn
#

update to newer version of unity that has a safe mode

#

otherwise u can try and clone the code to a new fresh project

tough cairn
#

in unity 2020.1 there is a "safe mode" that lets you open the project if there are errors

#

clone it and try upgrading maybe would be my bet

neon anvil
#

i am 2019.4

tough cairn
#

so you want to open the project ?

#

but you can't ?

neon anvil
#

yes

tough cairn
#

what do you see

#

error ?

neon anvil
#

the unity image appears but soon after it stops

neon anvil
tough cairn
#

make new project same version

#

new empty project

#

copy "Assets" folder to new project

#

neon anvil
tough cairn
#

where is your project on the disk ?

#

/ProjectName/Assets <----

#

copy this folder

neon anvil
#

but where do i put her

tough cairn
#

in a new project

#

make a new project

#

with the same version

#

^ read my text again if you don't understand

neon anvil
tough cairn
#
1.新しいプロジェクトを作成します
2.古いプロジェクトから新しいプロジェクトにフォルダをコピーします
3.新しいプロジェクトを開きます 
tough cairn
#

what is this ?

neon anvil
#

my language

tough cairn
neon anvil
#

is a linux video?

tough cairn
#

nope

neon anvil
#

but my editor not open

#

my project is new

tough cairn
ashen dirge
#

Is there any editor shortcut that will let me jump straight to these Onclick functions in VS????

tough cairn
#

no

stark geyser
#

@arctic bolt Don't cross-post. Read channel description.

pale cliff
#

im relatively new to custom drawers, can anyone explain whats going on with this black box next to size?

visual stag
#

show code

pale cliff
#

in a code block or some external site

visual stag
pale cliff
#

the affectors list is full of Affector objects which also use a custom draw but i dont think thats causing the issues

visual stag
#

you should not need to do EditorUtility.SetDirty(property.serializedObject.targetObject); btw
The editor should be applying the changes to the serializedObject

pale cliff
#

oh im not sure why thats there

#

that was a test for some other fix ages ago

visual stag
#

what type of property is Size?

pale cliff
#

thats just what comes up for a list

#

this is the full thing

#

its the same as the Size thats showing at the top for Stat List

visual stag
#

Oh, I see

pale cliff
#

i may be doing things wrongly in my code as this is my first attempt at doing stuff with PropertyDrawers so feel free to correct anything

visual stag
#

your affectors rect might just be too thin

#

try making it much wider

#

I imagine the size field is negative width for that control

pale cliff
#

ah yes

#

it was width

#

so its working now within reason

#

some other unrelated issues that ill fix now but that was the main problem

#

thanks for that

sage oyster
#

is there a way to kind of, paste a picture in an editor window (or inspector i guess)

#

eg. Picture = null, drag and drop and picture and it shows

onyx harness
#

Picture = Texture2D, and yeah use DragAndDrop

neon anvil
tough cairn
#

what linux do you use ?

neon anvil
#

Kali Linux

waxen sandal
#

Unity only supports Ubuntu officially so you might just be out of luck

tough cairn
#

install ubuntu

neon anvil
tough cairn
#

no

#

🙂

#

nobody makes you

#

but

#

hear me out one this one

#

if you want unity

#

... well

#

🙂

neon anvil
waxen sandal
#

Don't ask me, ask Unity

#

Highly doubt they're going to support Kali officially though

neon anvil
tough cairn
#

I used Kali, its a good system , nothing evil about it

#

unless you are 😛

neon anvil
#

that's what i meant

tough cairn
#

install ubuntu if linux is what you want , all those Tools* in kali are not special - you can put them on any linux if that's why you don't want to switch from kali

neon anvil
neon anvil
#

@tough cairn can i use unity with Ubuntu 12.04.5 LTS?

#

because my computer doesn’t support the newer versions (I think)

tough cairn
#

u can use Ubuntu 16.04, 18.04 or CentOS 7

#

i have used it with ubuntu 19 and it worked ok as well

#

i don't think it will work in 12.04

#

unity began support for ubuntu in 2019 , maybe 14 will work

#

but i would still try it

neon anvil
#

ok

neon anvil
tough cairn
#

idk about those

#

u should ask on a linux discord about this

#

sounds like xubuntu is based on ubuntu

#

so in theory if it's supported by ubunutu with the same version then the xubuntu that is based on the same version will also support this

neon anvil
#

which would be the lightest ubuntu or centos?

tough cairn
#

idk

#

how much do they weight ?

#

this is getting off topic by the way

#

dm me if u have questions i could also recommend a linux server

neon anvil
#

I have:
4gb RAM
2x Processor 2.90gh
128mb VRAM

tough cairn
#

@onyx harness i never figured this emoji, is this a happy robot or a sad robot

onyx harness
#

Up to your mood I guess 😄

tough cairn
#

lol that's one way to answer a question

#

:pokerface:

tough cairn
#

dm = " send me a message on discord "

neon anvil
#

ok

humble mortar
#

How can I translate this script from 3D to 2D? (FieldOfView script: https://pastebin.com/DsWUrjHF). I'm currently trying to visualize the vision radius of the player using this tutorial: https://www.youtube.com/watch?v=rQG9aUWarwE, but I can't seem to get it to work.

Editor script:

using UnityEditor;

public class FieldOfViewEditor : Editor
{
    private void OnSceneGUI()
    {
        FieldOfView fov = FindObjectOfType<FieldOfView>().GetComponent<FieldOfView>();
        Handles.color = Color.white;
        Handles.DrawWireArc(fov.transform.position, Vector3.up, Vector3.forward, 360, fov.viewRadius);
    }
}

In this miniseries (2 episodes) we create a system to detect which targets are in our unit's field of view. This is useful for stealth games and the like.

Source code + starting file:
https://github.com/SebLague/Field-of-View

Support the creation of more tutorials:
https://www.patreon.com/SebastianLague
https://www.paypal.me/SebastianLague

▶ Play video
rigid ledge
#

what exactly doesnt work?

patent pebble
#

Can I use AssetDatabase.CreateAsset for my custom file types that have their own scripted importers and their own extensions?

So let's say I have this Example class and its importer, and the file has the extension .example

public class Example : ScriptableObject
{
    public string text;
    public string[] textSegments;
}

[ScriptedImporter(1, "example")]
public class ExampleImporter : ScriptedImporter
{
    public override void OnImportAsset(AssetImportContext ctx)
    {
        string json = File.ReadAllText(ctx.assetPath);
        Example example = ScriptableObject.CreateInstance<Example>();
        JsonUtility.FromJsonOverwrite(json, example);

        Texture2D icon = (Texture2D)AssetDatabase.LoadAssetAtPath(Example.IconPath, typeof(Texture2D));
        ctx.AddObjectToAsset("example object", example, icon);
        ctx.SetMainObject(example);
    }
}
#

When i create an instance of Example doing this:

Example example = ScriptableObject.CreateInstance<Example>();
AssetDatabase.CreateAsset(example, "Assets/SomeAsset.example");

The .example text file contents instead of being empty, they get set to this (as if I was creating a .asset file) :

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  ···
#

is AssetDatabase.CreateAsset only intended for built-in types?

visual stag
#

What on earth are you expecting it to do?

#

Yes, and ScriptableObject is a built in type. That's the expected file format of one.

#

(also, two backticks are not how to properly write single line code, it's 1 only. 2 will not display on mobile, nor in many markdown engines)

#

If you just want to write a file and import it, do that using system io and import asset

#

@patent pebble why use Json for this anyway?

patent pebble
patent pebble
tough cairn
#

how to get PropertyDrawer owner ?

#

( the object that owns the variables for witch the property drawer is used for , inside the property drawer GUI function )

visual stag
#

property.serializedObject.target?

tough cairn
#

yes

#

property.serializedObject.targetObject - - thanks vertex

gloomy chasm
patent pebble
#

curiously enough, my discord mobile doesn't care about 1 or 2 backticks

#

it displays both of them 🤷‍♂️

visual stag
#

Android?

patent pebble
#

yep

visual stag
#

Weird

patent pebble
#

on my phone it doesn't care, but 1 sec, lemme check on my Android tablet

#

same with tablet, doesn't care 1 or 2 backticks, displays properly

visual stag
#

Odd, that's the mobile ecosystem I suppose 🤷

patent pebble
tough cairn
#

i just spend 4 days automating what could have been done in 2 minutes making a script

#

i feel proud 🙂

onyx harness
#

So am I, good job 🙂

tough cairn
#

thank you kind sir , do you know where i can get professional help for my condition ?

#

jk ( moves on to refactor his little monstrosity )

tough cairn
#

food is better

patent pebble
#

It will also help us identify what stuff we should spend time on, you wouldn't want to spend 50 work hours in a tool that you will only use once in your lifetime 🙃

onyx harness
#

And one day, you will replace us all 🧙‍♂️

#

No more vertx, no more Navy, welcome Wad1m & MadLed!

tough cairn
#

thanks , what did i just became part of ?

onyx harness
patent pebble
tough cairn
#

lol i don't even know UIElements

patent pebble
#

me neither

onyx harness
#

Me neither

tough cairn
#

rofl

onyx harness
patent pebble
#

I've explored every corner and every line of code that IMGUI has to offer.
I have zero knowledge of UIElements. I haven't even opened the docs for that yet 🙃

onyx harness
#

Where you spent months, we spent years.
But lucky you, you got some help to go even farther & faster

patent pebble
onyx harness
tough cairn
#

that looks slick

patent pebble
tough cairn
#

^ html based ?

onyx harness
#

And from there, I will bequeath my knowledge upon you all! 🧙‍♂️

patent pebble
onyx harness
onyx harness
tough cairn
patent pebble
severe python
#

UIElements is great, but its new and its only been functional for like 2 major versions now

#

I'm using it in experimental (2018), and its weaknesses there are readily apparent

tough cairn
#

is there any stats on unity users per version ?

severe python
#

it seems pretty great in 2020.2

patent pebble
#

was performance their main motivation for making UIElements?
haven't read much about it, but seen some folks complaining it's much more work for stuff that is very very simple in IMGUI
so I guess they trade ease of use for performance?

onyx harness
tough cairn
severe python
#

maybe for the simplest stuff its easier

tough cairn
#

IMGUI is fast ( i mean it takes less time to make something )

severe python
#

So I don't disagree, but the moment things get a little bit more complex the time cost goes way up

onyx harness
#

And by complex, he meant very complex

severe python
#

the iteration cycles are slow because you have to wait for compiles so it just makes anything a little more complex just take a lot more time

#

nah, I mean a little

#

I can do any fine tuning in layout in uielements with instant feedback

#

to get the same thing in imgui you have to put the necessary values into variables that yuou can edit in another editor

onyx harness
#

I want to say no, but I know I am biased, you have more XP on this matter 🦀

severe python
#

I'm also biased because uxml is basicaly xaml for unity

#

so Ive got like a decade of relevant experience

onyx harness
#

I'm doing a lot of WPF recently

#

And I feel Unity is quite far from WPF technicality & powerfulness

visual stag
#

I really wish making and loading style sheets for both skins in UIToolkit was more straight forward than it is

severe python
#

its a half truth admittedly, XAML is a complete object graph language with data transformation built in

#

the things you can do with XAML are truly impressive. UXML lacks data templating, but its 'easy' to add it in, however its somewhat slow considering the problemd omain

#

what do you mean vertx?

#

I think UXML comes up a little short mainly in that you actually need to write code for it

visual stag
#

What's your method for styling windows for both light and dark mode

severe python
#

MIT licensed if you happen tow ant to steal it

visual stag
#

yeah - I wish you didn't have to write that

#

and maintain 3 style sheets

severe python
#

I wish I didn't have to write most of the code

#

well they have variables setup in the latest versions it seems

visual stag
#

variables?

visual stag
#

Ah, that's nice, I did not know

severe python
#

I'm not sure that you can sovle it using these mind you, but I imagine it makes it simpler to manage

visual stag
#

that definitely helps

severe python
#

I don't get to use these 😦

visual stag
#

but yeah, in IMGUI that's just all magically handled and I've barely had to make my own styling because you just steal from built-in

#

if I had a bunch of nice stylesheets prepared earlier, I think UIToolkit would be a breeze

severe python
#

so I think you're over thinking it

#

the thing is, if you avoid coloring things and use built in styles then you get light and dark automatically

#

if you limit yourself to managing the box model and layout, without setting colors then it mostly just works out

#

if you really want to add color, what I find works really well is just using grey scale and transparencies to establish differences in coloring

visual stag
#

yeah, it's the same go with UGUI there

severe python
#

managing the style sheets for multiple styles is a pita though

onyx harness
severe python
#

hence why my code there even exists, but honestly I think I was also over thinking it

#

I don't even get the Style tag, i'm trying to poly fill it in 2018 right now lol

#

just so I can use UI Builder to build some fast integrated documentation

tough cairn
# severe python to get the same thing in imgui you have to put the necessary values into variabl...

but can it do this ?

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class TempMono : MonoBehaviour {
    public void test() {
        Debug.Log( "Brah" );
    }
}
#if UNITY_EDITOR
[CustomEditor(typeof(TempMono))]
public class TempMonoEditor : Editor {
    public override void OnInspectorGUI() {
        if( GUILayout.Button("Test") )
            ( ( TempMono ) target ).test();
        GUILayout.Space( 20 );
        base.OnInspectorGUI( );
    }
}
#endif
#

also if u nest it u get access to private fields without reflection

severe python
#

I mean, due to the fact that you can't use UITK without code, you can still do this and just use UITK

#

instead of building your UI in the code, you'd just bind the UIElements to your object

#

I think Unity missed an opportunity personally, Unity should have setup a convention to load and bind UXML files to Inspectors without having to write any code

#

so if you don't need to execute any custom functions you could easily just modify the look and layout using UXML and USS

tough cairn
#

that would be neat for none coders indeed

severe python
#

its not a hard convention to setup either

#

hell, they could just let you assign templates to asset types like they do with icons

tough cairn
#

what i meant above is that u can make a VS template and have a quick way of extending your component in the same file

severe python
#

and then in the custom inspector maybe they just let you query the default template and do things like assign event handlers to buttons, etc.

tough cairn
#

i rly like the layout classes provided by default , immediate mode is just different paradigm of UI

#

it makes much more sense as a coder

severe python
#

absolutely, and it has certain strengths, that you don't get with a retained mode UI, like virtualization is trivial with immediate mode, its just something you do

tough cairn
#

what's virtualization ?

severe python
#

you have to put a bit more thought into a retained mode ui's virtualization though because of the layers involved

#

Virtualization is something you do to reduce the creation/destruction of objects in order to speed up UI and make it performent

#

technically you don't even do it in immediate mode, the nature of immediate mode makes it almost irrelevant

#

but say you have a list of 1000 items and you want to display those, in retained mode if you created all those ui objects it would take up a lot of memory and potentially take a good chunk of time to setup

tough cairn
#

ah right

severe python
#

with virtualization you only create the ones you can see, and maybe a few extra to make sure things look nice

tough cairn
#

i just shift the array start and end index

severe python
#

and then you just swap the data as you scroll

tough cairn
#

yes

severe python
#

in immediate mode its just basically automatic, you have a view range on an array and only render the values in that range

#

there are plenty of specific scenarios where one is better than the other, I just prefer that if I'm working on UI, I don't want to have to think about logic, I want to create the display I'm looking for, and add logic to it later

#

most of the time those are very disconnected concepts

#

Also, just in case anyone is curious, its entirely possible to make UXML files generated in 2019+ compatible with Unity 2018 using a few polyfill like classes

#

it was actually pretty easy

tough cairn
#

can you show an example ?

severe python
#

of what?

#

this polyfill thing?

tough cairn
#

backwards compatability

#

yes

severe python
#

yeah, one sec though cause I just broke it doing another experiment

#
namespace Polyfill
{
    public class UxmlVisualElementPolyFillFactory : UxmlFactory
    {
        const string unityNamespace = "UnityEngine.UIElements";
        public override string uxmlQualifiedName => unityNamespace + "." + uxmlName;
        public override string substituteForTypeName => nameof(VisualElement);
        public override string substituteForTypeNamespace => unityNamespace;
        public override string substituteForTypeQualifiedName => unityNamespace + nameof(VisualElement);
    }
}

edit: turns out you need less than I thought

#

just to be clear, what this isn't is a complete feature support back into 2018

#

it just makes the uxml files work because of the namespace mismatch, so you still have to deal with other incompatibilties

#

but this is great, because this more or less means I can work on my UI in 2020.2 and then just throw it into my 2018 project

tough cairn
#

2018 had uielements as well ?

severe python
#

in an experimental state, no support for inspectors

#

I'm making a compatibility layer for my project because I specifically need to be able to support a wide range of unity versions

quaint zephyr
#

In my editor, when I select my custom component, you know how OnDrawGizmosSelected kicks in? How can I show a GUI label in the Scene view like it was a Gizmo, and have that label follow a gameobject from the perspective of the scene view camera?

visual stag
onyx harness
waxen sandal
#

Maybe creating a VisualElement in UXML?

#

To create similar functionality to a div?

patent pebble
#

iirc the Handles or Gizmos class has a label function

severe python
#

That way I can use ui builder in 2020 and use the output uxml file in 2018

#

That specific chunk only works for visualelement

waxen sandal
#

Ah that's pretty cool

onyx harness
#

Interesting

severe python
#

This is the whole thing

#

Obviously not a complete solution, you can't actually backport all the features

#

But it will let the uxml templates work overall, giving you access to ui builder

#

I'm only using this for writing integrated documentation so it doesn't matter

#

But uxmlfactoriea are super useful it turns out

#

Sorry about that.. apparently the phone is aweful for this stuff

onyx harness
#

I'll keep that in mind for one day

severe python
#

well, only if you need to have some stuff working in 2018, uxml files are only the tip of the iceberg with incompatibilities, EditorWindows don't have rootVisualElement, they have internal rootVisualContainer, so you have to deal with that (I made a base class that maps)

#

I use reflection for that, though I should really just call GetRootVisualElement...

onyx harness
#

Good thing that 2018 LTS is soon to be over 😄

severe python
#

not for me lol

#

even if the game I like to do modding for upgrades to newer version of unity, which is a real possibility

#

the nature of the effort means I'm forever bound

#

well, unless the communities for the games in question either all die off or they all update to newer versions, I suppose thats possible

neon anvil
#

my terminal has the following error when starting Unity Hub (FLATPAK):

Traceback (most recent call last):
  File "/app/bin/start-unityhub", line 82, in <module>
    main()
  File "/app/bin/start-unityhub", line 74, in main
    env['TMPDIR'] = f'{env["XDG_RUNTIME_DIR"]}/app/{env["FLATPAK_ID"]}'
KeyError: 'FLATPAK_ID'
waxen sandal
#

Idk what flatpak is but forums is probably your best bet

nocturne geyser
#

Im tyring to use eulerAngles to find the rotation of an object (same as in inspector) but its incorrect, why?

waxen sandal
#

Unless this is a non editor question in that case, it doesn't matter it's the same rotation

nocturne geyser
#

thanks, yeah its for an editor.

quaint zephyr
#

How can I know which Editor GUI element is currently being focused on? Say I want to check if a certain TextField is focused (the cursor blinking in side, ready to receive input from keyboard) and I want to Deselect it. Can this be done easily?

quaint zephyr
#

What if I have children that have colliders set to it. And on the parent I have a list of those certain children. You know how the collider has that "Edit Collider Mode" button. Is there a way I can make a button on the parent list where I can click it and it will go into "Edit Collider Mode" for that particular child?

Or even better if it sets that mode for all those children at once? Or only way is to click the child in hierarchy and do it manually?

quaint zephyr
# onyx harness `GUI.FocusControl(null)`

Btw, I tried to actually set a focus control, and it works partially. It highlights the control, but doesn't respond to keys pressed until I actually click on it.
This is how I did it:

GUI.SetNextControlName("myField");
_name = EGL.TextField("Name:", _name);
GUI.FocusControl("myField"); // this only highlights the control, but no blinking cursor
EditorGUIUtility.editingTextField = true; // this shows the blinking cursor in that control
// but no keyboard response until I click on it manually
#

Seems only way to make it work without mouse is when focus control is set, you hit TAB twice and it works. 😛

onyx harness
#

hum that's strange

#

Maybe because you should give focus only once?

#

and not each frame

quaint zephyr
#

🤔 I’m away right now. But I didn’t think about that. I will check for that logic when I get back. Thanks!

shy vector
#

alright i'm completely stumped and google isn't helping. i'm trying to make a custom property drawer for a serialized struct that includes enums. for some reason, my enum field is not ending up editable. it displays the enum dropdown but i can't click on it to select it. i have very little experience with the editor...

gloomy chasm
shy vector
#

after endproperty?

gloomy chasm
#

Normally you would put EditorGUI.BeginChangeCheck() at the start of drawing your controls. And then a If (EditorGUI.EndChangeCheck()) { } after the last control. And put the applyProperties call in the if statement.

visual stag
#

you don't need to apply serialized properties in property drawers unless you're affecting another object afaik

#

the editor/your editor should be applying

quaint zephyr
gloomy chasm
shy vector
#

ok... let me see what happens if i just have the enum...

gloomy chasm
#

By the way, if you want it to act like other property drawers, you don't want to zero out the indentLevel like that. If you do, it will not respect the indent level of things like classes that it is in or other foldouts in the inspector.

quaint zephyr
#

How can I trigger a "Edit Bounding Volume" on a trigger via CustomEditor from a different GameObject? Is this possible?

shy vector
#

ok i'm an idiot

quaint zephyr
shy vector
#

i made the height of the enum rects really small...

#

hah

#

"EditorGUIUtility.standardVerticalSpacing"... i just changed it to 17. ok thanks guys, sorry for a dumb question.

gloomy chasm
#

OH, yeah, you want EditorGUIUtility.singleLineHeight

shy vector
#

yes, that's right

#

thanks!

whole steppe
#

Are there any alternatives to c# reflection like a library with faster access, less gc alloc?

onyx harness
#

Bypassing Reflection?

#

Hard path

whole steppe
#

Not bypassing it but something similar, I think BOLT in it's preview images showed something like 6* faster than standard c# reflection

onyx harness
#

XD

#

show me

whole steppe
#

It got me wondering if their is an alternative to standard reflection

onyx harness
#

bolt apparently

whole steppe
#

Any idea what they are doing?

waxen sandal
#

If I were to guess they're emitting IL to access those methods

#

At build time

#

Lets ask in their server

onyx harness
#

By emit you mean Emit or just converting node to C#?

waxen sandal
#

As in, emitting IL into the compiled DLLs that contain the methods bolt wants to call

onyx harness
#

Altering the DLL? Why not

waxen sandal
#

I mean Unity is patching Path.GetFullPath so might as well

whole steppe
onyx harness
#

Oh they do much more X) but yeah

waxen sandal
#

The official bolt server, it's in their description

waxen sandal
onyx harness
#

They have a huge use of Mono.Cecil to automatically apply their backward compatibility

#

Beside that, @whole steppe I would go Emit as well if you want near native performance

whole steppe
#

I wanted to implement this btw

onyx harness
#

Since I guess you are doing runtime over internal stuff, Emit works well for Unity Editor

whole steppe
onyx harness
#

This is a hard path as I stated earlier

#

You need to understand IL (assembly-like stuff)

#

This is not a way I would suggest if you are not aware of those things

whole steppe
#

So if not this then are there any ways to implement reflection in a optimized manner?

#

Right now it takes 2ms just for an assembly with two classes, to find fields with a attribute

onyx harness
#

Is it any assembly?

whole steppe
#

Just two c# classes in an assembly using assembly definition

onyx harness
#

If you don't want to use TypeCache you can optimize somehow by narrowing the search to just look up Unity assemblies

#

If you are looking for fields with an Attribute that is YOURS

onyx harness
#

You can narrow down the search to only assemblies referencing your code

#

Probably put down 2ms to <1ms

#

Except if your assemblies are huge

waxen sandal
#

Which is probably the case since Unity

whole steppe
#

Just out of curiosity what does unity events use?

onyx harness
#

Simple C# delegate

waxen sandal
#

It uses reflection to create a C# delegate

rigid abyss
#

I hate to be a bother but does anyone know the proper way to access functions from a C++ dll plugin? I see a lot of tutorials saying to use 'extern "C"' instead of just 'extern' but it doesn't seem to be an option for the plugin I am trying to import.

gloomy chasm
onyx harness
#

Can you elaborate?

gloomy chasm
#

Here is a really good blog about Expressions. It is long, but pretty thoroughly explains how to use Expression https://tyrrrz.me/blog/expression-trees
But basically, you create an expression for the method info with Expression.Call(instance, methodInfo). Then create a lambda expression for it and compile it in to a delegate.

onyx harness
#

Oh yeah, similar to emiting IL

gloomy chasm
#

Yep, expressions are pretty cool! iirc the VFX Graph uses them for their nodes.

waxen sandal
#

Generating those is quite expensive though

#

IIRC you can call it through reflection multiple times before it pays off

onyx harness
#

Usually, if you start going toward IL, it means you need performance, implying more than "few" calls

waxen sandal
#

Sure but it's not a fair comparison 😛

onyx harness
# waxen sandal Sure but it's not a fair comparison 😛

I don't see where generating is expensive.
I had a case in NG Console, where the initialization of 50k logs after domain reload took roughly 0.9s.
I converted the Reflection part (6 GetValue()) to native using Emit and it went down to 3ms.
I was pretty amazed by the result and it was a good reminder of the cost of Reflection.

civic river
#

Do you need to take into account platform specifics when you're writing editor emit code?

copper laurel
#

when I went to install the unity hub it appears to me "requires windows 64 bits" is there a version of the unity hub for 32 bits? because I didn't find anything about

gloomy chasm
#

Is there a way to set the selected object to an asset, without moving the project browser to focus it?

onyx harness
onyx harness
civic river
#

I see, I have a similar application where I'm using a few GetValue per object and it's proving to be quite expensive

#

I might give it and go and see what breaks lol

gloomy chasm
ancient sable
#

Hi all, I have been trying to figure out how to play multiple audio files simultaneously from a function in an editor window script.

I wrote a post here with two working examples of playing single clips one by one. But can't seem to have more than one clip play at once.
https://forum.unity.com/threads/playing-multiple-audio-files-simultaneously-from-an-editorwindow-script.1071593/

#

I've also begun considering combining the audio clips into one and just playing it.

gloomy chasm
ancient sable
#

I have my own timeline editor tool that now handles audio but not being able to sample more than one at a time is a huge problem.

#

This bit of code looked promising

System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer()
myPlayer.SoundLocation =PathToWAVFile
myPlayer.Play();

However even called from a new thread will still end the currently playing clip.

civic river
#

(UITK/Visual Elements) Anyone have some thoughts how to mitigate this jittering effect that's caused by the text field resizing my visual element?

#

you can see as the text field initially pushes the node's size it jitters the size of the text input box around a bunch =x

bold moth
#

The type or namespace name ‘Editor’ could not be found

#

I know it must be simple because it’s a name space but I don’t know what

#

The errors marked at
public class MapGeneratorEditor : Editor {

waxen sandal
#

Use UnityEditor.Editor

#

Your namespace is named Editor so it gets confused which one you want

bold moth
#

I changed it to public class MapGeneratorEditor : UnityEditor.Editor

And the line below now complains

Public override void OnInspectorGui () {

#

The error

MapGeneratorEditor.OnInspectorGui() no suitable method found to override

waxen sandal
#

Might be GUI instead of Gui, check the docs

bold moth
#

Yeah it was GUI instead of Gui

#

[CustomEditor (typeof (MapGenerator))]

#

came up with a error saying the name 'CustomEditor' could not be found

#

I dont know if im running on a old tutorial or something because im following it and getting errors with something they did not have errors with

robust ledge
#

Hi! 😃
How can I get my visual studio code to show the different colors of my code and the code auto-completer?

waxen sandal
robust ledge
#

Oh, okay, thanks!

waxen sandal
bold moth
#

no

#

fixed

robust ledge
waxen sandal
#

Probably because you're missing the unity plugin in VS

#

But not sure since I don't use VS

wheat kettle
#

I just joined

#

And hi

robust ledge
robust ledge
wheat kettle
#

Can someone tell me why he has 4 fingers only

#

And can someone help me make a new one.

robust ledge
#

I prefer visual studio if possible though 😅

bold moth
#

true

#

but ive just given up on visual studios

robust ledge
#

Why?

#

Did you have the same problem like me?

bold moth
#

no others

#

other issues

#

Im fine with notepad++ thoe

#

Its never been annoying

pastel osprey
#

Does anyone have a robust way of determining if cursor is over any handle?

Im using control IDs and HandleUtility.nearestControl to check and cache various handles, but im also using PositionHandle and similar where I dont see a way to set/get the control ID for that handle?

waxen sandal
#

Doesn't positionhandle handle that themselves?

#

Or do you want to do custom things?

pastel osprey
#

Yea im using the control IDs to "mask" the scene view for custom click operations (ie: dont do the custom click stuff when im over a handle).

#

Which works fine for most of my handles, but not when I want to use Position/Rotation/Scale handles

waxen sandal
#

Yeah... I don't think there's an easy way to do that

#

Might want to check the source if you can somehow get it

#

Or override it

pastel osprey
#

Yea I guess its time to do that...

indigo epoch
#

can someone help me with some editor code. currently my project has gotten to the point where it needs to startup from a startup scene for it to function properly but i dont want to have to keep loading in the startup scene to play-test properly then switch back to the original scene to make a small change and go back. i know how to create a editor window and such but i dont really know how to make code that ideally saves the loaded scene switches to the startup scene presses play.... then once you stop playing it auto switches back to the original scene

#
#if UNITY_EDITOR
    using UnityEditor;
    using UnityEditor.SceneManagement;

    [InitializeOnLoadAttribute]
    public static class DefaultSceneLoader
    {
        static string LastSceneLoaded = "";
        static DefaultSceneLoader()
        {
            EditorApplication.playModeStateChanged += LoadDefaultScene;
        }
        static void LoadDefaultScene(PlayModeStateChange state)
        {
            if (state == PlayModeStateChange.ExitingEditMode)
            {
                EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            }

            if (state == PlayModeStateChange.EnteredPlayMode)
            {
                LastSceneLoaded = EditorSceneManager.GetActiveScene().name;
                EditorSceneManager.LoadScene(0);
            }
            if (state == PlayModeStateChange.ExitingPlayMode)
            {
                if(LastSceneLoaded != "")
                {
                    EditorSceneManager.LoadScene(LastSceneLoaded);     
                }
            }
        }
    }
#endif
#

nvm found something!

waxen sandal
#

There should be a startup scene variable you can set somewhere

quaint zephyr
#

I have a prefab asset I am accessing from custom editor. In my situation I need to modify a private field of that asset. And although I can properly read it via reflection, when I SetValue, nothing happens. I am doing all this via static methods because of InitializeOnLoad and MenuItem calls.

#

How can I set that prefab value from there and so it will persist to the asset itself and save?

civic river
#

@quaint zephyr Can you post the code? There's quite a bit involved here

quaint zephyr
#

Oh snap I forgot to delete the message. I'm sorry. Through heavy trial and error and tinkering around, I was able to figure it out. Thank you for follow up though!

civic river
#

👍 a victory then ;p

quaint zephyr
#

Indeed. Probably would of been a lot easier and faster if you got on this at noon though 😛

onyx harness
#

You should not erase your message, you should post your solution, in case, for someone else learning something (I understand Discord not the best for archiving...), for advanced users to correct.

onyx harness
#

This way you possibly learn twice @quaint zephyr

civic river
#

I have no explination and an hour of trying has yielded nothing, I can literally only get my asset to write if I force the asset database to throw which makes absolutely zero sense.

Throws:
https://hatebin.com/grmboygang

#

no throw

#

doesnt write

rigid ledge
#

docs arent really explicit about what happens when you save the asset, try calling AssetDatabase.Refresh after saving?

patent pebble
#

No idea about this. But have you tried setting it to dirty?

severe python
#

Anyone happen to know if the Unity Package manager will handle git submodules for a git package project?

civic river
#

After a few hours I seem to have solved the problem by copying the code into a new project

#

~,~

#

I guess if it works it works

hazy umbra
#

Hello guys, is there any way to draw gizmos from a scriptableobject when you select it ?

waxen sandal
#

Custom editor and then use handles

hazy umbra
#

ok thx

trail dawn
#

Thought I'd ask here as well, but is anyone experienced with Odin Inspector and specifically customizing the MenuTree/MenuItems?

#

I'm struggling to understand how to override menu items such that I can change their draw colours.

quaint zephyr
onyx harness
quaint zephyr
#

What if my solution involved some conflicting code in another script/logic that produced this problem for me and had nothing to do with what I was asking in the first place? 😛

onyx harness
#

If the solution is typically local, yeah keep it to yourself 🙂

snow bone
#

I'm drawing gizmo's onto a character in the scene view, but the mode obscures the gizmo's, is there a way that i can make the gizmo's be drawn on top of the scene objects please?

#

The wire gizmo's are ok, but the solid gizmo's get obscured.

patent pebble
#

I'm having a little bit of trouble with SerializedObjects in this context:

public class SomeEditor : Editor
{
    private bool _someBool;
    private SerializedProperty _someBoolProp;

    private void OnEnable()
    {
        SerializedObject sObj = new SerializedObject(this);
        _someBoolProp = sObj.FindProperty("_someBool");
    }
}

It doesn't find the property. Is it because I can't create a SerializedObject of an Editor type?

#

I remember being able to do something similar to this. But can't find it 😓

onyx harness
#

Private?

patent pebble
#

oh my god

#

i'm so stupid

gloomy chasm
patent pebble
#

setting the field to public or using [SerializeField] fixed it

patent pebble
#

another question regarding that. Are Custom Editors serialized by default like a Monobehaviour is?

#

when i click away and come back to that custom editor it loses its values

#

I suspect Custom Editors are just instantiated when inspecting the target object, is that why?

onyx harness
#

Editors are not persistent

patent pebble
#

and move the rest to the target class instead?

#

(or serialize it manually to ScriptableObjects,json, etc)

onyx harness
#

Keep that in mind and everything will be find

patent pebble
#

oke, thx for helping me understand this aspect of Serialized Objects 😊

onyx harness
patent pebble
#

I'll keep my eyes peeled 👀

#

That has to be potentially one of the most helpful tools for learning how to extend the Unity editor

#

it seems like it's a monstrous amount of work to cover everything, props to you! @onyx harness

onyx harness
#

Unfortunately, it will only cover what I know, and there are a vast amount of areas I don't master.
But I am willing to make it community-driven, by allowing people to write tutorials/cheatcheets

#

Unfortunately again, I am putting a Patreon/BuyMeACoffee, maybe people won't like that 🐑

patent pebble
#

I mean, either you get financial support through Patreon and similars, or sell it as a paid asset

#

either way, the idea of community driven content for it seems neat, and specially if the stuff people add is in someway curated (either manually or through a voting system or something)

onyx harness
#

I won't make people pay for learning 🙂
They can support, but that's totally optionnal

patent pebble
#

I would gladly pay for a tool like that one

#

i guess that's up to you if you want to charge for it or not

#

you could always try to sell it to Unity Technologies or something 👀

onyx harness
#

Hahaha so they can mess it up rightafter? No no no XD

severe python
#

kinda like the InEditorTutorials thing that Unity just put out in pre-release/preview?

onyx harness
severe python
#

ahh okay, I've been working on an in editor documentation engine this past week or two, and then unity announced that in the blogs, I was a little annoyed, especially since it doesn't work on 2018

#

I'm not surprised it doesn't, just annoyed

#

because it means I still have to make my system

onyx harness
#

2018 LTS is almost over, not surprised

severe python
#

yeah, its going to get progressively more sad for me, its never going to get better 😦

onyx harness
#

I wrote a complete tutorial system 4 years ago, never released it, at some point I realized it would be too much work for maybe nothing

#

Drop 2018, drop it

severe python
#

I literally can't, its not an option, like, I'd be dropping support for myself

#

the game I do modding for is ror2, they are on 2018, they might move up a version, but even so

#

modding is wierd, you really need legacy support as much as possible

#

since the users have no say over unity version, at best they can nag the game developer

#

sometiem i'll put this project down and get back to working on a game and then I'll be back to working against bleeding edge builds

onyx harness
#

We are eternally cursed🐼

shrewd turtle
#

Anybody know how i can scale the unity editor ui?

sage oyster
#

trying to work with assembly definitions. i want a root script/asm eg. namespace Root, and then branched into other folders/asm eg. Root.A Root.B. but how do access using Root.(class) in my branches? doesnt seem to find them

#

i set the branch assembly references to my root asm, but the code in it doesnt come up

snow bone
#

In my editorWindow, each time i save the code, some of the variables get reset, such as bool values etc, is there a way that I can stop these being reset each time i make a change to the code?

onyx harness
#

Save them.

snow bone
#

isn't there an easier way

onyx harness
#

lol

#

Make them public

snow bone
#

that doesn't work

#
public class MyEditor : EditorWindow
{
    #region Instance Variables
    public static bool showModelGizmos = true;
    public static bool showAvatarGizmos = true;```
onyx harness
#

You can't persist static fields.

snow bone
#

so, could I have a non-static public field and assign that to the static perhaps, would that work?

onyx harness
#

Yes

#

Weird design, but it works

#

Just remember to assign back the value when changing the static field.

snow bone
#

thank you

onyx harness
#

(Which makes the static senseless)

snow bone
#

the statics are only there because i'm drawing gizmo's which is a static fn

onyx harness
#

If it works, it works

snow bone
#

i got fed up of resetting lots of settings each time i build

onyx harness
#

Still

#

Do you use those static fields in MyEditor?

#

How come the gizmos does not know MyEditor?

snow bone
#

this is my gizmo fncs [DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Active | GizmoType.Selected)] static void DrawGizmos(DrawMetaBones scr, GizmoType gizmoType) {

#

the editor basically adds an empty component to the target model, so DrawMetaBones is basically an empty class, so that I can draw the gizmos

onyx harness
snow bone
#

i wasn't sure if there was a better way, but it worked that way. i also have to add the component. i can put the draw gizmo's in the DrawMetaBones script if necessary

#

it's an editor for use with the avatar config, so when that's opened, there is no component on the model, so i have to add it manually

fickle copper
#

hello lads!

I am currently having problems aligning an EditorGUI.Toggle() ui element in my unity editors:

#

The toggle element is a Property Attribute linked to a Property Drawer. I am not sure how to make it so that it aligns properly with the original property.

#

Help would be much appreciated

snow bone
#

my gui code knowledge is a bit crap and can't help, but i feel your pain dude.

fickle copper
snow bone
#

is it the Fire Type box you can't align?

fickle copper
#

No, its this bit

snow bone
#

i probably should have prefixed that with probably can't help instead of can't, as I'll take a look anyway

fickle copper
#
 if (property.objectReferenceValue != null)
                b = EditorGUI.Toggle(
                    new Rect(r.x + (EditorStyles.inspectorDefaultMargins.padding.horizontal + r.width / 2f) / 1.5f, r.y,
                        r.width / 4f,
                        r.height), b);
#

This bit right here has the wrong rect info

#

not sure how to align the rect info exactly with the original property

onyx harness
#

Offset X, substract indentLevel * 15F

fickle copper
#

On which exact part?

onyx harness
#

Probably your toggle

fickle copper
#

I dont edit the indent level of the toggle at all

#

the indent level is being edited after the second editor is being drawn, which is further below

#

that section is fine

onyx harness
#

Yes, but look at your picture, you clearly see the Toggle is off-area because of the auto indentation from Editor

fickle copper
#

As for the indentLevel, i should probably reset it after i draw the Toggle so that the editor below can be indented correctly

onyx harness
#

You are offsetting yes, but is the result ok for you? Otherwise you wouldn't be here

snow bone
#

@onyx harness should i put the DrawGizmos in the DrawMetaBones that I'm adding as a component instead of having it in the editor, then assign the static fields from the editor perhaps?

onyx harness
#

It often happens that an issue was the consequence of another issue

snow bone
#

damn those other issues and their consequences¬

onyx harness
snow bone
#

not really, i'm just wondering if there is a better way to draw the gizmo's, i feel like it's a bit of hack way to do it having the gizmo's in the editor

#

it's just advice really from a seasoned & knowledgeable person who has more experience than myself in these matters

onyx harness
#

Keep the variables near their users

#

It's a bit strange to see static fields from Editor being used from the DrawGizmos which is.... in a MB?

snow bone
#

MB?

onyx harness
#

MonoBehaviour

snow bone
#

i don't know any other way to draw gizmo's on a gameobject without having a component on it. the original text i used for reference had the draw gizmo's on the MB

onyx harness
#

This is the normal way

snow bone
#

shame there isn't a mandalorian emote! lol

#

the draw gizmo's is using the data from the editor, just for visualization

#

I'll put the draw gizmo's in the MB and see what happens and let you know

onyx harness
#

Wait, from where is your gizmo drawn?

snow bone
#

from within static void DrawGizmos(DrawMetaBones scr, GizmoType gizmoType)

onyx harness
#

Sorry, but you are so cloudy X)

#

I need the level upper

#

The class

snow bone
#

I'll try and explain what my editor does, maybe that will help

onyx harness
#

Go on

snow bone
#

it's for use within the Avatar config, I drop an asset into an field within the editor, this searches the scene for the appropriate Transform, in the case of the Avatar config, this would be something like Bot(Clone),. the editor then looks at bones from the model and also the avatar meta file, it then adds a component onto the transform so that it can then draw gizmo's onto the Bot(Clone) transform.

fickle copper
snow bone
#

in a regular scene, i could just add a component and it would remain on the Transform, but as it's in the Avatar config, i have to dynamically add the component, which gets removed when the Avatar config is exited.

fickle copper
#

certain offsets work, but only for one size of the current editor ui scale.

#

the second i move or rescale the window, it just breaks

#

We can discuss this later as this avatar config editor sounds more interesting.

snow bone
#

The editor is for saving Avatar configuration poses, so that when I edit a pose within the AvConfig, I can move a joint and if it's wrong, I can reload a pose without losing other changes I made that are good.

#

I got really pissed off with changing a joint and unable to revert back to a previous pose when trying to make retargetting of characters fit better with the animation

onyx harness
snow bone
#

ie, when i retarget a different character to an animation, the retarget character's head is looking into the ground, so moving the head in the retarget model is required to make it look right, but then when I do an arm and screw that up, there's no way to revert that change to it's original without losing everything that I've already done

#

that's correct

onyx harness
#

Do it, print me a screenshot

#

Maybe it will clear things out

fickle copper
onyx harness
#

And what happens if you set X = labelWidth?

fickle copper
onyx harness
#

it goes to the right? No no no XD

#

This is not possible

fickle copper
#

doing r.width / 2f does not put it correctly:

fickle copper
#

wait, that works on every scale

#

It literally took me 2 months to come to this..

#

Time to jump of a bridge i guess..

onyx harness
#

Don't worry, one day I will release my tutorials, I will cover those simple but primordial stuff 🙂

snow bone
#

I did that once and bent my middle lower tooth inwards when i hit the water from a summer sault, i then went to the dentist for my final appointment, who'd spent the last 4 years fixing my teeth, she was NOT impressed at all.

onyx harness
#

I'm no mod, but meme are not allowed 🙂
If Fogsight comes he will beat you up

onyx harness
fickle copper
onyx harness
#

A normal offset X with labelWidth would draw on the right part.

snow bone
#

reality is just the confusion caused by the lack of alcohol

onyx harness
#

But the indentLevel is tricking you, adding the 15F, therefore you think it works, but it's "luck"

#

Just remember labelWidth is the left part and you'll be fine

snow bone
#

how would you suggest i inject the editor into the MB?

onyx harness
#

Use an interface

#

So your keep your code clean.

fickle copper
#

uhm...

#

stacking the property onto itself is uh..

#

intertesting

onyx harness
#

interface IMyVariable
{
bool showModelGizmos { get; set; }
}

fickle copper
#

i see the illusion you are speaking of..

stark geyser
#

@fickle copper Don't post off-topic media, please

fickle copper
onyx harness
#

Warned ya 🙂

fickle copper
stark geyser
#

Sure.

snow bone
#

if i want to post a meme, i normally delete is about 30s later

#

otherwise, they clutter the conversation up, which is probably why they are banned

fickle copper
#

I keep my memeing prowers to my emoji game, dw.

snow bone
#

plus, having a vid repeat over and over is a little annoying after about 30s

fickle copper
#

Also @onyx harness I solved the problem by adding more illusions:

#

Here is the offset code: offsetRect.x = EditorGUIUtility.labelWidth - (15f * EditorGUI.indentLevel);

onyx harness
fickle copper
#

Yes, my very small brain realised your comment

#

like 3 minutes ago

onyx harness
#

2 cases closed, my quota is done for today 🙂
Have a good one!

snow bone
#

thank you for your assistance

fickle copper
#

you are a god sent ❤️

snow bone
#

injecting the variables works well

#

no more statics!

onyx harness
#

This design is more robust, resilient

#

Also prettier

snow bone
#

I'm using this cs public interface IDrawBoneGizmos { bool showModelGizmos { get; set; } bool showAvatarGizmos { get; set; } } public class DrawMetaBones : MonoBehaviour, IDrawBoneGizmos { public bool showModelGizmos { get; set; } public bool showAvatarGizmos { get; set; } public void OnDrawGizmos() { DrawRefGizmo(); //DrawAllBoneGizmos(null); }

#

is that what you meant with the injection?

onyx harness
#

Almost

#

Editor must have it

#

DrawMetaBones must use it

onyx harness
#

Those are 2 different things

snow bone
#

I'm using EditorWindow only, i was using the word editor as a general term

#

i'm not sure how i'd pass the EditorWindow reference to the MB

#

the interface i shown above, isn't really injection at all, just an interface, i don't really need the interface in that example

onyx harness
#

Your EditorWindow is creating the MB right?

snow bone
#

yes, there's a call to AddComponent, im guessing I pass the reference into it at that point

onyx harness
#

Yes

#

You pass a IDrawBoneGizmos to your MB. It keeps it and uses the variables from there

snow bone
#

that works nicely

#
public void DrawGizmos(IDrawBoneGizmos editorWindow)
    {
        editor = editorWindow;
    }```
onyx harness
#

SetDrawGizmos is better

#

The verb Draw is very specific to drawing.

snow bone
#

you are correct, i just hacking away

onyx harness
#

Keep semantic in mind, it improve the code

snow bone
#

I've read a lot about clean code and design paradigms etc, however when there isn't someone picking up faults and stuff, it's not easy to identify where those principles and practices can or should be used

onyx harness
#

It takes a lot of time/XP to properly name your code

snow bone
#

i'd say that is the simplest but most difficult part of coding, the hours i've spent pondering over what I should name something...

#

I would have renamed that fn given time

#

i was debugging a send to printer function, this was the first call to send something to be printed, I spent nearly 1/2 a working day looking for the code and eventually gave up, I asked one of the senior devs and he answered alomost immediately. the name was completely misleading, not even remotely connected to printing something.

#

why had no one thought to name it something meaningful was totally beyond me

misty igloo
#

anyone got any hints for drawing a line in a customer editor window? i.e. point a to point b (could be diagonal) with a set colour and width

waxen sandal
#

Use GL

misty igloo
waxen sandal
#

Probably?

deep wyvern
#

why do you need to draw it without ongui?

halcyon pine
#

Ok, so to go into more detail I have a simple editor script that changes several variables in the script. Those variables are also keyframed, and if I select each of those values I can manually add the new values as keyframes- but it is a very tedious and finnicky process.

Ideally, either the script would register as a change for the animation window recording to save(ideal) or the script would be able to tell what animation is currently being edited and keyframe the new values to that animation directly.

#

I am completely open to being told that there is a much better solution I am unaware of 😄

waxen sandal
#

Would Selection.ActiveObject return the right animation?

#

You can use assetpostprocessors to check when the animation controller is being saved

visual stag
#

the animation window can be locked, but if that's not relevant, that can work

waxen sandal
#

Oh right, there's an internal method on the inspectorwindow that returns the right object if it's locked iirc

halcyon pine
#

Navi- it isn't being saved; that's the problem. Going back to the animation window, scrubbing the timeline, etc lose any script-entered data

visual stag
#

I'm a little confused by what exactly is going on, you're changing values via an editor, and then you want to keyframe them into an animation?

halcyon pine
waxen sandal
#

If it's not saving then you probably need to use serializedobjects or record it with Undo

halcyon pine
#

But when setting the values via script, the animation window isn't registering the values as having changed and can't 'see' the script-edited values at all unless I manually click on the vaiable in the inspector and then hit enter to save it.

waxen sandal
#

You should show some code

halcyon pine
#

Ok. Bear in mind that it is very ugly temp code.

#

All I'm doing is ```public void registerQuad(){

p0 = vertices[0];
p1 = vertices[1];
p2 = vertices[2];
p3 = vertices[3];
    
}```
waxen sandal
#

I've probably seen worse from people that were totally serious about it

halcyon pine
#

What it is doing is reading the vertices from a quad to four variables.

#

(An annoying workaround because you cannot access array values via animator.)

waxen sandal
#

What's p0?

visual stag
#

I'm confused, where's the value you're animating?

waxen sandal
#

Need more context here but it's likely that register things with Undo

halcyon pine
#

the four variables are just regular Vector3

visual stag
#

are you just animating these p values?

halcyon pine
#

Yes.

visual stag
#

if so, you'll have to record them with Undo.RecordObject, or SerializedObject functions

#

otherwise they're not dirtied

halcyon pine
#

Ok, I'll look into that.

#

Is one more suitable than the other?

visual stag
#

by the looks of it, Undo will be easier for your situation

waxen sandal
#

If they're not recorded with Undo or SerializedObject then they're not serialized (aka saved) to the actual backing file

visual stag
#

well, Unity just doesn't know they've changed

#

they're not written until later

#

when the actual save occurs

waxen sandal
#

True but getting into when it's actually saved gets more confusing

visual stag
#

Though, I'm not exactly sure what happens with the files in the Library, I've never really gone into knowing when they're written

halcyon pine
#

Ok

#

Thank you.

#

While on the subject, I wasn't able to get any real ideas aside from 'just make a variable for each entry in the array' for how to access array values from an animation. Don't suppose either of you do have a better suggestion for doing that?

#

Editor scripting refs I've looked into seem to not reference the built in animation tools much

visual stag
#

I'm also not sure what that means exactly, values in arrays are the same as others

#

their property paths are just a bit fiddly

halcyon pine
#

Yes, except that the animation window won't let you animate them. Or if it does, it is too obscure for me to find how.

visual stag
#

I can't remember, but I'm sure it's the same as usual

#

I'll take a look

halcyon pine
#

If you could figure that out It would make this whole process a LOT easier

visual stag
#

oh weird, you can't

#

I swear I've done this before 🤔

halcyon pine
#

Right? Super weird.

visual stag
#

maybe I've just done it via editor scripting

halcyon pine
#

That is why I did the workaround with having a variable for each array value. Which is obviously not ideal for SO MANY reasons.

#

For larger meshes I am considering spawning a child gameobject for each vertex and just using them to store keyframes. But that seems unnecessary and messy.

#

Also, once it is doing that I almost feel like I might as well just use a skinned sprite renderer and put a bone on each vertex >.>

visual stag
#

how do you get the animation window to manually edit a property again

#

I swear I've clicked it in every fathomable way

#

either way, I tried by code, and all though Unity knows the properties are targetted via the inspector

#

the animator doesn't

#

and they're ultimately not animated

#

looking at some of the things I've animated in the past doesn't make me feel confident animating arrays is a thing haha

worn falcon
#

hey i set up unity but i cant select vscode for C# script editor
i have ubuntu linux and i cant find that extension

hallow flax
#

Hi,
i made an custom Editor Window where i can drag game objects (which create a button with object name) however those added buttons disappear after i hit Play button, how can i keep them ?

visual stag
#

Do not cross-post

#

you've been cautioned before

ivory frigate
#

ops sorry I just thought my question is related to both channels

visual stag
#

Even if it did, it wouldn't make it appropriate to do so

#

Plus, it does not relate to this channel

#

This channel is for authoring custom extensions

ivory frigate
#

ok about that

mighty void
#

Hi, i'm struggling installing Nuget package into unity, i installed Nuget For Unity, and then i installed 'Network' and 'Network.bluetooth' to my project, but unity says i am missing an assembly reference, any ideas to remove the warnings ?

waxen sandal
#

Include the dependencies it needs

#

And this is not the right channel

#

This is for developing your own extensions and not help with an extension

mighty void
#

Oh sorry

#

I'm switching

indigo epoch
#

Ok so i have the DungeonGenerator script

#

Its attached to a game object

#

Then i have a DungeonGeneratorEditor script

#

That gives me a nice GUI to interact with

#

ive gotten the varables and fields to work fine

#

but for example on the top you can see 4 tabs

#

i have a int varable that stores the current tab your on

#

from 0 - 3

#

if i store that varable inside of the DungeonGeneratorEditor script the value gets reset when i deselect and reselect it

#

And i dont want to store that value on the DungeonGenerator target script because that feels clunky

waxen sandal
#

I don't remember but if you serialize the int on your Editor, does that work?

indigo epoch
#

Nope

onyx harness
#

Editor is not persistent. You can't do that

indigo epoch
onyx harness
#

You must use EditorPrefs

waxen sandal
#

Yeah I thought so

#

EditorPrefs or SessionState

indigo epoch
#

Intresting

#

Ill try that

waxen sandal
#

Keep in mind when using editorPrefs, it's cross project

#

Aka all editor instances no matter what project

indigo epoch
#

Nah thats fine ill just prefex it with DungeonEditor_

#

so like this?

#
                int SettingsToolBarInt = EditorPrefs.GetInt("DungeonEditor_SettingsToolBarInt");
                SettingsToolBarInt = GUILayout.Toolbar(SettingsToolBarInt, new string[] { "General", "Dungeon", "Layer", "Room" });
                EditorPrefs.SetInt("DungeonEditor_SettingsToolBarInt",SettingsToolBarInt);
waxen sandal
#

Might want to prefix something with the instance as well since otherwise all of them will be expanded

#

Assuming you'll have multiple

#

And I'd probably load/save in OnEnable/OnDestroy

indigo epoch
#

Nah your only ever supposed to have one DungeonGenerator

#

Its incharge of all of the math to generate dungeons

#

its over 2.6k lines xD

waxen sandal
indigo epoch
#

Lol im hoping to shrink that by breaking the mathy stuff into multiple script and im planning on going throught the whole project with rider and just refactor

solid pollen
#

Hi 🙂 I hope this is the correct place to ask this! I have a quick question about custom Unity Windows. Is there a built in way to create something like the side menu in the Preferences window? For reference:

onyx harness
#

Nothing I know of

solid pollen
#

That's what I thought, I looked everywhere and couldn't find anything. It's a tricky thing to google search though 😛 I guess I'll keep using Selection Grid

onyx harness
#

Just get look at the source code, it's nothing furious

solid pollen
#

Yeah, I will do so when the time allows, I'm a bit pressured on time, so Selection Grid will do for now. Thanks for the help!

onyx harness
#

Simply put, it is just 1 horizontal and 2 scroll views

split bridge
severe python
#

That would be the way you did it for a few version, I want to mention though, my implementation appears to fail in 2020.2

onyx harness
#

Looks like he wants something custom for himself

solid pollen
#

I don't want to add my stuff to the Preferences window though, I'm creating my own

severe python
#

Oh well I just made something with a very similar layout using ui elements

#

Its pretty easy to put together, but you'd need to figure out how you want to aggregate different sections and populate them

#

This isn't exactly what you want but it covers the same set of features

#

A left bound list of items that should be searchable and provides different views on the right panel via selection

#

This is the uxml its paired with at the root

#

I'm populating the list by examining a folder structure, but you could populate the list however you need to

#

This is what that looks like

solid pollen
#

Thank you! I will bookmark these and have a look at a later date, and try to update the Editor. Currently I'm using a Selection Grid with one column to do something similar and it works great, but not as visually appealing

severe python
#

With uxml and uss you can rapidly iterate on the look to make minor tweaks pretty quickly so once you get the layout setup you can pretty easily tweak it till you like it

solid pollen
#

Nice, I have limited (read: nearly none) experience with UIElements, still using the old stuff. That's something I really wanna dive into when I have the time.

severe python
#

My solution isnt complete yet, I haven't implemented search just yet

#

Its worth learning, it really enhances separation of concerns once you understand how to use it right

#

Which admittedly can be hard, I felt like I knew better how to use it than I did because of my xaml experience but there are important fundamental differences

solid pollen
#

I also have a bit of xaml experience, but probably not nearly enough 😛

severe python
#

Just don't try to implement data templating for and you'll be fine lol

#

Otherwise said, constructing templates at binding time can cause performance issues

umbral sinew
waxen sandal
#

Context..?

umbral sinew
#

see hatebin

#

public class SyncVarAttribute : PropertyAttribute { }

waxen sandal
#

Use Begin/EndProperty and pass the label yourself

umbral sinew
#

this works fine in 2019...2020 fails

onyx harness
#

I dont see the issue

#

what are you expecting?

umbral sinew
#

expecting the name of the field on the left

onyx harness
#

Perhaps miniLabel having TextAlign to right

#

Left of what?

#

Of the whole line?

umbral sinew
#

left of the check box

onyx harness
#

I don't read that in your code

#

labelRect is shifted with valueWidth, it is expected to be on the right part

umbral sinew
#

The word "SyncVar" is supposed to be on the right. The actual field name is supposed to be on the left - it's missing

#

should look like this

onyx harness
#

just pass the label as Navi suggested

umbral sinew
#

sorry this isn't my area of expertise - pass it where?

#

This is what 2020.2.7 does

#

is this a Unity bug?

#

this has worked for years until now

onyx harness
#

Well, shit happens sometime 🙂

umbral sinew
#

so where do I "pass the label"?

onyx harness
#

Isn't there an overload in Propertyfield

#

that take a label?

umbral sinew
onyx harness
waxen sandal
#

Lol

#

Thanks

fair helm
#

Is there a function that executes on unity shutdown? I couldn' t really find something.

gloomy chasm
severe python
#

I suddenly feel like I'm working on my package project in the wrong way. what I have is a folder in assets that is my package. This creates a whole bunch of problems with finding assets because the path changes between development and usage. am I somehow supposed to be working on the package differently?

onyx harness
#

You mean it can be both in Assets & Packages?

gloomy chasm
severe python
#

there is a better way

#

"Create a new subfolder for your package inside the Packages folder using a name that matches the package name. For example, if your package is called com.example.mypackage, the subfolder should also be called com.example.mypackage."

#

man

#

I feel like I should have realized this sooner

#

I feel like this is going to cause problems, but I'm going to give it a go

gloomy chasm
#

Far as I can tell it is almost exactly the same result.

severe python
#

the worst that could happen is unity destroys everything

#

are you able to attach and debug fine?

gloomy chasm
#

Yep!

visual stag
#

I personally just stick them on my hard drive and reference them

#

But the packages directory does work fine

#

It's just... I like having them in my general projects directory, makes them not really tied to a development project

severe python
#

whenever I'm using a package in a downstream project I pull it from git via upm

visual stag
#

I do too, but sometimes I switch to local to do some relevant development

gloomy chasm
#

Only problem I have found with doing packages is that VS does not like renaming files, but maybe that is just a bug on my end.

visual stag
#

Probably VS

severe python
#

i just have a project for every package lol

#

I kinda feel stupid for it now

visual stag
#

I have one example project with them all in it, and versions of that for different editor versions

severe python
#

for some packages, I have multiple projects...

gloomy chasm
#

Quick question. What is the normal naming for undo operations?

visual stag
#

I don't think there is one

gloomy chasm
#

Cool...

civic river
#

I'm guessing the difference has to do with play mode settings 🤔

#

But I don't know how to work around it

heady shadow
#

Not sure what the technical term for this is, but I'm trying to access the instance of custom inspector script for a component from a plugin.
Is it possible to do that?

I basically need to call a method on the given class above, and I can't figure out how UnityChanHelp

waxen sandal
#

You want access to the custom editor?

heady shadow
#

Sort of. It has a function which creates some data which I want.

waxen sandal
#

Resources.FindObjectsOfTypeAll might find it but I doubt that

#

Probably no other way without editing the editor

heady shadow
#

I see, thanks. I'll try and find the actual object it creates then

waxen sandal
#

I guess you might be able to do it through reflection somehow

heady shadow
#
public static T CreateShareData<T>(string dataName) where T : ShareDataObject
        {
            T shareData = CreateInstance<T>();  //SO.CreateInstance
            shareData.name = dataName;
            return shareData;
        }

EditorUtility.SetDirty(CreateShareData<MeshData>("SomeName"));

I assume I won't be able to access this too?

heady shadow
#

or a link, whichever works

waxen sandal
#

Nope

#

Unity probably has a list of editors somewhere

#

Maybe in InspectorWindow maybe somewhere else

onyx harness
fresh turret
#

Hello,
Does anyone know how to use the new UI builder in editor windows?
Editor windows don't have a CreateInspectorGUI()

#

I do get it to work in the inspector

gloomy chasm
gloomy chasm
fresh turret
#

ah i see o

#

k

onyx harness
#

This is just a callback for the user to be triggered when an object is being Reset, or newly created. Might be wrong, I doubt it

waxen sandal
#

Reset is only called when you Right click the component and press reset

#

Newly created might be too yeah

gloomy chasm
onyx harness
#

From there you can call Reset.
This, it won't do anything if you call it.

waxen sandal
onyx harness
#

No no, I'm not confirming, Reset() and other methods are mono-directional messages, it is not suppose to work bi-directionally

#

Meaning, Unity Editor calls them when it suits it, not when it suits you

gloomy chasm
waxen sandal
#

Oh I didn't read the first part. You shouldn't call it yourself

onyx harness