#↕️┃editor-extensions

1 messages · Page 51 of 1

onyx harness
#

@heavy plaza I'm sorry mate, your issue seems to be "outdated" (the documentation pointed out)

#

@whole steppe Selection.gameObjects is already a GameObject[].

heavy plaza
#

So I'm not able to make an asset bundle in that version?

onyx harness
#

I never did that before, sorry dude I can't help you. However I'm sure it's doable

heavy plaza
#

I don't know whether it's an issue with monodevlop or not as this is my first time using Unity

onyx harness
#

As a first suggestion, I would say try Visual Studio or Visual Code. Anything but MonoDevelop

heavy plaza
#

I will try visual studio. I have both 2017 and 2019 of visual studio installed

onyx harness
#

Yep, give it a try

#

But I don't think it is an IDE issue

heavy plaza
#

I can try in an about an hour once I get home

heavy plaza
#

so I've managed to use visual studio however the script in the example is giving me this error

onyx harness
#

That's pretty clear

heavy plaza
#

even though the function has 4 arguments inside it

onyx harness
#

Where do you see it?

heavy plaza
#

line 10

onyx harness
#

And VS is telling you there is no method BuildAssetBundle taking 4 arguments

heavy plaza
#

which is the BuildPipeline.BuildAssetBundle() function

onyx harness
#

As I told you, your documentation is outdated

#

Learn about this error, the message is very explicit

#

IDE are veeeeery unlikely to spit out false-positives

heavy plaza
#

but I'm guessing that the updated code won't work on older versions of unity?

onyx harness
#

I guess you are right

#

API changed, the documentation is explicit

heavy plaza
#

I am trying to see where (in the updated build assets documentation) I can specify which assets are built into the assets bundle

onyx harness
#

hum...

#

and where did you look at?

heavy plaza
#

as it's just a material and a texture I need to bundle and not the rest of the assets

onyx harness
#

Dude...

#

You are not even looking at the right method

heavy plaza
#

well I am kind of new to this

#

so I am not sure what methods etc to use

#

can you point me to the right method?

onyx harness
#

remove the 'S'

heavy plaza
#

but it states at the top of that particular page that it's obselete?

onyx harness
#

Which page?

onyx harness
#

Oh BuildAsseBundle?

heavy plaza
#

as you said to remove the S

onyx harness
#

They are saying that BuildPipeline is obsolet

#

You need to use AssetBundle instead

#

BuildAssetBundles is stating:

Build all AssetBundles specified in the editor.

#

I guess you need to tag your assets first

heavy plaza
#

I have tagged the two assets I wish to bundle

onyx harness
#

What the result of the method?

heavy plaza
#

eh?

onyx harness
#

You tagged them

#

Have you try to call BuildAssetBundles?

heavy plaza
#

not yet as this is the first I've heard of that function

onyx harness
#

Don't be afraid

#

Try 🙂

heavy plaza
#

when I try to look at the docs it always leads me back to the buildassetbundles page

onyx harness
#

Which might be the one you are looking for

heavy plaza
#

I'm quite confused, as you say buildpipeline is depreciated however that is the function used in the update doc

onyx harness
#

Allow me to correct myself, the method you were looking for is deprecated

#

I have to go, good luck in your journey

heavy plaza
#

wait, so this?

tidal cave
#

What do I need to do to have alternative icon for selected node? Scriptable object icon changes to all white, and easily visible. However Mesh icon does not. And my custom icon on TerrainData also doesn't. I'm placing icon into Gizmos with the AssetScript icon.png name.

tidal cave
#

Hmm, according to EditorUtility.GetIconInActiveState it should be AssetType on icon.png, but it doesn't work because GetAssetPath for already loaded gizmo icon is empty… Looks like something is broken inside

hallow glen
#

@onyx harness Incorrectly submitted here

blissful sinew
#

Hey. Does anyone know a way to check if a tile is flipped in a tilemap editor script?

onyx harness
#

How do you know without using a script?

blissful sinew
#

Using a script that loops through every tile in a tilemap

#

I'm making a tool that instantiates prefabs based on tiles. The only problem is that I need the gameObject to be "flipped" if the tile is flipped but I can't find any property in the Tile class that would give this information since a flipped tile scale and rotation seems to be the same as a normal tile

onyx harness
#

So, how do you know it is flipped?

#

If you can't tell me humanly speaking, I don't think I can help you editorly speaking

blissful sinew
#

Because it's flipped on the tilemap itself. Like I pressed shift + [ when painting the grid . I'm just wondering if there's a way to detect that in code or if I need to create a separate image where the tile is already flipped

onyx harness
#

Sorry, can't help ya then, not my area =X

whole steppe
#

I'm back to work on my editor script to help set 110^2 gameobject references for VRchat Trigger scripts

#

im not really sure how to reference a VRC_Trigger script

#

if it were a component like a rigid body or something i could just say item.GetComponent<Rigidbody>();

#

but item.GetComponent<VRC_Trigger>(); doesn't work because it doesn't know where to look for that namespace

#

the script is apart of the VRchat SDK

#

ohh i just have to import the namespace duhhhh

tidal cave
#

@blissful sinew doesn't it have something like transform property? If that's UnityEngine.Tilemaps.Tile, it has it.

tough cairn
#

Is there any way to execute OnAnimatorIK during edit mode ?

tough cairn
#

nvm i managed to manually update it

digital spoke
#

I want to draw the properties of a list onto a custom editor
I can currently draw the fields of each item in the list, now how can I then draw the properties of those?

Here's my current code:

            SerializedProperty listIterator = assetSo.FindProperty("nodes").Copy();
            Rect drawZone = GUILayoutUtility.GetRect(0f, 16f);
            bool showChildren = EditorGUI.PropertyField(drawZone, listIterator);
            listIterator.NextVisible(showChildren);

            //List size
            drawZone = GUILayoutUtility.GetRect(0f, 16f);
            showChildren = EditorGUI.PropertyField(drawZone, listIterator);
            bool toBeContinued = listIterator.NextVisible(showChildren);
            //Elements
            int listElement = 0;
            while (toBeContinued)
            {
                drawZone = GUILayoutUtility.GetRect(0f, 16f);
                SerializedProperty nodeIterator = listIterator;
                bool Continue = nodeIterator.NextVisible(showChildren);
                showChildren = EditorGUI.PropertyField(drawZone, listIterator);
                toBeContinued = listIterator.NextVisible(showChildren);
                listElement++;
            }
visual stag
#

PropertyField should draw the children already, I thought. But you can pass true as the third parameter to force that to be the case

digital spoke
#

? I don't understand

#

I don't want to draw the children/items of the list, I want to draw their properties

visual stag
#

Can you explain what it is that you're trying to do as a whole?

#

because if you just want to display the contents of an array/list without the Unity UI faff that comes with it, just drawing the items one after another...
You can just for loop over your array using GetArrayElementAtIndex and then draw that property

digital spoke
#

I have a list of scriptableobjects

I want to draw their properties

visual stag
#

You need to create (and cache) SerializedObjects for each of them, where you then draw the properties. Or you can use Editor.CreateCachedEditor and call it's GUI function

cosmic dagger
#

so i'm trying to create an animation from a list of sprites through code, but none of the keyframes have sprites associated with them, however the list is populated with sprites

visual stag
#

@cosmic dagger I assume images is an array of Sprites?

cosmic dagger
#

yeah a list

#

that has sprites

visual stag
#

Unity's internal code in SpriteUtility seems to do basically what you're doing

#

I don't know if you've looked at it for comparison

cosmic dagger
#

never knew that existed

cosmic dagger
#

maybe the remapobjecttosprite

#

ill try using the SpriteUtility

visual stag
#

Looking at the code

#

I think you can create a sprite with an animation automatically

#

if you drag an imported sprite into the scene and hold alt

cosmic dagger
#

well i'm creating a bunch of different animationclips from sprite sheets that aren't mine so that wouldn't work

#

it would but i'd be too time consuming

#

there's like 100's of different animations

visual stag
#

Makes sense. It might be worth just reflecting into this code though and passing your stuff to it

cosmic dagger
#

probably will

#

still no sprites associated with the key frames

cosmic dagger
#

perhaps it's how i'm creating the sprites? I'm making them from a sprite sheet using Sprite.Create

visual stag
#

I assume you've serialized them before you run this function?

cosmic dagger
#

Uh maybe?

#

@visual stag what do you mean?

visual stag
#

Like, AssetDatabase.CreateAsset

cosmic dagger
#

No. I just store the sprites in a dictionary

#

Should i save them?

visual stag
#

Yeah, otherwise the animation asset cannot refer to them

cosmic dagger
#

But i’m referring to the dictionary

#

Oh wait

#

I see what you mean

#

It would only work at runtime right?

visual stag
#

How do you mean? All of this is editor-only stuff

cosmic dagger
#

Well i load the sprites dynamically, but create the animations only once and save the .anim asset

visual stag
#

You cannot author animations at runtime as far as I know

cosmic dagger
#

I’ll try serializing the sprites, i think i know what’s going on

next slate
#

Guys is there any way to make an enum like dropdown menu for serialized custom classes that derive from the same base class?

#

The dropdown will select the type and there should be a button to set a [serializedRefernce] baseclass field to an object of derived type.

#

I don't want to write separate buttons for every derived type.

visual stag
next slate
#

@visual stag [serializeReference] handles the serialize part. I want an easily customizable list<baseclass> that has properly serialized derived classes. I will try typecache.

#

@visual stag How can I call the constructor of a type from the typecache?

waxen sandal
#

Use reflection to get the constructor reference

#

Then you can just invoke it

next slate
#

@waxen sandal I have little experience in using reflection, could you give a sample syntax?

#

Would activator.createInstance work?

waxen sandal
#

I don't think you can pass arguments with create instance

#

But if you don't care then sure

visual stag
#

There are lots of overloads

waxen sandal
#

Oh you can apparently

#

Cool

next slate
#

thanks, one of the overloads worked. MSDN site to the rescue.

#

On a side note, can you recommend any sources for learning the basics of reflection? Clearly I have a lot to learn.

visual stag
#

Just googling when you have a question is how I learnt what I know

onyx harness
#

It's just a slide of my Reflection course I give.
Unfortunately, the course is in french... Except if you can understand it, I'll send it to you if you want

waxen sandal
#

That's a lot of information for one slide

onyx harness
#

Because you don't have all the previous slides explaining how to use Reflection.
The one above is a summary

waxen sandal
#

Makes sense

onyx harness
#

You have in front of you most 'things' you can interact/get/reach with Reflection.

molten nimbus
lucid hedge
molten nimbus
#

I could but although the question is about lights, it is not lighting related 😦 it's about the prefab editor window. it should have a neutral light set as default. not so bright.

next slate
#

Is there any equivalent of OnEnable() for PropertyDrawers that works like onEnable of custom Editors?

#

I only need to use reflection once to fetch the data I need.

chrome geyser
#

No, u need to make a flag for example first time in GetPropertyHeight() that will initilize your property drawer

next slate
#

One more thing, how can I use the serializedproperty of a propertydrawer to change the object it's pointing to? I want to make it point to a new instance of the fields class.

onyx harness
#

Nope, i don't think you can do that

#

But you can look for the right SP

chrome geyser
#

you can always call NextVisible()

#

but the drawer for the next property will invoke nonetheless

next slate
#

@onyx harness I meant making the field the property drawer is attached to. I want the field point to a new custom class object.

#

I can already do that by calling a function on the serialised object. But I don't think that handles undo.

onyx harness
#

A new custom class? It means you completely change the SerializedObject right?

next slate
#

@onyx harness doesn't the serialised object mean the gameobject with the monobehavior that has the field?

onyx harness
#

Technically no, and factually no.
It targets the Component, which in your case is your MonoBehaviour

next slate
#

@onyx harness Yeah, I messed up a bit there. But I should be able to access the field on the monobehavior?no?

#

I just want to set that field to a new reference.

onyx harness
#

You can access it, yes

#

You can have the SerializedProperty of it as well

next slate
#

But I can't figure out the syntax.

#

Most methods for modifying the serialised property mentions propertyfield which is not what I want.

#

unsure if property.objectreference does what I need

onyx harness
#

No no

#

Look for FindProperty

#

Or FindRelativeProperty

#

It requires a path

#

Similar to propertyPath provided by your SerializedProperty

next slate
#

What's the difference between the two?

#

And getting the property is not the problem. I need to set it to a new object. I don't see any other way to do that other than object reference value.

onyx harness
#

I think one is relative the other is absolute

#

One is in SerializedObject, the other is in SerializeProperty

#

But you can't set it

#

A SP is fixed

next slate
#

Can I just post my code then? I think both of us are unsure about what we want

onyx harness
#

Shoot

#

Lol, I hope you know what you want

next slate
#

The code won't compile since I removed some lines there.

#

But the idea is the same as my code

onyx harness
#

You want to create an object and set it as the new SerializedProperty

next slate
#

Yes

onyx harness
#

But you can't do that

#

As stated above

#

Remember one thing, Unity can't serialized polymorphism

next slate
#

But I can access the object and call a fucntion to do the same thing. Just without the undos

#

Serialization has some workarounds in 2019.3

#

so that's not the problem

onyx harness
#

Oh you are on the latest

next slate
#

If serialized object does not work, how do I tell it to mark the undos?

onyx harness
#

You can manually draw it, but won't be able to recreate a Serialized context around it

#

You can't Undo if you are not working on an Object

next slate
#

So long story short, Not possible?

onyx harness
#

Yes

#

No Undo

next slate
#

What if I used a custom editor. I would be directly accessing the monobehaviour then

#

*By casting the target to the monobehaviour

onyx harness
#

Like SO

#

You can cast it to MB from both

#

You can create your new object from the selected Type

#

You can draw it manually

#

But not using anything related to serialisation

next slate
#

Some asset store packages do have inspector serialized classes. And they also support changing types with undo support.

#

Ex:Gameflow.

#

Do they also rely on external serialization methods?

onyx harness
#

I'm sure you are not giving me all the details

#

Or you don't know that you didn't give me all the details

#

Perhaps they serialized stuff themselves

#

Like a lot of plugins do

next slate
#

In other words I can't compete.
Oh well, I'm pretty sure I can love without an undo. It's not like anyone else is going to use my stuff.

#

Sorry for wasting your time.

onyx harness
#

Hehe its all fine

#

Maybe it's not a too big task

next slate
#

Maybe, but I've already spent more than the amount of time I wanted on this.

#

Just a thought, does undo.recordobject also rely on serialisation?

onyx harness
#

Yes

#

Undo relies on serialization

tough cairn
#

how can i make a selection handle ?

#

i plan to draw multiple handles in different positions on the same script

digital spoke
#

I'm trying to go through a list of scriptableobjects and then display the properties of those scriptableobjects on the inspector. Currently I've just only been able to get each of the scriptableobjects in the list and create a propertyfield for them (for testing) but I can't seem to do anything else.

My idea was to add each one to a list and then iterate through that list and get their properties but for some reason only Element 2 gets added to the array and I can't figure out why.

        if (sp.isArray)
        {
            int arrayLength = 0;

            sp.Next(true);
            sp.Next(true);
            arrayLength = sp.intValue;
            sp.Next(true);
            int lastIndex = arrayLength - 1;
            List<SerializedProperty> nodes = new List<SerializedProperty>();
            for (int i = 0; i < arrayLength; i++)
            {
                EditorGUILayout.PropertyField(sp, new GUIContent("Label"));
                nodes.Add(sp);
                if (i < lastIndex) sp.Next(false);
            }
            Debug.Log(nodes[2].displayName); //only prints "Element 2", no matter which index I choose (0,1, or 2)
        }

When printing the display name of an item in the nodes list, it ONLY prints Element 2.

#

(changed the label from new GUIContent("Label") to new GUIContent(sp.displayName))

#

i feel like this is similar to a closure problem since it seems to only add to nodes the last 'node' in the list I'm getting them from.

onyx harness
#

Because

#

@digital spoke When you Next() a SP, you move it forward.
When adding your sp to the list, you just add the same and again and again

#

You need to create a copy of SP

keen pumice
#

Hi Everyone!
My brain is melting, and I need a hand. (Please let me know if you think I should post this in a different channel.)
I have a line of code that compiles fine in the standard unity editor build, but fails when I try to compile it into a custom DLL (for unity editor). Clearly, I’m missing some DLL reference in the project settings of my custom DLL.
The function call giving me trouble is : https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodinfo.createdelegate?view=netframework-4.8&viewFallbackFrom=netframework-2.0
At the top of the page documentation it shows multiple dll’s, which, apparently include this function. *** How do I know which of these (AND which version of these on my computer) I should be including in my custom DLL references?
I’ve tried a including a few of them, semi-randomly ... some lead to a bunch of other weird errors popping up, and some have no effect.

onyx harness
#

@keen pumice Look at your .csproj

keen pumice
#

you mean the unity editor project? I havn't looked in that file.. but I do see in visual studio it has a TON of references... it even looks like it has all the DLL's at the top of that page.

onyx harness
#

Yep

#

You can either check those csproj

#

or check the references in your projects via Visual Studio

#

They are suppose to be equivalent

keen pumice
#

I did try adding a couple of those in.. had the results I metnioned.. I didn't try adding in ALL of them tho...is that actually necessary?

#

(feel like I shouldn't need to reference 5 dlls to use a single function...)

onyx harness
#

no no

#

you just need what is required

#

Only one

#

There is a simple trick

#

Click on your method CreateDelegate

#

And press F12 on it

#

At the top of the preview, you will the origin assembly

keen pumice
#

AH! cool.. ok .."mscorlib" .. trying it

onyx harness
#

This one is like the most fundamental

#

It contains a lot of primary stuff

keen pumice
#

and I should use the one in the Unity folder? This is what the editor project says..."C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll"

#

oh! I got an error why I tried to add it..

#

which is cool... except that I get that compile error 😦

onyx harness
#

How do you compile the assembly?

#

An external project?

keen pumice
#

a seperate project .. but in the same "solution"

#

been working fine.. just get stuck with some of these missing references somtimes.. I don't see the pattern

onyx harness
#

Open the output window

#

Build

#

Look at the compilation command line

#

You will see several "/reference:BLABLABLA.dll"

keen pumice
#

hmm.. must need to turn that on.. don't see that at all...

onyx harness
#

yep

#

Tools / Options / Projects and solutions / Generate and execute
Set verbose to "Normal"

keen pumice
#

ok.. now when I compile the editor buld I see a TON of these... 2> Copying file from "C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll" to "Temp\bin\Release\mscorlib.dll".

#

it loooks like all those that are in the project references.. still no idea which one to include.

keen pumice
#

not there.. oh: "The Do not reference mscorlib.dll build property doesn't exist in Visual Studio 2017."

onyx harness
#

lol

#

Well

#

To be honest

#

It's a bit hard for me to help you

#

I can only ask you questions to try to see the big picture

#

but you barely give me some

keen pumice
#

hmm.. perhaps I'm refernceing the wrong version of other dll's which is creating the problem... I see that the system.dll I'm referencing is NOT from the unity folder.. C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll

#

and I see that folder does not have a system.reflection.dll .. hmm

onyx harness
#

Go reference System.Reflection directly

#

It might help ya

keen pumice
#

I'm just looking to understand the pattern/stardard procedure one should use to reference dlls. There are so many of each version! Guess I'll start by duplicing exactly the references in the editor project.

#

Well, I used the exact same references as in the Unity Editor project, and included system.refelection.dll... but the error persists.

#

(Also, had to updtae from .Net2.0 to .Net4.0 in project settings to work with those dlls)

onyx harness
#

Can you provide me more context/data/information?

#

Like the logs?

keen pumice
#

AH.. got A fix: I removed the system.reflection.dll reference entirely.. and change project version again.. this time to .Net 4.5- it complied.. so what am I misunderstanding at the bottom of the docs.. looks like it's there in 2.0....

onyx harness
#

It is

#

You are doing something wrong

#

but i can't help you without the data

keen pumice
#

"Applies to
.NET Core
3.0 2.2 2.1 2.0 1.1 1.0
.NET Framework
4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6 4.5.2 4.5.1 4.5
.NET Standard
2.1 2.0 1.6 1.5 1.4 1.3 1.2 1.1 1.0"

#

.Net Framework is listed seperately.... does that mean anything other than marketing branding stuff.. is it relevant to the dll stuff??

onyx harness
#

No no

#

They are different families

keen pumice
#

which one does unity use?

onyx harness
#

Unity uses a fork of .NET 3.5

#

And now is using .NET 4.6

keen pumice
#

does that mean my dll must use 4.6.. or can it use a lower version (and even if it CAN.. should I avoid that?)

onyx harness
#

No you can use lower version

#

As long as the end user have the necessary assemblies

keen pumice
#

so if I set my compiler to "2.0 Framework".. does that ACTUALLY mean it would use the ".Net Standard 2.0" listed as compatible.. (2.0 is NOT listed in the ".Net Framework" section). also... is THIS setting how it chooses which mscorlib version to use?

onyx harness
#

If I'm not wrong, that is right yes

#

There is a lot of framework, all have their own version of mscorlib

#

and others

#

Depending on what you need

#

some are light, others full

cosmic dagger
#

Is it possible to save a sprite created through code as a Sprite asset?

barren moat
#

@cosmic dagger yes.

cosmic dagger
#

I tried just doing AssetDatabase.CreateAsset(sprite, ...) but the asset created is unreadable

#

is that not the correct way to do it?

barren moat
#

Ah, right.

#

Yeah, I remember this... hold on.

#

I actually don't save mine cos I hit it.

#

You need to save the image as an asset too.

#

I believe.

cosmic dagger
#

what image

#

the original?

barren moat
#

Ah, right. Sorry, this is slightly different to what I did. I generated a texture at runtime and created a sprite asset for it so that I could add it to a UI.

#

So when I tried CreateAsset the sprites had no image data.

cosmic dagger
#

that's kind of what i'm doing

#

i create a sprite from a sprite sheet and then trying to save that sprite as an asset

barren moat
#

Yeah, sorry, I don't know how to persist it to the project, mine is just for runtime.

cosmic dagger
#

hmm, ok

barren moat
#

But you're not generating the texture, right?

#

It exists in your project?

cosmic dagger
#

i am not

#

yes

lilac python
#

How are you generating the new Sprite?

cosmic dagger
#

Sprite.Create

lilac python
#

Hmm...

#
var p = AssetDatabase.GetAssetPath(text);
Debug.Log("sprite.rect = " + sprite.rect);
p = Path.GetDirectoryName(p);
p = Path.Combine(p, spriteName);
AssetDatabase.CreateAsset(sprite, p);

var s = AssetDatabase.LoadAssetAtPath<Sprite>(p);
Debug.Log("s.rect = " + sprite.rect);```
cosmic dagger
#

what should be the file ending to a sprite?

lilac python
#

Both Debug.Log() print the same for me, but if I look at the inspector it appears to have a 0 in the rect

cosmic dagger
#

.png right?

lilac python
#

I do .asset

#

Given that I don't make a copy of the actual texture

#

I'm.. not sure if this is correct

cosmic dagger
#

i'll try .asset, but i need to copy the texture so i don't think it'll work

lilac python
#

Yeah, if I try with .png it gives me an "File could not be read" error on the CreateAsset line

#

But.. the actual sprite that I've made does not appear to render

cosmic dagger
#

oh

#

it works

#

.asset works

#

i just thought i'd lose image data if I did .asset so i didn't try it

lilac python
#

I'm guessing it just links internally to the correct texture2D

cosmic dagger
#

it must, because when i tried creating the sprite.texture it said the texture already existed

lilac python
#

Like when you make a multisprite I assume that under the hood it creates sprite objects for each sprite and this one is just saved in a different location rather than the .meta file of the texture

digital spoke
#

im gonna try asking this again even though I don't think I'm explaining it well

#

I have a list of serializedobjects called nodes. I want to go through this list and draw the properties of these nodes onto the inspector

#

i'm not sure how to do this and every time I ask it seems people think that i just want to draw the contents of the list onto the inspector which is NOT what I want to do

#

at the moment I've been able to add the contents of the list to a list in my custom inspector script but it seems that their properties are not correct even despite the fact I have triple-checked to make sure I am getting the correct things so ?????

onyx harness
#

If properties!=content, define properties

digital spoke
#

every node has position but if I try to get it via FindProperty it returns null

onyx harness
#

Do you know how to find a property by path?

digital spoke
#

even though, I am getting the correct objects according to my debugging (this is me displaying the contents of the list I put the nodes into after getting them from the other list)

onyx harness
#

Look at propertyPath in your SerializedProperty

digital spoke
onyx harness
#

What you should try, get the cached Editor of the ScriptableObject draw it, repeat for each element

#

You are giving me the result, but never how you did it

#

How do you want us (helpers) to help you correctly if you give half the picture

#

Try to think from our point of view

digital spoke
#

what do you think I did? I literally just printed the propertyPath of one of the objects in the list. That's what it returned.

onyx harness
#

Give me the code

#

It will simply things

lilac python
#

@digital spoke do you want to draw inline the inspector of these objects? So instead of opening up the object in it's own inspector it's right there?

onyx harness
#

Yes, this is his will

tough cairn
digital spoke
#

im sorry if i seem aggressive ive been trying to solve this issue (it started with ExposedReference)

#

i found something that I think might help me so I'm quickly going to see if that works and if it doesn't ill come back with code

#

welp

#

after all that, this works lmao

lilac python
#

TestObject is just a ScriptableObject with some variables to test it out

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

[CreateAssetMenu(menuName = "TestObject")]
public class TestObject : ScriptableObject {
    [Serializable]
    public struct Test {
        public string name;
        public GameObject go;
        public int y;
    }
    public int x;
    public List<Test> list;
}```
tough cairn
digital spoke
#

@lilac python thanks but I found a solution that works fine.

lilac python
#

Fair enough

digital spoke
#

@onyx harness also thanks for helping

#

is there a way to override OnInspectorGUI of a cached editor?

#
            if (!editor)
                Editor.CreateCachedEditor(property.objectReferenceValue, null, ref editor);
            editor.OnInspectorGUI();

I want to do some stuff with the OnInspectorGUI of editor

onyx harness
#

@digital spoke have you seen line 30 of his script

Editor.CreateCachedEditor(property.objectReferenceValue, null, ref editor);

#

Oops haven't read your messages yet, my bad 😅

#

OnInspectorGUI is here to draw, if you want to bypass, either you recode the Editor, or just draw it yourself

digital spoke
#

i need to draw the editor in a specific way so i can set ExposedReference types and I'm not sure how to do that for a cached editor

#

the cached editor is handelling the drawing of Testing's properties. Object is a ExposedReference<GameObject> and I need to do some weird stuff to get it to work properly because of course I do

onyx harness
#

What do you mean by

draw the editor in a specific way

digital spoke
digital spoke
#

and I'm not sure how to do that since it seems I have no control on how a cached editor draws

onyx harness
#

Can you try to use Editor.DrawDefaultInspector()

#

instead of OnInspectorGUI

#

I never touched ExposedReference, I can't help much about those new things

digital spoke
#

exposedreference has been a thing for a while iirc

#

it's just that no one has seemingly ever used it outside of custom playables/the timeline in general

onyx harness
#

I'm stuck to 2017.4

digital spoke
#

exposed reference has been a thing since before that it seems considering it exists on 2017.1 documentation

onyx harness
#

O_o really...

digital spoke
#

it seems to have been introduced in 5.6

#

before unity started using the current naming convention of the versions

#

that's why this problem is so annoying for me, exposedreference is such a obscure type no one knows it exists

#

Unity really needs to give us a better way to reference scene objects in a scriptableobject

onyx harness
#

I'm not even sure I understand your issue right now

#

They are shown in your Inspector, but what do you want to do with them?

digital spoke
#

i want to be able to drag scene objects onto the Object field but I can't since it doesn't work like that for scene objects

onyx harness
#

That's very strange, because in my test, I can ONLY drop assets on it, not scene Object

cedar reef
#

Why not just store your data in a component on an in-scene object? If something is explicitly or implicitly tied to a specific scene, it should probably just be in that scene

#

Maybe you're hamstringing yourself by being set on using ScriptableObjects

digital spoke
#

well considering this a node editor, i kinda need to use scriptableobjects to store the data of the nodes

cedar reef
#

Not really...you can store the data of the nodes in a MonoBehaviour just as easily

digital spoke
#

im pretty sure that would require a pretty significant re-write of xNode's source code to use monobehaviour instead of scriptableobject

cedar reef
#

Ah, you're using a specific plugin as your node editor

digital spoke
#

yeah

#

i was able to get to the point where I can set an exposedreference on the node

#

but for some reason, they don't stay unless I set resolve it with a monbehaviour, it seems?

#

atleast that's what I've been told by someone in the xNode discord

cedar reef
#

Dunno, all that is specific to the plugin you're using, so the chat specific to that plugin will have more people who're likely to be able to answer your questions about it

digital spoke
#

he said "i've never used exposedreference, dunno"

#

only one guy on there has been able to help but but I think I'm pretty much stuck at this point.

I need to be able to handle how the cached editor draws but I can't override any of it's functions

#

can you believe this was just to get over the inconvenience of using custom playables for a completely unintended purpose

digital spoke
#

nvm i thought i had an idea

#

didn't work

onyx harness
#

@digital spoke Use this to see the paths

public static void    OutputHierarchy(this SerializedObject so)
{
    SerializedProperty    it = so.GetIterator();

    //it.Next(true);

    while (it.Next(true))
    {
        if (it.propertyType == SerializedPropertyType.String)
            Debug.Log(it.propertyPath + " " + it.stringValue);
        else if (it.propertyType == SerializedPropertyType.Integer)
            Debug.Log(it.propertyPath + " " + it.intValue);
        else
            Debug.Log(it.propertyPath + " " + it.propertyType);
    }
}

public static void    OutputVisibleHierarchy(this SerializedObject so)
{
    SerializedProperty    it = so.GetIterator();

    it.Next(true);

    while (it.NextVisible(true))
        Debug.Log(it.propertyPath);
}
#

I dont know if you do a lot of editor scripting, but I am preparing a series of tips for the editor world. If you are interested, I will tag you the day I start

digital spoke
#

no it's fine.

lucid hedge
#

isn't there some UI elements wysiwyg editor?

#

I thought I heard something about that

#

but I've only seen the UI Elements debugger

onyx harness
#

Heard about it, don't know much

lucid hedge
#

and speaking of the UI Elements debugger

#

it seems a bit buggy sometimes

#

but the workflow is promising

#

this is it I guess?

onyx harness
#

I guess

lucid hedge
#

will give it a try

onyx harness
#

Keep me in touch 🙂

lucid hedge
#

this tool is super nice tbh

#

I love it

onyx harness
#

Man, this is Unity, there is always a catch X)

lucid hedge
#

haha I mean I'm just going to use it for simple stuff so I will probably not 'reach' the 'catch'

#

but it's cool, just drag and drop elements, edit properties, see instant changes

#

and also I can preview how it looks in dark mode, which is super nice for a free user

onyx harness
#

Say whaaat?? Hahahaha they thought about it, amazing

waxen sandal
#

I think the catch is that it's UIElements

lucid hedge
#

Mikilo don't want to tag you but check

#

generic asset support menu made with relative ease using UI builder

onyx harness
#

Don't worry, i'm always there 😄

#

We are all expecting drastic increase of UI building efficiency

waxen sandal
#

I'm expecting to hit lots of edge cases

#

That make me hate my life

#

And I'm expecting lots of unnecessary boilerplate

lucid hedge
#

also if UI elements is a package

#

that means that it will be a dependency for my asset if I use UI elements for editor windows etc

waxen sandal
#

Yeah that'll be fun

#

If you don't want to support all versions of UIElements and some other package requires a newer/older version; then you're fucked

onyx harness
#

It would be surprising to have UI Element as a non native package

lucid hedge
#

so it would come pre-installed when user downloads Unity?

onyx harness
#

They (Unity) are revamping all their windows with it. If the package is not present, how is the editor running?

#

To be honest I don't know, but the opposite is quite strange when you think about it

lucid hedge
#

you're right

crisp knot
#

Hello. I need to create a ReorderableList inside a loop on the OnInspectorGui. My problem is that creating a ReorderableList inside this method makes it impossible to remove or drag items arround.

What can I do to make the remove and drag items arround possible when creating a reorderable list ?

waxen sandal
#

Can you show your code?

crisp knot
#
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        DrawDefaultInspector();

        EditorGUILayout.Space();


        for (int i = 0; i < interactionProp.arraySize; i++)
        {
            SerializedProperty interactionListRef = interactionProp.GetArrayElementAtIndex(i);
            SerializedProperty objectTypeRef = interactionListRef.FindPropertyRelative("objectConcerned");
            SerializedProperty eventsToLaunchTypeRef = interactionListRef.FindPropertyRelative("eventsToLaunch");
            AddPopup(i, ref objectTypeRef, "Object concerned : ", typeof(ObjectSettings.ObjectType));

            ReorderableList list = new ReorderableList(serializedObject, eventsToLaunchTypeRef, true, true, true, true);
            
            list.drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, "Events to launch");
            };

            list.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    var element = list.serializedProperty.GetArrayElementAtIndex(index);
                    rect.y += 2;
                    EditorGUI.PropertyField(
                        new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight),
                        element, GUIContent.none);
                };

            list.DoLayoutList();
        }
        serializedObject.ApplyModifiedProperties();
    }

waxen sandal
#

Pretty sure the issue is that you're recreating it every frame

#

You should cache it

visual stag
#

You just create it in OnEnable

#

and then call DoLayoutList in the GUI loop

crisp knot
#

Ok thank you I'm going to try and cache it.
But I need to create it on the OnInspectorGUI() method because it tries to fetch a list of items from a list that is serialized and updated on the OnInspectorGUI() method

visual stag
#

That's not how it works

#

you can create it in OnEnable

#

seeing as it uses serializedProperties and callbacks

waxen sandal
#

Best case you'd want to create it in OnEnable

visual stag
#

You can and should initialise almost all SerializedProperty values in OnEnable when you can

waxen sandal
#

And if the list changes you remove/create a reorderable list

visual stag
#

If the list changes entirely like, it's a completely different list, you'll have to make a new one

crisp knot
#

Thank you again it works now 😆

severe python
#

@waxen sandal @onyx harness @lucid hedge Honestly, the UIBuilder and UI Elements in general are actually an excellent UI package overall

#

it combines the strengths of WPF and HTML/CSS and does so quite well

lucid hedge
#

I agree

severe python
#

the main issue I've run into is Z-Ordering of popups

#

which i was able to solve, but it was a problem

lucid hedge
#

but I've never done a lot of advanced editor scripting though

onyx harness
#

Hahaha I knew you would be around about this subject 😅

severe python
#

😄

#

UIElements is Love, UIElements is life

#

seriously though, been doing WPF for 10 years, some html/css here and there, winforms, and of course the scourge, the evil queen, known as IMGUI

onyx harness
#

But you said it, UI Element needs a package?

severe python
#

yes it does

#

well, no, the UI Elements Builder needs a package

#

UIElements itself is integrated into the core

#

and the debugger is also part of the core, so you don't need that either.

onyx harness
#

@lucid hedge well, we got our answer here

severe python
#

The rabbit hole goes deeper

#

it will be a package

#

Not being a package currently carries some limitations in their flexibility, slowing down the development pace for UIElements, and preventing them from providing support for a few scenarios

#

so they are migrating to using a package, which will of course probably be forcefully installed

lucid hedge
#

yeah that forum page is why I asked

severe python
#

its just like a number of existing packages which always exist and can't be removed (atleast as far as I can tell)

onyx harness
#

Imagine you update the package and there is a bug.
Boom Editor is not usable anymore

severe python
#

hmm

#

I want to believe there will be contingencies for that

digital spoke
#

i can now set the exposedreference of my nodes

#

but now i have the small issue of that it's kinda annoying to have to set exposedreference's in the inspector rather than the node editor

#

reason why is because Unity refuses to save ExposedReference types when restarting the editor unless IExposedPropertyTable is inherited in a monobehaviour.

tidal cave
#

Re UIElements Runtime, is what in UIElementsUniteCPH2019RuntimeDemo the same as 0.0.3-preview hidden package?

trim gale
#

Would anyone know how to not need to make wrappers for a structure like EnumCollectionDrawer<TEnum, T> : PropertyDrawer ?

#

or to automatically make the wrappers

onyx harness
#

Just derive the class

trim gale
#

I mean to use that drawer I need to keep add for each class that uses it [CustomPropertyDrawer(typeof(LayerAnimator))] public class LayerAnimatorDrawer : EnumCollectionDrawer<Layer, Animator> { }

#

it's getting old

onyx harness
#

You have a second argument in the CustomPropertyDrawer to include derived classes

trim gale
#

Execpt you can't use generic types inside of attributes :S

onyx harness
#

Well, there may be a way

#

But it's very hacky

trim gale
#

the way I'm presently thinking is way hacky so

onyx harness
#

It's about altering the dictionary in charge of selecting the right drawer from a given type

trim gale
#

it's be easier to check the assembly and write a wrapper file in code IMO

onyx harness
#

How? What would you gonna do in your wrapper file?

trim gale
#

in the editor use the [DidReloadScripts] then reflection to find all the types of the base classes

#

then write a cs file via code with the wrapper stuff

#

meaning by hand you'd only have to do the one generic wrapper and then unity will write the drawer wrappers

onyx harness
#

And the day you remove one derived class, you break compilation

trim gale
#

how?

onyx harness
#

You have type A and B.
You generate LayerADrawer and LayerBDrawer.
The day you delete A or B, your script will stop compiling

trim gale
#

the most you'd get is an error that the dependent class is not defined, you delete the unneeded wrapper.

onyx harness
#

If this flow is fine for you, I won't push ;)

trim gale
#

I'm going to test it and see at least

#

worst to worst I'm just back to writing them by hand

onyx harness
#

If it is fine for you, I'm good with it

tulip plank
#

I'm confused about how to access certain classes from my project. Specifically, UnityEditor.UIElements.EditorMenuExtensions seems completely missing/inaccessible from my project (I'm running 2019.3.0b7 and this class clearly exists in the reference source for 2019.3.0.a3).

#

I don't understand if it was removed from its assembly at some point, or what is going on here.

#

It seems likely because the EditorMenuExtensions class is private, which is weird. I don't see why it would be.

somber mesa
#

Anyone have experience using Data Binding systems?

#

Specifically I’m trying to bind UI elements - slider and toggle to game object parameters and exposed VFX/ Shadergraph stuff

onyx harness
#

@tulip plank a lot of things that could have been public, are private. Nothing surprising

tulip plank
#

@onyx harness While I would totally expect Unity to do something like that, it was used as a solution provided in a Unity forum--though granted, it was provided by a Unity employee, so maybe they took for granted the fact that they were working within that project. :/
In any case I copied the code from the reference source and put it in my own project.

onyx harness
#

If it works, it works.
Or you can create a wrapper with Reflection to mimic the private clasw

tulip plank
#

👍 I like your style.

onyx harness
#

The benefit doing this way is, as long as their methods' signature remain the same, it is forward compatible

#

I can provide a class wrapper generator if you want

tulip plank
#

Hah, you've written such a thing? I mean, that sounds amazing so I'd love that (assuming it already exists, I don't want you to do that work just for me.)

onyx harness
#

It is done already.
I will send it to you tomorrow

lucid hedge
#

okay so I've been using the UI builder some more

#

I love the workflow and speed you get of just designing an interface

#

sometimes it freezes big time though

#

and also I have yet to figure out how to create custom elements and add real interactivity instead of just nice looking designs, I'm not sure if those things are really doable without coding

severe python
#

they are and are not

lucid hedge
#

Any clarification?

severe python
#

Sorry, I got totally distracted

#

so you can do a lot with binding paths to get things done, but some more complex interface issues are not so simple

#

like having a list selection feed some other display basically requires code behind

#

but anything for modifying the contents of a UnityEngine.Object can basically be done through binding

#

I built a little framework for making some of that easier

#

the first link is setup for loading into the package manager

#

it may just serve as useful examples

severe python
#

basically, yuo will not build a comprehensive UI without atleast some coding, its required, how you setup that code will determine how much code you have to write

#

which is why I built those two repos, because I wanted to reduce the amount of code I needed to write to create more complex interactions

onyx harness
#

@tulip plank What Unity version are you using?

tulip plank
#

2019.3.0b7

solemn ermine
#

Does anybody know if there is an equivalent command line to build for WebGL like this command:
-buildWindows64Player [buildpath]

#

The command line -buildTarget <name> only specifies the build output but no path

arctic frigate
#

Hey all! Just wondering, can i create a MonoBehaviour with a field ScriptableObject, where GameDesigner could drag desired asset file, and after that choose what field from the SO he / she would like to use in later functions (for ex. display chosen one as a text)

Something similar to this one:

#

Where some dropdown menu would have all fields like, ID, name etc.

onyx harness
#

@arctic frigate Yes you can.

tidal cave
#

"I'm understanding the semantic of the question but ignoring the meaning" – "Can you give an example?" – "Yes, I can" 🙂

onyx harness
#

He is just wondering, so I answered as precised as I could 8)

tidal cave
#

I think the real question is "how"

onyx harness
#

I never answer that question.

tidal cave
#

"What Unity version are you using?" – "The one I have installed", like this? 😆

onyx harness
#

The reason is very simple.
If the question is not backed with background elements. I am not going to make the job for him/her.

#

I don't wanna help people if they don't do their homework.
Gladly, this Discord has no gamification.

#

While I try to educate those young programmers, nobody (or rarely) will try to bypass my help and drop the work.

tidal cave
#

Yeah, I agree, doing homework is important. But often people are stuck and not just lazy, and they need nudge in the right direction

#

Anyway, not complaining, just noticed it's funny 🙂

onyx harness
#

Well, they really need a very minimum of homework to allow me to guide them.
Especially when the request is more complex than just "shit, do you have a method/algorithm to do that?"
If the answer is just an API, I don't have any to problem to tell them.

#

Or, if I know the author behind the question is someone who did his homework before. I don't have any issue helping them.

#

I try my best to not answer, but to guide them.
So they can guide themself later and not come back to this Discord ever 😄

tidal cave
#

Your definition of success would be "noone ever ask questions again"? 🙂

onyx harness
#

Yes. Because little bird became a PHOOEEENIXXX!! 🤪

lucid hedge
#

can confirm I once asked Mikilo a question and he didn't hold my hand and instead I found it myself and felt very proud

tidal cave
#

Okay, here is a question (and I will come again). I'm using SO to configure an AssetPostprocessor and I need a property that represents a folder. I've found that folder is represented as DefaultAsset and I can use AssetDatabase.IsValidFolder to check if it is a folder. So far everything works fine, except I want to disallow selecting non-folders. Right now I issue a warning during import if there is a non-folder asset in the property, but I want to prevent it in the first place. Is there some kind of validation logic that I can plug into and filter non-folders from being drag'n'dropped into the property or selected from the list? If there is, what's the API? I probably can plug into UI events and handle Drag* events, but that's too low level and also doesn't handle selector window.

#

Bonus question to Unity devs, if any, is why there is no FolderAsset? 🙂

onyx harness
#

Your property, use a custom property drawer to filter it manually.

#

(I'm off to bed, will reply tomorrow)

golden stratus
#

hello, i'm stuck on editor stuff :/

#

I would like to have dropdown with values in my inspector, that i can change when my project is not playing

#

i want these values to be used in a script in the scene, i used a editor script, and i popup the content of my lists using EditorGUILayout.Popup

#

I change my 2 dropdowns than hit play, but when the project is playing, dropdowns have been reset to default values (so dropdown value changement is not saved when i hit play

#

here my editor class

#

before i hit play :

#

just after i hitted play :

#

the target class :

dim walrus
#

That's because you are saving the option selected in the editor

#

And editor is reseted when you enter play mode

golden stratus
#

is there a way to maintain those changes when i hit play ?

dim walrus
#

Having the selection in the MonoBehaviour or using PlayerPrefs or something like that

golden stratus
#

So they must be static in my monobehaviour script ?

#

the selection i mean

dim walrus
#

No, it can be a normal field

#

If it's static since it cannot be serialized it'd be reseted aswell

severe python
#

hes already saving it

#
var prevChoice = (target as DebugManager).url;
var indexFromPrev = options.indexof(prevChoice);
choice = EditorGuiLayout.Popup("Servers",  indexFromPrev, options)
#

same deal with the other popup

dim walrus
#

You can change the int for a string?

severe python
#

I mean thats wrong, you'll need to reverse lookup the index from the options

dim walrus
#

Oh okay

severe python
#

something like that now

#

that could certainly fail, if the values are changed in options

#

I'm gonna stop now because I keep making tiny mistakes

golden stratus
#

var indexFromPrev = System.Array.IndexOf(options,prevChoice);

#

i'm trying this

#

dont need this part anymore ?

#

OK i kept this part, and this is working, thx 🙂

cloud wedge
#

I have a EditorGUILayout.LabelField($"Summary: {t.GetSummary()}", GUILayout.ExpandHeight(true)); and I want all the contents to be visible when it overflows like in html. How do I do that?

onyx harness
#

Don't use the default style of LabelField

cloud wedge
#

how do I avoid that?

onyx harness
#

You can provide a GUIStyle just before your GUI layout option

cloud wedge
#

GUIStyle.none?

onyx harness
#

No no, more like from a copy of label style:

var label = new GUIStyle(EditorStyles.label);
label.wordWrap = true;
cloud wedge
#

ah

#

thx

#

now i have this: var wrappingStyle = new GUIStyle(EditorStyles.label); wrappingStyle.wordWrap = true; wrappingStyle.alignment = TextAnchor.UpperLeft; EditorGUILayout.LabelField($"Summary", t.GetSummary(), wrappingStyle);

onyx harness
#

Good but not good

cloud wedge
#

why is the text centered?

onyx harness
#

Cache you style

#

Dont generate each frame

#

Hum...

#

Can't tell

cloud wedge
#

oh well, i an live w/ this

onyx harness
#

Is the text shifted, or your below GUI shifted?

cloud wedge
#

not intentionally

onyx harness
#

Write a test. LabelField("A", "B")

cloud wedge
onyx harness
#

XD

#

Ok yeah something is wrong

cloud wedge
#
            var wrappingStyle = new GUIStyle(EditorStyles.label);
            wrappingStyle.wordWrap = true;
            wrappingStyle.alignment = TextAnchor.UpperLeft;
            EditorGUILayout.LabelField($"Summary", t.GetSummary(), wrappingStyle);
            EditorGUILayout.LabelField($"A", "B");
onyx harness
#

You can play with labelWidth

lucid hedge
#

Using EditorGUILayout.PropertyField on a Texture2D I get this

#

but is there a straightforward way to get it to show up like this?

#

like in a material editor

#

so that there is a visual 'preview' of the texture and a 'select' button

onyx harness
#

Augment the height?

lucid hedge
#

doesn't blow up the texture

onyx harness
#

Let me dig into it

#

I know Unity is doing some automatic UX modification

lucid hedge
#

Don't put too much effort into it, it's not super important

onyx harness
#

what is the Object given as parameter?

#

Sorry, the Object Type provided

lucid hedge
#

a Texture2D

onyx harness
#

Strange

#

if the Type is deriving from Texture or is a Texture or Sprite, and the height > 18F, it should display a big preview

lucid hedge
#

Alright well it's not important, just think it looks nicer with a preview but no big deal at all

#

thank you for looking in to it 🙂

#

Where did you find the information?

onyx harness
#

From this:

EditorGUILayout.ObjectField("Test 1", null, typeof(Texture2D), false, GUILayoutOptionPool.Height(64F));
EditorGUILayout.ObjectField("Test 2", null, typeof(Texture2D), false, GUILayoutOptionPool.Height(24F));
EditorGUILayout.ObjectField("Test 3", null, typeof(Texture2D), false, GUILayoutOptionPool.Height(32F));
EditorGUILayout.ObjectField("Test 4", null, typeof(Texture2D), false, GUILayoutOptionPool.Height(48F));
lucid hedge
#

I am using EditorGUILayout.PropertyField

onyx harness
#

Sorry, I never use PropertyField 🙂

visual stag
#

I don't think PropertyField has the ability to do it

lucid hedge
#

what are the downsides of using PropertyField?

onyx harness
#

Well you got one already.

lucid hedge
#

haha

visual stag
#

PropertyField is great

#

just not when you want something specific

#

you could make a PropertyAttribute and Drawer pair that enables you to use PropertyFields

#

or tag anything to use that specific object field impl

lucid hedge
#

yeah that's not worth it in this case, it's really a small small detail

visual stag
#

Also looking at the actual CS source the logic for which it draws makes a lot more sense

lucid hedge
#

I could also use this

#

Texture2D texture = AssetPreview.GetAssetPreview(sp.objectReferenceValue);

onyx harness
#

This is why PropertyField can not handle what you want.
The 3rd argument is the Type, which is null.

#

And as I stated above, it needs a Texture/Sprite or deriving one

lucid hedge
#

that's interesting

onyx harness
#

I prefer to say it is stupid 🙂

#

Even if SerializedProperty does contain the true inner Type. It can fetch it somehow.

#

Performance speaking, it's not the best I give them that point

plucky nymph
#

Is it possible to rename scenes (hopefully enmasse) with an editor tool?

onyx harness
#

Yes.

plucky nymph
#

Do you know which function I would use? I can make the window etc, I just havent found anything for the actual change yet

onyx harness
#

A scene is just an like any asset

#

Which implies they are Object.

#

Implying they have a name.

#

AssetDatabase.RenameAsset

plucky nymph
#

ah, thanks!

autumn harbor
#

How to play an AudioClip from an editor script?

visual stag
#

There's an internal class AudioUtil that has an internal method PlayClip

#

you could call that

gloomy haven
#

hello, I got the Odin editor for unity during the black friday sale and I am loving it so far. I am having one problem with it though and that is that the min max slider is hard to set the exact value I want with it. is there any way to make it increase / decrease it in increments for example it moves up or down by 0.5?

waxen sandal
gloomy haven
#

thanks

lucid hedge
#

or contact the asset owners

#

would be better idea

split bridge
#

I'm finding that overriding public override bool RequiresConstantRepaint() to return true even with an empty inspector trashes my editor performance (~6ms -> ~30ms) - is that expected? 2019.3.0f1 - UIElements any better for this kind of thing (i.e. an animated progress bar)?

onyx harness
#

I would not recommend overriding this one

#

Prefer using onMouseMove and repaint on a real event MouseMove.

onyx harness
#

@split bridge

split bridge
#

unfortunately that doesn't work for a progress bar...

onyx harness
#

what exactly is your progress bar?

split bridge
#

editor-preview of a tween

onyx harness
#

I guess you are drawing something and need the next frame to repaint to keep animating?

split bridge
onyx harness
#

Yeah this is what I thought

#

The moment you start doing your "animation"

#

You just call Repaint()

#

Until your "animation" has completed.

split bridge
#

sure, that's what it does currently

#

also when you roll over the buttons (even though it takes a while before the first mouse move in the area is detected)

onyx harness
#

So what is the issue then? I don't get it

split bridge
#

the massive drop in editor performance.. when all I want to do is re-render that small bar

#

do you know if UIElements is any better in this regard?

#

so hang on, are you saying that calling Repaint is cheaper than setting RequiresConstantRepaint()?

onyx harness
#

If repainting is eating your CPU you need to question your code

#

Yes

#

I never used UIElement, can't tell

#

But from my feeling whenever I am in Unity 2019.3, I feel the experience is utterly slow

split bridge
#

the performance drop happens even with an empty OnInspectorGUI so don't think it's my code

onyx harness
#

RequiresConstantRepaint() is basically a... constant repaint...

split bridge
#

but isn't calling Repaint in OnInspectorGUI the same thing?

#

I see the same performance characteristics

onyx harness
#

I don't think you are using the proper word

#

I don't think performance drop is the right word

#

I think you mean you are seeing your CPU busy while nothing is done, am I right?

#

If you don't profile it, your statement remains weak

#

Define "performance characteristics".

split bridge
#

This is the difference between calling 'Repaint()' in an otherwise empty OnInspectorGUI() or not

#

perhaps this is a .3 thing

onyx harness
#

Can you deel profile?

#

Just to gather more data on the culprit

split bridge
#

hmm interesting, I didn't expect deep profiling the editor work (did it always?)

onyx harness
#

Yep

split bridge
onyx harness
#

What is DOTS doing here, do you have an idea?

split bridge
#

it is a DOTS project but what it's doing here I have no idea...

#

investigating...

onyx harness
#

I need to see more

#

To help ya

split bridge
#

going to try and replicate in a blank project

onyx harness
#

Good habit.

#

But from my feeling, UI Element is really not on point. It's like the inertia is really really huge, like you are moving a bulldozer

split bridge
#

oh?

onyx harness
#

I didnt profile it, but I know one fact, they implement hovering of element

#

This means onMouseMove is ALWAYS active.

#

Which triggers Repaint() on each move.

#

Technically, it is not suppose to be an issue, but in UI Element it is

#

@split bridge Keep me in the loop please, I would like to know

#

(If you have any interesting data of course)

split bridge
#

so... it seems like the mention of DOTS is due to the LiveLink edit mode... but it's not the cause of the slow down and I can reproduce similar in an empty project

onyx harness
#

What is deep profile telling you then?

split bridge
onyx harness
#

Remove VS please, I need to see the metrics X)

split bridge
onyx harness
#

Can you unfold at the first line having 0KB of GC Alloc?

#

What is important here is the whole call stack, not just the deepest one

#

Because after 0KB, they all have minor impact

split bridge
#

sure - though if you have f1 installed, I could just sent the two minimal scripts if it's easier

onyx harness
#

That's true X)

#

The truth is I want to know what is happening, because I will be impacted, but I am too busy working on other stuff

#

We can stop investigating if you want

split bridge
#

well to me, it looks editor-related and worse perf than we should expect... so unless you think differently I'm kinda assuming this is an issue that they'll fix in f2 or f3

#

I guess I could try the same in 2019.2 but it's getting late here

onyx harness
#

Hope you are right

unborn bluff
#

Hi all
I am playing around with the new [SerializeReference] in conjunction with some editor scripts but for some reason I lose my interface references if I close and reopen Unity. It seems to work fine between edit/play mode but doesn't survive closing Unity. Anyone with an idea how that is so? My other changes/variables that aren't interfaces are saved properly, because I use EditorUtility.SetDirty(object);

stark geyser
#

I think it is still a subject to limitation of Unity serialization. You can't reference scene objects... in a normal way.

#

In the assets that is

unborn bluff
#

In my case, I am not referencing a unity asset. My code is as follows:

public class TileArray : ScriptableObject
{
    [SerializeReference]
    public List<LevelGrid.TilePair> tileArray;

    [SerializeReference]
    public ITileOccupy objType;
}

As you can se, ITileOccupy is an interface:

public interface ITileOccupy
{
    TileObjectType TileObjectType { get; }
}
#

During edit time, I create a GenericBaseObstacleTile which implements ITileOccupy and assigns it to objType:

public class GenericBaseObstacleTile : ITileOccupy
{
    public TileObjectType TileObjectType => TileObjectType.Obstacle;
}
stark geyser
#

Vice versa, referencing a scene object in the asset directly is not supported.

unborn bluff
#

Huh, interesting. If that is not the case, what use case does it have?

stark geyser
#

I haven't got a chance to use it yet. But if you are using just one scene you can use a work around featured here. I think. https://www.youtube.com/watch?v=raQ3iHhE_Kk
Using generics they (scene objects) can be referenced sustainably.

unborn bluff
#

From the looks from this post, it seems like I should be able to Serialize an Interface on a UnityEngine.Object: https://forum.unity.com/threads/serializereference-attribute.678868/#post-4543723

The funny thing is, the serialization works fine between edit and play mode, so its not the serialization itself. It is just that the object is destroyed when I leave Unity and return.

rustic abyss
#

Where could I find some good and latest tutorial / courses to learn how to build great menu / layout whatever about GUI in Unity?

onyx harness
#

Perhaps it is saving InstanceID which is not persistent. Maybe I'm saying shit.

unborn bluff
#

When I investigate the ScriptableObject with a text editor, I can see that it has actually saved the type to disk:

stark geyser
#

@unborn bluff Objects present on the scene are not persistent. I assume your tileArray references something on the scene. Because scene can be unloaded at any moment. That's the limitation. Again, using generics you can persistently reference those.

unborn bluff
#

@stark geyser it doesn't reference anything in the Scene

stark geyser
#

yes

#

you can turn it into prefab and reference it

unborn bluff
#

I don't quiet follow you. My setup is:
ScriptableObject (TileArray.cs) contains a single field ITileOccupy. The type I assign to ITileOccupy is GenericBaseObstacleTile : ITileOccupy (notice it does not derive from MonoBehaviour). So I don't fully understand why I would lose anything by closing and opening Unity. Especially when I can see directly in the .asset using notepad that it is actually saving my Interface instance.

stark geyser
#

@rustic abyss For the latest, probably one of the numerous YouTube channels may have some. There are learning resources in pins in #💻┃unity-talk which have older ones.

#

If you can lose it by unloading a scene, this is what happens,

rustic abyss
#

@stark geyser oh thank you, i didn't know that there are pins! gonna check now!

unborn bluff
#

@stark geyser alright, I have simplified my problem. The following still doesn't work:

using UnityEngine;

[CreateAssetMenu(fileName = "TileArray", menuName = "ScriptableObjects/TileArray", order = 1)]
public class TileArray : ScriptableObject
{
    [SerializeReference]
    public TestInterface interfaceField;

    [ContextMenu("Create Instance")]
    public void CreateInstance()
    {
        interfaceField = new TestInstance();
    }

    [ContextMenu("Print")]
    public void Print()
    {
        Debug.Log(interfaceField);
    }
}

[System.Serializable]
public class TestInstance : TestInterface { }

public interface TestInterface { }

This is all the code there is to reproduce the issue.

stark geyser
#

In what way it doesn't work and where is the object you are referencing. Also checkout its limitations in the manual.

unborn bluff
#

I just believed I figured it out.

If I run CreateInstance() and then run Print() it will print:
"TestInstance".

Closing and opening Unity, on the same ScripableObject running Print() then returns:
"Null"

However, I now tried adding just adding a single integer into the class instance. Then, after closing and reopening Unity it now prints properly.

#
using UnityEngine;

[CreateAssetMenu(fileName = "TileArray", menuName = "ScriptableObjects/TileArray", order = 1)]
public class TileArray : ScriptableObject
{
    [SerializeReference]
    public TestInterface interfaceField;

    [ContextMenu("Create Instance")]
    public void CreateInstance()
    {
        interfaceField = new TestInstance();
    }

    [ContextMenu("Print")]
    public void Print()
    {
        Debug.Log(interfaceField);
    }
}

[System.Serializable]
public class TestInstance : TestInterface
{
    public int someValue = 5;

    public int GetValue
    {
        get
        {
            return someValue;
        }
    }
}

public interface TestInterface
{
    int GetValue { get; }
}
onyx harness
#

I would categorize this result as a bug in my opinion.

stark geyser
#

Yea, but in this case you are creating TestInstance only in memory. Only assets are persistent.

#

same thing will happen if you do this with Scriptable Object

onyx harness
#

And as FreakingPingo said, it works with a field, but not without a field.
This really smells like a bug.

#

I didnt try his code above, but I will keep that in mind the day I will tackle this new feature.

unborn bluff
#

I am fairly sure this is a bug. I can't imagine this is expected behaviour

shadow violet
#

What is the proper way to use Undo for multiple objects? I tried

foreach (var obj in Selection.gameObjects.Select(c => c.GetComponent<Text>()))
{
Undo.RegisterFullObjectHierarchyUndo(obj, "Text Conversion '" + obj.name + "'");
//... my actual logic I do in the for-loop exists below this line
}

But that just seems to crash Unity, and I tried other forms of Register as well, with the exact same crashing result - my guess is that im using it wrong, or that it shouldnt be called in a for-loop, but I cant think of another way to do it other than maybe a coroutine with a WaitForSeconds(1f), since I didnt see any callbacks or "isDone" type of functions I could use (but I feel like a coroutine will probably end up with the same crash result)

onyx harness
#

Why not just simple registration?

shadow violet
#

What do you mean? Like the deprecated function, Undo.RegisterUndo(obj, "..."); ?

unborn bluff
#

How do I display the "default" inspector for a non-MonoBehaviour that has the [System.Serializable] attribute, inside an EditorWindow?

#

I know you can do the following for UnityEngine.Object classes.:

Editor editor = Editor.CreateEditor( gameObject );
 editor.DrawDefaultInspector();

But I am not sure what to do if it is an ordinary class.

shadow violet
#

Huh... I just discovered Undo.DestroyObjectImmediate(obj); which basically solves what im trying to do, but still crashes Unity inside a for-loop, now its almost like 50-50 though, sometimes it will, sometimes itll work o.o

onyx harness
#

@unborn bluff you need to serialize an Object, get the SerializedProperty and display it with a PropertyField.

#

@shadow violet oh its deprecated, didn't know

#

Make simple test, test over a loop of 2

shadow violet
#

Yeah, but after enough research, I found a very disgusting way of doing it, but it seems to work... O.o

void MyFunc()
{
m_LastEditorUpdateTime = Time.realtimeSinceStartup;
        EditorApplication.update += OnEditorUpdate;
//for-loop logic I need to perform on Selection.gameObjects...
queueDestroy.Add(objFromLoop);
}

static void OnEditorUpdate()
    {
        float diff = Time.realtimeSinceStartup - m_LastEditorUpdateTime;

        //destroy old text objects in replacement of the newly converted one, with UNDO,
        //doing it in this way, prevents Unity from crashing a stack overflow, due to
        //calling Undo operation, destroy, and reference loss, several times in a static for-loop
        for (int i = 0; i < queueDestroy.Count; i++)
        {
            if (diff >= 0.12f) //"wait" a small timeframe
            {
                try
                {
                    GameObject obj = queueDestroy[i]; //has to be referenced otherwise either Undo will queue nothing after Remove, or vice versa
                    queueDestroy.Remove(obj);
                    Undo.DestroyObjectImmediate(obj);
                    m_LastEditorUpdateTime = Time.realtimeSinceStartup;
                }
                catch { }
            }
        }

        if (queueDestroy.Count == 0) { EditorApplication.update -= OnEditorUpdate; } //unsubscribe to prevent spamming the Editor
    }

Now that I think about it, I probably could use a Queue<GameObject> instead of a List<GameObject> but this seems to get the job done without crashing o.o

onyx harness
#

Why delaying the destruction?

shadow violet
#

Cause otherwise, Unity will crash (and my only guess is, it may have something to do with how Destroy works internally, cause even using the regular GameObject.DestroyImmediate, it still crashes - and the Editor log has nothing relevant on what happened)

onyx harness
#

Can I see the full code?

#

Have you tried just registering then destroying only. Without doing any other action.
Just to make sure this is this code that crashes

shadow violet
#

Sure @onyx harness (https://hatebin.com/cihqntoueg)
OnEditorUpdate on line 17 is basically my "coroutine", in the lightest terms possible - ConvertSelectedToTMProContext on line 43 is what the user will use from the Hierarchy context menu - then ConvertUnityTextToTMPro does the actual work, for all functions

And I have, I tried commenting out everything else, and maybe the function is called multiple times (so I tried to put in some hardcoded "stops"), or something else is going on, but it seems to be just the destroy lines, cause with them commented out previously, everything worked flawlessly it just obviously didnt destroy anything

onyx harness
#

OK ok, well if you are on the latest version, just make a bug report

shadow violet
#

Oh, ok im not on the absolute latest version, my project is in 2018.3, but I do plan to form this into an asset, cause im sure it could help some others as well - ill put in a bug report anyway, just incase

rustic ginkgo
#

does someone have a script thats create sortinglayers?

onyx harness
#

@rustic ginkgo Can you elaborate

#

@shadow violet in fact i wrote a script for that years ago

#

To replace a any Component A by any other Component B.

#

Not even sure it wouldnt crash like you

shadow violet
#

Yeah, the only downside I just realized with my system, (minus the workaround for crashing), is that it will destroy the old object, so if you had components or scripts on it, none of those would get carried over - maybe there might be a way to solve that, but for now, I just decided to add a "checkbox" function to decide if the object should be destroyed or not, within the users control @onyx harness

thick eagle
#

Is this intended behavior in UIElements? When registering Mouse Enter/Out events on the element, mouse out event gets called each time pointer enters and leaves a child element. For example:

#

Events are registered on gray background element, squares are children

waxen sandal
#

I'd except an enter as well in that case

#

It's probably a "feature"

#

Just like how it doesn't work in editors for animator state scripts

tidal cave
#

Doesn't look right. If it were Enter, Out, Enter, Out there would be some logic in it.

#

I'd file a bug

quasi monolith
#

does anyone know how to reorder these root level items?

#

we can use the priority argument in MenuItem attribute, but that only affects the items inside the menu

#

I want to reorder the root level stuff

lucid hedge
#

Any reason why this code

#

is giving me the following errors?

quasi monolith
#

restart unity

#

those look like random editor glitches

onyx harness
#

The Reflection error or GUI error?

lucid hedge
#

both of them

onyx harness
#

Drop the stack tracew

lucid hedge
#

they both appear due to this script

#

it mentions UIElements

onyx harness
#

Because it does not work like that

#

OnSceneGUI is a Unity message.

#

Just change the name.

lucid hedge
#

fixed, thank you

#

although

#

what I wanted to achieve is this

#

but it says onSceneGUIDelegate was deprecated

#

and I should use duringSceneGUI

#

so I did

#

but it doesn't have the effect of drawing handles whether selected or not

onyx harness
#

Which is fine. But not with this exact method name.

#

Oh

#

Put a log, to see if it is triggered

lucid hedge
#

like this?

onyx harness
#

Yes

lucid hedge
#

doesn't log

#

only when object is selected

onyx harness
#

Which is normal XD

#

OnEnable is called only if the Editor is created

#

Which will never, if you don't select it

lucid hedge
#

yeah but so what is a workaround to have handles be always displayed?

onyx harness
#

Use InitializeOnLoad

#

So so? 🤓

lucid hedge
#

I switched to gizmos haha

#

they fit better in what I'm trying to do actually

#

I only need the visuals in play mode

#

sorry

severe python
#

it makes me sad that you abandoned uielements

simple cove
#

@lucid hedge There's a Handles.Begin() which works like EditorGUI.Begin() (or something alike)

sand spindle
#

I am having an error when I am trying to use the UnityEditor.Build library, error CS0234: The type or namespace name Build' does not exist in the namespace UnityEditor'. Are you missing an assembly reference?

onyx harness
#

What have you tried?

sand spindle
#

Not many things, the script is inside a folder called Editor and I have tried using #if UNITY_EDITOR

#

I am working on a linux machine that is running fedora

#

I am using Unity 5.4.0p1

onyx harness
#

Can you show a screenshot or code?

#

Anything that we can use to help you

#

Because we are not god among humans X)

sand spindle
#

I guess that google was wrong by saying that admob could be used in any version above Unity 4.6.8

onyx harness
#

I guess you're right

sand spindle
#

Thanks by the way

#

Wait you searched for UnityEditor.Build.BuildFailedException which means that BuildFailedException might be a subfile of UnityEditor.Build right?

onyx harness
#

I used the first class VS suggested me

#

Used the one you would like

#

Because remember, I don't have a clue what you used

sand spindle
#

As I mentioned befor I am having the error on the line using UnityEditor.Build it is saying that Build does not exist in UnityEditor so the library can not be imported cause it can not find the file

#

But it does find the UnityEditor

#

`#if UNITY_ANDROID

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
#if UNITY_2018_1_OR_NEWER
using UnityEditor.Build.Reporting;
#endif
#endif`

#

The error is on the 10th line

#

That is importing the UnityEditor.Build

#

If I had more infos about what is going on I would have told them

#

When I googled the error I found almost nothing

onyx harness
#

Use triple backticks ```cs

#

and end it with triple backticks

#

for code

#

You have UnityEditor, which is right.
But the error is about UnityEditor.Build. Which might not be available before 5.6

sand spindle
#

Thanks for the tip, moreover the link you sent to me is not exactly right since I tried searching for UnityEditor library and it says that the first released was at 2019.1.0f2 but the library exists back in Unity 5.4

#

Is it possible that the UnityEditor.Build library is a part of a unity asset package?

#

From unity?

onyx harness
#

Which classes of UnityEditor have you searched?

sand spindle
#

I guess that, I was wrong, I searched for UnityEngine but it matched with UnityEditor.Compilation.CompilationPipeline.PrecompiledAssemblySources.UnityEditor

#

I am downloading a new unity version I will inform you if it was a version problem

queen crag
#

Does anyone know of a good solution to drawing many thousand handles / gizmos in the scene view?

#

as in round about a 100K lines or so?

onyx harness
#
Begin
Draw 100k lines
End
#

Or

#
Culling
Begin
Draw less lines
End
queen crag
#

@onyx harness thanks I ended up using a geometry shader

#

working on some vector field based nav

onyx harness
#

Much better solution, gj

wispy delta
#

I'm generating some jpgs in an editor window and want to change the texture's wrap/filter mode after creating them. However the changes don't seem to stick. Here's my code. Any ideas? This is in an async script, but making calls to Unity has worked so far, so I'm not sure why changing properties on the texture wouldn't work.

var texturePath = $"{textureFolder}/{tileKey}.jpg";
var texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));

if (texture == null || !skipIfAlreadyCreated)
{
    texture = await DownloadTileTexture(tilePosition, token, urlTemplate);

    var fullTextureFolder = $"{Directory.GetCurrentDirectory()}/{textureFolder}";
    var jpgBytes = texture.EncodeToJPG();

    using (var jpgFile = File.Open($"{fullTextureFolder}/{tileKey}.jpg", FileMode.OpenOrCreate, FileAccess.Write))
        jpgFile.Write(jpgBytes, 0, jpgBytes.Length);

    AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceSynchronousImport);
    texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
}

texture.wrapMode = textureWrapMode;
texture.filterMode = textureFilterMode;
#

To be more specific, the changes don't work when the jpg is created. If it already existed and was loaded correctly on the second line the changes do stick Nevermind they don't ever get applied. Weird

waxen sandal
#

You should use serialized objects or record it with Undo

calm thistle
calm thistle
onyx harness
#

@wispy delta delay it

#

And print a log, to make sure you are on the right asset

#

@waxen sandal why do you want him to use SerializedObject?

#

@calm thistle what is the issue exactly?

wispy delta
#

@onyx harness Where should I put the delay? To test, I set the texture to null before importing/loading the asset and it appears to be assigned correctly.

onyx harness
#

EditorApplication.delayCall

wispy delta
#

No luck with this. Does it look correct to you @onyx harness?

EditorApplication.delayCall += () =>
{
    texture.wrapMode = textureWrapMode;
    texture.filterMode = textureFilterMode;
};
onyx harness
#

Debug.Log(texture, texture);

#

And click on the log to make sure it is the new one you just wrotr

wispy delta
#

The errors do ping the generated textures

#

This is so weird

onyx harness
#

You should create the asset directly, and not importing it

calm thistle
#

@onyx harness The position of the gizmo is different from the position of the transform. This...

Vector3 size = Vector3.Scale(cachedRenderer.bounds.size, cachedRenderer.transform.lossyScale);
                ops[i] = new GUIOps
                {
                    screenRect = new Rect(cachedRenderer.bounds.center - (size/2), size),
                    texture = croppedTexture
                };

... should give me the rect of the sprite renderer in its prefab world position while this...

for (int i = 0; i != ops.Length; i++)
            {
                GUIOps op = ops[i];
                Rect rect = op.screenRect;
                rect.center += (Vector2) transform.position;
                Gizmos.DrawGUITexture(rect, op.texture);
            }

... should reposition the rect center using the current transform position but the texture is drawn with its center on top left, top middle or top right depending on the transform position.

wispy delta
#

I was creating Texture2D .assets originally, but I ended up needing actual image files. Can I create jpg files via AssetDatabase?

calm thistle
wispy delta
#

@onyx harness I got it to work like this:

var importer = (TextureImporter)AssetImporter.GetAtPath($"{textureFolder}/{tileKey}.jpg");

importer.filterMode = textureFilterMode;
importer.wrapMode = textureWrapMode;

importer.SaveAndReimport();
dense cobalt
#

Hey guys, i just downloaded Unity and VS Code on a new computer, but i can't find a way to get AutoCompletion for unity, i tried adding "Unity Tools" and "Debugger for Unity" nothing changed, could you guys help me ?

onyx harness
#

@wispy delta But I thought you wanted to create a texture. This is totally different

#

@dense cobalt Your file is not part of the project.

#

Delete your .sln/.csproj

calm thistle
dense cobalt
#

Where can i find this file ? @onyx harness

wispy delta
#

@onyx harness I am creating a texture, this is just how i'm changing the import settings

onyx harness
#

You are writting a texture

#

then importing it

#

while you can use AssetDatabase.CreateAsset

#

@dense cobalt at the root of your project

dense cobalt
#

Got it, working now, thx

wispy delta
#

if i use CreateAsset it has to be a .asset which doesn't have as many import options and I don't think generates mip maps

onyx harness
#

Hum... I don't think this is true

#

If I create a Material, it's gonna be .mat

#

but it needs to be confirmed

wispy delta
#

"You must ensure that the path uses a supported extension ('.mat' for materials, '.cubemap' for cubemaps, '.GUISkin' for skins, '.anim' for animations and '.asset' for arbitrary other assets.)"

calm thistle
#

Ok so another question if I can't find any answer... How would you draw a texture in the editor scene if it wasn't using Gizmos.DrawGUITexture ?

onyx harness
#

GUI.DrawTexture perhaps

#

Like drawing any GUI in the scene

#

It works

#

I'm looking into your code right now

#

But perhaps you are not using the right position

calm thistle
#

I debugged it and it's ok 😦

onyx harness
#

I mean, try this:
EditorGUIUtility.ScreenToGUIPoint

calm thistle
#

If it was just not well positioned I still wouldn't understand why the distance between the transform and the texture keeps changing

onyx harness
#

Or something similar to correctly convert a position from the 2 perspectives

#

You don't see it because you are around 0,0

#

Try around 500,500, you will clearly see the problem I think

#

you might even zoom in/out

calm thistle
#

neither ScreenToGUIPoint nor GUIToScreenPoint

#

Already triend with World To Screen and Screen To World

onyx harness
#

Hum... strange

calm thistle
#

Just checked my rect are ok :

Gizmos.DrawWireCube(rect.center, rect.size);
Gizmos.DrawGUITexture(rect, op.texture);