#↕️┃editor-extensions

1 messages · Page 88 of 1

serene spear
#

I forgot that was part of serializedproperty

gloomy chasm
#

No, I just used var to make it shorter.
internally EditorGUILayout.PropertyField basically just does

if (property.type == PropertyType.Bool)
  property.boolValue = EditorGUILayout.Toggle(property.displayName, property.boolValue);

(This is pseudo code, and isn't exactly what it does, but I think it should give you a better idea of what is happening)

serene spear
#

oh nice

gloomy chasm
#

It does more than that, like makes sure that Unity treats the field properly when working with prefabs. So it is best to just use PropertyField unless you know what you are doing or need it to display differenty.

serene spear
#

if I were to then put it in an if statement, can I just call the value directly, or do I need to just do boolvalue too

gloomy chasm
#

You almost never want to use both serializedProperties and direct access.

serene spear
#

ok I'll keep that in mind

gloomy chasm
#

The reason is that SerializedProperties manipulates the object data on the C++ side, while accessing directly manipulates the data on the C# side. So you can get unexpected values if you use both.

serene spear
#

I changed one part, is this correct?

gloomy chasm
serene spear
#

Alright I'm on track then, think I have a feeling it'll mess up the dialogue and responses, but that's fine

serene spear
#

I fixed it and it crashed Unity, but it seems fine now

#

alright, that fixed it, thank you @gloomy chasm

viral dune
#

Hi, i'm trying to follow Sebastian Lague's tutorial on bezier curve and implementing it in EditorWindow (not scene view) (https://www.youtube.com/watch?v=n_RHttAaRCk),

I have a problem using handles. apparently i can't use handles on editorwindow because it needed a camera, how do i resolve this ?

#
            Vector2 newPos = Handles.FreeMoveHandle(path[i], Quaternion.identity, .1f, Vector2.zero, Handles.CircleHandleCap);
#

this line of code cause a nullref error

viral dune
#
  void Draw()
    {
        for (int i = 0; i < path.NumSegments; i++)
        {
            Vector2[] points = path.GetPointsInSegment(i);
            Handles.color = Color.black;
            Handles.DrawLine(points[1], points[0]);
            Handles.DrawLine(points[2], points[3]);
            Handles.DrawBezier(points[0], points[3], points[1], points[2], Color.green, null, 2);
        }

        Handles.color = Color.red;
        for (int i = 0; i < path.NumPoints; i++)
        {
            Rect handleTan = new Rect(path[i].x, path[i].y, 10, 20);

            BeginWindows();
                handleTan = GUI.Window(i, handleTan, DrawNodeWindow, "");
            EndWindows();

            Vector2 newPos = new Vector2(handleTan.x+handleTan.width/2, handleTan.y + handleTan.height/2);// Handles.FreeMoveHandle(path[i], Quaternion.identity, .1f, Vector2.zero, Handles.CircleHandleCap);
            if (path[i] != newPos)
            {
                Undo.RecordObject(creator, "Move point");
                path.MovePoint(i, newPos);
            }
        }
    }

i've tried this approach but it also does not work

waxen sandal
#

There's no easy equivalent afaik

#

You can't really apply a tutorial like that to something else

viral dune
#

yeah, i'm trying to replace the handle with gui.window, so it looks like the shader graph but with a window of 20*20

viral dune
waxen sandal
#

Chances are something else is null then

#

You should attach a debugger and see what's null

viral dune
#

okay i didnt think about that, i'll try it tomorrow, thanks for the advice

#

and also, i've managed to create smting like this

#

but i'm too anxious to implement it myself since my math is not that good

#

but i'll give it a try

gloomy chasm
#

I am working on ScriptableObject Variants, and have the basics working really nicely (with almost no reflection too!).
I was thinking of how to handle Undo, right now I am storing the variant data with AssetImporter.GetAtPath(path).userData, but that of course does not support undo. I can handle it, but it would be rather messy.

The other options I thought of are to store the variant data in hidden sub-assets on each SO, or to have a single file that contains the variant data for all SOs.
Thoughts?

whole steppe
#

I posted my question in #🔀┃art-asset-workflow but I guess this would actually be a more appropriate place... I started learning probuilder yesterday and decided to make a simple 3d lamp, it turned out as youd expect from a begginer like myself but my issue is that I can't figure out how to make it so that when I move the body of the lamp, the object keeps being connected and moves the head of the lamp down? ( I want this to decorate a house in my game )

#

any help appreciated

gloomy chasm
civic river
gloomy chasm
civic river
#

I had an issue where grouped undos did not cross contexts but I'm not sure if it was only my specific case or what

#

so it would only undo 1 object at a time regardless of how many undo's were on the stack

#

even if you crushed the groups together

gloomy chasm
#

My thinking was that if I had the variant data stored in an asset (thus a UnityEngine.Object) it would be trivial to support Undo. But both ways I mentioned are a bit, ehh.

gloomy chasm
crimson estuary
#

Not sure if this should be here or in #💻┃code-beginner, but I'm curious if it's possible to write a script that lets me do custom inputs for navigating the scene view

#

eg, have orbit on my scrollwheel

civic river
gloomy chasm
#

So if I change a property in a child and make it overridden, but then undo. It will still show that it is overridden.

civic river
#

ahh yeah I see

#

that's a tough one, I don't think you can even interact with the undo object in a meaningful way

#

you could set up an undo listener that fixes the object after it's been undone

#

but that's obviously pretty gnarly

#

Undo.undoRedoPerformed += ...

gloomy chasm
wild forge
#

ah, completely missed that this channel exists, might be better off asking here. I'm having Object reference not set to instance of an object error at line 51 and it's to do with Handles.DrawBezier I'm probably missing something obvious http://pastie.org/p/0UJmQXSo3NzAQsSdxUbOOo

gloomy chasm
#

You can use Texture2D.whiteTexture for a default 1x1 white texture.

gloomy chasm
#

@civic river Ah, I found Undo.RegisterImporterUndo() which works! I need to do some messing around to group things properly, but it should work just fine in the end! 😄

crimson estuary
#

I feel unqualified to ask, but this is kind of a big deal,

I want to move the scene viewport with scripts, eg, orbit

#

For the life of me I can't find any way to hook into the viewport's camera though

#

If I must, I found a plugin that lets you use 3DConnexion devices to move the viewport, so surely I can figure out how they did it

gloomy chasm
#

You would use the EditorTool if you want to make a tool like the transform tools (Move, scale, rotate).
If not, you can just use the [InitializeOnLoad] attribute to add a listener to the SceneView.duringSceneGUI event, and handle the movement with that.

crimson estuary
#

I see. I wish I was not stupid so I can continue figuring it out

#

Thanks though, this is worth thinking about for me

gloomy chasm
crimson estuary
#

well, in which case it's my stupid to pursue such a thing, but it would make working 100x smoother for me!

gloomy chasm
crimson estuary
#

Yeah, I have a mouse that can scroll horizontally as well as vertically, and I want to replicate the behavior in Blender (scrolling by default orbits the focused object, with modifier keys for pan and zoom)

#

I gotta AFK for a while, thanks for the help!

sterile lake
#

Hi Everyone, how do I get a world position on SceneGUI in 2D?
I'm trying to create an Editor Tool to help me create a POE-Like Skill tree.
Thank you

sterile lake
#

Hello, new Problem this is on an Editor Script, why is it Disabled?

waxen sandal
#

Probably the property drawer for that field

terse hazel
#

So, you still can't draw grids with UI Elements? Because I'm confused to no end because of the runtime variant.

#

Something like this I mean

waxen sandal
#

That should work just fine?

#

Which part are you struggling with?

terse hazel
#

My question is, is the grid layout system there yet, because I see nothing of it in the examples.

#

Instead of having to do it all manually

#

Because it was asked 3 years ago but on the docs is says it's still not there yet.

#

Well I'm not sure what they mean by grid view though, but I guess it's this.

waxen sandal
#

I guess a "formal" grid view isn't there

#

But you can easily achieve it yourself

terse hazel
#

Alright, that's what I wanted to know.
Didn't want to work on something I don't need to.

gloomy chasm
#

Is there some way to delay reimporting a specific asset until after the user is no longer inputting a value in to a field? (Can't require a custom editor)

waxen sandal
#

As long as you don't apply the import settings while it's being changed it doesn't reimport

gloomy chasm
# waxen sandal As long as you don't apply the import settings while it's being changed it doesn...

Yeah.. that is exactly what I am doing 😛
I am doing a check to see if any fields of an SO are different than the SO it inherits from, and if so I am adding those fields to a list which I then store in the AssetImporter.userData. And then I need to save those changes. It works great but the problem is if the user is dragging a field, the field will lose focus and it messes up the hot controls.

waxen sandal
#

Going to need some more context here

gloomy chasm
# waxen sandal Going to need some more context here

Right, sorry. So I am making ScriptableObject variants. I store SerializedObject paths for all of the properties that have been overridden, the GUIDs of all of the variants of the SO, and it's parent GUID if it has one. They are all stored in AssetImporter.GetAtPath(path).userData.
I have hooked in to a unity callback for every time a object property changes. I iterate over all of the properties in the object that changed and see if any are different than it's parent. If so I add them to the data stored in the userData. I then save the importer.

#
if (RegisterOverriddenProperties(targetSerializedObject, data, archetypeSerializedObject))
{
  Undo.RegisterImporterUndo(path, "Changed Override States");

  var importer = AssetImporter.GetAtPath(path);
  EditorUtility.SetDirty(importer);
  ArchetypeUtility.SetArchetypeData(path, data);
  importer.SaveAndReimport();
}
// Then here I iterate over all of the properties again and apply each to the variants of the SO assuming that the variant does not override it.
#

The problem is that the change callback is invoke every time that a SerializedObject has ApplyModifiedProperties() called (and it actually has things to apply)

waxen sandal
#

So when someone drags a field then it'll try to apply every time?

gloomy chasm
#

Honestly I would prefer it to work how Prefabs work, and only apply changes it the variants after an edit has finished. But I am am not sure how to do that. (looking at the source now to see if I can figure out what Unity does for prefabs...)

gloomy chasm
#

@waxen sandal So it is kind of hacky but I can do it in EditorApplication.update by keeping track of the undo group when I set the import data and then in the update call, see if the current group is different, and save it there.
But that sometimes will give a warning about hot controls, and the editor will not longer update for hover events and stuff until I select something.

#

Would it be a bad idea to just use hidden subassets to store the data instead...?

waxen sandal
#

I'd just save it in a SO in ProjectSettings

gloomy chasm
waxen sandal
#

Yeah

gloomy chasm
waxen sandal
#

It should be

#

If they don't then they're stupid

gloomy chasm
# waxen sandal It should be

I guess I will do that then. On the plus side I won't have to make a note about not using the userData. It just hurts a bit because using the userData of the importer is so clean, and so close (yet so far) from working.

waxen sandal
#

Eh, userdata is annoying

#

There's no standard so if someone else uses it they might relpace your data

gloomy chasm
waxen sandal
#

Project settings

#

Don't want people messing with it

gloomy chasm
#

The worst they could do is delete it I guess. I could hide it too I think if I really wanted to.

gloomy chasm
#

I got 2 questions.

1. I have been struggling with naming.
A. I can't call them prefabs, so I have been calling them Archetypes, is that good?
B. What do I call the SO that another SO derives from? "Original", "Source", "Root", "Parent", "Archetype"? I know this is dumb, but I keep waffling between them and want another opinion.

2. Should you be able to change in the inspector what SO an SO inherits/derives from? Or should it be like prefabs and be locked it?

Opinions please

waxen sandal
#

You should probable be able to change it if it's the same type

#

But it's not that big of a deal probably

gloomy chasm
#

Is there any callback for when an inspector opens?
Edit: I found Editor.finishedDefaultHeaderGUI which does exactly what I was wanting.

#

Or better yet, a way to have a custom editor for a ScriptableObject Importer.

dark plume
#

is there a extension that makes code look good

#

and how would i implement it onto my editor

gloomy chasm
dark plume
#

in the editor

gloomy chasm
dark plume
#

1 sec

#

so heres how code will be looking

gloomy chasm
#

Do you mean you want it formatted like that?

dark plume
dark plume
#

u can see the difference

#

uneven spaces,massive unused space

#

i need to do this because yesterday i called a function in a function

gloomy chasm
dark plume
#

and i have also seen stuff like these

gloomy chasm
# dark plume yep

OH, this channel is for writing extensions to the editor (Like new editor windows and custom inspectors).
I think you would be better asking in #💻┃code-beginner though the forums may be best. Tbh I am not sure what happened, Visual Studio should handle the formatting for you. Is the formatting like that even when you create new scripts?

dark plume
#

after saving it looks all wonky

gloomy chasm
dark plume
#

ah lemme try that ty

crimson estuary
#

I understand that EditorWindow.focusedWindow will let me see what window is focused, but how do I compare them?

eg,if(EditorWindow.focusedWindow == [what goes here?])

#

note: please ping, I will probably be in bed in a few minutes

waxen sandal
#

That snippet is intended to compare it to a certain window, i.e. sceneview or your own window

crimson estuary
#

Hiya, actually I trying to use the mouse over one, which works the same.

I’m currently using EditorWindow.mouseOverWindow == SceneView.lastActiveSceneView

#

But I don’t know how else I could refer to a window

waxen sandal
#

What exactly are you trying to do?

outer kraken
#

@crimson estuary

If i understand you correct, you probably want to do something like

if(EditorWindow.focusedWindow == MyWindow.Instance){}

make a static field "Instance" in your window class and then set the Instance either in OnEnable or when you're creating the window

crimson estuary
waxen sandal
#

Why not use OnSceneGUI?

crimson estuary
#

I'm not sure if OnSceneGUI will be called at the correct times

waxen sandal
#

What are the correct times?

crimson estuary
#

any time the mouse is over the scene view, for now

waxen sandal
#

Any time gui receives input it'll redraw and get called

#

So at the very least mouse clicks + scrolls but likely move mouse as well for hovering

crimson estuary
#

The issue is I don’t think it will receive input

#

And it should work when the mouse is stationary

waxen sandal
#

Scrolling is input

crimson estuary
#

Scrolling will be overridden as something else afaik

#

Eg, I’ll be grabbing the scroll input to do a calculation with

#

Not to mention the editor doesn’t seem to recognize horizontal scrolls at all right now

crimson estuary
#

I must be stupid or something but I can't get OnSceneGUI to work

gloomy chasm
gloomy chasm
#
if (Event.current.type == EventType.ScrollWheel)
{
  float horizontalScrollDelta = Event.current.delta.x;
  // Do something with the horizontal scroll...
}
crimson estuary
#

I'm processing that

#

one moment

#

I'm currently still struggling just to print one line when I press a key

gloomy chasm
crimson estuary
#

It's currently in ondrawgizmos

#

probably the worst place to do it but that's where it is right now

gloomy chasm
#

Yeah.. idk if you can even get the events in OnDrawGizmos.

crimson estuary
#

Probably not, but it's the only one that updates once per frame as if it were an Update()

#

*That I can find, and that's probably the wrong way to do it

#
    void OnDrawGizmos()
    {
        if (Event.current.keyCode == KeyCode.B)
            print("Pressed B");
    }```

This works, ish, it starts filling the console but doesn't stop until I move the mouse out of the unity window
#

Oh, my bad. It keeps sending it until I move the mouse at all

gloomy chasm
#
[InitializeOnLoad] // This calls the static constructor everytime unity reloads.
public static class CustomSceneControl
{
    // This is a static constructor and is called only once.
    static CustomSceneControl()
    {
        // This adds the `OnDrawSceneGUI` method to this event. So everytime this event is raised, the methods that are added to it are run. This event is called everyimt the SceneView's OnGUI method is called.
        SceneView.duringSceneGui += OnDrawSceneGUI;
    }

    private static void OnDrawSceneGUI(SceneView sceneView)
    {
      if (Event.current.type == EventType.ScrollWheel)
      {
        float horizontalScrollDelta = Event.current.delta.x;
        Debug.Log("Scrolled");
        // Do something with the horizontal scroll...
      }
    }
}
crimson estuary
#

ok let me process this for a minute, thanks

gloomy chasm
#

Sure, and don't forget you can look at the docs on unity for more info about something 🙂

crimson estuary
#

Sometimes the docs expect me to know more than I do, or I can't actually figure out what the tool I actually need is called

#

I don't want this to turn into MyFirstProgrammingExperience™️ but can I know what the [...]duringSceneGui += OnDrawSceneGUI does?

#

I just wanna know so I can actually learn it proper and not have this kind of issue again

gloomy chasm
#

If you want a more in depth explanation, just search for "C# delegate" and some good info will come up 🙂

crimson estuary
#

so it's like, an alias for something else?

#

And the += you did added OnDrawSceneGUI to.. duringSceneGui?

gloomy chasm
crimson estuary
#

By using += you added it to a list of everything that DuringSceneGui will trigger, and if I added something else it will also trigger with it?

#

Ohh I see

#

Theoretically I can add more than one of these "lists" together?

gloomy chasm
#

Yeah (assuming I understand what you mean)

crimson estuary
#

Well I don't think there's a use for it but lets say there's another delegate similar to duringSceneGui, and I have a few things on that. Can I do duringSceneGui += theOtherDelegate?

gloomy chasm
crimson estuary
#

Well, it doesn't matter that's a dumb question, but thanks!

#

One more, is, why does it not have () on the end of OnDrawSceneGUI?

#

Is it supposed to just be the method name without arguments?

gloomy chasm
#

Because you use () you are telling it to invoke the method and it would return whatever it's return value is. Instead we are passing the reference to the method itself.

crimson estuary
#

So it is indeed just the method name, and there's no way I could possibly screw it up(...?)

#

Cool!

#

Thanks a bunch!

crimson estuary
#
    private static void OnDrawSceneGUI(SceneView sceneView)
    {
        if (Event.current.type == EventType.KeyDown &&
            Event.current.keyCode == KeyCode.B)
        {
            rot.y += yRotBy;
            if (rot.y >= 360) rot.y -=360;

            sceneView.rotation = Quaternion.Euler(rot);

            Debug.Log("Work!");

            SceneView.RepaintAll();

        }
    }

So far this is what I have going, and it does work, but it's very choppy. It seems to only be once per keyboard repeat in this case. Is there any way to get it to move constantly?

#

Also, it only works if I have the Scene tab active, where I would like it to work whenever I'm hovering on the Scene window

hollow spruce
#

Im not sure if I should ask here or general code, but since the code are in editor window, i assume i can ask here.
It is a tool to package prefab in asset bundle 1 by 1.

Basically the code is simple:

  1. Check the selection (can be in project or hierarchy). If hierarchy, get original prefab
  2. Go through all the list of objects in the selection (atm, i will manually select only prefab)
  3. Then process it to send to asset bundle (it just a list of object) to pack individually.

Question here, I already have some solution to check if object is a prefab in scene or project.
Problem is, somehow even I selected couple of fbx or other file type, it got sent to asset bundles.
So i know the check for prefab was incorrect.

I used : PrefabUtility.IsPartOfPrefabAsset(), PrefabUtility.GetPrefabAssetType()
But seem it failed sometimes (especially when you select multiple objects)
The prefab is simple prefab, no variant but contains some 3d model packed individually

Anyone have tips / idea? (i will delete this if this was in wrong section)
This is editor script not for runtime.

waxen sandal
#

I'm guessing that the gameobject that unity generates for meshes (to drag it into the scene etc) is a prefab and thus detected by those APIs

#

Not sure how to differentiate between them though

#

Maybe try AssetDatabase.GetMainAssetType ?

hollow spruce
#

oh silly me, 3d model is a prefab, but it prefab asset type model
i done a wrong check earlier (i was using != not a prefab).
so as long as i check if it regular or variant prefab, it should be ok

tough cairn
#

In the upcoming unity (alpha) looks like we are getting floating tooling window inside scene view - but why break the design defaults and prevent from putting this back where my muscle memory remembers it should go ? this is bad UX :< plz don't break conventions

waxen sandal
#

I thought it was in both places 🤔

#

It's in general better ui/ux though

tough cairn
#

breaking standards isn't very friendly

#

so much empty space !

#

ngl pretty cool snapping , but i'd prefer to have it below the title bar

#

<@&502880774467354641> this is cool , but and we also add an option to use the old way ?

hollow spruce
#

my gosh, this remind the trauma of GIMP or blender for first time

waxen sandal
#

This is not the place to provide feedback

#

Use the forums

tough cairn
#

tru

stark geyser
#

@tough cairn Don't ping admins with non-server related issues.

visual stag
#

There's a lot of problems with the bars, but I think in the long run it'll be much better for in-scene tooling

#

Do you even lift ...I mean, grid snap?

west fog
#

Single bar setups look pretty good. Had a pretty negative reaction to the multi bar setup where it seems to be taking a lot more space than before.

tough cairn
#

my point is that the current tooling bar stays ( play button and cloud stuff no the right ) and it's looks empty :\

gloomy chasm
#

They said the considering several different things to do with the space. Like letting you put 'favorites' there, or maybe if they do a blender style 'workspaces'. Also said they were considering maybe even just getting rid of it all together. (These are just ideas they said they were considering)

crude fiber
#

I have ExecuteAlways script. this script calls functions which I need .When I change variable values from original script it executes anytime but when I use custom inspector for changing values functions arent execute always.what is problem here ?

gloomy chasm
gloomy chasm
crude fiber
gloomy chasm
#

That is why it is not updating like you want.

crude fiber
#

I search about SerializedProperties but its shows very complex things and I guess I dont need complex thing such a basic thing

#

am I wrong ?

onyx harness
#

You think you don't need

crude fiber
#

am I need 😄

waxen sandal
#

If you just want a slider why not use the slider attribute?

crude fiber
waxen sandal
#

Well, you're best off using SerializedProperties

#

They're not that complicated

crude fiber
waxen sandal
#

You don't want to recreate the serializedObject very frame and you need to apply it if it's changed

gloomy chasm
waxen sandal
#

Oh yeah that too

gloomy chasm
#

You also want to get the value from the serializedProperty, not just set it. Right now you are getting the value from minMap and setting it with the SerializedProperty. You don't want to do that.

#

And lastly, at the end you want to make sure at the end to call seralizedObject.ApplyModifiedProperties() otherwise the changes will not be saved.

crude fiber
#

its works and I figured out everything I guees thanks guys @gloomy chasm @waxen sandal

gloomy chasm
onyx harness
#

Replace Rotation with the serialized value

#

Cleaner

gloomy chasm
#

It can also cause bugs if you keep it how it is.

crude fiber
onyx harness
gloomy chasm
# onyx harness Like what?

In this particular case, not much I guess since the change is being applied each frame. But things could get out of sync and cause unexpected behavior in other situations.

#

Just being on the safe side, you know.

onyx harness
#

I see

narrow crystal
#

Hya. Im trying to instantiate a prefab, while working on a Prefab in the editor. Using PrefabUtility.InstantiatePrefab it keeps spawning in the Active Scene, not in the prefab. How would I spawn it where I need it to?

opaque zenith
#

Hi guys! Just looking for some approval if this looks good?

#

sorry, accidentally covered that line up in screenshot. It's suppose to be if (!AssetDatabase.IsValidFolder(folderCheck)) AssetDatabase.CreateFolder(parentFolder, folderNames[i]);

onyx harness
#

If it is supposed to be a check, where is the check?

opaque zenith
# onyx harness If it is supposed to be a check, where is the check?

yeah, and it's a class I just call whenever I want to check if the targeted location has the folders for the things being done. Basically I have a default location for the things I'm doing, but, want to allow the user toe be able to change that location. So if they do, it will create those again. I know it seems pointless to probably have something like this. Just trying to break down everything as simple as possible and make it easy to use in other projects

onyx harness
#

Dunno why, but sounds much straightforward to use Directory.CreateDirectory()

opaque zenith
onyx harness
#

It just takes a path and create folders if they do not exist

#

Anyway, i would suggest you to have some kind of Utility classes where you put your reusable chunks of code like the above

opaque zenith
onyx harness
#

Yes

#

it's purely C# .NET

opaque zenith
# onyx harness Yes

oh sweet! I love Unity, but, also love to use what I can away from it just in case ever in an environment not Unity

opaque zenith
opaque zenith
#

oh is it basically making it a static class?

onyx harness
onyx harness
opaque zenith
# onyx harness What do you mean?

I guess I mean do I make the constructer(?) static? So in FolderCheck class do something like, public static void GetFolders(string path) and then I can access that by just doing FolderCheck.GetFolders(string)?

onyx harness
#

Yes

#

You turn the constructor into a normal static method

opaque zenith
#

okay

#

ty for the advice!

crude fiber
#

what is "allowSceneObjects"

opaque zenith
crude fiber
#

thanks 🙂

gloomy chasm
native snow
#

Hey guys.

So I want to write this editor script, which changes the Input type from the old InputManager to the new InputSystem. Also, I want to include certain packages from the package manager, but I don't want to do any hardcoding for the package version numbers depending on unity's version.
Any ideas?

opaque zenith
#

Is it possible to make PopupWindowContent from https://docs.unity3d.com/ScriptReference/PopupWindow.html into a method?

doing

public PopupWindowContent TestWindow()
{
  return TestWindow()
}

crashes me Unity and I know that is wrong, but, I'm not googling the proper phrasing to find what I'm looking for

onyx harness
#

You are calling yourself

opaque zenith
onyx harness
#

Perhaps

opaque zenith
#

okay, I'll keep messing with this, thanks for the advice again

opaque zenith
#

okay I decided to just go the normal route and make a new class with popupwindowcontent since I couldn't figure out this way

#

just put it into same file so I still get the same organization I was trying for

gloomy chasm
#

Why are you using SerializedObject?

#

But yes it is, sort of. You get the material it self from a SerializedProperty using objectReferenceValue, and then just get the texture property from that.

hearty basin
#

Hi

Is there a simple way to draw a Shader Dropdown selector in a custom interface like in the Material Editor? The MaterialEditor code for drawing this dropdown is terrifying...
Thanks !

crude fiber
#

I cant assign "SerializedProperty" objects from custom inspector how can I solve this

gloomy chasm
gloomy chasm
hearty basin
#

It use an Advance Dropdown, but the code seems realy complicated for something like this

#

(sorry for my english)

gloomy chasm
#

For the most part this exactly what you would have do too. A lot of it is just boilerplate.

#

(Btw your English is perfectly fine, wouldn't know it wasn't your primary language)

hearty basin
#

Thank you very much, I look at it 🙂
The AdvancedDropDownGUI class that MaterialDropdownGUI inherit from is an internal class. Hope I can make it work without it !

crude fiber
gloomy chasm
#

Maybe it is legacy code that was never updated properly or something?

#

You should be able to get the exact same results without it just fine.

hearty basin
gloomy chasm
#

Sorry, it is a bit hard to follow along. But no, you can get textures whenever.
If you want to share the code I could try giving you some better advice.

gloomy chasm
gloomy chasm
#

Alright lets see. So unless some of the fields do not have public properties, I see no reason to use SerializedObject and SerializedProperties. It just makes things harder in this case.

#

That is because Materials are not like other Unity Objects. You need to use it's built-in methods to get and set shader properties like myMaterial.GetFloat(...);

#

Well there is no Material component.

#

So I would imagine that it would throw an exception.

#

What you are looking for is MeshRenderer

#

No, look at the code specifically in the commend that is linked there

stray hemlock
#

in the roadmap

stark geyser
#

@stray hemlock Please don't spam on the server. If you want to discuss something use #💻┃unity-talk

stray night
#

So, I have a frustrating problem trying to make some dialogue data. I want to attach unique behavior to certain lines of dialogue without bloating up a single class. The problem-space in it's most basic form is that:
• I've got a list of some data.
• There is no guarantee that every instance of data is the same format.
• I wanna be able to edit all of it outside of runtime.
• Using ScriptableObjects inside this list would be far too time-consuming and messy, unless they can exist exclusively within it.
Ideally, I'd have a ScriptableObject with a List of line instances which all implement an interface that the dialogue box can call, but Unity doesn't like to serialize polymorphic data.

Anyone solved this problem before?

stray night
#

Tried that. Got nothing.
...I mean, like, actually nothing. Nothing showed up.

visual stag
#

once you assign serializable values they show up

#

the default null case will show nothing

stray night
#

Okay, but how would I assign specific implementors, and where?

visual stag
#

Via a custom editor

#

or via my magic property decorator/drawer thing

stray night
#

Good point. I'ma try an enum and a button. Enum for specifying which type, button to add it. I assume it's a reorderable list where I can just remove things.

stray night
visual stag
#

what are you adding? A plain serializable class?

stray night
#

The List is of interfaces. What I'm actually feeding the List is a serializable class, yes.

#

I could just convert the interface into an abstract class, if need be.

visual stag
#

Can you link to some code?

stray night
#

...Oh wait a minute, I have it backwards. Must have converted it to a class and never set it back to an interface, one sec...

#

Aha!
That did it!

stray night
minor knoll
#

Hi, I'm having an issue with an editor script. I have a script that cleans up my scene and then exits the editor. When I call the cleanup part of the scripts without the editorapplication.exit it works fine. When I add editorapplication.exit at the end of the cleanup part, It just exits Unity without doing all the things I asked it to do. Anyone that has experience with this issue?

#

Here you can see the code

#

If I comment the editorapplication.exit it works

#

but with it, it just exits without doing anything

#

I also added a save function before the exit statement so it saves my scene but it didn't solve it

waxen sandal
#

It's likely not saving the scene to disk

#

Not 100% sure what you need to do to make a scene save but you can try doing SetDirty, then SaveAssets

daring glade
#

in editor, is there any way to interact with system clipboard to get something other than only plain text?

#

I want to add functionality to paste images from system clipboard, but no method I tried works so far

#

Unity natively doesn't seem to have such functionality, and both Winforms and WPF dll's refuse to work within editor

visual stag
#

It'll still just have plain text in it ^

waxen sandal
#

You'll have to parse it yourself 😛

visual stag
#

It won't have image data at all

#

even as text

waxen sandal
#

Oh yeah I didn't read the middle sentence

visual stag
#

I made my own exe that I called into when I wanted to get RTF from the clipboard. Sadly clipboard stuff just seems to be a pita

daring glade
#

yeah, it's for text only - if there is image in clipboard or anything else than just text, it will be empty

daring glade
#

ok, managed to figure out promising solution using extern calls to user32.dll API

minor knoll
#

@waxen sandal I tried using saveScenes but that didn't fix it, I also checked if the scene was not dirty and only then it should exit editor but it still exists without saving

#

I'm not sure if it's a bug or that I'm missing something but i'm doing it exactly like their documentation but it doesn't seem to work

elfin maple
#

hello does anyone know how i can bake impostor for multiple objects?

#

multi object editing not supported

waxen sandal
#

Idk ask the amplify people

elfin maple
#

ok thanks

#

thought i can ask here 🧐

waxen sandal
#

This is for developing your own editor plugins not help with existing plugins

elfin maple
#

yeah but i thought someone can tell me if its possible to write a for each that calls this button on each asset in the scene

waxen sandal
#

Sure, you can just write a static method and annotate it with MenuItem that'll find all of those components and calls a method on them

elfin maple
#

that's what i was looking for thanks boss

minor knoll
#

I'm trying to clear my folder through an editor script, using assetdatabase.deleteAssets

#

But I have to give a list of outFailedPaths, any idea on how to do this?

gloomy chasm
minor knoll
#

I don't really understand what they mean by it

#

oh okay

#

So I just have to make a random list and they'll fill it?

gloomy chasm
#

Yeah, just give it an empty list and it will populate it.

minor knoll
#

Okay thanks, their documentation is a bit confusing on this part :p

distant shell
#

I was wondering how I could generate an image of 3d models when I import them in the editor, so I can use them in my UI. I am aware of render textures, but this seems like it could be a better solution, depending on complexity. Any ideas on how to generate the image in the editor would be appreciated, thanks.

vestal sand
#

can I ask here help regarding the use of LeanTween?

fickle copper
#

Greetings, i am working on a room builder editor tool for a project of mine. I am trying to make a Method that detects if a Vector3 exists inside a region. My current problem is that the current region that i am checking for is not local to a rotation. As such, the detection region on some rotations is incorrect as seen below (Magenta boxes are the detection areas):

#

here is the code: ```csharp
public static bool IsPositionWithinRegion(this Vector3 pos, Vector3 regionCenter,
Vector3 regionSize, Quaternion regionRotation = new Quaternion(), bool showDebug = false)
{
// regionSize = regionRotation * regionSize;

        //Testing matrix stuff
        Matrix4x4 regionMatrix = Matrix4x4.TRS(regionCenter, Quaternion.identity, regionSize);
        Matrix4x4 currentMatrix = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one);

        if (showDebug)
        {
            Handles.matrix = regionMatrix;
            Handles.color = Color.magenta;
            Handles.CubeHandleCap(GUIUtility.GetControlID(FocusType.Passive), Vector3.zero, Quaternion.identity, 1,
                EventType.Repaint);
        }


        bool isWithinXLimit = pos.x > regionCenter.x - regionSize.x && pos.x < regionCenter.x + regionSize.x;
        // pos.x > regionCenter.x - regionSize.x && pos.x < regionCenter.x + regionSize.x;
        bool isWithinYLimit =
            pos.y > regionCenter.y - regionSize.y && pos.y < regionCenter.y + regionSize.y;
        bool isWithinZLimit =
            pos.z > regionCenter.z - regionSize.z && pos.z < regionCenter.z + regionSize.z;


        return isWithinXLimit && isWithinYLimit && isWithinZLimit;
    }
I have tested a bunch of things with no success. My guess is that matrices are the way to go in creating regions that account for both rotation and position but i am not sure how to use matrices in a condition similar to the example above. I am very new to matrix math so, any help would be appreciated.
serene spear
#

I feel like this should be the easiest thing to do but I don't know what I'm doing wrong, I can't get a gameobject from this to put in my editor

waxen sandal
#

It returns the new one

#

So you got to reassign it

serene spear
#

wdym

waxen sandal
#

ObjectField return the item selected or the item you passed depending on what the user does

#

So you got to assign the return value to the objectreferencevalue

serene spear
#

so I would add "animationSetterGOProperty.objectReferenceValue = " before the ObjectField?

#

That doesn't work

waxen sandal
#

Gotta provide more context then

serene spear
#

I want to make this a gameobject that persists when I restart Unity because for some reason it sets itself to nothing after restarting

#

I need some help I don't know what I'm doing it seems

#

this is what I would assume would work, but it doesn't let me assign anything in the inspector

waxen sandal
#

What's animationSetterGo?

#

Yoiu gotta apply the SO

serene spear
#

it's just a gameobject that lets me put actors in a position that teleports actors to a position before they play an animation

waxen sandal
#

I mean the definition of the property

serene spear
#

I don't understand

#

if you mean ApplyModifiedProperties, this is in a function called Draw, and everything is applied afterwards

#

how do I apply the SO in this case

#

I only really know how to do it for properties

waxen sandal
#

Ah yeah that looks fine

serene spear
#

but

#

it doesn't work

#

it only shows up as None, and any time I assign anything to it, it still shows up as None, you said to apply the SO, but I don't know how for object fields, could you please help, been googling it for a while now, can't find anything for gameobject fields

#

@waxen sandal

serene spear
#

if I leave it like this, it doesn't give me an error in visual studio, but it gives me this error in unity which doesn't mean anything to me

#

like this*

#

can anyone help

#

leaving it as just the direct object field works...until you restart unity, i just want it to save the field instead of me having to re-assign everything again

serene spear
#

the line in red works, but the line in blue sets it back to null, I don't understand

serene spear
#

can I just not serialize objectfield

grim vector
#

hello does anyone know where is the tool thing because i am following a video and i cant find it

serene spear
#

you're supposed to create something called "Tool"

#

a MenuItem*

grim vector
#

i want aot pre build like this

serene spear
#

I've never used bolt

grim vector
#

it is for uploading my game

serene spear
#

tbh I've never used Unity for more than standalone builds, so I'm completely clueless

#

I'm just stuck on figuring out on how to make a gameobject field persistent and not disappear after restarting unity

grim vector
#

ok thanks for trying

gloomy chasm
serene spear
#

I changed my code a bit so I have to revert back

#

if you recall, I set my npc dialogue system so that all of it would update after this Draw function

#

doing just this causes an error, what can I do to fix it, I just wanna make a gameobject field that doesn't delete itself after I restart unity

#

I don't know why this is so complicated

gloomy chasm
waxen sandal
#

Idk what the behaviour is if you have 2 SOs that you apply in sequence but only change one of them

serene spear
#

sorry for my late response but it's this line, the gameobject in question is null at first

serene spear
#

@gloomy chasm

gloomy chasm
serene spear
#

yes

#

I want it to be null at first so that I can assign it in the inspector @gloomy chasm

gloomy chasm
serene spear
#

I'm not sure what to do then

gloomy chasm
#

@serene spear Can you share your code through here https://paste.mod.gg/ so I can try to understand what you are trying to do.

serene spear
serene spear
#

I tried that about 10 times earlier, unfortunately, it doesn't let me assign anything to the object field, and your code is basically the same as what I tried then @gloomy chasm

onyx harness
#

If i understand correctly, you just want the field animationSetterGO to be persisted?

serene spear
#

yes

onyx harness
#

Try to dirty it when it changes.

serene spear
#

I can't set it with objectreferencevalue

onyx harness
#

Before quitting Unity it should pop a warning to save the project

#

Because a reference from a scene cant be saved in a project asset.

#

The scene is temporary

#

As soon as you reload it, the refe is gone already

serene spear
#

it saves my animator references though

onyx harness
#

Where does it come from?

serene spear
#

nvm, I got that wrong, that's from my project

gloomy chasm
#

OH, I feel dumb sometimes. Why didn't I notice you are trying to save a scene object to an asset. Unity doesn't let you do that.

serene spear
#

oh

#

😐

#

I'm trying to think of how I should solve this now

onyx harness
#

Many ways, none is really reliable

#

GlobalObjectId, path, custom Component, anything that can identify this GO from your SO

serene spear
#

I'm just thinking about where I should store the reference now

#

possibly somewhere outside of the SO

onyx harness
#

Replace the GO by a string or whatever suits you

#

oh

#

Well, if it is in the scene, it's pretty easy, it works already

serene spear
#

this is probably very close to what I'm going to do

gloomy chasm
#

Man, I have been digging through the source code trying to figure out if there is a way to hide an EditorWindow without closing it, but it just doesn't look like there is 😦

#

The problem is that it seems the only way to do it would be to Close the container window, but that Destroys the EditorWindow. And if I set the field referencing the EditorWindow to null, then I get a null exception.

gloomy chasm
#

I take it back. I got it working 👌

grim vector
#

hello i have trouble building my game

#
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <03b7a01d7ff445ec8ed231b348714f65>:0 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <03b7a01d7ff445ec8ed231b348714f65>:0 
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)```
#

this is the error also there is another one

waxen sandal
#

That's not the error that's failing your builf

#

Also not the right channel

loud vortex
#

Does someone know if it's possible to have a ReadOnly list of objects, but the properties of that object are read/write?

gloomy chasm
#

You would need to make a custom editor for it, but yes.

gloomy chasm
outer kraken
#

What if he'd try to do it in a plain C# class where custom editors are not an option?
Still possible? I'm curious as well
😀

gloomy chasm
#

If it is a plain C# class you can make a custom PropertyDrawer instead. But if you want to know if you can do it without any custom editor coding, the answer is no.

outer kraken
#

Thx!

outer kraken
# loud vortex Does someone know if it's possible to have a ReadOnly list of objects, but the p...

CopyPaste from MSDN

A readonly field can't be assigned after the constructor exits. This rule has different implications for value types and reference types:

Because value types directly contain their data, a field that is a readonly value type is immutable.
Because reference types contain a reference to their data, a field that is a readonly reference type must always refer to the same object. That object isn't immutable. The readonly modifier prevents the field from being replaced by a different instance of the reference type. However, the modifier doesn't prevent the instance data of the field from being modified through the read-only field.

#

Short form: if you have a readonly list where the items are reference types, you can change their properties

#

But ofc not the items themself

#

Idk if that's helpful or answers the question in anyway

gloomy chasm
loud vortex
outer kraken
#

Ok then Mechwarrior is 10000% correct, gotta need a custom editor or property drawer

loud vortex
#

yup, i'm trying to figure it out right now^^

onyx harness
#

As a trick, putting min/maxSize to 1,1

#

Not a real hide

gloomy chasm
# onyx harness With.... A try/catch?

For give my ignorance, but how would you use a try/catch in this case?
I got it working using the RemoveTab method in DockArea. This works great however it has the problem of unity throwing a warning when changing layouts if I store a reference to the editor window.

gloomy chasm
sage crater
#

Can we assign something in inspector variable through editor code? 🤔

onyx harness
gloomy chasm
sage crater
loud vortex
#

@gloomy chasm i tried to hack my way through this, but i'm kinda stuck:

public class AbilitySystemConfig
{
    [FixedList]
    public List<DataComponent> components;
}

public class DataComponent
{
    public float value;
}

[AttributeUsage(AttributeTargets.Field)]
public class FixedList : PropertyAttribute { }

[CustomPropertyDrawer(typeof(FixedList))]
public class FixedListDrawer : PropertyDrawer
{
    private ReorderableList reorderableList;
    private SerializedProperty myProperty;

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        myProperty = property;

        List<DataComponent> comps = new List<DataComponent>();
        comps.Add(new DataComponent());

       
        reorderableList = new ReorderableList(comps, typeof(DataComponent), false, false, false, false);
        reorderableList.drawElementCallback += DrawElement;
        reorderableList.DoLayoutList();
    }

    private void DrawElement(Rect rect, int index, bool active, bool focused)
    {
        EditorGUI.PropertyField(rect, myProperty.GetArrayElementAtIndex(index));
    }
}

I dont even know how to get the real list from the property. I tried it like property.isArray, which returns false. If i do property.propertyType i get generic... no clue what to do

gloomy chasm
#

Not the list itself.

loud vortex
#

so can you give me a hint what to do next? i'm totally clueless

gloomy chasm
loud vortex
#

is a propertydrawer not a custom inspector?

gloomy chasm
loud vortex
#

uhm okay, i just got more questions than before. Nvm dont think i can make it work

serene spear
#

Is there a way I can rename these reference file paths in an editor script? It adds "1" since there's multiple characters in the scene in Blender (I assume), I would like to rename these so it isn't marked as missing

serene spear
#

I did a bit of research, turns out it's called an "EditorCurveBinding", can I change this path through a script/editor script?

serene spear
#

Could anyone follow up

serene spear
#

I found this tool called "Animation Hierarchy Editor" but it doesn't work, it has a lot of stuff I don't understand, really, all I just want to do is rename this stuff through an editor script

serene spear
#

I feel like I'm so close on this, I can get the editorcurvebinding and their property names, but I don't know how to change their path values, when I try, it doesn't change in the Animation window

gloomy chasm
visual stag
#

@serene spear

serene spear
#

I don't know what SetCurveBindings is, I've been looking a bit in AnimationUtility is, not sure how to piece it all together though

visual stag
#

you need to use GetEditorCurve and SetEditorCurve

serene spear
#

SetCurveBindings doesn't exist?

#

So GetEditorCurve and SetEditorCurve, I'll look into them

gloomy chasm
serene spear
#

oh

#

my bad

crude fiber
#

Why "LayerMask" field too hard to add my custom ibspector I tried some methods but they dont work properly do you guys know any method about this

gloomy chasm
#

If so then you can just do a PropertyField I think.

crude fiber
gloomy chasm
#

Do you need the actual value for other places in the editor?

crude fiber
#

I will try thanks

gloomy chasm
# crude fiber I tought this just for enums

What? EditorGUILayout.PropertyField(...) just draws the default field for the property. A text field for a string type property, a float field for a float type property, an enum field for an enum type property etc.

crude fiber
#

thanks for explanation

gloomy chasm
#

It uses the PropertyDrawer for the provided property if it has one.

crude fiber
#

I was using "EditorGUILayout.MaskField" but its very very hard to use

#

its takes tons of parametra

gloomy chasm
crude fiber
#

yea ı found thia one

#

but this is temporary and has some problems

crude fiber
gloomy chasm
#

Well you have to apply the changes and stuff or it won't save.

crude fiber
#

I was trying to find but U already told me methods so thanks

gloomy chasm
#

I advice only using SerializedProperty since it handles undo/redo, and supports prefab variants and stuff.

serene spear
#

Is there a way I can make this scrollable, it doesn't show everything on the window at once, also, having all of these labels to show the editor curve bindings is really making Unity lag

gloomy chasm
#

If lagging is the problem I would use UIToolkit instead of IMGUI, and use it's ListView. Or implement your own virtualized list view in IMGUI (not as scary as it sounds, though still not simple either).

visual stag
#

there is a scroll view scope you can use for IMGUI

#

it will lag 😛

#

the UIToolkit version will probably be less laggy, the non-laggy IMGUI version takes a lot of code to use

gloomy chasm
visual stag
#

likely

serene spear
#

I see ScrollView, just wishing I could make it way less laggier, it was lagging a lot in the Animation Window and was tedious to open expand arrays to rename more stuff

#

when you export from blender to unity and bones have same names, for example, "Root", it renames one to just "Root 1" and then it marks it as missing...

#

so then you have to manually rename stuff

visual stag
#

I would really recommend what MechWarrior suggests, UIToolkit is very straight forward

#

other than the list they use, it's almost all what you want

tough cairn
#

is there a way to read / write to project user settings ?

waxen sandal
#

Which part?

tough cairn
#

anywhere i can store data really ( relative to the current projects )

#

without making scriptable* objects

waxen sandal
#

Not that I'm aware of

tough cairn
#

unity makes those files in user settings

#

somehow

#

ProjectSettings next to Assets

#

for example XRSettings.asset wasn't in unity5 afaik

#

and it pops up when u add the package

waxen sandal
#

Yeah you can make those but they're just SOs

wild dragon
#

Can someone who's knowledgable with 2D collisions and rigidbody2D help me out? I'm trying to program hitboxes but sometimes collisions are not going through.

tough cairn
#

but they are not store in the assets folder , right ?

waxen sandal
#

Yeah

wild dragon
#

I can explain more in DM.

tough cairn
#

sounds good to me

wild dragon
#

that has to do with physics?

#

well alright then.

tough cairn
#

yes

tough cairn
waxen sandal
#

There's SerializeFileAndForget in UnityEditorInternal somewhere

tough cairn
#

0 results on git

waxen sandal
#

yeah it's not the exact name

#

If you ask me again tomorrow then I can check the exact name

tough cairn
#

first time seeing this but looks like a step towards the right direction ?

waxen sandal
#

Oh yeah scriptablesingleton is a thing as well

tough cairn
#

does it means it will be automatically created ?

waxen sandal
#

I think so but I've never used it

tough cairn
#

i think i found what you where talking about a moment ago

waxen sandal
#

Yep

tough cairn
#

ill try this , thanks

gloomy chasm
#

So fun fact for the day AssetDatabase.GetTypeFromPathAndFileID just return UnityEngine.MonoBehaviour for ScriptableObject assets making it basically useless... yay...

waxen sandal
#

What about GetMainAssetType?

#

Oh right subassets

gloomy chasm
#

The thing is just straight up broken, it throws an error if the type is a C# file. 👌

#

Saying that it maybe corrupt or was serialized with a different version of unity.

#

Subassets are a joke.

tough cairn
#

well that worked better then expected

#

super simple

waxen sandal
#

Nice I should replace some of my code with that

tough cairn
#

now i just need to figure out how to listen to editor keyboard events without having the window opened

tough cairn
waxen sandal
#

👍

tough cairn
#

hmmmm this one is marked Obsolete without any replacement links , any ideas ?

#

ah nvm found it : EditorSceneManager.OpenScene

serene spear
#

When you create a new ListView, which argument controls how big the spacing between the items are?

#

Would it be itemHeight?

#

Nvm, it is, but now that's done, how would I be able to change the text contents?

gloomy chasm
#

Or manually in C# with element.style.fontSize = 20;

serene spear
#

where is that? I tried looking in listView, and just typing element

tough cairn
#

trying to load package via UPM but its complaining about SemVer ... ?

#

ah ... nvm Semantic Versioning needs 3 integers

gloomy chasm
serene spear
#

I've been trying to look up stuff related to ListView, there's only one video I can find, he doesn't explain anything though unfortunately, the rest of the results are stuff related to Unity's UI and vertical layout group

tough cairn
#

my package won't be included in the editor for some reason

#

its a single file , when i remove the package and place the file manually it does work , any ideas ? ( repo link above )

serene spear
#

I can't seem to find .style, I copy pasted what was on the documentation and changed a few values @gloomy chasm

gloomy chasm
#

@serene spear

private VisualElement MakeItem()
{
  var labelElement = new Label();
  labelElement.style.fontSize = 25;

  return labelElement
}
tough cairn
#

tried updating the version and adding the package as git url again , now its showing there errors ( shows as many errors as there are files in my repo )

tough cairn
#

ok... so after adding assembly def it seems to work , trying to figure out upm took me longer then it took me to write this editor window smh

serene spear
#

I put in the VisualElemnt function, but now I don't know how to put that into a Func

gloomy chasm
#

If you are still not sure, I would recommend looking up C# delegates to learn more. There is a lot of great info on them! 🙂

serene spear
#

it tells me that it cannot convert from a UnityEngine.UIElements.VisualElement to a System.Func<UnityEngine.UIElements.VisualElement>;

gloomy chasm
serene spear
#

yeah, delegates are still a bit foreign to me

gloomy chasm
#

I have no where to share this, and I want to because I think it is interesting.
Getting an asset path from a GUID is significantly faster than getting from an object directly.

Calling each method 10k times, on average GetAssetPath took 650 ms, while GUIDToAssetPath was around 75 ms.

gloomy chasm
#

Sick, just found out that AssetDatabase.FindAssets() can't find subassets. I'm really trying hard here to support Unity's own sub-assets system. But man does it feel like they really don't want you to mess with it at all...

#

I guess that make sense since only have one guid... Now I am going to dive in to the black abyss which is the Project Browser source code to see what they do... 😧

#

They handle it in external code of course... You know what this is too much, even QuickSearch doesn't support sub-assets.

serene spear
#

been trying to look up func stuff for a couple of hours now, I don't understand now, I understand a little bit of the other delegate types, but Func is confusing me, it keeps giving me that error that it can't convert VisualElement to System.Func<VisualElement>

#

I want to just return the func, but also be able to edit the text content

#

ok well I just messed around and tried stupid stuff, I don't know why this works

vocal bough
#

Are there any good debugging extensions for Unity to help find out what is going on in spaghetti code?

serene spear
#

How do I get a value in this listView so I can then change the text value of it?

civic river
#

the items are all stored in itemsSource

serene spear
#

I think, I finally have everything working, but it lags just as bad as the Animation window, although it still is clearer to see, anything I can do to optimise that?

#

Here's the code I'm using, it's very short

serene spear
#

it doesn't rename everything for some reason

gloomy chasm
#

Something to know about UIToolkit is that it is what is called a Retained Mode GUI. That basically means it does not update every frame like Immediate Mode
does GUI, GUILayout, etc. in unity are all Immediate Mode, meaning they update every frame, and so need to be put in the OnGUI method which is called every frame(ish).

#

Retained Mode(UIToolkit) only updates based on certain events. It is heavily event driven. So you only make the UI elements once in OnEnable.
UIToolkit controls have events you can register to.
In your case the most important one is RegisterOnValueChangedEvent. That is called every time the element's value changes.
So in your case you would want to register to that event when you bind an item, so you can do your checks and apply the new value to the source data.

serene spear
#

I just randomly searched around on the forums for looking on how to fix this, turns out people have already done what I'm failing to do

gloomy chasm
#

Oh yeah? What's that?

serene spear
#

joao-cabral has already made it

gloomy chasm
#

Well nice for you!

serene spear
#

there's like a lot of iterations of the same thing

#

I should at least study what they did

#

I got lucky here

tough cairn
#

is there a way to make the ObjectField filter only asset files ( prefabs ) ?

#

rn it will pop up with Scene Tab selected by default and the selection is still valid but not for my purposes

visual stag
tough cairn
#

ah right

#

is there a way to check if preview scene is dirty or not ?

#

EditorSceneManager.GetActiveScene().isDirty seem to work for scenes but not opened prefabs

tough stream
#

Hey there! I have an editor program for a conditional field (-> Show/Hide a field depending on other field's value), but doesn't works on arrays and lists. Any ideas of why?

tough cairn
#

so apparently this is not the same scene :

((Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage()?.scene ?? null) == EditorSceneManager.GetActiveScene()); // always false 
#

but the preview scene stage gets saved automatically regardless

#

now i just need to figure out how to save none preview stage ( current active scene ) 🤔 ... ( trying : EditorSceneManager.SaveScene )

mental belfry
#

Not sure if this is the channel for this. I want to change all the compression type for a particular build type for all the images in my project. When I try to search using the t: tag, I realised that it gives the sprite not the meta object with the properties, is there a way to do this in a faster way, then select each sprite and setting property? I am open to writing code for it.

plucky nymph
#

Need some advice...
I have a 'SequenceManager' which is a monobehaviour that just has a list of 'Sequence'. Sequence contains a List<IAction>, which is a polymorphic list. I am using a custom property drawer for Sequence to add an enum field that I am using to add a new value to the IAction list.

Code: https://pastebin.com/NQxwX8x1

The problem is, my property drawer is rendering all messed up inside the inspector array container, and the enum field I added is rendered after the array container, not as a sub element. Anyone got any resources on why this happens?

waxen sandal
#

Don't call base.OnGUI, reserve the height by overriding GetPropertyHeight and don't use GUILayout

waxen sandal
#

ScriptableSingleton is still a thing before then but the FilePath attribute doesn't exist and thus making it a lot less useful

#

Or rather it's internal

plucky nymph
#

Thanks for that Navi 🙂 Now just have to figure out why the relative property get is returning null...

plucky nymph
#

Is there a confirmed issue of property drawers not being able to use FindPropertyRelative?

onyx harness
#

I'm more encline to think you did something wrong

plucky nymph
#

I mean, yeh generally

#

I tried switching to UIElements and now its not even calling haha

#

This code is returning "No GUI Implemented", and no debug is called. Can you see an error?

public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var container = new VisualElement();

            var propField = new PropertyField(property.FindPropertyRelative("actions"));
            Debug.Log("propfield: " + (propField == null));
            container.Add(propField);
            return container;
        }
waxen sandal
#

Are you also overriding OnGUI?

plucky nymph
#

I am not. Do I need to if Im overriding CreatePropertyGUI?

waxen sandal
#

Nah

#

What version are you on?

plucky nymph
#

I commented out my old code, so only this function is in the property drawer.
2021.1.7f

waxen sandal
#

Does your class have a custom editor?

plucky nymph
#

Nope, just the property drawer

waxen sandal
#

🤔

plucky nymph
#

right?

#

gonna try chucking a debug just before the prop field get just in case its failing

gloomy chasm
plucky nymph
#

ah, that explains that then!

#

Just the prop field issue to go and I've got this haha

waxen sandal
#

But it should be called from UITK if it's 2021 and they don't have a custom editor

waxen sandal
#

Because Unity has been replacing all editors with UITK

gloomy chasm
#

Did they move default to UIToolkit?

waxen sandal
#

I'm not sure but I think I heard that it should work by default in either 2019 or 2020

gloomy chasm
plucky nymph
#

Final one, can anyone see any obvious errors in this? Im running at so much of a loss rn

[CustomPropertyDrawer(typeof(Sequence))]
    public class SequenceDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty prop = property.FindPropertyRelative("actions");

            EditorGUI.PropertyField(new Rect(position.x, position.y, position.width - 30, position.height), prop);

            var type = (Sequence.ActionType)EditorGUILayout.EnumPopup("Create Sequence: ", Sequence.ActionType.SelectType);
            if (type != Sequence.ActionType.SelectType)
            {                
                switch (type)
                {
                    case Sequence.ActionType.SelectType:
                        break;
                    case Sequence.ActionType.Debug:
                        SerializedProperty newAction = prop.GetArrayElementAtIndex(prop.arraySize++);
                        newAction.managedReferenceValue = new DebugAction();
                        break;
                    case Sequence.ActionType.MoveTransform:
                        break;
                }
            }

            EditorGUI.EndProperty();
        }
    }

    [Serializable]
    public class Sequence
    {
        public enum ActionType
        {
            SelectType,
            Debug,
            MoveTransform
        }
        public bool running;
        [SerializeField] private List<IAction> actions = new List<IAction>();
    }
waxen sandal
#

What's IAction?

gloomy chasm
#

It needs to have the [SerializeReference] attribute or unity will not serialize it

#

The IAction list I mean.

plucky nymph
#

So, make it public and add SerializeReference?

waxen sandal
#

Just SerializeReference should be enough

plucky nymph
#

IAction is an interface, its a polymorphic list

waxen sandal
#

There you go, use SerializeReference

plucky nymph
#

I had it working with default UI, i just wanted to add a bloody button haha

#

just to check the placement, this is what you meant?

        [SerializeReference] public List<IAction> actions = new List<IAction>();
gloomy chasm
#

It can still be private, but yes.

waxen sandal
#

You can make it private if you want

plucky nymph
#

eh, either way works for me

gloomy chasm
#

In your code, you are using EditorGUILayout for your enumpopup.

plucky nymph
#

It draws! It draws wrong but it draws!

#

That would be the draw wrong part i think haha

#

Tryna make that render inside the list

gloomy chasm
#

You shouldn't use the "...Layout" classes in property drawers

plucky nymph
#

ah right, gotcha

#

thank you both for the assistance btw, much appreciated

plucky nymph
#

Im not sure what term to google here...
Im trying to increase the size of the space alloted to the item in the list?
There are two weird things going on. First, the enum field is being drawn outside of the list area, second when I expand the actions property, no sub elements are being drawn. Do I need to do that? I thought the PropertyField would cover it.

Current view attached, minimised and maximised.

The actions list is making space for the sub elements, as its property height grows when I use the enum to add an action to it. Just cant see the action...

waxen sandal
#

Override GetPropertyHeight

plucky nymph
#

You sent this just as I found an answer saying the same haha

#

Thank you

#

Ah, worked!

#

Except for the invisible subcontent 😠 Its never easy is it

#

ah, include children !!

onyx harness
#

You see, not too hardcore 🙂

plucky nymph
#

I would ... LOVE to agree with you Mikilo haha.

But when I expand a child of one of the action lists, all the other sequence elements turn invisible haha.

#

So thats what im tackling now 😛

waxen sandal
#

Show code

plucky nymph
#

Righto, heres the editor code:

namespace DI_Sequences
{ 
    [CustomPropertyDrawer(typeof(Sequence))]
    public class SequenceDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty prop = property.FindPropertyRelative("actions");

            float propHeight = EditorGUI.GetPropertyHeight(prop);
            Rect propRect = new Rect(position.x, position.y, position.width, propHeight);
            Rect enumRect = new Rect(position.x, position.y + propHeight + EditorGUIUtility.standardVerticalSpacing, position.width, 50);

            EditorGUI.PropertyField(propRect, prop, true);

            var type = (Sequence.ActionType)EditorGUI.EnumPopup(enumRect, "Create Sequence: ", Sequence.ActionType.SelectType);
            if (type != Sequence.ActionType.SelectType)
            {                
                switch (type)
                {
                    case Sequence.ActionType.SelectType:
                        break;
                    case Sequence.ActionType.Debug:
                        SerializedProperty newAction = prop.GetArrayElementAtIndex(prop.arraySize++);
                        newAction.managedReferenceValue = new DebugAction();
                        break;
                    case Sequence.ActionType.MoveTransform:
                        break;
                }
            }

            EditorGUI.EndProperty();
        }

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            SerializedProperty prop = property.FindPropertyRelative("actions");

            return EditorGUI.GetPropertyHeight(prop) + EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.singleLineHeight * 2;
        }
    }
}
#

And heres the data structures

[Serializable]
    public class Sequence
    {
        public enum ActionType
        {
            SelectType,
            Debug,
            MoveTransform
        }
        public bool running;
        [SerializeReference] public List<IAction> actions = new List<IAction>();
    }

    public interface IAction
    {
        void Begin();
        void Complete();
    }

    [Serializable]
    public class DebugAction : IAction
    {
        [HideInInspector]
        public string name;
        public bool running;

        public string message;

        public DebugAction()
        {
            name = "Debug Action";
        }

        public void Begin()
        {
            throw new NotImplementedException();
        }

        public void Complete()
        {
            throw new NotImplementedException();
        }
    }
waxen sandal
#

Hmm, it looks okay

plucky nymph
#

Im wondering if I should be changing anything with prop.isExpanded, but i'll probably only end up using that to hide the enum popup inside

onyx harness
#

does it help?

plucky nymph
#

huh ill try it

#

Nope, no real change that I could see between using that or not

onyx harness
#

remember you use it in 2 spots

plucky nymph
#

Yep, changed in both.

I feel like the property height is correct now, as the highlighting for the portion seems accurate.
For example. on this shot, you can see where the element finished, one line space under the enum field

#

Okay, im making no headway. Gonna call it a night.
One more giant thanks for all the help tendered tonight

copper portal
#

Hello guys, I am trying to loop thru prefabs and call function from script that inherits from editor. Is there any way I can do this?

fading zealot
#

I need some help with Unity Editor Window, I am trying to create a ScriptableObject through a tool extension, This is the current code cs public void CreateItem(string Name, int Damage, int Durabillity, ItemRank rank) { Item item = ScriptableObject.CreateInstance(typeof(Item)) as Item; item.ItemRank = rank; item.Name = Name; item.name = Name; item.ItemDamage = Damage; item.ItemDurability = Durabillity; AssetDatabase.CreateAsset(item, "Assets/Preset/Items"); }

#
public class ItemEditor : EditorWindow
{
    string Name;
    int Damage;
    int Durabillity;
    ItemRank Rank;

    public static void ShowWindowStats()
    {
        var window = GetWindow<ItemEditor>();
        window.titleContent = new GUIContent("ItemManager");
        window.Show();
    }

    public void CreateItem(string Name, int Damage, int Durabillity, ItemRank rank)
    {
        Item item = ScriptableObject.CreateInstance(typeof(Item)) as Item;
        item.ItemRank = rank;
        item.Name = Name;
        item.name = Name;
        item.ItemDamage = Damage;
        item.ItemDurability = Durabillity;
        AssetDatabase.CreateAsset(item, "Assets/Preset/Items");
    }

    void OnGUI()
    {
        GUILayout.Label("Create your item here and quickly put it into the game!");
        GUILayout.Space(2);
        Name = GUILayout.TextField(Name);
        GUILayout.Label("Item Damage");
        Damage = EditorGUILayout.IntField(Damage);
        GUILayout.Label("Item Durabillity");
        Durabillity = EditorGUILayout.IntField(Durabillity);
        Rank = (ItemRank)EditorGUILayout.ObjectField("Rank", Rank, typeof(ItemRank), false);
        GUILayout.Space(4);
        if (GUILayout.Button("Create New Item"))
        {
            CreateItem(Name, Damage, Durabillity, Rank);
        }
    }
}```
#

Whole Code

waxen sandal
#

Cool?

#

What's the problem

fading zealot
#

Fixed it, the problem was AssetDatabase.CreateAsset(item, "Assets/Preset/Items"); wasn't set to a Format

#

So if became a Default asset

#

it was supposed to be .asset in the end ;-;

opaque zenith
#

is it possible to make an editor script that is a typeof all scripts?

#

nvm, finally found the right phrase to type in google

onyx harness
#

typeof(Object)

#

Good job

opaque zenith
#

I can't seem to get it to work how I want 😦

gloomy chasm
opaque zenith
#

@gloomy chasm slow response, but that works! What exactly is the true doing as an overload?

#

okay, apparently that true makes it always active, but pretty cool!

[CustomEditor(typeof(Object), true)]
[CanEditMultipleObjects]
public class DefaultCustomInspector : Editor
{
    string testText;

    public override void OnInspectorGUI()
    {
        testText = Selection.activeObject.name;
        EditorGUILayout.LabelField("~~~~~CUSTOM INSPECTOR~~~~~");
        testText = EditorGUILayout.TextField(testText);
        EditorGUILayout.LabelField("~~~~~CUSTOM INSPECTOR~~~~~");
        DrawDefaultInspector();
    }
}

for example giving me something like

#

I noticed though that this customeditor doesn't work on audio clips and animation clips. I thought the base type of everything was Object though?

visual stag
#

the more specific editor will always take precedence afaik

opaque zenith
#

okay, I'll try to look more into that. Is there an override for that? Not really important, but, now I'm curious

visual stag
#

only if you override them specifically

opaque zenith
#

okay, ty, looking into that now! See what I can find

#

found a need to cast audioclip as an object

shadow moss
#

Is anyone aware of any attributes for inspector values that would trim strings?

#

I wrote one, TrimTextAttribute, but it breaks TextAreaAttribute

#

I could write TrimTextArea and TrimMultiLine...

#

Can't... TrimTextAttribute is sealed.

Anyone know of a solution?

visual stag
#

you could make a TrimTextAreaAttribute that was also a TextArea

#

sadly Unity doesn't allow multiple property drawers

shadow moss
#

I can't inherit from TextAreaAttribute if that's what you're suggesting 😦

visual stag
#

You would have to reimplement it

copper crown
#

Hey, I've been experimenting with 3d renderers from scratch for the past few days like Raymarcher and raytracers

#

I'd like to move my Raymarching code to Unity but I want it to run directly in the editor

#

Meaning I can move around the SceneView's camera to see the objects

#

In order to do that I need my compute shader to override the image generated by the SceneView camera basically

#

I found a way on this forum that worked

#

It involves copying the renderer component from another Camera to the SceneView

#

But i'd rather directly add components to the SceneView camera. Anyone know a way to do that?

#

By scenecamera I mean this object

#

I can get it to work in edit mode by using [ExecuteInEditMode] too

#

but still, directly adding the components would be better

#

Because I can also edit the parameters of the script without having to refresh

muted sphinx
#

I am using AssetDatabase.CopyAsset and AssetDatabase.LoadAssetAtPath for generating animation controller using a template animation controller. Is it normal that the scene takes a while now until it starts (there is a loading icon now, when I start)? Can I reduce the loading time?

waxen sandal
#

Profile it

tough stream
#

Hey there! I have a custom attribute script (->that Shows/Hides a field depending on other field's value), but doesn't works on arrays and lists. Any ideas of why?
What scripts should i send to get some help?

waxen sandal
#

The attribute is applied to the elements and not the whole list

tough stream
#

here is the script itself, i wasn't the one who made it, that's the principal reason i need help lol, because im lost

tough stream
tough stream
#

oh

#

do i need to import all tools?

muted sphinx
#
                    AnimatorController controller = new AnimatorController();
                    controller.name = $"{_attachToPrefab.name}_movement";
                    AnimatorControllerLayer layer = new AnimatorControllerLayer();
                    layer.name = "Base Layer";
                    controller.AddLayer(layer);

                    // Create movement tree
                    BlendTree tree = new BlendTree();
                    tree.name = "Movement Tree";
                    tree.AddChild(_moveUp, new Vector2(0, 1));
                    tree.AddChild(_moveRight, new Vector2(.9f, 0));
                    tree.AddChild(_moveDown, new Vector2(0, -1));
                    tree.AddChild(_moveLeft, new Vector2(-.9f, 0));

                    controller.AddMotion(tree); // Exception

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Animations.AnimatorController.AddMotion (UnityEngine.Motion motion, System.Int32 layerIndex) (at <c77ced6644e541b7ad3d7315a5e92a0a>:0)
UnityEditor.Animations.AnimatorController.AddMotion (UnityEngine.Motion motion) (at <c77ced6644e541b7ad3d7315a5e92a0a>:0)
Why does AddMotion throws a NullReferenceException?

waxen sandal
#

Idk, see if there's anything useful in the reference source

#

Maybe something on your tree is uninitialized

muted sphinx
waxen sandal
#

No reference source

muted sphinx
#

I found the problem 😄

copper crown
#

Hey, I've been experimenting with 3d renderers from scratch for the past few days like Raymarcher and raytracers
I'd like to move my Raymarching code to Unity but I want it to run directly in the editor
Meaning I can move around the SceneView's camera to see the objects
In order to do that I need my compute shader to override the image generated by the SceneView camera basically
I found a way on this forum that worked
https://forum.unity.com/threads/image-effect-in-scene-editor-views.102515/

#

It involves copying the renderer component from another Camera to the SceneView
But i'd rather directly add components to the SceneView camera. Anyone know a way to do that?

#

By scenecamera I mean this object
I can get it to work in edit mode by using [ExecuteInEditMode] too
but still, directly adding the components would be better
Because I can also edit the parameters of the script without having to refresh

#

Reposted cause orgiinal got buried

waxen sandal
#

Not sure that's possible, you can try getting the scene view camera and just calling addcomponent

stray ridge
copper crown
#

Thats the method I did and it kinda sucks but its alright

stray ridge
#

so its installed

copper crown
#

Ya

#

so what do I do now

stray ridge
copper crown
#

Yeah omnisharp.json is missing

#

very oidd

#

So I should make a json file?

stray ridge
#

search in file> preference>setting then search omnisharp

copper crown
#

Im abck

#

back

#

lemme do that

#

@stray ridge

stray ridge
#

now go to down and find setting.json , and open it

copper crown
#

Alright

#

omnisharp.path: ""

stray ridge
#

now you have

#

now set the path

copper crown
#

Hmm

#

I set it to this folder

stray ridge
#

path is wrong

copper crown
stray ridge
#

show me the path that you set

#

to omnisharp.exe

copper crown
#

Ohh

#

C:\Users\Krampus' Secretary.vscode\extensions\ms-dotnettools.csharp-1.23.12.omnisharp\1.37.10\OmniSharp.exe?

stray ridge
#

yes

#

\\

copper crown
#

B R U H

#

Everything else worked

#

THANK YOU SO MUCH BUT

#

The csproj problem is still there for some reason

stray ridge
#

restart the vscode

copper crown
#

Alright

#

Same problem

#

it opened the sln

#

The projects thing still isnt there

stray ridge
#

click the fire icon

#

and stop it

#

and restart the vsc

copper crown
#

Ok

#

Clicking ti does nothing

#

Still wont work damn

stray ridge
#
   "omnisharp.useGlobalMono": "always",```
add this in settings.json
copper crown
#

Ok

#

What about monoPath?

stray ridge
#

not needed

copper crown
#

Ok

stray ridge
#

😢

copper crown
#

Ahhh god

stray ridge
#

okay i think we should leave it on vsc

copper crown
#

Yeah

#

I think ill just reinstall later

#

Thank you so so much for the help

#

and taking the time to give solutions

#

Hope I can fix tis oon

wispy delta
#

I'm trying to make a special scriptable object that I can use as a pointer to a specific Resources folder to help me load resources without hardcoded strings. So right now it literally just stores a string for the asset's current directory, but once I have that working I can reliably use it as a variable, shareable path for loading resources.

[CreateAssetMenu(menuName = "Resource Group")]
public class ResourceGroup : ScriptableObject
{
    [SerializeField]
    private string resourcesDirectory = null;
    public string ResourcesDirectory
    {
        get => resourcesDirectory;
        internal set => resourcesDirectory = value;
    }
}

The big challenge is making sure the asset always knows its directory within the Resources folder. To do this, I've created an editor-only class that derives from AssetsModifiedProcessor which sends me the paths of any assets that are created, changed or moved.

Should be straightforward implementation: when file is created or moved, overwrite its resourcesDirectory string with the correct value.

The problem I'm running into is that I need to load the scriptable object to be able to update it. This is normally fine, I just call AssetDatabase.LoadAssetAtPath, however when the scriptable object is moved and I try to load it from the destination path, it often returns as null. I tried loading the scriptable object at the destination and source path but if one fails, so does the other.

I guess sometimes the asset exists in some sort of limbo until I return from the OnAssetsModified callback and Unity finishes the move? It's weird. Sometimes it works, sometimes it doesn't - and I can't find any rhyme or reason.

Does it seem like I'm goin about this the right way, or is this idea sketchy? 😅
src if it helps: https://hastebin.com/noqihugoqo.csharp

#

Another thing that feels weird about this approach is that I get the callback for every asset. Can't seem to tell unity to only send events for my specific scriptable object. This means whenever any asset is created or moved, I have to load it to check if it's a ResourceGroup

gloomy chasm
#

@wispy delta So the ResourceDirectory, is that a path to a folder or a game asset?

#

And it isn't clear, is that path relative to the resources folder? Or is it a path to a specific resources folder itself?

wispy delta
#

@gloomy chasm
The path is relative to the Resources folder and is just to the directory that contains the ResourceGroup asset. So the idea is that the string should be usable directly with Resources.LoadAll and other similar methods

Resources.LoadAll<Sprite>(someResourceGroup.ResourcesDirectory);
#

I'll likely add my own load methods to the resource group so you can do:

someResourceGroup.LoadAll<Sprite>()
gloomy chasm
wispy delta
#

idk, on the off chance I use it in edit mode I guess. just trying to make sure the directory is always correct if possible 😄

gloomy chasm
#

Would AssetPostprocessor.OnPostProcessAllAssets not work?

wispy delta
gloomy chasm
#

Could brute force it and set the path everytime it is deserialized 😛
But AssetPostprocessor.OnPostProcessAllAssets should work...

wispy delta
# gloomy chasm I thought you said you used the `AssetsModifiedProcessor`? Or did you try both?

Hmm ok I wasn't aware of AssetPostprocessor, I was using AssetsModifiedProcessor.
They seem to be very similar classes with similar callbacks
AssetsModifiedProcessor.OnAssetsModified(string[] changedAssets, string[] addedAssets, string[] deletedAssets, AssetMoveInfo[] movedAssets)
vs
AssetPostprocessor.OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
I was a bit confused. However after switching to using AssetPostprocessor it seems to work?!

#

I guess OnPostprocessAllAssets is called after the movement so I can load the asset fine 🤷‍♂️

gloomy chasm
wispy delta
gloomy chasm
#

Does there happen to be a good way to get the index of an item in a UITK ListView from a mouse position...?

#

Right now I am looking at using reflection to get the recycle items pool, so I can check which element contains the mouse and then return the index stored in the recycle item...

crude fiber
#

I am getting this error . Why I cant assign from custom inspector its says you should assign this from original script inspector

gloomy chasm
crude fiber
gloomy chasm
#

Will need to see the code and more details about what you are trying to do and what is not working.

crude fiber
#

but I cant assign from editor script I must write base.OnIspectorGUI and assign from base inspector

gloomy chasm
crude fiber
#

yep

gloomy chasm
#

but I cant assign from editor script
What do you mean by this? What happens?

crude fiber
#

its says (MiniMapController base script btw)

#

omg

gloomy chasm
#

I assume you check that you assigned it right...?

crude fiber
#

I just figured out but I am embarrassed for that

#

in base script all variables are "GameObject" but in editor script they has different types

#

bcuz of that I guess

#

thanks 😄

gloomy chasm
#

Glad you got it worked out!

crude fiber
#

soo can I ask something

#

what is difference between "typeof(Object)" and "typeof(GameObject)"

gloomy chasm
gloomy chasm
#

How can I give focus to a custom IMGUI control that doesn't use any builtin controls?

crimson estuary
#

I've gotten quite far with my scrolling orbit plugin/script, but there's one issue. I can't figure out how to cancel out Unity's default handling of zoom. e.g, even though I have my vertical orbiting bound to vertical scrolling, it still zooms in and out.

Is there any way to just, block Unity from seeing that scrolling?

snow bone
#

I'm trying to store the sceneview camera position & rotation, ```cs
//Store
var cam = SceneView.lastActiveSceneView.camera;
Pos = cam.transform.position;
Rot = cam.transform.rotation;
Piv = SceneView.lastActiveSceneView.pivot;
//Restore
cam.transform.position = Pos;
cam.transform.rotation = Rot;
SceneView.lastActiveSceneView.pivot = Piv;
SceneView.lastActiveSceneView.Repaint();

#

nvm, i sorted it.

gloomy chasm
waxen sandal
#

IIRC there's a special method to set the sceneview camera pos

snow bone
#

This worked for me cs class PositionData { public Vector3 Position; public Quaternion Rotation; } void StoreCamera() { var scene = SceneView.lastActiveSceneView; Pos = new PositionData(scene.pivot, scene.rotation); } void RestoreCamera() { var scene = SceneView.lastActiveSceneView; scene.pivot = Pos.Position; scene.rotation = Pos.Rotation; scene.Repaint(); }

#

it seems that SceneView.lastActiveSceneView.camera .position & .rotation don't do anything to the scene view camera at all

gloomy chasm
#

I'm going to re-ask my question from earlier if thats okay.
I have a IMGUI GridView and I want to be able to give focus to the items in it, and also have them lose focus when another control or window is focused. Any ideas how to do this?

waxen sandal
#

hotcontrol?

gloomy chasm
#

I tried, but it doesn't seem to change when selecting other windows.

waxen sandal
#

How did you try?

#

Look at the code in those examples

gloomy chasm
#

@waxen sandal Thanks for the links, I am still reading them. But it seems like hotControl is not indented for this. I want to give focus to a control, while hotControl seems to be about capturing mouse input. Maybe I'm wrong?

waxen sandal
#

More like mouse focus as I understand

#

There's also keyboardControl which is the same as hotControl but with keyboard focus

#

Maybe I'm misunderstanding what you're trying to do

gloomy chasm
waxen sandal
#

That's controlled by selection and not really something in imgui

gloomy chasm
#

I think I got it to work, or at least know how to. I also took a look at the source code for the TreeView and they check to see if the window is focused. So I guess I will have to start passing a reference to the editor window around. Thank you for the help and the links! I have a better understand of it now!

#

EditorGUIUtility.HasCurrentWindowKeyFocus() why would they make such a useful thing internal...

gloomy chasm
#

So... it seems like you can't set Selection in OnEnable because it will not set if you are reloading scripts or entering play mode... Any good workarounds for this?

crimson estuary
#

How would I apply it in such a context?

#

would I apply it before I return the current delta?

#

like so?

#

Oh derp, that works flawlessly, sorry!

waxen sandal
#

One of these days I'm going to write a hack to turn on toggleOnLabelClick by default for foldouts ._.

warm gale
waxen sandal
#

I think they want an attribute that automatically creates a foldout around a group of properties

nimble perch
#

how do i build with ar core please help

cosmic lintel
#

I'm trying to create a custom editor with graph view and struggling to figure out how to hook into when a edge is disconnected from a port. IEdgeConnectorListener.OnDropOutsidePort doesn't get called for a EdgeConnector manipulator on the port (which, I suppose, make sense). The only way I can think to do it is to subclass Port, which has it's own set of complications. Is there another way that I'm missing?

open verge
#

i'm making a custom editor, and i have problem with scroll view

#

how come it doesn't set automatically ?

civic river
# cosmic lintel I'm trying to create a custom editor with graph view and struggling to figure ou...

Graph View (the class) has a callback when certain things on the graph change, edges are one of them:

        private GraphViewChange OnGraphViewChanged(GraphViewChange changes)
        {
            if (changes.movedElements != null)
            {
                ProcessElementMoves(ref changes.movedElements);
            }

            //Checks for changes related to our nodes.
            if (changes.elementsToRemove != null)
            {
                ProcessElementRemovals(ref changes.elementsToRemove);
            }
            
            if (changes.edgesToCreate == null)
                return changes;
            ProcessEdgesToCreate(ref changes.edgesToCreate);
//...etc
        }

You register the callback with
(GraphView).graphViewChanged = OnGraphViewChanged;

gloomy chasm
#

I'm working on an a tool for making collections of assets. I have been trying to figure out styling for the cells, and I tried generating custom thumbnails for assets 'without' a background.
Is this a bad idea? It doesn't exactly match with default styling, but I also think it looks pretty nice.

waxen sandal
#

Lgtm

gloomy chasm
waxen sandal
#

Looks a bit weird but fine tbh

gloomy chasm
#

I guess which is better looking? That or normal previews?

waxen sandal
#

The first ones

#

They look slightly funny in the white theme because they're close in color

gloomy chasm
#

Yeah, I can mess with the lighting in the previews to make them a bit darker.
Cool I think I will go with them them. I wish their was a way to render a preview with just no background, but best I can find is just setting the color to be the same as the windows background color.

#

Also need to figure out how to properly cache the images and delay the generation so it doesn't lag.

waxen sandal
#

Unity did some work with previews in one of the newer versions so they might've improved the api

gloomy chasm
#

Really? All I can find is the PreviewRenderUtility. Which works fine, just kind of cumbersome to work with. No way to automatic caching or anything.

snow bone
#

I'm using GUIContent to display some textures as buttons on my editorWindow, how can i set the background colour of the texture to transparent?

#

I'd like the white background to be transparent

gloomy chasm
snow bone
#

For reference, here's my code: ```cs
loadProject = Resources.Load<Texture2D>("Icons/Load");
loadButton = new GUIContent(loadProject, "Load Project");
buttonStyle = new GUIStyle(GUI.skin.button);

if (GUILayout.Button(loadButton , ButtonStyle, GUILayout.Width(40)))
{
DoSomething();
}```

#

I'm copying the button style from GUI.sking.button

gloomy chasm
snow bone
#

@gloomy chasmthat works great, thank you

snow bone
#

the issue I'm finding now, is that I want it to behave as a button, but it behaves as a label

#

This does nothing. I'm just using a coloured image for PressedButton.pngcs var bg = Resources.Load<Texture2D>("Icons/PressedButton"); menuButtonStyle = new GUIStyle(GUI.skin.label); menuButtonStyle.background = bg;

opaque zenith
#

in a lot of my editor scripts I include AssetDatabase.SaveAssets(); followed with AssetDatabase.Refresh() follow with a Repaint(). I feel like this is excessive and creating extra unnecessary load(Is that the right word?) in my Editor Windows. So I'm asking if anyone has a better explanation of using this 3? For example, if I use AssetDatabase.CreateAsset() do I need to include saveassets or can I just go straight to refresh?

young mango
#

I hit this problem, I can't click on any objects and the hierarchy and the inspector are gone.

#

How to fix this

opaque zenith
#

Try clicking to reset layout in the top right corner

young mango
#

thanks

opaque zenith
#

Is there a way to dock non utility editor windows to a utility editorwindow?

gloomy chasm
opaque zenith
#

I guess, better yet, have 1 main window that copies the dimensions and stuff of the utility window, but, I can dock things to

#

so that I'll still get the always on top

open verge
#

can we change the x value in which a editorGUILayout.BeginHorizontal() begins ?

cosmic lintel
#

I'm curious if there are any examples out there of using GraphViewEditorWindow and GraphViewEditorWindow.ShowGraphViewWindowWithTools - I seem to be missing something.