#↕️┃editor-extensions

1 messages · Page 81 of 1

onyx harness
#

You need CreateInstance, min/maxSize, ShowPopup

waxen sandal
#

Pretty sure I'm not doing min/max size in my code

#

Can't check till tomorrow though

onyx harness
#

Without it, it won't show borderless, am I wrong?

#

Let's wait then 🙂

waxen sandal
#

It definitely shows borderless 😛

whole steppe
#

Milkilo is it better to add fences to pathways but like small ones that make the game look more detailed

onyx harness
#

This question is about taste, am i wrong?

sage crater
#

hey guys, I was trying to make a custom header attribute and I needed a little help. here's my code. But it uses name of the variable under the attribute as header text. I want to make it get the text from string like in [Header(string)]

onyx harness
#

I dont even see the use of an attribute

sage crater
#

Well the code is wrong itself. I don't think I need to use a label field i suppose

#

My main objective is to make header attribute but with my skin

#

same working of header but using my own skin

onyx harness
#

Well, then you need to use your attribute

sage crater
#

yeah that's what I'm asking how to or any example code to understand

onyx harness
sage crater
#

Well I have seen it already and as you can see the code above and here's the attribute use

#

but rather than being a separate heading, it changes string field under it to heading

#

since I was using LabelField from editor gui. I don't see any other option directed towards separate heading

onyx harness
#

Are you sure you derived your drawer from DecoratorDrawer and not PropertyDrawer?

gloomy chasm
#

Is there a good way to do ellipsed text in UITK? I haven't been able to find anything.

sage crater
onyx harness
#

Change the GetPropertyHeight

#

Your style is bigger than the default

sage crater
#

and i suppose GetPropertyHeight needs serialized property parameter

onyx harness
#

GetHeight

sage crater
#

ooo works like charm. thanku!

quaint zephyr
#

Is there a way to update values in customeditor IF there were any changes made? Like just cache them in a private variable and only redraw data if there was a change? I have a variable that holds quite a bit of data and editor lags because it's updating it every editor frame.

#

I'm gonna have to put the update on a deferred timer, but if there is a way to "watch" for changes, that would be ideal.

waxen sandal
#

Changecheck

#

@onyx harness I was mistaken, I'm using ShowAsDropDown and not ShowPopup

patent pebble
#

I made a simple Scripted Importer to learn how they work.

#

How can I make the fields on the imported object editable?

#

I'm searching on the importers APIs, but can't seem to find anything to make the data editable...
Do I have to manually draw controls instead of using SerializedProperties in PropertyField?

nocturne geyser
#

Im trying to create a new gameobject as a child of the currently selected GameObject in the hierarchy. How would I code this?

patent pebble
#

Ah I just had to set the flags on the ExampleEditor's target

target.hideFlags = HideFlags.None;```
It seems that importers by default set the imported object's flags to ``NotEditable``
tawdry creek
#

How do I reliable distinguish between a mouse up for a single click and a mouse up after a drag?

#

it seems that the mouseUp event is the same on both occasions

patent pebble
#

@tawdry creek when I need to do that I manually set a flag when I mouseDown and clear the flag when mouseUp. I don't know if there's a better way of doing it

#

remember to take into account what button of the mouse is being pressed or released (in case you care about it)

#

there was also the class DragAndDrop and I think it had stuff for when you perform/exit a drag

#

can't remember exactly the use of that class tho, it's been a while

onyx harness
#

MouseDown comes with MouseUp.
MouseMove is when you simply move the cursor without buttons.
When you hold on something and move, it's a MouseDrag.
If you release it, it's a DragPerform.

#

(Or DragExited if you did not accept the drag)

patent pebble
#

@onyx harness I think DragPerform is not a "normal" even like the others though

#

I think you actually have to set up a drag operation or something like that

#

maybe I'm wrong

onyx harness
#

Yeah yeah you have to setup DragAndDrop

#

@tawdry creek Easy, you print Event.current.type to the console in your OnGUI, then do your tests

#

It's gonna be clearer

#

(and skip Layout & Repaint)

patent pebble
#

@onyx harness is the DragAndDrop only for dragging objects? Or like... can you get those events doing bare mouse drags like for example dragging GUI controls and handles and such?

onyx harness
#

They all use DragAndDrop I guess, i mean, if it drags a real entity (like an asset, an path or something, and the data is transferable)

#

Handles probably just move themselves

#

Nothing special to drag, it's not transferable

onyx harness
patent pebble
#

ohhh right right I'm looking at the docs and SetGenericData accets any object, I got it confused with UnityEngine.Object

#

they return an array of UnityEngine.Object in DragAndDrop.objectReferences which I guess is to make it easier to deal with actual Unity objects

#

and the examples in the docs are only doing drag and drop with assets

#

digging through code I see they use DragAndDrop a lot in the TreeView API

onyx harness
#

Pretty much everywhere

nocturne geyser
#

Any way to have an EditorGUILayout.TextField have a max length of a certain number of characters?

gloomy chasm
#

From one package, how do you reference assemblies from another package and keep them?

gloomy chasm
nocturne geyser
#

How about starting the Text Field more to the right to prevent cutting off the Field's name?

patent pebble
#

set it to whatever length before your field and then after the field set it back to 0 to reset to default

#

even thought when I set field's label widths I like to set the width consistent for the whole inspector, or for a group of related fields

#

if you have a bunch of fields starting at different inconsistent positions, readability suffers a lot

coral epoch
#

I created my own behavior tree api and would like to create an inspector editor for it with top-down nodes not sideways flow like the shader graph, hence why I like what they did

visual stag
coral epoch
#

Oh I had no idea. looking at the API it wasnt clear

visual stag
#

Graph View is a little annoying to learn though. There's a great tutorial pinned to this channel

#

I've never made a vertical port - but VFX Graph has them (Unsure whether it uses them outside of the Stack)

#

so I assume it's fine

coral epoch
#

Dont care what it looks like but I do care about orientation so if I can control where the ports are then itll work

#

Thanks for the help @visual stag

chilly bough
#

if im extending a previous window. how do i add ongui but keep the windows properties that i am extending to. (like drawdefaultInspector but for an extended window.

waxen sandal
#

Make the base method virtual

chilly bough
#

appreciate it. that actually fixes several other issues..

tawdry creek
# onyx harness <@!555142344622735363> Easy, you print Event.current.type to the console in your...

I know the basic order and execution timeline of those events. However, it seems there is no way to know in a "MouseUp" event, if this MouseUp is the end of a drag or the result of a simple click.

You can see the code I'm working on here, how could I get more information inside the "MouseUp" case?
https://pastebin.com/mW961juj

onyx harness
#

MouseUp is when you release MouseDown.

#

And the case of a drag, it's DragPerform or DragExited

#

(The 2 messages next to the one you quoted)

tawdry creek
# onyx harness MouseUp is when you release MouseDown.

Yes, there are different events for drag available. There is a call to MouseUp however, when a drag has ended, right? And is this MouseUp different in any way to a MouseUp after a drag?
Or in other words, is there a way to identify only MouseUp events that were not the end of a drag?

onyx harness
#

Are both fired when the Drag is completed?

tawdry creek
#

Yes, especially MouseUp.

I think i found a solution by using a static Vector3 that keeps track of the last delta. If there is none, there was no drag before.
Here's the updated switch-case.

Watch line 37 and 47 that set delta and then line 31+32 do the check
https://pastebin.com/CutYa55P

final falcon
#

hello

#

i need help for map design.

#

How can I create this kind of map?

onyx harness
#

I talked about Drag events when really dragging using DragAndDrop.
You are just talking about MouseDrag

#

And I really doubt MouseDrag is fired up when you release the mouse to get the MouseUp

tawdry creek
onyx harness
#

I find that so weird, I need to test it myself

#

Well, I don't know how you deducted that when releasing the mouse, it fires 2 events, both MouseUp & MouseDrag.

#

It does not.

#

The code I used on an empty EditorWindow in Unity 2018.4

gilded violet
#

Hey guys, my editor code isn't calling OnSceneGUI() unless gizmos are visible in editor scene, is there a way to force gizmos to be enabled or get the status of gizmos so that I can popup a warning when trying to use the tool?

patent pebble
#

I think i found a solution by using a static Vector3 that keeps track of the last delta. If there is none, there was no drag before.
@tawdry creek wouldn't that cause problems when you don't move the mouse? why not just set a bool to true the first time you detect a mouseDrag event and then set the bool to false when you detect mouseUp?

#

oh and by the way, another problem you have to deal with when using event.Delta, it not only registers movement but also scrolling

patent pebble
#

Question, why my propertyField for an array doesn't detect any changes in the property when I add elements with the buttons at the bottom (red circle) but it does detect change when i change the size at the top (green circle)

#

here's code

public override void OnInspectorGUI()
{
    serializedObject.Update();

    if (_textSplitsProp.arraySize != 0)
    {
        EditorGUILayout.PropertyField(_textSplitsProp);
    }

    if (serializedObject.ApplyModifiedProperties())
    {
        SaveToJson();
    }
}
#

serializedObject.ApplyModifiedProperties() doesn't get called when i use the buttons in the red circle

#

any idea why? 🤔

gloomy chasm
#

I believe that the button calls the ApplyModifiedProperties() method itself.

patent pebble
gloomy chasm
patent pebble
#

I'm not a big fan of undocumented/internal things 😅 and I've never used ReorderableLists, can I just use them with serializedProperties like normal arrays and lists?

onyx harness
#

Reorderable is pretty widely used

gloomy chasm
patent pebble
#

oh I see, I guess it's finally time to learn how to use Reorderable Lists

#

thx for the info 😊

patent pebble
#

is there a way to make PropertyField "delayed"? I want it to act like EditorGUILayout.DelayedTextField

#

because I'm saving to disk every time a property changes, but I'd like to reduce calls

onyx harness
#

Just delay your save yourself

oak stratus
#

Hey all, I would like to add a text input field as default to TMP pro, should I extend it or not and how can I do it well

patent pebble
#

I don't want to have to make custom controls or an elaborate system just to make properties act "delayed"

#

I'd rather just use a DelayedTextField instead... 😅

onyx harness
#

If you override GUI you will go crazy

#

Just whenever you want to save your data, put it in a EditorApplication.delay

#

And wait X secs

#

And whenever you want to save, you restart the countdown

patent pebble
#

oh I see

#

didn't know about EditorApplication.delayCall

#

man, extending the editor truly is a bottomless pit of APIs

#

seems like there's always something new I have to learn 😓

onyx harness
patent pebble
#

I could also use EditorCoroutineUtility

#

but I don't know the implications of using that

#

I assume it's just like runtime coroutines? 🤔

nocturne geyser
#

Why is the gap here in this textfield so wide?

#

This is how wide the entire thing is.

#

This is my code

patent pebble
#

@nocturne geyser are you using EditorGUIUtility.labelWidth anywhere in your code?

nocturne geyser
#

no, I wasnt able to properly figure out how to use it

patent pebble
#

when you use it to set a width, every control after it that has a label will be affected, to reset it back to normal you set it to 0

#

try setting it to 0 to see if your label goes back to normal

nocturne geyser
#

So like

EditorGUIUtility.labelwidth(someinteger)
TextField
TextField
TextField
EditorGUIUtility.labelwidth(0)
EndHorizontal()```
patent pebble
#

yeah

#

those 3 text fields inbetween the labelWidth assignments will use the someInteger width

#

i think it uses floats tho, but same thing

#

and it's EditorGUIUtility.labelWidth = someValue

#

not a method

onyx harness
#

This system is kinda absurd

#

It's like you would have to reference a package for Mathf, Editor, GUI, etc.

#

I don't know why they had to make a package for EditorCoroutine

patent pebble
patent pebble
#

oh damn, ReorderableLists have a lot more functionality than I expected. Just look at all this! 😋

#

they are a bit awkward to learn due to lack of documentation tho, but it's not the end of the world

onyx harness
#

the names are pretty self-explanatory

patent pebble
#

yeah, what took me a while was to figure I had to use ReorderableList.defaultBehaviours.DoAddButton() and ReorderableList.defaultBehaviours.DoRemoveButton()

#

the source code is kinda messy

onyx harness
#

defaultBehaviours?
No use the delegate onAddCallback

#

I never touched defaultBehaviours

patent pebble
#

yes but I only want the callback, I don't want to do anything, just call a method but keep the default behaviour

#

if I don't call those defaultBehaviours the list stops working

onyx harness
#

Ok ok

patent pebble
#
private void OnEnable()
{
    _list = new ReorderableList(serializedObject, _textSplitsProp, true, true, true, true);

    _list.drawElementCallback = DrawListItems;
    _list.drawHeaderCallback = DrawHeader;

    _list.onReorderCallback += ReorderList;
    _list.onAddCallback += AddToList;
    _list.onRemoveCallback += RemoveFromList;
}

private void AddToList(ReorderableList list)
{
    ReorderableList.defaultBehaviours.DoAddButton(list);
    SaveToJson();
}

private void RemoveFromList(ReorderableList list)
{
    ReorderableList.defaultBehaviours.DoRemoveButton(list);
    SaveToJson();
}
#

if I didn't call the defaultBehaviours the list breaks when adding/removing elements

gloomy chasm
#

How would one open something like a 'blank' /no border/ non-dockable EditorWindow, but without giving it focus? I am trying to make a window that acts like a tooltip.

waxen sandal
#

Uhh look at the show modes of editor windows there's probably something there

gloomy chasm
tough cairn
#

is there a way to edit build in vfx nodes ?

dark grail
#

Is there a way to "override" default script creation?
What i essentially want to do is replace the default "Create C# Script" command from the asset menu with a ScriptableObject-like selection for e.g. (Class/Interface/MonoBehaviour/...), so that i don't have to modify all the stuff all the time. I got custom templates working already, just wondering if there's a way to achieve that?

small oriole
#

Hi. If I have a custom editor window with a button that starts doing some linear work (loop generating meshes and assets) and it's in steps but still it freezes the editor. Is there a way to make the custom editor window repaint with some progress? Repaint doesn't work. I'm thinking about using editor coroutines but I'm not sure if that would work and is worth the time.

onyx harness
#

If it freezes, it is frozen

gloomy chasm
#

Hey @onyx harness I remember a while ago you did a thing with the inspector where you had a boarderless window open up beside it. I was wondering how you did that without the Inspector losing focus? Best thing I can find is the internal ShowPopupMode.

onyx harness
gloomy chasm
harsh estuary
#

Got an issue. Documentation is lacking a lot and ive known that for a long time now. But this is steering my head. I want to get when the cursor is in the sceneView window.

onyx harness
harsh estuary
#

So im getting the windows position and the cursors position and doing some stuff to check when the cursor is inside the range of the window. It works but at the same time not. The window that its comparing with is my custom editor window not the SceneView window

#

Any ideas?

#
currentSceneView = EditorWindow.GetWindowWithRect<SceneView>(sceneViewLoc);
#

Here's how im getting the window

#

im thinking of trying to use localtoworld instead

gloomy chasm
onyx harness
#

Is it borderless that you are seeking?

gloomy chasm
gloomy chasm
onyx harness
#

To have a borderless:
Editor.CreateWindow
set min/maxSize
ShowPopup

harsh estuary
#

but the editorwindow has to get sceneView

onyx harness
#

If Im not mistaken, any window is always on top, it cant go behind. if it does, it s bug.

harsh estuary
#

Not my custom editor @gloomy chasm

onyx harness
#

A window wont close until you close it.
You might be confusing with PopupWindowContent.

harsh estuary
#

Im not confusing it with a popupwindow.

onyx harness
#

Sorry I forgot to 'answered' MechWarrior

harsh estuary
#

hahaha its fine im sorry. didnt notice

gloomy chasm
onyx harness
#

Don't use AsDropdown

#

And play with mouse enter/leave to show/hide the tooltip

gloomy chasm
# onyx harness And play with mouse enter/leave to show/hide the tooltip

Yeah, thanks for the help I was so close to getting it to work. Just too many different combinations. When I had tried using the ShowPopup method I had forgotten that you can set the position of the window, so by the time I remembered that I had forgotten to try it with the Popup mode. Oh well.
Thanks again for the help!

gloomy chasm
harsh estuary
#

Not an issue. Lack of documentation so need ideas. I want to get when the cursor is over the scene view.

#

@gloomy chasm

#

Im trying mouseoverwindow now but i doubt it will work. I need to get the scene view window. So far ive noticed from debugging that its getting my custom editor window not my scene view window

gloomy chasm
harsh estuary
#

il give it a shot and get back to you

#

thanks

onyx harness
#

windows = Resources.FindAllObjectsOfType(sceneviewtype)
if mousePosition in window
do

#

mouseOverWindow is also a good track

harsh estuary
#

ive tried a couple methods, mostly custom made from scratch cause as i said, the documentation really disapoints me TeRRIBLY.

#

But il give that one a shot mikilo too.

#

thanks

harsh estuary
#

Thanks man

onyx harness
#

Be careful

#

mouseOverWindow can be null

harsh estuary
#

It was null at first haha. But i only need it to initilize a class. So its safe.

#

If its null i do nothing, if it has the correct scene view value i call the function

#

should work right?

#

or what do you say

onyx harness
#

well if it is null, you wont go anywhere

#

But you have to use this variable like a singleton

#

var sceneView = EditorWindow.mouseOverWindow;
if (sceneView != null)
sceneView.

harsh estuary
#

That was the idea. Thanks man

gloomy chasm
#

@onyx harness Related to what I was asking earlier. So if the main window is floating, and I use ShowPopup and then set the focus back to being the main window, the popup window will be placed behind the main window. Any ideas on how to fix that?

onyx harness
#

Are you on mac?

gloomy chasm
#

See, it is behind it. This is not a problem if the main window is docked though.

onyx harness
#

Oh

#

Yeah between floating Windows there is no priority

gloomy chasm
#

Oh well. The internal method works just fine, I just prefer to not use internal things when I don't have to.

crude sand
#

Hey all, joined as had a quick question
I'm making a custom inspector for some ScriptableObjects that encode a lot of the mechanics of our game (it's crafting-based so recipes, resources, conditions etc)
I'm working on an inspector for conditions and as an example, there's a bit that has a list of achievement IDs (strings) and I wanted this to be assignable with Object Fields, so you can select a condition that has been made, but make it assign in the inspector as its string ID
I'm doing it like so:

private void DrawAchievementElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        SerializedProperty element = _reorderableListAchievements.serializedProperty.GetArrayElementAtIndex(index);

        Achievement ach = EditorGUI.ObjectField(
            new Rect(rect.x, rect.y, 240, EditorGUIUtility.singleLineHeight),
            AchievementManager.Instance.GetAchievementById(element.stringValue), typeof(Achievement), false
        ) as Achievement;

        if (ach)
            element.stringValue = ach.AchievementId;
    }

(^this is the callback method for drawing elements of the UnityEditorInternal.ReorderableList)

and this seems to work - but was wondering if anyone has any better ideas of ways to do this / if its supported in a less hacky way?

harsh estuary
harsh estuary
# crude sand Hey all, joined as had a quick question I'm making a custom inspector for some S...

And incase you arent already, id say try splitting stuff up in to classes, use more of a object orianted aproach. So a script for the ui. So one script for handling all the UI (a main script) and then other scripts that are just classes containing the UI. So for example, you would have the main ui in a class and call it in the main script onEnabeled. and then if you have stuff like cards you want to be added to the UI but not onEnabeled but on request,etc... you can have a different class containing the info for that and call it from the UIhandler script (main script)

#

Il gladly show you some examples if youd like some more help

harsh estuary
#

Need help. This makes no sense. im trying to raycast from cursor to world space in sceneview. This is literally just through a BS error that can not be true

#

It just cant. Ive tried multiple aproaches,etc... Still the same issue. IT DOESNT MAKE SENSE

harsh estuary
#

Fixed

fluid sparrow
#

yall know where to find probuilder in unity 2019

gloomy chasm
fluid sparrow
#

It wouldnt show for me but i just had to verify my acount

#

already got it fixed thanks tho!

untold dragon
#

How would I go about changing how my syntax is auto-generated from next-line syntax to same-line syntax?

gloomy chasm
untold dragon
#

My bad

#

Figured this was the best place fir but will remember future questions

quaint zephyr
#

I created a public static class EditorSession it has a static ctor and uses attribute [InitializeOnLoad] It does some AssetDatabase operations as well, very basic stuff.
And for some reason, for each script compile, the console shows the following error:
'EditorSession' is missing the class attribute 'ExtensionOfNativeClass'!
No stack trace either.

#

What's going on?

#

My script is NOT attached anywhere in the scene.

#

The script does work though as it should. I just don't know how to get rid of this annoying error.

plucky nymph
#

Hey, can anyone see an obvious flaw in this? Its part of a larger EditorTool, I just want to replicate the Position Tool functionality, but for some reason when I drag the object too fast, its jumping to >10000m away.

My first thought is that the delta is accumulative or multiplied, but neither seem to be the truth! Been a few days, cant quite figure it...

EditorGUI.BeginChangeCheck();

Vector3 position = Tools.handlePosition;
using (new Handles.DrawingScope(Color.green))
{
    position = Handles.PositionHandle(position, Tools.handleRotation);
}

if (EditorGUI.EndChangeCheck())
{
    Vector3 delta = position - Tools.handlePosition;

    var mObjects = ObjectsToMove();

    Undo.RecordObjects(Selection.transforms, "Move Platform");
    foreach (var transform in mObjects)
        transform.position += delta;
}
#

Objects to move is just Selection.transforms + 'connected' objects (objects have 'snapping' functionality as part of the tool. I want to move connected pieces too)

waxen sandal
#

I feel like that's not the intended way to use HandlePosition but I've never used it myself

plucky nymph
#

There is also DoPositionHandle, with the same inputs, but there is zilch documentation about it

#

I found some code for the 'all tools' tool they introduced at the same time, and it just uses the objects current position, not handle position

#

I cant quite tell if it worked though haha, wont know until tonight (at work remoting in :P)

waxen sandal
#

Last time I did anything like this, Tools.handlePosition didn't exist (atleast afaik)

#

I think it's just there to make sure that you don't end up with multiple handles for hte same object at different locations

plucky nymph
#

Yeh, I think its just an automatic mean position. I was using it because it was in the EditorTools doc page, but that may have been a mistake

#

Enjoying this learning curve though 🙂

waxen sandal
#

It also accounts for center/pivot and local/global

#

(I assume)

plucky nymph
#

Likely yeh. Fine for this circumstance, I just needed basic movement, im doing rotation on an increment with hotkeys

patent pebble
#

A while ago i made a couple of scene Tools using those APIs, i can share code later when i'm on my PC. I remember it being pretty simple to implement

plucky nymph
#

Thanks, appreciated 🙂

#

I played too much valheim and wanted to make an editor tool for snapping level pieces together. Its.... getting there

#

I can snap manually rn, i still need to figure out my logic for whether I want it to snap when I move it or not

patent pebble
#

Freya Holmer has a tutorial for a snapping Tool iirc, will share a link later

plucky nymph
#

oh damn, her stuff if amazing. Im on her patreon, so ill have a scroll through

patent pebble
#

It's part of a larger set of videos where she explains a bunch of stuff related to editor extensions, can't rememeber the name of the video

plucky nymph
#

Think i got it!

#

Ill have a watch through later tonight, see how it goes 😛
3h 40m is a trek haha

patent pebble
patent pebble
#

i hope it helps

#

looking at your code snippet, it doesn't seem to be the issue

#

you are probably doing something else that affects the object's position

plucky nymph
#

Hey man, thanks for that 🙂 I just watched the first hour of that stream, damn theres some good stuff in there haha.

I just tested my new version of the movement code, it still judders, but it doesnt shoot to the end of the screen, so thats nice 😛 I think my other code my be a bit heavy. Its a first run, so I need to cache a lot of it, and sort out variable calc priorities

oak stratus
#

Hey guys, what is the best way to make TMP button and texts come with a required component, make my custom buttons and text menu items with req component or can I somehow extend tmp class methods?

harsh estuary
#

Im honestly going to kill unity. Ive tried every single way to raycast from cursor to world point in editor not on runtime, every single way. and every time, it either gives me mouse position = 0,0,0 ALL THE TIME. OR IF I USE EVENT.CURRENT.MOUSEPOSITON it returns an error that object is not set to an instance of an object. IT FUCKING IS.

#

Any one has any ideas. ANY. honsetly. this is the most amount of shit, UPDATE THE DOCUMENTATION FOR FUCK SAKE. ONSCENEDELEGATE ISNT A THING, UPDATE. honestly. nothing is making sense, either im wayy too tired or this is PURE BS

#

any ideas, il take any, just hit me with one.

gloomy chasm
#

@harsh estuary Here you go.

[InitializeOnLoadMethod]
    public static void Init()
    {
        SceneView.duringSceneGui += scene =>
        {
            Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            if (Physics.Raycast(ray, out RaycastHit hitInfo))
                Debug.Log("Hit: " + hitInfo.transform.name);
            else
                Debug.Log("Hit: Nothing");
        };
    }
#

Note that it doesn't account for if the mouse is actually over the scene view or not. But that is easy to fix.

harsh estuary
#

i already have the if cursor on scene

#

Its a large script. Im doing stuff never done before in unity. i already finished the main large part thats never been done as far as i know and now im implementing this new part that i think has been done but man the headache i got, i cant figure anything out. Il try the script and get back to you but just so you know, ive tried handleUtility.

#

@gloomy chasm

#

Ight it works. very unoptimized but il optimize it XD

gloomy chasm
harsh estuary
#

Apreciate it man. Thanks. Btw if you got time and interested, i wouldnt mind hanging out in a call now or later. Might be fun

#

i can show you around the project

gloomy chasm
harsh estuary
#

understandable good luck man. thanks again

harsh estuary
#

Here's the thing, i did the script the same way you did but i didnt assign to duringsceneGUI. Now the issue im noticing is that even if i do make it only run on mouse, its way too unoptimized. So i have to figure out how to set instance of an object with out using duringsceneGUI if its possible.

jovial plaza
#

Hi Folks, I'm thinking of making an extension that will install a list of Asset Store packages / dependencies. Kind of like a npm install for unity. Mostly so I don't have to check in all the 3rd party code / assets into git. Does anyone know if this kind of thing already exists (and I'm missing it) before I make one?

patent pebble
#

I'm learning about editor extensions for managing assets and GameObject references and experimenting with the different ways Unity identifies those
I'm having trouble finding information on Instance IDs
All I could find on the docs is this
The instance id of an object is always guaranteed to be unique
So, when does an InstanceID change?
I've had situations where they persist across editor sessions (closing and reopening Unity)
I've had situations where they do not persist across editor sessions
I've had situations where they change in the same editor session, for example when closing/opening scenes

#

so... are they tied to objects being in memory or something?

waxen sandal
#

Afaik they're constant for assetdatabase items while the editor is open

#

Scene gameobjects are recreated so I think they're recreated

#

Afaik between editor restarts that's luck aka no guarantees

patent pebble
#

hmmm I see. Yeah doing some simple checks it seems that for assets the IDs persist as long as I don't close the editor
they seem to be more volatile for scene gameobjects

waxen sandal
#

It's probably different between objects that persist between assembly reloads and those that don't

gloomy chasm
patent pebble
harsh estuary
#

@gloomy chasm well right now im just debugging the info it gets. but the frames are dropping like hell when i let it run.

patent pebble
#

so I guess instance IDs are mostly useful for debugging things in the same editor session, or debugging play sessions in the case of gameObjects

#

they don't seem reliable for much else

waxen sandal
#

Yeah

#

That's mostly what they're for

#

Guaranteed to be differnet objects

#

Oh I vaguely remember they might use it to sync cpp things

#

But might be miss remembering

waxen sandal
#

c++

#

The native layer I mean

patent pebble
#

oooh, right

gloomy chasm
harsh estuary
#

hahaha well i got the entire rest of the scripts XD

#

its not just one script. Its a large project as i said XD

#

including new features that as far as know never done before with this aproach

#

But those scripts are optimized and didnt cause me issues.

gloomy chasm
#

Well, time for you to do some profiling then because SceneView.duringSceneGui is literally the same as running code in the OnGUI() method of the SceneView window.

patent pebble
#

I don't think doing sceneview raycasting is a "never done before" thing. It's pretty standard to do that for a multitude of editor tools
If you are stuck on something, look for tutorials or open source tools. There's a bunch of them online

harsh estuary
#

yea thought so too. I think the issue is coming from my main script. Tpbrush_Main

#

Ima see what i can do

#

@gloomy chasm

gloomy chasm
harsh estuary
#

@gloomy chasm optimized it. was calling from an update while i was profiling before. So now it works well. Just gota unassign it, harder than it look, the class structure needs to make sense for it to unassign so ima see what i can do to stop it from raycasting

gloomy chasm
harsh estuary
#

XD haha yea man thanks. Just need to unassign the raycasting from duringscenegui. Its runing even when the method is not being called. kinda wierd

#

@gloomy chasm

gloomy chasm
# harsh estuary XD haha yea man thanks. Just need to unassign the raycasting from duringscenegui...

That is because it is being called. duringSceneGui is an event delegate. When you do +=, you are basically adding a reference to a method to the delegate. Then, any time that the delegate (In this case duringSceneGui) is called, every method that it is referencing is called.

In this case, duringSceneGui is called in the SceneView window's OnGUI method, so that means that if the SceneView window is on the screen, it is being drawn, so duringScenGui is being called.

#

Does that clear it up for you?

harsh estuary
#

Well i already understood that. thats why im unassigning it by using -=

#

still not doing that. or am i missing something?

gloomy chasm
#

Otherwise it would still be calling the method even if you removed one.

harsh estuary
#

hmm? interesting. could be the issue.

#

well what im doing is that the main script checks when a boolean is true. if it is, then it calls another script where it finds if the mouse is on the sceneview window, and that calls the class where it starts raycasting and should contain the rest of the features im going to add after i figure this out. So its never calling the unassign method.

#

Is it possible to get all references of the method in duringsceneGUI. like with a foreach? just throwing ideas here.

#

Other whise i could probably just make a method where it just deletes the reference but if its running per frame and a new reference is being added per frame. Then it has to run for the same amount of frames to remove all the references

gloomy chasm
harsh estuary
#

understandable

gloomy chasm
harsh estuary
#

well im referencing a method to the duringsceneGUI

gloomy chasm
harsh estuary
#

I already know the issue haha. just wanted to understand more about the duringsceneGUI to see if there's a easier way of doing it.

#

The way im implementing the events is standard. Distributed across multiple classes, I got a main class that controls everything. And each class has a subclass. None of them call each other. So no issues on that end. The events them selfs are all controled in the main script.

#

All i have to do is add the script that disables and it should work. Its just that in this case. when the tool is disabeled. the main class stop calling the method. So it stay assigned.

#

I just need it to call when its disabeled as well to disabel it.

#

@gloomy chasm

midnight cedar
#

Is there a way to make the lines drawn with handles.drawline not render over objects closer to the camera than they are?

#

that ped model is closer to the camera than the line is but it always renders first for some reason.

midnight cedar
#

I will give it a try i was under the impression it was only used for z sorting the handles themselves

gloomy chasm
midnight cedar
#

Yeah that does it @gloomy chasm thank you

brisk turtle
#

Seems like the right channel. I have an importer script that changes my files to the correct settings, but it's also making me unable to alter the settings when the files are in the sprites folder, or subfolders. How can I avoid this?? They just revert to sprites.

https://pastebin.com/tPZd1ECQ

plucky nymph
#

Can anyone tell me what the "EventType" parameter in the HandleCap classes is for? Is it the event that the handle is drawn on, or the one it receives its input from?

thin fossil
#

Is there any way to properly place my settings SO in the ProjectSettings folder?

outer ether
#

Hi, how can i use dll files or nuget packages in a custom unity package? Does it work and if it does where should I place them?

patent pebble
#

the events don't do anything by themselves to the handle caps

#

the handle caps use those events to do the things they need to do in order to work properly

#

as you see during the Layout event I register the handle cap with HandleUtility.AddControl with the calculated distance

#

and during the Repaint event I do a bunch of stuff to draw the actual cap mesh

#

then you would use that handle cap in a handle function like this one for example

pos = Handles.Slider(pos, dir, size, CustomHandleCaps.PyramidHandleCap, snapIncrement);
timid sapphire
#

Anyone know if there is a callback for when you drag an asset into the scene view / hierarchy and it instantiates it as a new gameobject? Goal is to be able to drag a sprite/whatever from Project panel into the Hierarchy, and to automatically place it in the center of the Scene View and set Z position to 0

patent pebble
#

depending on what you want to do

timid sapphire
#

Ideally having a callback that says "GameObjectWasInstantiated(GameObject newGameobject)" so that I can do whatever I want with it

#

Been looking for about an hour and don't see anything yet :/

patent pebble
#

what I linked gives you the instantiated gameObject

timid sapphire
#

But wouldn't that get called any time a prefab in the scene is updated?

#

or maybe I'm misunderstanding

#

I need an "initialization" sort of callback

#

or some way to at least tell if it was just created 🤔

patent pebble
#

iirc yes, but you could do some manual comparing to check what new GameObject has been added
it's been a while since I've used it

#

I don't know if there's anything else similar to that that would give you a more precise callback

timid sapphire
#

There is an "OnHierarchyChange" callback, but im not sure how i'd use the combination of those two things to know if the PrefabInstanceUpdated(gameobject) was just created or not

#

without like, keeping track of everything in the hierarchy to check for something new, lol

#

There is also Reset(), but thats called per-MonoBehavior, whereas I'd need just a single callback (I can't add this code to every single monobehavior lol)

patent pebble
#

To be honest I have no idea to achieve what you want just using Unity's built-in functionality.
Maybe someone with more knowledge can help 😕

cosmic iron
#

Is it possible to draw a rect to a EditorWindow?

cosmic iron
warm pendant
#

Probably a noob question:
I want to make a weighted picker where the weight of the object and its actual chance as well as a toggle box are displayed horizontally next to each other. Doing these with EditorGUILayout didnt seem to work so I used EditorGUI and manually calculated the rects. They appropriately each take up a third of the space, but when I put in the Fields it looks absolutely broken and messy...

#

(The red, green and blue rects are the rects I previously calculated)
As you can see the toggle box isnt even shown and the FloatField for Weight clips into the Label for Chance and cant be used properly. Where is the issue and how can I get around that?

gloomy chasm
warm pendant
#

Would I have to create a new EditorStyle for that or is there an easier way?

gloomy chasm
warm pendant
warm pendant
gloomy chasm
warm pendant
#

But then I think about my last projec tin Unreal and how neat it would have been to have such flexibility in the editor there and keep pushing through

severe python
#

This is a bit of a long shot, but I'm trying to generate a ScriptableObject to add to new Packages that are added to the current project so that they can be used for a dependency management scenario, however when I reference those ScriptableObjects on an asset in my Assets folder the GUIDs stored for the reference are all zero.
They always serialize as all zero when I reference them out of a package, and thus when things get reloaded the references don't work.
I am creating and loading these assets in an unusual way. I create the asset in the Assets folder and then move them into the appropriate packages folder, since I can't save assets to a package folder directly.

#

However, the meta files for the assets seem to be fine and so I'd expect them to reference appropriately

#

I do need to create these files but I can't seem to do so in a way that doesn't cause problems, I'm hoping someone has some ideas on this problem, all my searching has turned up nothing useful

severe python
#

seems maybe my project was corrupt, doing a re-import all fixed the issue

craggy axle
#

Hi ! can someone please enlighten me on how to do this right please?

#

how do i make an object field for an animation layer please ?

visual stag
#

it's an enum isn't it?

#

not a Object

craggy axle
#

the problem is that i want to be able to drag this :
into the drawn option

visual stag
#

I have no idea what that is

craggy axle
#

an animation controller

visual stag
#

Then why did you use

#

It's a RuntimeAnimatorController

craggy axle
#

i tryed different things i didnt find a single way on how to do it

#

i just dont know

#

oh thanks you !

#

is there any page where i can see all of those by the way ?

visual stag
#

🤷 in the docs?

#

I just looked at the Animator code

craggy axle
#

ok thanks you i guess i need to learn how to document myself with unity since i'm still preaty new to it

severe python
#

Okay, I'm trying to detect whether the user is holding control when a control loses focus, for testing and debugging purposes only, and I'm finding its not working

#

I figured I could just do this by using Input.GetKey but it doesn't seem to work, which turns out to be expected? documentation says it should be checked in Update, so I figured, caching the value in Update might work, but that also always returns false

#

So I'm wondering, is there some specific way you're supposed to check key states in the editor?

patent pebble
#

@severe python runtime code or editor code?

severe python
#

straight editor code

patent pebble
#

since you mentioned when a control loses focus

#

oh ok

severe python
#

for an EditorWindow specifically

patent pebble
#

iirc this works

severe python
#

oh

#

wow talk about brain fart

#

thank you

patent pebble
severe python
#

yeah, thats absolutely what I'm looking for, I can't believe I just forgot that and couldn't figure it out with google...

patent pebble
onyx harness
patent pebble
#

@severe python you can also use this to check whether left or right control is pressed/released https://docs.unity3d.com/ScriptReference/Event-keyCode.html

Event c = Event.current;

//returns true for both KeyDown and KeyUp events
if (c.isKey)
  {Debug.Log($"{c.keyCode}");}

if (c.type == EventType.KeyDown)
  {Debug.Log($"{c.keyCode}");}

if (c.type == EventType.KeyUp)
  {Debug.Log($"{c.keyCode}");}
patent pebble
severe python
#

I actually know all about Event and how to use it... it just totally left my brain for the past 20 minutes entirely

patent pebble
#

happens to me often 🙃

tepid prairie
#

Hey all, I'm making a custom editor/inspector for my PostProcessing asset on U2020, but none of my variables change on the volume asset unless they are drawn with the default propertydrawer

#

Does anyone have an example of a bit of editor code that manually draws volume component variables (like I used to be able to in 2019 and earlier) but actually works/changes them?

waxen sandal
waxen sandal
tepid prairie
tepid prairie
waxen sandal
#

What type is useColorCorrection?

tepid prairie
#

SerializedDataParameter

waxen sandal
#

Are you doing apply on the useColorCorrection.value serializedobject?

tepid prairie
waxen sandal
#

Where's serializedobject coming from?

tepid prairie
#

from the target in the inspector - it's the same reference I get the SerializedDataParameter variables from

waxen sandal
#

Can you show more code? I'm not familiar with SerializedDataParameter so just trying to figure things out

tepid prairie
#

public override void OnEnable()
{
serObj = new SerializedObject(target);
var prism = new PropertyFetcher<PRISMEffects>(serializedObject);
useColorCorrection = Unpack(prism.Find(x => x.useColorCorrection));
}

public override void OnInspectorGUI()
{
serObj.Update();
useColorCorrection.value.boolValue = EditorGUILayout.Toggle(colorContent, useColorCorrection.value.boolValue);
EditorUtility.SetDirty(target);
serObj.ApplyModifiedProperties();
}

#

is basically the meat and bones of it

#

noting that the exact same code that doesn't set the value correctly there (the editor toggle) works as soon as I put a generic/Unity propertyfield line in (anywhere)
PropertyField(useColorCorrection);

visual stag
#

SetDirty and SerializedObject functions are in direct contradiction with each other

#

if you are using properties you apply them, if you're not, use the Undo functions

tepid prairie
#

Not the issue

#

have tried with/without those bottom line(s) also, exact same issue

#

and I do use undo properly but don't want to paste 500LoC into discord 😄

waxen sandal
#

SetDirty is redundant there, iirc Apply will override in this scenario

#

Actually, you're using 2 different serializedObjects

#
serObj = new SerializedObject(target);
var prism = new PropertyFetcher<PRISMEffects>(serializedObject);
tepid prairie
#

good call

#

and yeah I also have tried using the inbuilt serializedobject

#

no bueno either

waxen sandal
#

What happens in Unpack?

tepid prairie
#

That is the "new" example code on how to write a custom editor from the URP manual

#

that I don't know how it works tbh, it's linq

#

assumedly some reflection

waxen sandal
#

0.o

tepid prairie
#

yeah don't get me started on why they added that haha, but I know for sure those unpack lines all work as intended

waxen sandal
#

Do you have docs relating to that?/

visual stag
#

I would definitely start by removing your serialized object if you haven't done that

tepid prairie
#

oh and of course the undocumented "Draw Override Checkbox" works

visual stag
tepid prairie
#

I say "undocumented" meaning it's actual function isn't properly documented, it (appears) as though it functions as a per-variable "ApplyModifiedProperties"

#

with no(?) other way that I can see to just tell the inspector that I want to change every variable(?)

visual stag
#

I don't think it does, it's just the checkbox next to the variable, the override checkbox that enables the variable to be used by the Volume

#

unrelated to ApplyModifiedProperties

waxen sandal
#

I think you might've been using the wrong property, think property.overrideState is the correct one

tepid prairie
visual stag
waxen sandal
#

^

tepid prairie
#

Works now, thanks for y'alls help. TL;DR, for custom Volume Component editors now you have to make sure all SerializedProperties overridestate is set to true before any value will actually set

#

So in my example code above, all that's needed to make it work is a
useColorCorrection.overrideState.boolValue = true;

waxen sandal
#

Interesting

plucky nymph
#

Can anyone see why Mode.ViewSelected would add everything, including connected nodes? Node data is definitely set properly

public static void UpdateIterate(this ConstructionTool tool)
    {
        tool.snapIterate.Clear();
        if (ConstructionTool.mode == ConstructionTool.Mode.ViewSelected)
        {
            foreach (var segment in tool.segments.Where(x => Selection.transforms.Contains(x.transform)))
            {
                tool.snapIterate.AddRange(segment.snaps);
            }
        }
        else if (ConstructionTool.mode == ConstructionTool.Mode.ViewSelected)
        {
            tool.snapIterate.AddRange(tool._snaps.Where(x => x.connected == false));
        }
        else
        {
            tool.snapIterate.AddRange(tool._snaps);
        }
    }
waxen sandal
#

Add a breakpoint and see what that where returns

#

And you're checking the same condition twice

#
        if (ConstructionTool.mode == ConstructionTool.Mode.ViewSelected)
   else if (ConstructionTool.mode == ConstructionTool.Mode.ViewSelected)
plucky nymph
#

oh my god thats so obvious now i see it

#

Thanks Navi, my bad

onyx harness
midnight cedar
#

Is there a way to add an item to the create menu that isn't a scriptable object?

#

like can I just hook into the create button add a value and listen for onclick?

gloomy chasm
#

I think the menu path is Assets/Create/My Item

midnight cedar
#

can it be done inside a package @gloomy chasm

#

cause i tried that and its not working?

#

nvm

#

i needed to add an asmdef

#

to editor folder

quaint zephyr
#

I got a ScriptableObject WorldData and a WorldDataEditor. Is there a way to find all instances of WorldDataEditor in project? When Editor loads, I want to have them all subscribe to EditorApplication.onProjectChange event. Or is there a better way to do this?

civic river
#

@quaint zephyr

        public static List<T> FindAssetsOfType<T>() where T : Object
        {
            var searchStr = "t:" + typeof(T).Name;
            var charGuids = AssetDatabase.FindAssets(searchStr);
            var items = new List<T>();
            foreach (var chGuid in charGuids)
            {
                var path = AssetDatabase.GUIDToAssetPath(chGuid);
                var assetsAtPath = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (var asset in assetsAtPath)
                {
                    if (!(asset is T item))
                        continue;
                    items.Add(item);
                }
            }

            return items;
        }

This is what you're looking for I think

quaint zephyr
#

Thanks

quaint zephyr
#

I setup a FileSystemWatcher and it works good. Issue is that when an event fires, I am trying to iterate through a dictionary. But it doesn't work.
Here is the method that gets fired whenever a file gets deleted in that directory:

    private void OnChunkDataDeleted (object sender, FileSystemEventArgs e)
    {
        Debug.Log($"World <b>{Name}</b> had Chunk data deleted:  {e.Name}");
        Debug.Log($"Current chunks saved in list: {chunks.Count}");
        foreach (var chunk in chunks)
        {
            Debug.Log($"Chunk: <b>{chunk.Key}</b> => {chunk.Value}");
        }
    }

And the console actually logs the first two Debug.Logs in the method. But it does NOT log anything inside the foreach loop. The second log where it displays chunks.Count spits out the number 3, which is true that's how many are in the list. But why doesn't the foreach fire???

#

I ran the same foreach loop OnEnable and it worked as expected. So why then does it get ignored in this method?

plucky nymph
#

Hi all 🙂
Im making a toolbar for my editortool, and while all is mostly going well, I cant seem to change the padding/size of the images in bar? For now I have shrunk them to 32x32 using texture import settings, so size is less of an issue, but if possible i'd like to change how they sit in the bar itself.
I am currently creating a new guiskin based of GUI.skin.button, then changing its padding, but im seeing no result.

Pic of current (bad) bar:

visual stag
#

I would create a new GUIStyle based on (GUIStyle)"Button" and modify it

plucky nymph
#

The guiskin is being applied to the toolbar

visual stag
#

and pass that into the button

plucky nymph
#

ah sorry, thats what im doing! Said skin by mistake
current code:

_toolbarStyle = new GUIStyle(GUI.skin.button);
_toolbarStyle.padding = new RectOffset(20,20,20,20);
toolbarSelection = GUILayout.Toolbar(toolbarSelection, toolbarContent, _toolbarStyle);
#

Is creating using (GUIStyle)"Button" different to my implement? I've never seen that used tbh

visual stag
#

I'm not sure tbh, I don't tend to use GUI.skin

plucky nymph
#

I'll do some research, thanks for the info 🙂

#

Implemented it instead, no change. I feel they're just different methods to the same result

visual stag
#

Probably. Have you tried .border instead?

#

GUISkin's always fiddly with images - I try avoiding it because I hate it 😛
The api doesn't separate the actual image used for the control and the image used by the GUIContent very well

plucky nymph
#

I did try both border and margin, found neither worked. And just like you, I have now abandoned images for that very reason 😛
Found a good tutorial on setting up a custom GUIStyle using an asset, which made things a bit more visual for me and really helped!
The result:

#

which im pretty happy with 🙂

heady shadow
#

Not sure if this is the right channel, but whats the correct way to store values in play mode into a Scriptable Object? I'm caching an animation and storing it into the SO, but the SO resets on each compile, but I need those values to persist after the playmode session.

waxen sandal
#

Just put your SO in the assetdatabase

#

And it'll persist unless y our animation gets deleted of course

#

Obviously that won't won't work if you have to persist it in build as well

heady shadow
#

Was hoping for it to work in the build as well

heady shadow
#

the goal is to record on high end system, play on low end system

waxen sandal
#

Well if you save the data then you can access it but you can't save it like that in build

#

Since scriptableobjects aren't saved in builds

heady shadow
#

Yeah, only recording in the editor not in the build

#

But the editor values still get lost after compiling

waxen sandal
#

Unless you're doing createinstance or your SO is in memory only then it shouldn't

heady shadow
#

Not using create instance just a plain old SO asset. I'll go back and see what I'm doing wrong, thanks for your time ablobowo

heady shadow
waxen sandal
#

Blame odin

heady shadow
#

🙁 I gotta get rid of Odin completely for this to work?

waxen sandal
#

No clue but that's the only reason I can see why it doesn't work

#

Assuming you're not doing a createinstance

#

You can try just a normal SO without any of the odin shit

heady shadow
waxen sandal
#

What unity version?

heady shadow
#

2019.4

waxen sandal
#

Should work

heady shadow
#

@waxen sandal ^ if you see anything wrong. gonna try a fresh project without odin though

waxen sandal
#

Did I jsut see that your fields are itnernal?

heady shadow
#

yeah, how does that make a difference?

#

please tell me it doesn't >.>

visual stag
#

None of that is serializable

waxen sandal
#

^

visual stag
#

Dictionaries, not serializable by default.

#

If it doesn't appear in the inspector, Unity is not serializing it

waxen sandal
#

Unless you have HideInInspector or have a custom editor

visual stag
#

by default

waxen sandal
#

Or odin does stupid shit

visual stag
#

or a property drawer, or blah

heady shadow
#

Still not getting it tbh. So, if Unity doesn't serialize it, it doesn't save it?

visual stag
#

that's what serialize means

heady shadow
#

Always thought that it just wasn't capable of showing that it has saved it rather than incapable of savingit anyway

#

that explains why this doesn't even work without odin

waxen sandal
#

nope

#

Odin does serialize dictionaries I think

#

But no clue about the details

polar plinth
#

Odin will serialize dictionaries with their serializable monobehavior and such

#

But it doesn't work with Prefabs

waxen sandal
polar plinth
heady shadow
#

so, to my understanding since nothing is getting serialized, nothing is getting saved. Without saving to a JSON or similar, would it be possible to achieve the same goal?

visual stag
#

serialize the dictionary

#

using ISerializationCallbackReceiver

waxen sandal
#

Or let odin do it for you

visual stag
#

and mark your fields as serializefield too so they actually serialize

heady shadow
#

Got it working. Making them public + Serialized actually made the data persist, danke @visual stag @waxen sandal thankuwu

patent pebble
#

public fields are already serializable by default, don't know about Odin

ornate cairn
#

I am a little stuck making an interface typed field available in the inspector so I can drag an object onto it. any idea where I can read about this topic?

gloomy chasm
ornate cairn
#

thanks

latent patrol
#

I'm looking at switching to PlasticSCM for our VCS. It looks pretty good so far but I'm curious if anyone used it and in particular if anyone's had bad experiences with it?

plucky nymph
#

Doing the same thing, just a few days ahead of you haha. Accidently wiped some work by removing the changes instead of commiting, but that was a learning experience. far better than sourcetree/github so far

polar plinth
#

I've been using it for awhile, no complaints. But I also haven't had occasion yet to do any branching etc.

plucky nymph
#

Im keen to use the shelving feature, because that seems suuuper useful

waxen sandal
#

Not sure what shelving means in plastic but if it's the same as in p4 then those are the same as stashes in git

patent pebble
#

is there a way to "override" internal classes to overload their methods?
For example if I wanted to make an overload for the method AssetDatabase.GenerateUniqueAssetPath(), would that be possible?
I'd like to just call

//Call to original method
AssetDatabase.GenerateUniqueAssetPath(somePath)

//Call to my overloaded method
AssetDatabase.GenerateUniqueAssetPath(somePath, true)```
instead of having to use my own classes
```cs
MyAssetPathUtils.GenerateUniqueAssetPath(somePath, true)
onyx harness
#

This is called an extension, but you can't extend static, can you?

patent pebble
#

yeah i know about extension methods, but since they need an instance they don't work with statics

#

that's why I asked if there's something I can do to achieve what I want in this case

waxen sandal
#

You can patch the assembly

#

But I just make an interface that mirrors assetdatabase and then add my own things if needed

#

Or provide my complete own implementation

#

I get an instance through my DI framework

patent pebble
#

hmm I see, I'll look into that

errant briar
#

Hey guys, does anyone have experience with using microsoft playfab with unity for Android? I'm trying to implement in app purchasing and in app currency. Basically a way to store user data like journal entries, in app currency, and execute in app purchases for additional in game items without having to run my own server or db. Currently I'm having this issue when trying to get testers to sign up via Google oauth. I have everyone's correct emails in the Google play tester list.

#

I've been stuck on this error for a month so it'd be a huge help if anyone could assist.

whole steppe
#

Do you guys know if the animation file can be sent?

waxen sandal
#

Wrong channel, sounds like you should ask on some playfab server

waxen sandal
whole steppe
#

I wanna compile it with my file if thats possible??

errant briar
#

It's still a Unity question

waxen sandal
#

But not relating to extending the Unity editor and thus you probably won't have good results asking in this channel

errant briar
#

Oh ok I thought this was a channel for all unity extensions

waxen sandal
#

(nor in any other channel here since most people won't know about playfab)

#

No, this is for developing editor extensions

errant briar
#

It doesn't yet reach the point of the playfab code, the return for the Google oauth fails

patent pebble
#

As long as I properly dispose of the files when I'm finished using them. Does it really matter what approach to use?

onyx harness
#

Temp folder is not important and can be deleted anytime

#

But specifically for Unity, why dont you use SessionState for process lifetime ?

patent pebble
#

What about runtime data tho?

#

Should I just stick with the Temp folder for that?

onyx harness
#

Yeah, SessionState is editor-only

#

For runtime, stick to whatever you want

#

But there are no domain-reload, it should be easier to maintain data

patent pebble
#

I don't have much experience in this topic, but seems like having more manual control over temporary data doesn't really have any immediate benefits, and it will result in more work (making sure the selected folder exists, manually creating unique file paths, having to clean up orphaned folders when the game is uninstalled, etc)

#

so i guess just using the Temp folder is more reliable?

onyx harness
#

yep, much more

#

Also, the system knows this special folder is temporary

#

When your storage requires space, Temp might be the first one to vanish

patent pebble
#

@onyx harness I see. Thanks a lot for the info! 😋 I was having a little bit of trouble finding info online

deep wyvern
#

Ok I figured out the problem is using the GUILayoutOption in the textArea and setting the height to something fixed. Now I am stuck that the textArea is obviously too large

civic river
#

Heya guys, looking for some insight here. I'm using Undo.RecordObject to add a node to a list when it's created:

            Undo.RecordObject(editorGraph, "graphChanges");
            editorGraph.nodeModels.Add(model);

The problem is, when an undo is performed I have no apparant way to know what changed, so although undo correctly removes the object from the list, it does not destroy it's creation. This effectively creates a memory leak, I suppose I could use two parallel lists and diff them or something, but is their a better way?

#

(Can I add the creation to the same undo maybe?)

#

Hmm, tried something like this but no dice... I'm sure I'm doing this wrong

            Undo.IncrementCurrentGroup();
            Undo.RegisterCreatedObjectUndo(model.RuntimeData, "graphChanges");
            Undo.RecordObject(editorGraph, "graphChanges");
            Undo.CollapseUndoOperations(Undo.GetCurrentGroup()-1);
civic river
#

Yeah, I very much don't understand the undo system.

            Undo.RegisterCreatedObjectUndo(model.RuntimeData, "graphChanges");
            Undo.RecordObject(editorGraph, "graphChanges");

This works, not really sure how grouping works but if anyone's curious you can group undos together... possibly just by string. Not really sure when the group index changes

#

but it is a working solution for the curious

waxen sandal
#

Undo grouping is a bit iffy

#

I think your idea of using group Ids should work but I don't remember that well

#

That said it should also group if the name of the undo operation is the same

onyx harness
#

Your Undo is composed of 2 actions, creation, then adding to a list.
You need them to be grouped if you want your Undo to revert the 2 actions.
Otherwise it would require 2 undos.
Grouping is mandatory for those multi-actions

civic river
#

It undos both in the current setup @onyx harness which is why I was a bit confused

#

it seems like it automatically groups by string though

onyx harness
#

Isn't it what you wanted?

#

If so, then good job :)

civic river
#

yeah, result was unexpected but working is working ;p

patent pebble
waxen sandal
#

Half of that is easily answered by googling + looking at the docs

onyx harness
#

Like 90% of the questions here, isn't it?

waxen sandal
onyx harness
#

Yeah the average knowledge of helpers is higher 😄

sage oyster
#
public static (string a, string b)[] Data2 = Data1 + new (string, string)[] { ("1a", "1b"), ("2a","2b") };
#

how can I make a new tuple array, that includes the first tuple array?

#

its for an editor extension copy/paste across projects

#
public static (string a, string b)[] Data2 = new (string, string)[] { { Data1 },("1a", "1b"), ("2a","2b") };
#

trying a few different things, but i feel this must be easy, not sure!

waxen sandal
#

The same way you combine normal arrays

sage oyster
#

you mean copyto?

#

i suppose i should just use a list

waxen sandal
#

Copy to works, linq works, lists work, manual copying works

sage oyster
#

not so proficient with linq, what would you suggest using link? its on my list of things to learn!

#

*linq

waxen sandal
#

You can just a.concat(b).toarray

sage oyster
#

ah so a.concat(b).concat(c).toarray?

waxen sandal
#

Yeah

sage oyster
#

definately need a bit of that

#

i thought it would be possible to unwrap inside a declaration

#

eg. = ... { data1.unwrap, data2.unwrap };

waxen sandal
#

Nope

sage oyster
#

must be a way though

#

but for now Linq should help in the easiest way, appreciate your help!

#

wanted to make a reversable dictionary, i couldnt think of another way

#

as in key/value, or, value/key

waxen sandal
sage oyster
#

yeh thats what i thought

#

haha

whole steppe
#

hey guys, I can't seem to inherit from the Editor base class so I can create my EnemySightEditor since it comes up with Editor is a namespace which is used like a type. The only thing I can think of is that Visual Studio keeps creating a separate .csproj for Editor scripts (is it supposed to do that?). Here is my code:

#
using UnityEngine;
using UnityEditor;

namespace Assets.Scripts.Editor
{
    [CustomEditor(typeof(EnemySight))]
    public class EnemySightEditor : Editor
    {
        private void OnSceneGUI()
        {

        }

    }
}
onyx harness
#

Namespace Editor

#

Avoid those names

whole steppe
#

yeah, I realised that as soon as I tested that

#

i think i got tripped up because the tutorial I was looking at didn't use namespaces when creating a Editor folder... thanks for the help!

patent pebble
#

is it a bad practice to delete Unity project folders by doing this instead of using AssetDatabase.DeleteAsset?

Directory.Delete(_directoryToCreateDelete);
File.Delete(_directoryToCreateDelete + ".meta");

According to this blog (https://unityatscale.com/unity-meta-file-guide/avoiding-broken-references/):

While moving and renaming assets outside of Unity Editor, doesn’t guarantee reference breakages, it certainly increases the risk of them occurring.
When you modify assets outside of the Editor, there is a possibility that you separate an asset from its meta file. When this happens the Asset loses its GUID and any links to it become broken.
onyx harness
#

Yes.

patent pebble
#

As far as I know with AssetDatabase.Delete, GUID references will automatically be cleaned up

#

but not sure how Unity handles external modifications

#

I've seen editor extensions floating around online that use that external way of deleting empty folders, and I found it weird they didn't use the AssetDatabase

onyx harness
#

They are noobs.

patent pebble
onyx harness
#

I hate myself for saying that, but rely as much as you can on Unity APIs.

#

UWP related

patent pebble
#

right

#

I guess we are eternally bound to playing by Unity's rules

onyx harness
#

We never know if they are going to do stuff under the hood

patent pebble
#

yeah, some day if they decide to fundamentally change how something is handled internally in the Engine, external stuff may become unusable

#

so I guess it's better to play it safe from the beginning to avoid future headaches

onyx harness
#

Yes.

#

They did that already in the past.
Wasn't really impacting the users directly, but it drastically changed how assets were handled

patent pebble
#

hmmm interesting

#

that must've been a massive pain in the ass for asset store devs

onyx harness
#

(The way assets were writen in Library)

#

Only those dealing with assets in Library directly 😄

waxen sandal
#

Tbh, deleting things and creating directories is just annoying with the asset database api so I generally don't

onyx harness
#

(Library back in the time contained extended info about assets, access was easy, now they changed that, my asset NG Missing Script Recovery had to find a new way to efficiently fetch those informations)

patent pebble
#

what I noticed about the AssetDatabase way of doing things is that it's a lot more limited. And you usually need to write a bunch of boilerplate to match what .NET classes can do

#

which is a little bit annoying

onyx harness
#

F*ck Unity, go full .NET 😄

waxen sandal
#

Yeah that's why I just make sure things are refreshed and imported, since j don't want to write that boilerplate

#

It doesn't matter in most cases

severe python
#

Just try making a package manager that does everything right, you dont have the option of using asset database id you're putting files in the packages folder unfortunately

#

Which makes sense with how they intended to use it i guess

neat drum
#

I edited some PlayerPref thing a while ago, and it caused every window to have these weird circles. How do I disable this?

civic river
#

might work for you if that's the problem

#

otherwise might have to walk the registry and clean it manually

quaint zephyr
#

Can someone give me a quickie?

EGL.BeginHorizontal();
EGL.TextField("Label", "Fake Test");
EGL.ObjectField("Obj", obj, typeof(MyObj));
EGL.EndHorizontal();

And the labels still keep their half window space between themselves and the field/object. How can I "compress" that space so that it will have room for the input?

visual stag
#

Remove the labels and substitute your own

quaint zephyr
#

You mean PrefixLabel?

visual stag
#

GUILayout.Label

#

That, or temporarily override labelWidth

quaint zephyr
#

Oh. I'd have to them keep track of the rect cursor huh?

visual stag
#

No?

quaint zephyr
#

Oh. I was confusing that for another class sorry.

waxen sandal
whole steppe
#

hi! i'm having issues with my editor not auto importing things? my intellisense works fine but in cases like this i get no fix automagically

weak void
#

Heyho! I'm developing an editor tool and I'm running into an issue. Im using EditorApplication.hierarchyWindowItemOnGUI to draw icons next to my GameObjects. Is there a way to know which hierarchy window the currently drawing GameObject is part of? I'm using EditorApplication.hierarchyChanged to recalculate which GameObjects should draw which icons. 1 specific icon is only drawn if the GameObject is expanded. The problem is checking what GameObject is expanded. I found some code online and realized that it's activating the current hierarchy window to get it's reference.

{
    // For it to open, so that it the current focused window.
    EditorApplication.ExecuteMenuItem("Window/General/Hierarchy");
    return EditorWindow.focusedWindow;
}```

This is not a good way of doing it, as I'm using the `hierarchyChanged` to recalculate. This means that whenever I type something in an input field inside the inspector, this event is invoked and the `GetHierarchyWindow()` is invoked, activating the hierarchy and thus stop me from typing in the inspector. Besides, multiple hierarchy windows can be active at a time and will all have different expanded states. Any help or tips is appreciated! 😄
onyx harness
# weak void Heyho! I'm developing an editor tool and I'm running into an issue. Im using `Ed...
private static bool            initializeCurrentEditorWindowMetadata;
private static PropertyInfo    current;
private static Type            HostViewType;
private static FieldInfo    m_ActualView;

public static EditorWindow    GetCurrentEditorWindow()
{
    if (Utility.initializeCurrentEditorWindowMetadata == false)
    {
        Utility.initializeCurrentEditorWindowMetadata = true;
        Utility.LazyInitializeCurrentEditorWindowMetadata();
    }

    if (Utility.current == null)
        return null;

    object    guiView = Utility.current.GetValue(null, null);

    if (guiView != null && Utility.HostViewType.IsAssignableFrom(guiView.GetType()) == true)
        return Utility.m_ActualView.GetValue(guiView) as EditorWindow;
    return null;
}

private static void    LazyInitializeCurrentEditorWindowMetadata()
{
    Type    GUIViewType = AssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.GUIView");
    if (GUIViewType != null)
    {
        Utility.current = AssemblyVerifier.TryGetProperty(GUIViewType, "current", BindingFlags.Public | BindingFlags.Static);

        Utility.HostViewType = AssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.HostView");
        if (Utility.HostViewType != null)
            Utility.m_ActualView = AssemblyVerifier.TryGetField(Utility.HostViewType, "m_ActualView", BindingFlags.NonPublic | BindingFlags.Instance);

        if (Utility.m_ActualView == null)
            Utility.current = null;
    }
}
#

I leave you to understand and make it work yourself

#

Basically, you need UnityEditor.GUIView.current.m_ActualView

weak void
#

Thanks, I'll dig though it! What is AssemblyVerifier?

onyx harness
#

My own stuff

#

Replace it with C# Reflection

weak void
#

Got it, thanks!

thin fossil
#

Just found out that Unity addressables is storing its user preferences in the library folder via ProjectConfigData. Havent seen any other Unity editor window/feature do this yet. What do you guys think? Is this an approach worth adopting or are you already using it? I was used to store user settings in EditorPrefs

fickle copper
#

Hello, i am currently having a problem where EditorGUI.GetPropertyHeight() returns false results based on an element in a list as seen here.

#

Here is the code its printing its logs from: ```csharp
private float GetPropertyHeightViaSearch(SerializedProperty property, GUIContent label)
{
_registedPropertyHeight = 0;
float height = base.GetPropertyHeight(property, label) + EditorGUIUtility.singleLineHeight * 2.5f;

        SerializedProperty eventToListenTo, conditions, responseToEvent;
        //         Rect r = position;
        //         _extraHeight = 0;
        eventToListenTo = property.FindPropertyRelative("eventToListenTo");
        conditions = property.FindPropertyRelative("conditions");
        responseToEvent = property.FindPropertyRelative("responseToEvent");

        height += EditorGUI.GetPropertyHeight(eventToListenTo);
        height += EditorGUI.GetPropertyHeight(conditions, conditions.isExpanded);
        Debug.Log($"Property ({property.propertyPath}) contains {conditions.name} with a size of {conditions.arraySize}. Reported PropertyHeight is {EditorGUI.GetPropertyHeight(conditions)}");
        height += EditorGUI.GetPropertyHeight(responseToEvent);


        _registedPropertyHeight = height;
        return height;
    }
#

Help would be much appreciated.

onyx harness
fickle copper
#

Removing said boolean wouldnt change much

#

as seen here: ```csharp
height += EditorGUI.GetPropertyHeight(eventToListenTo);
height += EditorGUI.GetPropertyHeight(conditions);

#

My guess as to why it acts this way is due to the fact that its referencing something that does not exist

#

somehow

#

even though im rendering the exact same variable using the aformentioned variables on the code in another part of the script here:

private void DrawViaSearch(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect rect = position;

            SerializedProperty eventToListenTo, conditions, responseToEvent;
            //         Rect r = position;
            //         _extraHeight = 0;
            eventToListenTo = property.FindPropertyRelative("eventToListenTo");
            conditions = property.FindPropertyRelative("conditions");
            responseToEvent = property.FindPropertyRelative("responseToEvent");

            EditorGUI.BeginChangeCheck();

            GUI.Box(new Rect(position.x, position.y, position.width, _registedPropertyHeight), GUIContent.none);
            EditorGUI.indentLevel++;
            DrawProperty(ref rect, eventToListenTo);
            if (eventToListenTo.objectReferenceValue != null &&
                eventToListenTo.objectReferenceValue is CustomEvent customEvent && !customEvent.isEventGlobal)
            {
                DrawReorderableList(ref rect, conditions);
            }

            DrawProperty(ref rect, responseToEvent);

            if (EditorGUI.EndChangeCheck())
            {
                property.serializedObject.ApplyModifiedProperties();
            }

            EditorGUI.indentLevel--;


            property.serializedObject.ApplyModifiedProperties();
        }
#

DrawProperty is just a wrapper method that encapsulates the EditorGUI.GetPropertyHeight() and EditorGUI.PropertyField methods as well as offsets the position of the next field by the current height:

private void DrawProperty(ref Rect rect, SerializedProperty getIterator)
        {
            rect.height = EditorGUI.GetPropertyHeight(getIterator, getIterator.isExpanded);
            EditorGUI.PropertyField(rect, getIterator, new GUIContent(getIterator.displayName));
            rect.y += rect.height + _spacing;
        }
#

This one works fine in both scenarios as both elements are positioned correctly as seen here:

#

As seen here, i have no idea what exactly is wrong with the code

#

Half of it works and the other doesnt, all without any errors to go over. I am probably missing something very tiny here.

#

I apologise for the huge spam, but hopefully i have articulated my problem well enough to warrant some discussion around it ❤️

onyx harness
#

I feel I am missing information

fickle copper
#

what do you require?

onyx harness
#

You said that conditions is of different heights. Why is that wrong?

fickle copper
#

The list conditions that contains 4 elements is bigger on one list and smaller on the other

#

the 4 elements should collectivily increase the size of the list

#

it does so in the first element of the instance

#

not on the second one

#

meaning that the list goes out of bounds of its own instance

onyx harness
fickle copper
#

RN, i made a workaround by manually calculating the size of the list like so:

float listHeight = (EditorGUIUtility.singleLineHeight * 2.5f) + EditorGUIUtility.singleLineHeight * 1.15f *
                Mathf.Clamp(ConditionsProperty(property).arraySize, 1, int.MaxValue); 
            height += listHeight;
fickle copper
#

For some more context, if you look at the picture, im trying to make a property drawer that draws over a selective amount of event istances.

#

The first event instance works as expected

#

The second event instance is where all the problems are caused

#

Though, this work around has sort of fixed my problem

#

if i were to revert my change, it would look like so.

#

With the fix, it looks like so:

#

You see the problem here? dogWink

tough cairn
#

anyone knows a repo that implements a custom unity event property drawer ? im looking for something that will have a drop down to select the script variable in a drop down form

#

so instead of an input field it would show a drop down and i could select "value" and it will pass it thru

cloud wigeon
#

Hey everyone. I'm having an issue with import settings for sub assets. I have a .asset main asset with a mesh and a texture as sub assets. The assetpostprocessor is only running for the main asset and I can't access the import settings of the sub asset texture. Anyone got an idea how I can change those settings?

quaint zephyr
#

What’s a quick proper way of adding tooltip to GUILayout.Button?

patent pebble
tough cairn
#

How to Invoke UnityEvent without using the inspector value ?
i want to Invoke( myArgument ) but instead its using the value set in the inspector

quaint zephyr
#

In my custom editor script I have a small form that entails adding/generating a new material. When you click generate it will create a new material via script then when you submit the form it will save the material to assets.

When a material is generated I want to display the material inspector on the bottom half of the same inspector window so that I can edit it’s attributes without having to do it separately in another inspector window. Kind of how UI Image and other components show the material attributes below in the same window. How can I accomplish this?

rigid ledge
#

so im checking out the graphview api (roughly following along the graph tutorial in the pins)
i created 2 nodes, with a in/out port each but i cant connect them, the port lights up when dragging a connection to it but when letting go it just disappears, is there anything im missing?
https://hatebin.com/wlhamovmgw

#

i tried the GetCompatiblePorts override with code in the video as well as just returning all available ports

patent pebble
#

but if I remember correctly material/shader editors work different, so I'm not exactly sure how you would do that

quaint zephyr
#

Woah! Sick! I got it to work! It's easier than I anticipated! Thanks @patent pebble

quaint zephyr
#

Thanks I'll check this out

patent pebble
#

so instead of something like this:

Editor tempEditor = Editor.CreateEditor(targetForNewEditor);
tempEditor.OnInspectorGUI();
DestroyImmediate(tempEditor);

you would make it like this

Editor tempEditor = Editor.CreateEditor(targetForNewEditor);
DrawFoldoutInspector(targetForNewEditor, ref tempEditor);
DestroyImmediate(tempEditor);
quaint zephyr
#

Not quite sure what to put in the second param editor for this one.

#

Oh

#

Thanks

#

What is the difference?

#

Better performance? or what?

patent pebble
#

makes a foldout header, no idea about performance

quaint zephyr
#

Well the way I did it too also shows the foldout, see the screen

#

OH!

#

Like as if it's a different component

#

I get it.

#

That's cool!

#

Not what I need in this case, but definitely will keep that handy! Thank you!

patent pebble
#

I've never played around with nested material editors so I don't know if the default material foldout does the same

#

just thought it was relevant to mention 🙃

quaint zephyr
#

Indeed it was

#

In the first method, before you draw OnInspectorGUI you just DrawHeader first and it does the magic for you.

patent pebble
#

I just tested with DrawHeader for my example with nested transforms. It does the header but doesn't add a foldout functionality

#

does the material editor have a working foldout?

#

I see the little foldout triangle in your screenshot, but does it fold?

quaint zephyr
#

Yeah mine works as expected.

#

It folds properly. And even lets me select shader as well!

#
    private void DisplayMaterialEditor()
    {
        if (_materialEditor != null && _materialEditor.target != null && _materialEditor.target as Material != _selectedMaterial)
            DestroyImmediate(_materialEditor);
        if (_materialEditor == null)
            _materialEditor = CreateEditor(_selectedMaterial) as MaterialEditor;
        
        
        Divider("Material Editor", -50f);
        EGL.LabelField("EDITING MATERIAL:", _selectedMaterial.name);
        EGL.Space();
        _materialEditor.DrawHeader();
        _materialEditor.OnInspectorGUI();
    }

Here is my code.

patent pebble
#

ah interesting

quaint zephyr
#

How can I GetControlRect without moving the cursor? I want to do two things while sticking strictly to EditorGUILayout and GUILayout classes when building inspector: 1) I want to color the background of certain groups of elements, like it was its own container, and 2) I want to calculate the height of certain groups of items to determine if I want to switch to "pagination" or "scroll view" otherwise default.

quaint zephyr
#

If I have a scriptableobject that has a reference to another asset that's a component or something like Material. If I modify the material, is merely SetDirty(myScriptableObject) enough? Or do I need to mark dirty the reference as well like so SetDirty(myScriptableObject.materialRef)?

visual stag
#

they are separate objects

#

and need to be dirtied separately

quaint zephyr
#

Thanks @visual stag . And thank you for the last input as well, I didn't leave a thank you for it before.

visual stag
#

I would advise using the Undo.RecordObject functions if you can over SetDirty btw

quaint zephyr
#

Undo.RecordObject persists a save past editor sessions as well?

visual stag
#

Yes

quaint zephyr
#

Oh wow. Awesome. Yeah I didn’t know about that. I think I will reformat my project with this. Thanks again man.

visual stag
#

SerializedObject, Undo, and SetDirty are the 3 ways to dirty objects

#

and I'd probably try to use them in that order for GUI-related editor stuff

#

if it's not really something in the GUI, like actions caused by a button then Undo is ideal

#

SetDirty is the least ideal and is generally only good for cases the other two don't handle

quaint zephyr
#

Ty ty

rigid ledge
inner folio
#

I have a bunch of assets. In this case, they are .SVG files; but they could also be .FBX or anything else that results in this "package" type.

I want to automatically add some components to them.

So... I'd like to postprocess these on import, so I don't have to manually turn each one into a prefab. What's the way to do this in Unity 2020.2 and later?

More of a google / what to look for project than a "how" problem at this stage. 🙂

#

Thanks in advance for your help 😄

#

They are some kind of prefab, but... not really editable.

Do I have to spawn variants from them?

visual stag
#

They are a model prefab

#

which is a prefab generated from a source model asset

inner folio
#

Yep.

visual stag
#

they're read-only because they are derived from the source

inner folio
#

Yes I'd like to add something to that because it should be tied to the source.

visual stag
inner folio
#

Ok but I can add components on postprocess I guess?

visual stag
#

I'm unsure whether the SVG importer calls this method

#

I assume so - I've not done it myself

inner folio
#

problem is, this isn't really a model (it's a SVG / Vector sprite), so I'll have to see if these methods apply.

visual stag
#

They have an example adding a mesh collider

inner folio
#

Cool.

#

Thank you, I'll try this way.

#

Ah yeah, but... what does the asset postprocessor work on? Is this a per-folder thing? Per-preset? Can I have importer presets for these?

visual stag
#

it works on everything

#

I'm unsure how presets interact with them, again, I haven't actually done any of this, I've only made my own importers

#

I think you can use OnPostProcessAllAssets regardless to do whatever you want, including creating additional prefabs

#

but you'll have to filter out what you want to operate on

inner folio
#

Yeah it works for "models" in the classic sense, .obj, .fbx, but it doesn't trigger for SVG.

#

I'll keep digging.

visual stag
#

you may also be able to just override that

inner folio
#

Because I wouldn't understand how to extend and then use it.

visual stag
#

it's a ScriptedImporter, so you can look at how that works, and glance at their implementation

inner folio
#

ScriptedImporters are cool but seem to trigger by file extension.

visual stag
#

Yep, but that works for you, no?

inner folio
#

In this case, not really. I'd more like need to do it by asset label / folder / addressablegroup [yes that would come later but this is one thing I want to set, plus populate some legacy animations]

#

But I have a good start, Thanks @visual stag

#

Well, getting there.

visual stag
#

oh, that makes sense

#

I am not sure if there's a good way around that one haha, worth a google

inner folio
visual stag
#

I'm not sure presets can do anything other than setting values on importers, but I might be wrong

inner folio
#

Yeah I mean more about the AssetPostprocessor, but... scriptable importers are mostly excluded.

#

Also, wow, Bolt really messes up Unity (I mean the new VisualScripting package that seems to be installed by default since recently - adds a "AddComponent" extension to just about anything Unity APIs return to you).

#

(and then fails at runtime with an exception that the method is not supported)

#

Wowee.

visual stag
#

I remove everything I can in new projects

inner folio
#

I try to keep defaults because it used to mess up things in the past.

visual stag
#

sad they're bloating it, but I suppose it's good for new users

inner folio
#

Should probably reevaluate that.

#

I think visual scripting is perhaps okay to have; even though I feel it's a dead end. But I ate my words only recently and now use ShaderGraph and VFXGraph a lot, and with passion. But shaderlab was and is a mess 😄

inner folio
#

Uhhhhhhhh.... I just realized that the color swatches take and display gamma values, but pass on linear?

#

Is there an option to have it display in linear (e.g. raise the brightness) or to have it interpret the Hex code as linear upon entry?

#

Because if I go to coolors.co (or the like) to make a palette... those unity treats as gamma values in editor, but as linear in the renderer. Yikes. ShockedBlushEmbarrass

inner folio
#

Wow this is so weird, I feel I must be doing something wrong.

tough cairn
#

is there a way to get Unity type from string ? my classes seem to work when using Type.GetType( full_name ) but for unity it will return Null

onyx harness
#

Of course

tough cairn
#

can you tell me why ?

onyx harness
#

Probably full_name is wrong

tough cairn
#
Debug.Log("FullName: " + typeof( Transform ).FullName );
Debug.Log( "GetType: " + Type.GetType( typeof( Transform ).FullName ) );
            
Debug.Log("Assembly: " + typeof( Transform ).Assembly.FullName );
Debug.Log( "Assembly.GetType: " + typeof( Transform ).Assembly.GetType( typeof( Transform ).FullName ) );
#

1st one isn't working

onyx harness
#

🙂

#

Because Type fetches from the executing assembly. Which is the editor assembly.

#

typeof(Transform) is the runtime assembly.

tough cairn
#

i see

#

so UnityEditor.* and UnityEngine.* are the same assembly ?

onyx harness
#

Or you can force it and use the "UnityEngine.Transform,UnityEngine" as input

#

No, they are not the same precisely

onyx harness
#

Well, try with ",CoreModule" then

tough cairn
#

Type.GetType( typeof( Transform ).FullName + ", " + typeof( Transform ).Assembly.FullName )

#

doesn't always work

tough cairn
onyx harness
#

Use AssemblyQualifiedName

#

A proxy name.

tough cairn
#

no AssemblyQualifiedName ?

onyx harness
#

AQN is from Type

#

Replace FullName

tough cairn
#

so "Transform,AssemblyQualifiedName" ?

#

sorry i don't see where to get it from

onyx harness
#

I said replace FullName

#

typeof(Transform).AQN

deep wyvern
#

Does anyone know how to make Asset Icons render sharp in the editor? Like the scriptable object Icon looks sharp but when I replace the Icon for a certain scritpable object the new Icon looks very pixelated even though its 512x512png and Import settings should be correct

tough cairn
#

oh

onyx harness
#

@deep wyvern probably your Texture not correctly setup

deep wyvern
onyx harness
#

Filter Mode > point

deep wyvern
#

That didn't do it but lowering the resolution of the original texture helped

split bridge
#

Probably you want to generate MipMaps with a larger source file

inner folio
#

Damn. I would really like to replace the color pickers with my own.

waxen sandal
#

Can probably make a custom drawer for color that then draws your own

inner folio
#

Yeah I guess. 🙂

quaint zephyr
#

Why would code analysis give me this warning: avoid base.OnGUI() when deriving from PropertyDrawer?
Here is my code:

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        Type propType = fieldInfo.GetValue(property.serializedObject.targetObject).GetType();
        if (propType == typeof(long))
        {
            DateTime createdAt = new DateTime(property.longValue);
            EditorGUI.LabelField(position, label.text, createdAt.ToDateTimeString());
        }
        else
            base.OnGUI(position, property, label); // analysis warning triggered here
    }

Basically if the propertyType is not long, just perform default draw is all.

onyx harness
#

Because it is dumb

#

And what is the warning exactly?

#

And who warns?

proud sedge
#

Does anyone know how to access a gameobjects public functions via property drawer. My case I want a user to select a gameobject and select a function via drop-down

    public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
        EditorGUI.BeginProperty(position, label, property);

        var startTriggerRect = new Rect(position.x, position.y + 60, position.width, 16);
        SerializedProperty startTriggerProp = property.FindPropertyRelative("StartTrigger");
        EditorGUI.PropertyField(startTriggerRect, startTriggerProp, new GUIContent("Start Trigger"));
        
        if (startTriggerProp.objectReferenceValue != null) {
            // Start Trigger is the obj I want to access its functions
        }
        EditorGUI.EndProperty();
    }
#

someone online mentioned using a MethodInfo List and get the MonoBehavious component off the object

#

but my class is inheriting from PropertyDrawer not monoBehaviour so I can't access that

quaint zephyr
visual stag
#

@onyx harness @quaint zephyr

#

(that top screenshot should be highlighting "Why is Rider suggesting this?")

#

if you want to just draw the default property, just use a PropertyField

quaint zephyr
#

Oh! I see.

#

Thanks @visual stag once again you steer me right 🙂

quaint zephyr
# visual stag

How come I don't have EditorGUI.DefaultPropertyField? I just have PropertyField.

visual stag
#

because it's internal?

quaint zephyr
#

Oh LOL

#

oops

#

@visual stag IYHO, is using var just bad practice?

visual stag
#

no?

quaint zephyr
#

Why question?

visual stag
#

because it's a silly question

quaint zephyr
#

my bad

visual stag
#

You can look at microsoft's standards to figure out appropriate practice

#

and people will disagree with them

#

because programmers are conceited fuckwits

quaint zephyr
#

🤣 Whew, I thought I was doing something wrong. I can't tell you how many times I saw in chat people dissing because they see people using var. You are the first to disagree with it. It's why I asked.

quaint zephyr
#

In Rider, when using Code -> Inspect Code... and ticking Custom Scope option, does it follow a different format that the Settings -> Scopes does? I can't figure out how to use properly.

visual stag
#

I have no idea what that is

quaint zephyr
#

No worries. Thanks anyways!

visual stag
#

seems like you just type in what you want and it suggests

quaint zephyr
#

Yeah, but I was hoping to run a solution-wide inspection but on a custom "scoped" so I don't get a report from plugins, and scripts I didn't write.
If you navigate to Settings -> Appearance & Behavior -> Scopes There you can setup your own custom scopes, which is VERY convenient want I want to search for a file without extra clutter. I have it broken down into a couple categories. Anyways, I thought that the Inspector's Custom Scope followed the same convention but it seems that is not the case. I wish it would let me use my own custom scopes I defined in the settings, it would be really nice.

#

Sorry I hope you don't mind me picking your brain. If I have some nested loops that iterate (cumulatively) several thousand times, is it wise to declare the variables that they use outside their scopes (I assume to prevent build-up of garbage; new variable in memory per loop)? Or does C# consider this.
For instance,

var a;
var b;
var c;
for loop
  // assigns, uses a, b, c
end loop

vs

for loop
  var a = blah;
  var b = so and so;
  var c = something;
end loop

@visual stag

visual stag
#

I have no idea

quaint zephyr
#

ok

quaint zephyr
onyx harness
#

You said cumulative, but you can't sum if your variable is reset in the loop.

quaint zephyr
#

I’m just wondering about memory allocation.

stark geyser
#

Compiler optimizes them. There was mentioned somewhere that in debug mode it doesn't.

onyx harness
snow bone
#

I have an editor window and I'd like to have a box that I can drag an asset from the project window into, any ideas how i can do this please?

snow bone
#

@onyx harness Could you be just a little less vague please

#

I found something that can help me, thank you for your suggestion

deep wyvern
#

Is the box supposed to be an object field?

snow bone
#

I sorted it. I found a post about drag & drop. I wanted to drag a project asset into an inspector, so that I could interrogate the .meta file

tough cairn
#
NullReferenceException: Object reference not set to an instance of an object
UnityEditorInternal.ReorderableList.get_count () (at <afa9f07022084fb2b65f56c776d2e220>:0)
UnityEditorInternal.ReorderableList.GetListElementHeight () (at <afa9f07022084fb2b65f56c776d2e220>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <afa9f07022084fb2b65f56c776d2e220>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <afa9f07022084fb2b65f56c776d2e220>:0)
RelayBase+RelayBaseDrawer.OnGUI (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Core/Signals/EventsEx/Relay.cs:184)
#

im getting this on the following line ( Relay.cs : 184 ) :

reorderableList.DoList( rect );
#

tried to add debug points inside the reorderableList.elementHeightCallback method but it won't reach it

#

( not sure if its even related to the error )

onyx harness
onyx harness
tough cairn
#

wdym interrogating

onyx harness
#

I would look at the source code if I were you

tough cairn
#

its mine , i can post it if u don't mind looking at it

onyx harness
#

Source code of ReorderableList

tough cairn
#

oh true that

onyx harness
#

it fails at get_count()

tough cairn
#

forgot its open source

onyx harness
#

doesnt sound hyper complex

tough cairn
#

not sure if i can fix that , m_Elements and m_ElementsList both are null , guess ill try a different contractor instead of serialized object

onyx harness
#

DoList requires a list. This is pretty straight

tough cairn
#

or not

#

😄

onyx harness
#

an array?

tough cairn
#

idk it worked b4 with a serialized object

#

it must had some cached data before , last time i used it it was ok , now after project reload it fails

#

i created ReordableList2 and new count method

#

used reflection to check what's bad