#↕️┃editor-extensions
1 messages · Page 81 of 1
It definitely shows borderless 😛
Milkilo is it better to add fences to pathways but like small ones that make the game look more detailed
This question is about taste, am i wrong?
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)]
I dont even see the use of an attribute
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
Well, then you need to use your attribute
yeah that's what I'm asking how to or any example code to understand
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
Are you sure you derived your drawer from DecoratorDrawer and not PropertyDrawer?
Is there a good way to do ellipsed text in UITK? I haven't been able to find anything.
yeah thanku. my bad that was the issue. but now I have the spacing issue. how can i adjust it? using rect's height or y properties make it go behind the fields under it
can it be used within decorator drawer? since OnGUI doesn't take any other parameter except rect
and i suppose GetPropertyHeight needs serialized property parameter
GetHeight
ooo works like charm. thanku!
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.
Changecheck
@onyx harness I was mistaken, I'm using ShowAsDropDown and not ShowPopup
Huehuehue
I made a simple Scripted Importer to learn how they work.
How can I make the fields on the imported object editable?
Here's my code:
Example (the asset type I import) - https://hatebin.com/nttlydsjio
ExampleEditor (the custom editor for the asset) - https://hatebin.com/vfqnkbwrqp
ExampleImporter - https://hatebin.com/mzyejohydh
ExampleImporterEditor (the custom editor for the importer) - https://hatebin.com/drmplyhcyj
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?
Im trying to create a new gameobject as a child of the currently selected GameObject in the hierarchy. How would I code this?
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``
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
@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
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)
@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
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)
@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?
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
You can put anything in the Drag, it's all up to you
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
Pretty much everywhere
GltfUnity2019_Animated_Glb_Scr_Ani https://media.discordapp.net/attachments/811660405906604092/813498327274487818/GltfUnity2019_Animated_Glb_Scr_Ani.gif
Any way to have an EditorGUILayout.TextField have a max length of a certain number of characters?
From one package, how do you reference assemblies from another package and keep them?
Just see if the string length is greater than max length and if it is get a substring from it of he max length that you want.
How about starting the Text Field more to the right to prevent cutting off the Field's name?
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
Are there any good resources on how to create a custom graph inspector. I am not wanting the GraphView api that is used with the shader graph. Rather something like what this asset does https://assetstore.unity.com/packages/tools/visual-scripting/behavior-designer-behavior-trees-for-everyone-15277. They are drawing some nodes in what looks like some type of graph view but is this actually something provided by unity editor?
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
Why do you want to not use GraphView? Just because it looks like shadergraph? You can create vertically oriented ports in graph view iirc. You would just pass Orientation.Vertical to InstantiatePort
Oh I had no idea. looking at the API it wasnt clear
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
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
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.
Make the base method virtual
appreciate it. that actually fixes several other issues..
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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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)
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?
Are both fired when the Drag is completed?
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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Since the beginning we are both talknig about different things
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
To clarify. MouseDrag is only fired when the mouse moves and a button is held down.
MouseUp is called every time the mouse button is released. This is the case for an end of a drag or a regular click.
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
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?
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
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? 🤔
I believe that the button calls the ApplyModifiedProperties() method itself.
oh really? Is there any way to hook into the buttons to add my code to it?
Use ReoderableList instead 😛
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?
Reorderable is pretty widely used
I mean the property drawer for the lists/arrays is just a wrapper around the ReoderableList. It is literally called ReoderableListWrapper.
oh I see, I guess it's finally time to learn how to use Reorderable Lists
thx for the info 😊
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
Just delay your save yourself
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
how would I go about doing that in a simple way?
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... 😅
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
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 😓
Or you have this one as well:
https://ngtools.tech/uv/UnityEditor.EditorApplication/update/
Type : public sealed class UnityEditor.EditorApplication
3.4.0f5 ⟩ 2021.2.0a5
Unity Doc
Field : public static update
Unity Doc
3.4.0f5 ⟩ 2021.2.0a5
GitHub Source
I could also use EditorCoroutineUtility
but I don't know the implications of using that
I assume it's just like runtime coroutines? 🤔
Why is the gap here in this textfield so wide?
This is how wide the entire thing is.
This is my code
@nocturne geyser are you using EditorGUIUtility.labelWidth anywhere in your code?
no, I wasnt able to properly figure out how to use it
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
So like
EditorGUIUtility.labelwidth(someinteger)
TextField
TextField
TextField
EditorGUIUtility.labelwidth(0)
EndHorizontal()```
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
Having to reference a package
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
Yeah seems a little bit counterproductive... Unity being Unity i guess 🤦♂️
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
the names are pretty self-explanatory
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
defaultBehaviours?
No use the delegate onAddCallback
I never touched defaultBehaviours
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
Ok ok
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
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.
Uhh look at the show modes of editor windows there's probably something there
I got it to work using reflection to get the ShowPopupWithMode method. Only problem now is that when I click the main window the popup goes behind it. Would be nice if I could set the depth some how.
is there a way to edit build in vfx nodes ?
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?
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.
If it freezes, it is frozen
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.
Revisiting the Inspector (Poke me to join the future open beta of NG Flow Inspector)
#madewithunity #indiedev @AssetStore #unity3d #gamedev #ngtools https://t.co/gB74rQwqqE
Yeah that. I am trying to make a tooltip type window.
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.
I guess you were fooled by its display, but its a simple EditorWindow that I stick to Inspector, and right after creating it, I put back the focus to the Inspector
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
I mean, I figured it was a simple EditorWindow. Which method do you use to display it? ShowPopup()?
Is it borderless that you are seeking?
Borderless, show on top of window, and not close when it loses focus of course.
I am not quite sure what you are saying your problem is. But just fyi there is EditorWindow.mouseOverWindow which may help you.
To have a borderless:
Editor.CreateWindow
set min/maxSize
ShowPopup
but the editorwindow has to get sceneView
If Im not mistaken, any window is always on top, it cant go behind. if it does, it s bug.
Not my custom editor @gloomy chasm
A window wont close until you close it.
You might be confusing with PopupWindowContent.
Im not confusing it with a popupwindow.
Sorry I forgot to 'answered' MechWarrior
hahaha its fine im sorry. didnt notice
I was referring to the ShowAsDropdown styling.
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!
Can you elaborate on what the issue you are having is?
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
Just do a check if(EditorWindow.mouseOverWindow.GetType == typeof(SceneView)) or whatever. I think that should work.
windows = Resources.FindAllObjectsOfType(sceneviewtype)
if mousePosition in window
do
mouseOverWindow is also a good track
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
mouseover window worked.
Thanks man
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
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.
That was the idea. Thanks man
@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?
Are you on mac?
Nope.
See, it is behind it. This is not a problem if the main window is docked though.
Oh well. The internal method works just fine, I just prefer to not use internal things when I don't have to.
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?
Well it works fine, but id say you dont need to draw your own rect. you can use unity visual elements. Then all you have to do is declare a Box element and done. you can style it use Ucss which is unities version of Css, but thats still in preview so you can use Box.Style to modify height,width,flexwrap,etc..
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
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
Fixed
yall know where to find probuilder in unity 2019
In the package manager?
It wouldnt show for me but i just had to verify my acount
already got it fixed thanks tho!
How would I go about changing how my syntax is auto-generated from next-line syntax to same-line syntax?
This is just a general Visual Studio question that doesn't actually have to do with Unity or editor extensions. Google would be a good place to look for this info. But here is the Microsoft docs on it https://docs.microsoft.com/en-us/visualstudio/ide/code-styles-and-code-cleanup?view=vs-2019
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.
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)
I feel like that's not the intended way to use HandlePosition but I've never used it myself
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)
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
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 🙂
Likely yeh. Fine for this circumstance, I just needed basic movement, im doing rotation on an increment with hotkeys
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
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
Freya Holmer has a tutorial for a snapping Tool iirc, will share a link later
oh damn, her stuff if amazing. Im on her patreon, so ill have a scroll through
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
Think i got it!
Ill have a watch through later tonight, see how it goes 😛
3h 40m is a trek haha
yeah in the next video she finishes it https://www.youtube.com/watch?v=limzVQFUMag
@plucky nymph ok so here's a simple Tool that just moves objects along the global X axis
https://hatebin.com/mparzwtmgh
and here's another Tool that moves objects on the global X/Z axis. This tool uses a custom Handle
The Tool - https://hatebin.com/wofgenzkqp
The custom Handle - https://hatebin.com/efvyzkqsca
The static class to access the custom Handle - https://hatebin.com/cubqlovjqq
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
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
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?
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.
@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.
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
Glad to hear it works for you. If you have any questions feel free to ask me 🙂
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
I appreciate the offer but I find it hard to work when on a call with people.
understandable good luck man. thanks again
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.
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?
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?
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
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
It's probably different between objects that persist between assembly reloads and those that don't
What do you mean it is too unoptimized? It is the same as running something in OnGUI as far as I know. What are trying to do that would cause such issue?
probably yeah. From what I've seen, script's instance IDs seem to survive assembly reloads
@gloomy chasm well right now im just debugging the info it gets. but the frames are dropping like hell when i let it run.
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
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
"cpp"?
oooh, right
Well you are clearly doing something besides just a debug.log on the hit info...
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.
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.
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
yea thought so too. I think the issue is coming from my main script. Tpbrush_Main
Ima see what i can do
@gloomy chasm
Yes, that is 100% the case and what I just said 😛
I looked at the source to double check, and it is a fact that duringSceneGui is simply called in the OnGUI method of the scene view.
@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
I have no idea what you are talking about, but it sounds like you got it working for yourself!
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
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?
Well i already understood that. thats why im unassigning it by using -=
still not doing that. or am i missing something?
Well, it is possible to add the same method multiple times. So if you have done that, then you would also have to remove it multiple times.
Otherwise it would still be calling the method even if you removed one.
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
Just do the checks in the duringSceneGui method, it should be very little overhead unless you are doing a lot of pre-calculations.
But again, I don't know what all you are doing so it is hard to give advice.
understandable
I have no idea what reference you are talking about so I can't help you.
well im referencing a method to the duringsceneGUI
Yeah, so I am pretty sure you are doing something wrong/improper. When working with events, you want to have a specific point where you add to the event, and remove from the event. Like if you are activating a tool, you would just do that once. Not every frame.
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
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.
I think zTest should work https://docs.unity3d.com/ScriptReference/Handles-zTest.html
I will give it a try i was under the impression it was only used for z sorting the handles themselves
The example it shows literally uses Handles.DrawLine 😉
Yeah that does it @gloomy chasm thank you
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.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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?
Is there any way to properly place my settings SO in the ProjectSettings folder?
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?
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
here's an example of a custom handle cap I made to learn how they work
https://hatebin.com/vneswmvmps
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);
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
@timid sapphire https://docs.unity3d.com/ScriptReference/PrefabUtility.PrefabInstanceUpdated.html this can work
depending on what you want to do
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 :/
what I linked gives you the instantiated gameObject
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 🤔
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
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)
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 😕
Is it possible to draw a rect to a EditorWindow?
Found it. EditorGUI.DrawRect
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?
It is a bit hard to see what is going on partly because of the colors. But the problem may be because of the label width?
Yeah sorry, here is without the debug colors.
Whats the easiest way to decrease that width?
Would I have to create a new EditorStyle for that or is there an easier way?
Nope! Just change EditorGUIUtility.labelWidth = myNewWidth. Just make sure to cache the current value before you change it and then change it back to the cached value once you are done with it!
Seem like a neat little trick! Ill try that
It worked! Thanks!
With Editor Programming there are all these really useful and neat tricks that are impossible to know unless someone told you ^^
Yeah, and it doesn't help that there are so many places to look to find something EditorUtility, EditorGUIUtility, GUIUtility, EditorGUILayout, GUILayout, GUILayoutUtility lol.
Yeah exactly 😄
Sometimes wants to make me bang my head on the desk
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
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
seems maybe my project was corrupt, doing a re-import all fixed the issue
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 ?
the problem is that i want to be able to drag this :
into the drawn option
I have no idea what that is
an animation controller
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 ?
ok thanks you i guess i need to learn how to document myself with unity since i'm still preaty new to it
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?
@severe python runtime code or editor code?
straight editor code
for an EditorWindow specifically
i think this also works https://docs.unity3d.com/ScriptReference/Event-modifiers.html
yeah, thats absolutely what I'm looking for, I can't believe I just forgot that and couldn't figure it out with google...
oh forget about the function key, it's this one https://docs.unity3d.com/ScriptReference/Event-control.html
In a context less GUI-related, you can give a try to :
https://ngtools.tech/uv/UnityEditor.EditorApplication/modifierKeysChanged/
Type : public sealed class UnityEditor.EditorApplication
3.4.0f5 ⟩ 2021.2.0a5
Unity Doc
Field : public static modifierKeysChanged
3.4.0f5 ⟩ 2021.2.0a5
Unity Doc
GitHub Source
@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}");}
oh nice, didn't know about that one
I actually know all about Event and how to use it... it just totally left my brain for the past 20 minutes entirely
happens to me often 🙃
This is what I thought
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?
This actually won't give you access to an instance of event, it just lets you know they've changed so you have to repaint your window and check the Event
I doubt anyone has any examples, normal editor code should work though. Are you sure you're using serializedproperties or calling Undo.RecordObject properly on your object?
Pretty sure as I've used the exact same code before on older versions (pre-volume component). Unless this looks wrong for example:
useColorCorrection.value.boolValue = EditorGUILayout.Toggle(colorContent, useColorCorrection.value.boolValue);
And the weird thing is, as soon as I add in just "PropertyField(whateverVariableHere);" line, then my custom field (like that above) suddenly works
What type is useColorCorrection?
SerializedDataParameter
Are you doing apply on the useColorCorrection.value serializedobject?
I believe so,
serializedObject.ApplyModifiedProperties();
Where's serializedobject coming from?
from the target in the inspector - it's the same reference I get the SerializedDataParameter variables from
Can you show more code? I'm not familiar with SerializedDataParameter so just trying to figure things out
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);
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
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 😄
SetDirty is redundant there, iirc Apply will override in this scenario
You can also use https://docs.unity3d.com/ScriptReference/Editor-serializedObject.html instead of creating your own
Actually, you're using 2 different serializedObjects
serObj = new SerializedObject(target);
var prism = new PropertyFetcher<PRISMEffects>(serializedObject);
good call
and yeah I also have tried using the inbuilt serializedobject
no bueno either
What happens in Unpack?
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
0.o
yeah don't get me started on why they added that haha, but I know for sure those unpack lines all work as intended
Do you have docs relating to that?/
I would definitely start by removing your serialized object if you haven't done that
Thanks, and yeah done that atm
oh and of course the undocumented "Draw Override Checkbox" works
?
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(?)
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
I think you might've been using the wrong property, think property.overrideState is the correct one
That sounds like it could be it 👀 Will investigate
^
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;
Interesting
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);
}
}
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)
Hence the non GUI-related, you handle that externally
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?
Just put the MenuItem attribute on a static method
I think the menu path is Assets/Create/My Item
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
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?
@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
Thanks
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?
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:
I would create a new GUIStyle based on (GUIStyle)"Button" and modify it
The guiskin is being applied to the toolbar
and pass that into the button
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
I'm not sure tbh, I don't tend to use GUI.skin
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
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
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 🙂
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.
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
Was hoping for it to work in the build as well
Not exactly caching the animation, but caching the vertex positions/normals and triangles
the goal is to record on high end system, play on low end system
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
Yeah, only recording in the editor not in the build
But the editor values still get lost after compiling
Unless you're doing createinstance or your SO is in memory only then it shouldn't
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 
can't place where I'm going wrong. https://hatebin.com/fjdvpzjawt
^ resets on compile
Blame odin
🙁 I gotta get rid of Odin completely for this to work?
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
just tried that, it reset..
What unity version?
2019.4
Should work
here's the entire thing in action
@waxen sandal ^ if you see anything wrong. gonna try a fresh project without odin though
Did I jsut see that your fields are itnernal?
None of that is serializable
^
Dictionaries, not serializable by default.
If it doesn't appear in the inspector, Unity is not serializing it
Unless you have HideInInspector or have a custom editor
by default
Or odin does stupid shit
or a property drawer, or blah
Still not getting it tbh. So, if Unity doesn't serialize it, it doesn't save it?
that's what serialize means
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
Odin will serialize dictionaries with their serializable monobehavior and such
But it doesn't work with Prefabs

The talk a bit about it here, and have a template you can use to get Unity to serialize a dictionary too: https://odininspector.com/tutorials/serialize-anything/serializing-dictionaries
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?
Or let odin do it for you
and mark your fields as serializefield too so they actually serialize
Got it working. Making them public + Serialized actually made the data persist, danke @visual stag @waxen sandal 
public fields are already serializable by default, don't know about Odin
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?
Unity does not support serializing interfaces on Unity Objects.
Here you can read about serialization in Unity: https://docs.unity3d.com/Manual/script-Serialization.html
And here you can read about the polymorphic serialization that unity does support: https://docs.unity3d.com/ScriptReference/SerializeReference.html
thanks
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?
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
I've been using it for awhile, no complaints. But I also haven't had occasion yet to do any branching etc.
Im keen to use the shelving feature, because that seems suuuper useful
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
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)
This is called an extension, but you can't extend static, can you?
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
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
hmm I see, I'll look into that
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.
Do you guys know if the animation file can be sent?
Wrong channel, sounds like you should ask on some playfab server
What does this mean
My friend helped me out with the animation with another file
I wanna compile it with my file if thats possible??
I don't know of any playfab servers that exist. In any case, it's Google oauth not working with unity on Android
It's still a Unity question
But not relating to extending the Unity editor and thus you probably won't have good results asking in this channel
Oh ok I thought this was a channel for all unity extensions
(nor in any other channel here since most people won't know about playfab)
No, this is for developing editor extensions
It doesn't yet reach the point of the playfab code, the return for the Google oauth fails
Digging around the .NET docs I stumbled upon this https://docs.microsoft.com/en-us/dotnet/api/system.io.path.gettempfilename?view=netframework-4.0
And it made me think about how to handle single-session temporary data for Editor tools (or single-session runtime data for that matter).
What would be the differences between:
vs
Keeping temporary data in a manually selected folder and manually creating temporary files```
As long as I properly dispose of the files when I'm finished using them. Does it really matter what approach to use?
Temp folder is not important and can be deleted anytime
But specifically for Unity, why dont you use SessionState for process lifetime ?
Oh, interesting, didn't know about the SessionState class. Seems pretty neat!
What about runtime data tho?
Should I just stick with the Temp folder for that?
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
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?
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
@onyx harness I see. Thanks a lot for the info! 😋 I was having a little bit of trouble finding info online
https://pastebin.com/KmMjvFTt
So am I missing something obvious or why isn't that scrollbar scrolling?
It shows both the text area and the scrollbar but the scrollbar doesn't work whatsoever
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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
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);
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
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
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
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
yeah, result was unexpected but working is working ;p
better ask in #🔀┃art-asset-workflow , this is not the channel for that question
Half of that is easily answered by googling + looking at the docs
Like 90% of the questions here, isn't it?
I like to think that #↕️┃editor-extensions is a bit above the average here
Yeah the average knowledge of helpers is higher 😄
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!
The same way you combine normal arrays
Copy to works, linq works, lists work, manual copying works
not so proficient with linq, what would you suggest using link? its on my list of things to learn!
*linq
You can just a.concat(b).toarray
ah so a.concat(b).concat(c).toarray?
Yeah
definately need a bit of that
i thought it would be possible to unwrap inside a declaration
eg. = ... { data1.unwrap, data2.unwrap };
Nope
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

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()
{
}
}
}
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!
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.
Yes.
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
They are noobs.
at first I thought using Directory would be fine too, since they have this in the docs https://docs.unity3d.com/ScriptReference/Windows.Directory.html
I hate myself for saying that, but rely as much as you can on Unity APIs.
UWP related
We never know if they are going to do stuff under the hood
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
Yes.
They did that already in the past.
Wasn't really impacting the users directly, but it drastically changed how assets were handled
(The way assets were writen in Library)
Only those dealing with assets in Library directly 😄
Tbh, deleting things and creating directories is just annoying with the asset database api so I generally don't
(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)
I mean, I guess for creating files and directories it shouldn't be a problem. But I'm scare of deleting things and breaking references and stuff
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
F*ck Unity, go full .NET 😄
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
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
I edited some PlayerPref thing a while ago, and it caused every window to have these weird circles. How do I disable this?
might work for you if that's the problem
otherwise might have to walk the registry and clean it manually
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?
Remove the labels and substitute your own
You mean PrefixLabel?
Oh. I'd have to them keep track of the rect cursor huh?
No?
Oh. I was confusing that for another class sorry.
It's probably because you have the internal debug mode enabled, you can disable it in editor settings or by typing internal in the about window
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
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! 😄
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
Thanks, I'll dig though it! What is AssemblyVerifier?
Got it, thanks!
Thanks! that worked
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
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.
Many places to store your data, it just depends on what you are looking for. Library for example is for data that live within the project, but not important, as Library can be deleted anytime.
What if you remove isExpanded?
Nothing changes. The debug log itself uses a version of the method that does not contain the isExpanded boolean.
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 ❤️
I feel I am missing information
what do you require?
You said that conditions is of different heights. Why is that wrong?
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
Do I have to understand, they share the same list? O_o
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;
The 4 elements? yes.
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? 
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
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?
What’s a quick proper way of adding tooltip to GUILayout.Button?
Probably this https://docs.unity3d.com/ScriptReference/GUIContent.html not sure how it behaves with a Button, but it should do the tooltip
How to Invoke UnityEvent without using the inspector value ?
i want to Invoke( myArgument ) but instead its using the value set in the inspector
Thanks. Worked perfectly
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?
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
@quaint zephyr i guess you would have to use this https://docs.unity3d.com/ScriptReference/Editor.CreateEditor.html to make a "nested" editor in your current inspector
but if I remember correctly material/shader editors work different, so I'm not exactly sure how you would do that
Woah! Sick! I got it to work! It's easier than I anticipated! Thanks @patent pebble
same as Editor.CreateEditor but with a foldout
Thanks I'll check this out
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);
Not quite sure what to put in the second param editor for this one.
Oh
Thanks
What is the difference?
Better performance? or what?
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!
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 🙃
Indeed it was
In the first method, before you draw OnInspectorGUI you just DrawHeader first and it does the magic for you.
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?
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.
ah interesting
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.
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)?
Thanks @visual stag . And thank you for the last input as well, I didn't leave a thank you for it before.
I would advise using the Undo.RecordObject functions if you can over SetDirty btw
Undo.RecordObject persists a save past editor sessions as well?
Yes
Oh wow. Awesome. Yeah I didn’t know about that. I think I will reformat my project with this. Thanks again man.
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
The docs for SetDirty go into it a little https://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html
Ty ty
Does anybody have an idea here?
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?
Yep.
they're read-only because they are derived from the source
Yes I'd like to add something to that because it should be tied to the source.
You can modify them via https://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessModel.html
But, as the doc says you cannot use that method to make new prefabs
Ok but I can add components on postprocess I guess?
I'm unsure whether the SVG importer calls this method
I assume so - I've not done it myself
problem is, this isn't really a model (it's a SVG / Vector sprite), so I'll have to see if these methods apply.
They have an example adding a mesh collider
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?
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
Yeah it works for "models" in the classic sense, .obj, .fbx, but it doesn't trigger for SVG.
I'll keep digging.
you may also be able to just override that
Because I wouldn't understand how to extend and then use it.
it's a ScriptedImporter, so you can look at how that works, and glance at their implementation
ScriptedImporters are cool but seem to trigger by file extension.
Yep, but that works for you, no?
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.
oh, that makes sense
I am not sure if there's a good way around that one haha, worth a google
https://docs.unity3d.com/Manual/DefaultPresetsByFolder.html
Maybe something like that
I'm not sure presets can do anything other than setting values on importers, but I might be wrong
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.
I remove everything I can in new projects
I try to keep defaults because it used to mess up things in the past.
sad they're bloating it, but I suppose it's good for new users
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 😄
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. 
Wow this is so weird, I feel I must be doing something wrong.
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
Of course
can you tell me why ?
Probably full_name is wrong
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
🙂
Because Type fetches from the executing assembly. Which is the editor assembly.
typeof(Transform) is the runtime assembly.
Or you can force it and use the "UnityEngine.Transform,UnityEngine" as input
No, they are not the same precisely
tried that
Well, try with ",CoreModule" then
Type.GetType( typeof( Transform ).FullName + ", " + typeof( Transform ).Assembly.FullName )
doesn't always work
what's core module ?
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
oh
@deep wyvern probably your Texture not correctly setup
Filter Mode > point
That didn't do it but lowering the resolution of the original texture helped
Probably you want to generate MipMaps with a larger source file
Damn. I would really like to replace the color pickers with my own.
Can probably make a custom drawer for color that then draws your own
Yeah I guess. 🙂
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.
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
JetBrains Rider Inspector.
@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
How come I don't have EditorGUI.DefaultPropertyField? I just have PropertyField.
because it's internal?
no?
Why question?
because it's a silly question
my bad
You can look at microsoft's standards to figure out appropriate practice
and people will disagree with them
because programmers are conceited fuckwits
🤣 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.
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.
I have no idea what that is
No worries. Thanks anyways!
seems like you just type in what you want and it suggests
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
I have no idea
ok
The results will be different.
What do you mean? One way versus the other has more effective use of memory and/or performance?
You said cumulative, but you can't sum if your variable is reset in the loop.
I’m just wondering about memory allocation.
Compiler optimizes them. There was mentioned somewhere that in debug mode it doesn't.
This is double true. Editor does not optimize. Therefore things are left untouched.
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?
DragAndDrop
@onyx harness Could you be just a little less vague please
I found something that can help me, thank you for your suggestion
Is the box supposed to be an object field?
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
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 )
I'm glad you did it by yourself 🙂
Looks like it is interrogating the list. Check the list
wdym interrogating
I would look at the source code if I were you
its mine , i can post it if u don't mind looking at it
Source code of ReorderableList
oh true that
it fails at get_count()
forgot its open source
doesnt sound hyper complex
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
DoList requires a list. This is pretty straight
an array?