#↕️┃editor-extensions
1 messages · Page 79 of 1
Yeah... that is true. But don't really have much choice. Only good way to do undo/redo and support prefabs.
well, that's just how Unity is with editor features, it seems in the last 2 to 3 years they've put out a bunch of half-baked features
looks and works nice on the surface, but once you start digging, you start running into issues
and sometimes it's not even that the feature is incomplete or has bugs, it's that they have it extremely poorly documented, which leads to user error
@raw viper please don't send private messages asking people for help 🙂 ask your question here, someone asked you to share code, but you didn't. So we can't help
🤷
So I have a List that's is showing up in inpsector.
how would I go about setting up an initial size of the list when the component is added into the gameobject.
coz normally => you add component, set size, list shows 4 fields.
I want to eliminate the part of setting the size.
can you not do e.g.
public List<int> someInts = new List<int>(4);? Or am I missing something? 😄
Hey, I created a window that I want to show use ShowModalUtility, and I want it to render to the Scene window, I tried hooking to SceneView.duringSceneGui but it seems the modal is blocking Unity entirely so the editor is not updated (no calls to duringSceneGui)
Any idea how I can achieve this while block my other EditorWindow?
@valid wharf @split bridge by doing new List<int>(5) you are only setting the initial capacity of the list, not the actual size. To set the size of a list when you initialize it you can do public List<int> someInts = new List<int>(new int[4])
a list has capacity as well as size, they are different properties
Good point - hopefully @valid wharf got the gist 🙂
well the size property is actually called count but yeah
@solid thicket as far as I know you can't render an entire window to the scene view
I don't want to do that, I just want to change SceneViews camera settings
what you can do is use GUI/EditorGUI/GUILayout/EditorGUILayout methods inside the method subscribed to SceneView.duringSceneGui with Handles.BeginGUI & Handles.EngGUI
you asked how to render an EditorWindow in the SceneView
🤷
if you want to show a modal window while keeping the SceneView updating you can use SceneView.RepaintAll()
I said I want to render to the scene view, I didn't saw the window itself
Hey, I created a window that I want to show use ShowModalUtility, and I want it to render to the Scene window 😅
(the SceneView is an EditorWindow)
I want it to render to
Nevermind, anyway I wanted to change the SceneView settings
that's just what you asked. Now what it seems you are actually trying to do is show a modal window within the screen rect the SceneView window is at
How do you get an event when an asset is deleted?
these are, as far as I know, the only 2 ways of getting native info from the deletion of an asset from the Unity Editor
maybe there's other ways of doing it, I'm not an expert in asset management
Am I crazy or does the
visualElement.RegisterValueChangedCallback(ev => Debug.Log(ev.newValue));
fire when you change the label text of a textfield?
Is this supposed to happen?
Ah, I had named it wrong. Thanks!
Hey people. Do you know if it's possible to make default array inspector to use type's default values when adding an element to array instead of copying it from the last?
(2020.2)
Hey guys, anyone know why the EditorGUI.Popup will not show numbers or symbols when it becomes active on click?
@mild reef show code?
Good day i research addressables now and want to create AnalyzeRule which shows Implicit reference too, but in examples and docs i didn't find any information which classes has this information
How do I get rid of the context menu for elements in an array drawn with a custom property drawer? Or at least get a callback for when one is selected.
Catch the click?
No go, plus I still want the prefab apply and revert menu options.
is there a way to add custom operations to the Undo? For example the undo api afaik only covers stuff like property changes, destroy and create objects. But i've had a number of instances where changes aren't registered properly because they don't fit into either of those categories.
There is not. But can you give an example of one of these instances where the Undo API doesn't work wel?
too bad
then aside from the packing/unpacking i also had issues with the BoxBoundsHandle not being registered in the undo at all, despite the clear example using Undo in the official docs
https://docs.unity3d.com/ScriptReference/IMGUI.Controls.PrimitiveBoundsHandle.DrawHandle.html
Undo.undoRedoPerformed looks interesting but it doesn't provide any sort of control or context, doesn't even tell you which of undo or redo being performed. Maybe Event holds the goodies?
no dice
heyhey! anyone knows how could one create a camera out of scene/without gameobject? I'm trying to create a custom view camera to view a singular selected object/mesh in the editor
or hiding the objects in Narnia or some other place would be okay aswell
just hide them from the user
Hideflags
thank you!
Hey @patent pebble I just saw your response. Here is the code:
index = EditorGUI.Popup(new Rect (guiDefaultPosition.x + 110, guiDefaultPosition.x, 200, 20), index, new string[]{"None", "Anim #1", "Anim #2"});
This is all that shows though when I click on it:
@mild reef I think you have to escape the # symbol
I don't know exactly how to do that
I know you can escape quotation marks with a backslash for example
"This is a string with a \"word\" in quotations"
that in a string will result in:
"This is a string with a "word" in quotations"
Hmm, don't ever remember having this issue before weirdly...
But you are correct about the # symbol. I just removed it and they all show up with 1 and 2...
you could try this https://en.wikipedia.org/wiki/Percent-encoding
it says the equivalent of # is %23
not sure if that applies to c#
@mild reef try with the backslash first, \#
Ok thanks...
yeah the # symbol is a weird one
Ill try the %23...
if you just put a space between the symbol and the number it works
but I don't think there's a way of having it on a string without a space
"Something # 1" will work
but not "Something #1"
i'd suggest just forgetting about that symbol and use plain numbers instead
You can also use string literals with the @ symbol and C# will interpret it diffeerntly: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim
like you can use a lot of characters without needing escape sequences
@twin dawn I think the # symbol still has conflict when something goes after it without a space
even when doing the verbatim literal string
could be!
could always interpolate your # symbols in too
string myString = $"phone {Hash}555-555-5555";```
Hey guys, I just did a skim through your posts and tried all of those and nothing works...I just reported this as a bug to Unity since there is no explanation...
as to why this happens when you can see it like this before it being active:
yeah nothing seems to work for the Popup in regards to the # symbol
probably something in their source code that treats the strings in a certain way
like for example doing index = EditorGUILayout.Popup(index, new string[] { "Test", "Test/1", "Test/2" });
will result in the menu item having a submenu
they probably have reserved some symbols internally for context menus and menu items and that sort of thing
ooooh lol
I was gonna go dig through their source code
surprisingly they have that documented 😅
SOmething about what you said re: menus rung a bell in my brain
yeah hehe
@mild reef there you go, seems like you won't be able to use any of the symbols %, #, &, / in any GUI stuff that uses menu items
Since what version of Unity?
Just use similar char
For % and &, it might be hard to find one
but # and / definitely have some
Is there a reason why a list marked with [NonSerialized] would be set to null after OnAfterDeserialze() is called?
@patent pebble Very weird since this is a project I’ve never noticed that issue with before...
Does anybody know if the shader for the built-in Handle Caps is available anywhere?
I'm making some custom tools for the sceneview and I'd like to recreate exactly how Unity does the Handle Caps
Like the cones in the transform tool
You can probably find the source somewhere in the editor
Or you cna just load it
If you can figure out hte name
internal/handles or something probably
@waxen sandal I saw this on the forums
The source of the Handles shader doesn't exist in the editor installation. The shader used is precompiled inside an asset bundle of default editor resources.
In that case you can just load it
@waxen sandal so if I figure out the name, I can just load it with Shader.Find ?
Yep
Is there a way to launch the preferred code editor via unity to a specific file?
I'm trying to replicate the "Edit Script" component menu option
@waxen sandal oh I seems now they just publicly release all the built-in Editor shaders.
In my old 2017 shader folder they weren't there
But in the newest releases they added the folder EditorDefaultResources with all the goodies 😋
@patent pebble There is HandleUtility.handleMaterial though I don't remember what it does and is undocumented.
@gloomy chasm yeah there's multiple issues with that one. It changes color (red, green blue) based on the camera direction, it fades out if any mesh is between the camera and the handle
and most importantly....
I'm not Nicholas
🙃
So I just downloaded the built-in shaders from their website and tweaked the one called HandlesLit
the Editor is probably doing other things to the way Handles are rendered, because I can't just replicate the same color, shading and fading behavior using the built-in shader. I got close enough tho
oh I'm dumb, I figured out why the weird behavior, I forgot global shader variables were a thing 🤦♂️
@gloomy chasm so yeah then technically using the HandleUtility.handleMaterial works, but it's just a pain having to make backups for all the shader variables
so using a new shader for my custom values saves that headache
Is there a plugin that can help disable editor hotkeys while you're testing in PlayMode?
I would like to create a drawing tool like extension for 2d scenes. How do i detect the input and how do i prevent accidentally selecting another gameobject?
How can I do a BeginVertical inside a specific Rect that I have calculated ?
Hello, is there a way to not draw each individual float value of a vector3/vector2?
So it is just the Vector3
Im using the GetIterator() stuff to get to every property
SerializedProperty it = serializedObject.GetIterator();
it.Next(true);
while (it.NextVisible(true))
{
switch (it.propertyPath)
{
case "useCustomAnimation":
it.boolValue = EditorGUILayout.Toggle(it.displayName, it.boolValue);
break;
case "customBridgeAnimation":
case "defaultBridgeState":
if (m_UseCustomAnim)
EditorGUILayout.PropertyField(it, new GUIContent(it.name), it.isExpanded);
break;
default:
EditorGUILayout.PropertyField(it, new GUIContent(it.name), it.isExpanded);
break;
}
}
Im trying to make it so that some specific properties are drawn when a boolean is true
you can place the individual values in a EditorGUILayout.Foldout
true, but i want to remove them from the editor completely as it is very reduntant to have duplicate variables imo.
I also realized that any custom property drawers made by Unity dont work: Here is how my Unity Event looks like:
you can check the type of the SerializedProperty and not draw it if it is a float?
Wouldnt that just not draw any float properties thou?
I don't think you should be passing isExpanded into the property field at all
Really?
like if it's not expanded, it won't draw the children regardless afaik. I think your issue is entering children in NextVisible
because you draw the property and its children
Exactly, i just dont know how to filter those children out.
and then enter the children and draw them too
Just don't enter the children in NextVisible
uhm..
enter it as so far to draw all of your root properties (ie. enter once) and then never enter the children again
so basically it.NextVisible(false)?
yup
❤️
ill test it to see if it draws correctly
And it sure does
Ill just have to disable the first property as its the script itself
Pretty sure that shouldnt be editable
or just skip it, screw that field 😛

I'm trying to determine what the best practice is for placement of a package settings asset. Here's the scenario:
- I have a
ScriptableObjectwhich stores the settings in myPackages/*/Editor/Default Resources/*.assetpath. - That object has a method to load and/or create the asset file and a method to return a
SerializedObjectfor it. - I have a
SettingsProviderwhich is registering a project settings window which loads/saves and allows editing of the values in that above asset. - The
SettingsProviderand theScriptableObjectare currently in myPackageName.Editornamespace. - I have code in a different namespace called
PackageNamewhich needs to load and use the settings.
Should I just include the PackageName.Editor namespace in my files which need to read the settings so I can use the ScriptableObject to load the settings? Or should I move the ScriptableObject to my PackageName namespace which is already included in the file defining the SettingsProvider? Or should I be doing something entirely different? What is the typical / recommended convention for separating editor code from non-editor code and making package-wide settings available to both sets of code?
i need help with somthing guys anyone here can help me tha'd be much appreciated
@whole steppe to make life easier for everybody on this Discord, please don't ask questions asking if anyone can help you.
Ask your question or state your problem and if someone can help, they'll answer 🙃
I have the following problem. I am trying to create a GUI for my Brush editor tool.
If I select the tool I can interact with the GUI, but once I click and draw in the scene I cant anymore.
My code:
Handles.BeginGUI();
GUILayout.Window(2, new Rect(Screen.width-310, 25, 300, 0), (id)=> {
// Content of window here
if (GUILayout.Button(visible ? "Hide" : "Show Brush settings")) visible = !visible;
if(!visible) return;
GUILayout.Label("Brush Radius");
GUILayout.BeginHorizontal();
GUILayout.Label(radius.ToString("F"));
radius = GUILayout.HorizontalSlider(radius, 0.00001f, 5f, GUILayout.MaxWidth(250));
GUILayout.EndHorizontal();
}, "Brush Config");
Handles.EndGUI();
// Cancel deselecting/selecting other objects
if (Event.current.type == EventType.Layout)
{
HandleUtility.AddDefaultControl(0);
return;
}
// Draw logic here
does anyone know if i can, or how to... put the lists in the area on the drop down? or at least the title?
I assume we're looking at a reorderable list or a property drawer?
Regardless you should not use the Layout functions
and use the rect provided
and override the property height function
i'm trying to make collapsable sections to be able to add or take away sections
and yeah its reorderable list
Is their any way to run the UI elements debugger on a runtime UI document?
It seems like UI documents have a flipped coordinate space compared to editor windows but it's not so easy to confirm this is the case without the debugger
For reference
UI Doc:
Editor Window
Guys, I'm making an editor window
How can I use the selection method
Quick question. How can I make it so that when I click on a object field to have that object be selected in the inspector?
Double click it?
?
what i mean is the context in the window changes depending on the object i selected
Selection.ActiveObject or something like that
Then just check the type or w/e you want to do
I'm a bit of a beginner, so i write this on the OnGUI()
Yeah
Quick question regarding UI toolkit based editor windows in 2020.2
In previous unity versions, I used this code to populate the hierarchy
However the CloneTree function appears to no longer work properly
I don't think you need to do rootVisualElement.hierarchy, can't you just add directly to rootVisualElement?
The error does seem to be coming from the clone function, not the add
so it must be something weird with your uxml?
the weird thing is since i am using hierarchy.add it appears to be an issue within the clonetree function itself
Just realised that the UI builder can't open the uxml either, works fine in 2019.4
:/
any ideas what changed or what needs to be changed in the uxml to upgrade it?
Not sure, can't see anything that immediately stands out to me https://docs.unity3d.com/Packages/com.unity.ui@1.0/changelog/CHANGELOG.html
Hm I'll do a clean reimport of the project and see if this helps first
Might have to open a thread in the forum if not. Thanks for the help thus far! 🙂
The UI Builder error seems to confirm that it doesn't like one of the uxml files
a few other files i tested loaded just fine
@visual stag It appears as if the ListView changed, mine have children and that's no longer supported
Think I ran into that before, really annoying...
So I'm using a GUILayout.BeginArea() with a specific rect to draw some mlticolumn header stuff and I cant get my head around how to make the damn Area scrollable with .BeginScrollView
Do you happen to know how to have the default behavior for it? It seems to not delete any assets unless I tell it to.
Sorry, never mind I just didn't read the doc comments... my bad.
How do you load assets local to a package? Using the normal Assets/My-Package/myAsset.asset path does not seem to work.
com.thingo.package/Path/File.asset iirc
Yeah, I just took a look at the UI Builder to see what it does, and that seems to be it. I was wondering how to handle when actually making the package. But I think I just realized that it should be in it's own, non-Unity folder and then add it as a package to a Unity project to work on it.
That's what I do
Makes sense. Does it need it's own solution file or anything? Or just drop a package.json file in a folder and call it a day?
Sorry, the latter will do, you can just add it if it's structured like a package with the package.json and assmdefs
Guys, how can I add a button that when pressed adds a dropdown menu
I'm a bit if a beginner
I've got a propertydrawer that is drawing array elements, for better visualization I need the rest of the array to do some calculations. I guess there's no clean way to do that except draw the whole array myself right?
ok. Does anybody know how to properly register for Undo the actions form a ColorFIeld ?
Code?
EditorGUI.BeginChangeCheck();
data.mat.SetColor(colorProp,EditorGUILayout.ColorField(data.mat.GetColor(colorProp), GUILayout.Width(100)));
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(data.mat, "matTint");
}```
I do this inside a loop that goes trough a bunch of data. It sets the color on the desired mat correctly
nvm I was being stupid
EditorGUI.BeginChangeCheck();
tintColor = EditorGUILayout.ColorField(data.mat.GetColor(colorProp), GUILayout.Width(100));
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(data.mat, "Base color change on " + data.mat.name);
data.mat.SetColor(colorProp, tintColor);
}
this is what needed to happen
Hello everyone, I'm trying to setup a foldout property, it's working, except than opening the foldout lowers the header and toggle one row below where it's supposed to be. Is there a catch I need to pay attention to ? I could swore I did something similar once without issue (I pass the position that gets fed to OnGUI to the EditorGUI.Foldout call)
How do you draw a line between two items? Something works line EditorGUILayout.Space
Nope, but I just found out what happened with the help of a colleague, I just have to set the position's height to single line or the header got drawn in the middle of the Rect. (I wrongly assumed that the content was anchored to the top left of the provided rectangle)
Hey guys, I've been trying to use VFX graphs to make a muzzle flash for an FPS game as I 'm struggling to make a nice looking one with unity's basic particle systems, but I can't figure out how to implement the VFX graph on click or how to implement it into my programming, does anyone know of any tutorials that show implementing VFX graphs with programming? (I've looked but can't find any with programming)
You interact with teh visual effect through the Visual Effect component: https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@7.1/manual/ComponentAPI.html
Also using Property binders and event binders https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@7.1/manual/PropertyBinders.html
Alright, Thank you, I'll reaproach this with these in mind!
Is there any way to make it so that the default constructor is called on items when they are made in an array? I have class that creates a unique ID for it self in the constructor. And the array kind of messes that up...
the only "constructor" you got is ISerializableCallback
Yeah, that is what I just did. Not too bad I guess.
Anyone know how you can invoke the script editor correctly?
or perhaps, even know where in the source code I could look?
I've been trying to figure it out, even by looking at the reference source, but I can't exactly figure out how the "Open C# project" menu item works, or double clicking on a script....
oh nevermind, I totally just figured it out
InternalEditorUtility.OpenFileAtLineExternal
yep
man my new composable scriptable object stuff is really coming along
thanks, this makes it real nice now
ah man
Okay, riddle me this, I have no idea why this wouldn't work, and why this would be different
I have a PropertyDrawer, inside which I have do some drag and drop handling
https://github.com/PassivePicasso/ThunderKit/blob/development/Integrations/Thunderstore/Editor/DependenciesDrawer.cs#L56-L94
the top Inspector is a custom editor for a type I call ComposableObject, this is the ComposableObjectEditor, which draws each field using EditorGUI.PropertyField
and so the DependenciesDrawer gets invoked whether the ComposableObjectEditor or the normal Inspector for the ThunderstoreManifest object is used
however, if I drag and drop onto the ComposableObjectEditor's Dependencies list, it never shows the asset as droppable, even if canDrop is true
Furthurmore, it isn't droppable I can't drop it in that state and have it drop
but I can drag and drop to the normal inspector just fine
Shouldn't the DependenciesDrawer behave the same regardless?
I even added...
if(canDrop) Debug.Log("We can drop here");
Which does log when I expect it to
which suggests the visual mode should be updated
and suggests that I should be able to drop it, I just don't understand why this wouldn't be working here, and it definitely was working at one point...
Ah, I apparently need to use Event.Current.Use()
Got a bug report going for the # symbol not showing in popups issue! https://issuetracker.unity3d.com/issues/displayedoptions-strings-dont-display-characters-after-the-number-symbol-when-using-editorgui-dot-popup
How to reproduce: 1. Open the attached '1308553.zip' project 2. In the top bar menu select 'Examples' > 'Popup' 3. In the EditorG...
Is there some way to get a event when a SerialzedProperty field has been changed at runtime? I have a TreeView that I need to call Reload() on when a value changes.
Also, is there some sort of callback for when the Revert item is selected from the property context menu?
Update returns a bool iirc
What do you mean?
Serializedobject.Update returns a bool whether something has changed
So while using event.current.use solved my specific issue, something in my editor appears to be a problem for drag and drop in general
Is there any really good guides on drag and drop that may help me understand what problem ive created?
okay, how do I draw a window that is 100% of the EditorWindow , not a % less, not a % more (in OnGUI)? this works somewhat but the height is not accurate at all probably new Rect(0, 0, EditorGUIUtility.currentViewWidth - 2, Screen.height - Screen.height * 0.2f - 21)
oh and this is janky, if I put the window on the right side of the editor there is a missing pixel column, put if I remove the -2 then it is not accurate for normal (central/in your face) window alignment
like Screen.width is incorrect for the editor window, BUT if I do change the editor window size in the editor, it does change Screen.width
anyone?
or is the editor like a down-scaled version of Screen.width and height? I might try that tomorrow
What is the state of the art in deploying custom packages? I have an open source package ready in GitHub and looking to deploy it via package manager...
But it seems like git URL still has problems with versioning and dependencies
Was thinking about using OpenUPM or npmjs or maybe even Asset Store?
Anyone know if its possible to render static imgui code in a graphview?
I want to make it so like 1/4 of my windows regular imgui code the rest is a graph view but can't figure out how
IMGUIContainer?
@waxen sandal you're a god damn legend.
This appears to be exactly what I need!
Thank you very much!
@waxen sandal is there a way to lock it so it can't be moved? I want it to like always show up on the left side of the graph.
wdym?
Are you drawing it as a node in your graph?
If so you should just be able to draw separate from your graph
that worked
thank you
What is the method to get the width when I am trying to do imgui
screen.width doesn't work correctly and neither does editorwindow.windowsize.x
i had issues with DPI
evt.mousePosition * Screen.dpi / 96f
that is if you're using a 4k display or above, if not i'll just fly away
EditorWindow.position.width?
Ok im going to bed im drunk screen.width works fine. I just was doing it wrong.
lol
I'm looking for a design pattern for event chains.
so far i've just been enabling GameObjects:
Object A does it's thing, then enables Object B
Object B does it's thing, then enables Object C.
this is done with a simple field that references the next object. It's dead simple to implement but it's also completely unmaintainable.
Just use a list of events?
put the list where?
It depends?
i suppose it does
public interface IEvent{
void Next();
}
i could implement an interface like this along the monobehavior. But then what is "Next". Is it enabling a component? Or GameObject? could be anything. One object should have no knowledge of the next operation in the chain.
I'd just separate your chain into a separate class that then handles the invoking and waiting for the next event
public interface IEvent(){
void Exec(System.Action next);
}
If you really only want one class then yeah that works but that'll be annoying to set up
yeah, each component needs to implement the interface
and i need to create an editor for the manager
public interface IEvent(){
void Exec(System.Action next);
}
public class AwaitTrigger:MonoBehavior, IEvent{
private Action _next;
public Exec(Action next){
_next = next;
}
private void OnTriggerEnter(){
_next();
}
}
public class EnableObjectEvent:MonoBehavior, IEvent {
public GameObject ThenEnable;
public Exec(Action next){
ThenEnable.SetActive(true);
next();
}
}
public class Eventer : MonoBehavior {
public IEvent[] Subscribers;
private int _position;
private void DoIt(){
Subscribers[_position++].Exec(DoIt);
}
}
but yeah, i need to create monobehaviors for triggering common events like triggers. And other than that everything else needs to implement that interface which may be a hassle when i get stuff like killing mobs or player actions like jump/move
@waxen sandal what was your suggestion again?
Remove that next action, make your eventhandler just iterate over the events
And make the eventhandler normal class
public class Eventer {
public IEvent[] Subscribers;
private void DoIt(){
foreach(var f in Subscribers)
f.Exec();
}
}
?
still got the interface
😂
I guess you want serialization support right?
i want i can set up the chain in the editor
i should study about it before i start building stuff, let's see if there's any hits on the Command pattern
In that case non unity object listeners might be harder to do
Might be able in 2019 with serializereference perhaps
i think the serialization is adequate as is. I can see an issue with restoring the state after reloading the game
"if it doesn't exist, a new one is created in the local materials folder"
this is really annoying behaviour that you can't turn off by default
i really really really wish it wouldn't do this
because it gets it wrong anyway
under "naming" it says 'from model's material'
the model's material in blender is named thrustTrail
but unity always ignores the existing material and generates a new one, because the generated name doesn't actually match this at all
it adds all this extra bullshit based on properties of blender that are irrelevant to unity
i really like to manage my materials strictly so this behaviour is frustrating
i have an editor script here to manage the default import of models
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
public class ForceExternalMaterialProcessor : AssetPostprocessor {
void OnPreprocessModel() {
#if UNITY_2018_1_OR_NEWER
var importSettingsMissing = assetImporter.importSettingsMissing;
#else
var importSettingsMissing = !System.IO.File.Exists(AssetDatabase.GetTextMetaFilePathFromAssetPath(assetPath));
#endif
if (!importSettingsMissing)
return; // Asset imported already, do not process.
var modelImporter = assetImporter as ModelImporter;
modelImporter.materialLocation = ModelImporterMaterialLocation.External;
}
}
#endif```
can i use this script to also modify the naming convention ?
and if so, how would i do that
morning all. can anyone point me in the right direction on how to write a custom property drawer for lists? requirements: it has to be a drawer (not an editor), and it needs to encompass the drawing of the entire list (my attempts so far only take over the drawing of the elements, but i want entire array control).
trying now, thanks. and yeah, i found your second statement to be true
hmm, so switching to a decoratordrawer, the list still draws in addition to my fanciness. is there a way to tell it to not draw the property it's attached to? reading docs, it sounds like that's not how decoratordrawers work (they don't draw a property)
You can make a wrapper around it and create a property drawer for that class
sorry, not sure i follow. are you saying instead of trying to draw only my List with a property draw, to instead create a custom drawer for the entire class?
class ListWrapper
{
public List<int> list;
}```
then create a PropertyDrawer for ListWrapper
oh right, yeah, i thought of that but that'll result in a lot of data loss.
so it sounds like taking over drawing of an entire array property is not possible without jumping through data-changing hoops. so next question would be: if i have a custom editor for the parent class of the array, is it possible to say something like "draw all elements as you normally would except for this one. let me take care of that one" instead of me having to custom-draw everything in the class.
DrawPropertiesExcluding
lovely. that'll have to do, i guess. thanks
hey all, another random question for the masses: first time working with reorderable lists in a custom editor and everything is fine except one oddity. i actually have two lists in the class and therefore two reorderable objects. the removal behavior differs between the two. when i remove from list A, it removes the entire element from the array as expected. when i remove from the list B, it first clears the field within that element, then i have to click "-" again to remove the element itself. why would that be?
Is there a smarter/shorter way to do this?
AnimationClipSettings animSettings = AnimationUtility.GetAnimationClipSettings(clip);
animSettings.loopTime = true;
AnimationUtility.SetAnimationClipSettings(clip, animSettings);
Only one property drawer is made and shared. So any 'initialize' logic would then be inaccurate. What I normally do is have a nested class that stores any 'per-instance' data that I then have a dictionary of if that makes sense.
it's not in a drawer because, afaict, drawers can't take over the entire array drawing. instead, it's a custom editor for the entire class, and in that class are two separate arrays of things, both of which I've overridden via reorderablelist. when i remove an element from list A, it actually deletes the entry. when I remove from list B, it only clears it out. then i need to hit remove again, THEN it removes the entry. same custom editor, similar code to run both reorderable lists, but they behave differently.
if that makes sense
OH, the thing is that if it is a list of UnityEngine.Object then when arrayProperty.DeleteArrayElementAtIndex(index) is called, if it is not null it just sets it to null instead of deleting it, if it is null then it will delete it.
ahh, that must be what's happening then. is there a way to bypass that behavior and just have it delete the array element?
For the ReorderableList, just set the OnRemovecallback to account for it. I personally have made a extension method for SerializedProperty that sets it to null if it is not already before deleting it which I use to make things easier.
ok, i figured as much. thanks
did anybody here already upload packages to OpenUPM? Not sure if the submission process is broken or if I just dont get it
I didn't see this channel, i'm looking for any decent tutorials, paid or free that actually teach about tool building and editor extensions in unity, if you find or have anything feel free to ping me! thanks in advance
@dim slate i think you need to be a little more specific
"tools" is a fairly broad term
start with making custom inspectors
https://youtu.be/pZ45O2hg_30 This is a course Freya Holmer ran for a game education in sweden, it's a very good primer
🔽 click for timestamps & info!
this was originally streamed as a course for students at http://futuregames.se/, who were super kind to let me both stream this live as well as upload it here! so massive thanks to the people at FutureGames!!
💖 Patreon ❱ https://www.patreon.com/acegikmo
🐦 Twitter ❱ https://twitter.com/FreyaHolmer
📺 Twitch ❱ http...
Thanks Basil!
Hello, question about addressable build (this is the most specific channel I could think of for this). Is there an equivalent to IPostprocessBuildWithReport to make operation after building an updating a catalog (I'm trying to automatically upload the catalog to our backend)?
hm how i can fix that thing
You can probably change it in the debug inspector
?
@waxen sandal
What are good ways of "hooking up" extra functionality to default Unity features?
For example:
Having a toolbar with some buttons being drawn on the SceneView by default from the moment I open Unity (and also be able to close it and open it from a menu item on Unity's top bar)
I know this can be used to achieve that https://docs.unity3d.com/ScriptReference/InitializeOnLoadAttribute.html
Is there anything else that I should learn on this topic?
Or anything I should be careful with?
*This isn't for a particular tool or anything, I'm just trying to learn about every way Unity can be extended
there are a number of methods that people have used, but none of them are particularly great
Thats why Gabriel has been working on a new system to manage this better
👀 tell me more
@severe python any pointers to what other people have used for this in particular? I find it sort of difficult to google info on the topic since I lack the specific vocabulary in order to do so
oh
I've honestly not done it myself
There are a ton of tools that have, ProBuilder has versions with such features IIRC
Curvy Spline does it
actually, I don't know why I'm saying IIRC, ProBuilder adds a button widget to the scene view
InitializeOnLoad is what most people use. I personally now also just get the rootVisuelElement and add stuff to that instead of messing around with IMGUI.
yeah I've used some ProBuilder for prototypes, iirc they have a small toolbar that pops on the sceneview, but I don't know if it's an Editor Window or just GUI controls hooked up to the SceneView.duringSceneGui callback
well you have the source code, and you know what to look for
so open it up in VS and do a find
oh right I should do some digging
maybe they have the source up on GitHub since they are now part of Unity Technologies
@gloomy chasm I'm not very familiar with UIElements, so I rely mostly on using IMGUI
but I'll look into that too
this looks very interesing, but I guess we'll have to wait for 2021 version to see how they shape up that tool! 🤔
yeah unfortunately
the preview of overlays is available, but you'll probably have to be on the 2021.1 beta
@severe python yeah, i just took a quick glance at their developer guide and seems they use UIElements for that, which I'm not very familiar with
I guess I'll have to learn how to deal with it soon 😅 heh
UIElements is the Way
I've been doing a ton of IMGUI lately, and it only cements my belief
the one thing I have to give to IMGUI as of late, is that its completely trivial to implement virtualization
its just kind of a given, only render what the user can see
yeah
What would be the best way to recover static vars in an editor tool after domain reload? I know I could use EditorPrefs but is there a way to keep it in memory without writing to registry or disk?
Did anyone ever use Addressables.LoadAssetAsync for editor scripting ? It doesnt resolve unless i wiggle the viewport or save the scene
Or any async method call in editor for that matter
Has anyone here ever used or seen any editor tool used to play and pause multiple audio clips simultaneously.
For years, I have been using Reflection to call UnityEditor.AudioUtil methods to play, pause , stop and resume audio clips but now I need to be able to play multiple clips at a time , pause or stop one or two without breaking playback for everything.
I am curious to find out if there are any editors that do this.
My speculation without trying it would be to look towards the Timeline audio API.
I'm fairly sure it has audio preview, and I would assume multiple tracks
I think it uses AudioClipPlayable
you can look at the source for AudioTrack and its associated files as it's in a package
Thanks @visual stag , I will look into this. Anything's helps
is there some functionality that let's me drag resize an area?
@grim vine resize what? a rect for an IMGUI control?
I don't think there's a built-in way of doing it
a while ago I made a way for dragging and resizing rects in an editor window, I can share it
(not sure how efficient or polished it is)
i can take a look
found something called EditorGUIUtility.HandleHorizontalSplitter
internal tho
Dragging https://hatebin.com/udqfhsiyyt
Resizing https://hatebin.com/wecjnbbmyq
@grim vine they are messy, unoptimized and not extensively tested
that code was just for some quick tests I did when I started learning about IMGUI, I haven't actually used them in any tool. But they seem to work
hello i am trying discord rp and when i start the editor it gives my this error DllNotFoundException: discord-rpc DiscordPresence.PresenceManager.Update () (at Assets/Discord-RPC/PresenceManager.cs:121)
and also does the discord rp count as an editor extension
void OnEnable() {
_method = typeof(EditorGUIUtility).GetMethod("HandleHorizontalSplitter", BindingFlags.Static | BindingFlags.NonPublic);
}
private static MethodInfo _method;
private static Rect HandleHorizontalSplitter(Rect dragRect, float width, float minLeftSide, float minRightSide) {
return (Rect)_method.Invoke(null, new object[] { dragRect, width, minLeftSide, minRightSide });
}
works like a charm 🕹️
@daring musk what did you install?
lol the github is in French
lol
seems the Dll exists in the repo but not loading correctly for you
how did you install it?
i took the enitre assets folder then put it in my assets folder
can you find the dll?
dll?
they both have a puzzel peice that is called discord-rpc
wdym
their properties
on the puzzlepiece
here is the full list of errors
your error leads me to this line:
[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void RunCallbacks();
try typing discord-rpc.dll
or the full path
type it where
should i put it after all of these?
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
[DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
public static extern void Shutdown();
[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void RunCallbacks();
[DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
private static extern void UpdatePresenceNative(ref RichPresenceStruct presence);
[DllImport("discord-rpc", EntryPoint = "Discord_ClearPresence", CallingConvention = CallingConvention.Cdecl)]
public static extern void ClearPresence();
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
public static extern void Respond(string userId, Reply reply);
[DllImport("discord-rpc", EntryPoint = "Discord_UpdateHandlers", CallingConvention = CallingConvention.Cdecl)]
public static extern void UpdateHandlers(ref EventHandlers handlers);
you can use ctrl+h
discord-rpc -> discord-rpc.dll
if it doesn't work try discord-rpc.dll -> /Assets/Plugins/x86_64/discord-rpc.dll
awesome, then i dunno
I have an issue I don't understad, Given this code...
public override void OnInspectorGUI()
{
dataArray = serializedObject.FindProperty(nameof(ComposableObject.Data));
CleanDataArray();
using (new VerticalScope())
for (int i = 0; i < dataArray.arraySize; i++)
{
var step = dataArray.GetArrayElementAtIndex(i);
var stepSo = new SerializedObject(step.objectReferenceValue);
var editor = CreateEditor(step.objectReferenceValue);
EditorGUI.BeginChangeCheck();
try
{
if (DrawElementHeader(step))
editor.OnInspectorGUI();
}
catch (Exception e)
{
Debug.LogException(e);
}
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(stepSo.targetObject);
}
}
}
If I make edits to any field via the inspector, I the changes are not persisted
I copied the general setup from the Unity C# reference, but they didn't even do what I'm doing with set dirty, which I added as a troubleshooting step
the editor in this example is always...
[CustomEditor(typeof(ComposableElement), true)]
public class ComposableElementEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
DrawPropertiesExcluding(new SerializedObject(target), "m_Script");
}
}
I honestly feel like I must be missing something dead simple
ah it has something to do with DrawPropertiesExcluding
Is it because you are never doing serializedObject.ApplyModifiedProperties() perhaps?
that was my thinking, but it seems to be more complicated...
it looks like I needed to update the serializedobject
[CustomEditor(typeof(ComposableElement), true)]
public class ComposableElementEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" });
if (GUI.changed)
{
EditorUtility.SetDirty(serializedObject.targetObject);
serializedObject.ApplyModifiedProperties();
Repaint();
}
Repaint();
serializedObject.ApplyModifiedProperties();
}
}
Ah, it is because you are recreating the editor each time
var step = dataArray.GetArrayElementAtIndex(i);
var stepSo = new SerializedObject(step.objectReferenceValue);
var editor = CreateEditor(step.objectReferenceValue);
this is totally copy pasta
ah okay
so I should perhaps try to persist my editors?
Yep, I normally use a Dictionary<Object, Editor>
With the key being the objectReferenceValue
Or I will use the propertyPath string as the key.
Actually, what I would do my self is use the propertyPath as the key, and then make a class that holds both the Editor and the SerializedObject, that way you don't need to recreate it either.
Sure thing!
If you look at this, there is this little rogue control going down the left side
I even went so far as to comment out my entire OnInspectorGUI method, and it still shows up on this type
If anyone has any clue, this is absolutely maddening, I have no idea where this is coming from :/
nevermind, turns out I had forgotten about a derived editor which had its own code, which I should have noticed because it doesn't happen in another place I have this same base inspector
Use the imgui/uitoolkit debuggers to figure out what it is next time
Well I just learned that SerializedProperty.DataEquals(propA, propB) was a thing! I just spent like 2 hours making my own version of it and debugging it!
Is there a good way to see if there is a custom property drawer for a type? I guess more accurately, I want to hide the foldout of a property.
there is an imgui debugger?
Yep, at least in 2019 you can press alt + 5, it is in window/analytics/IMGUI Debugger. I think in some older versions (don't remember how old) you have to get it off of github.
Sweet, that will definitely be useful
If you're in internal mode it's in the window menu somewhere I'm pretty sure
I also have a gist to open it regardless pinned to this channel
LOL, I just found this comment in the Unity source for the PopupWindow // Change to private protected once available in C#.
hey, is there a way to make PrefixLabel line up with the property above?
it returns a rect that doesnt line up
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
I think position = EditorGUI.IndentedRect(position) will do what you want.
@gloomy chasm like this?
position = EditorGUI.PrefixLabel(position, label);
position = EditorGUI.IndentedRect(position);
GUI.Label(position, coordinates.ToString());
because it didn't work
Nope, ya do it first.
position = EditorGUI.IndentedRect(position);
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
unfortunately this did not work neither :/
ill restart my unity and try again
nope
tried both, restarted unity but still its the same
I guess it uses the EditorGUI.IndentLevel.
EditorGUI.indentLevel++;
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
result:
@sonic crane iirc you need to use the EditorStyles.inspectorDefaultMargins style or EditorStyles.inspectorFullWidthMargins
need to add either the left padding or left margin
or directly use the style in a group or area that encompasses your control
I got something I think, I'll send you tomorrow
If it's a class/struct you can just go into the children of the serialized property and draw them
There's a list somewhere in propertyhandler iirc
new PreviewRenderUtility();
all constructors for PreviewRenderUtility throws and exception, any idea what's going on?
Preview scene could not be created
nvm, i just restarted Unity
Hi, i'm building a screenshots tool for a school assignment. I have an Editor script called "ScreenshotInspector" that uses OnInspectorGUI to add some extra functionality in the inspector to objects with "CameraScreenshot" script attached, all this works perfectly. When i add OnSceneGUI to "ScreenshotInspector" script and add anything like show some buttons, i can't click on inspector fields of that object anymore. If i leave OnSceneGUI blank it works normally. I can't find what causes this or how to solve it.
If someone needs to see the code its posted here:
https://forum.unity.com/threads/cant-click-on-inspector-fields-when-using-onscenegui.1044052/
Is there any way to prevent the EditorGUI.LabelField from hiding its icon when the space gets to small?
Not buy you can draw it yourself using draw texture
Hey, I have an EditorWindow that contain a ScriptableObject property, which I set on OnEnable (and It is declared SerializeField).
Everything saves great when I exit the window and open it up again, the properties are restored correctly, but when I play the game, my property seems to be null
Any idea what could happen? when I look at OnEnable my property is set correctly, and is not null, the next function is OnGui which there it is already null (I debugged it when I hit the play button).
By the way, I use SerializedObject to serialize the properties
Thx thats what I ended up doing. It also helps getting rid of the type description
position = EditorGUI.PrefixLabel(position, label, EditorStyles.inspectorFullWidthMargins);
GUI.Label(position, coordinates.ToString());
position = EditorGUI.PrefixLabel(position, label, EditorStyles.inspectorDefaultMargins);
GUI.Label(position, coordinates.ToString());
@gloomy chasm btw thanks for your help attempts, I posted the things I've tested but none of them seems to work
could something be wrong with my unity?
wait it just fixed itself
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
🤔
okay... I guess, lol
is there way to add stuff to the official unity documentation?
No, however you can make a bug report regarding it, and also there is a chrome extension called "User Contributed Notes for Unity Docs".
How do I add a custom menu entry to the editor windows default context menu?
okay found it. had to use IHasCustomMenu
Hi everyone, I made an attribute for display List<string> as a enum
It works for what I need, but I have something weird I don't want, and I don't know much about extending the editor
The Dropdown attribute, for some reason I don't understand, I have to put the type of this class
And I don't want it, I just want to call the string
This is the attribute
And the property drawer
(Sorry for the image "spam")
The reason you need the type there is because it is needed for the reflection. If you just want it to be a 'scene' dropdown, then you can remove both parameters and just hardcode them in to the property drawer.
If I hardcode them, I can still calling the attribute in other class?
Yeah of course, as long as you understand that it would only be for scenes and nothing else!
It such a pity to not be reusable, but it's ok
Wouldn't you be able to make a generic?
class DropdownDrawer<DropdownList> : PropertyDrawer
{
[Dropdown(typeof(DropdownList), "string")...
}
Hi guys, I was told to ask my question again here. I have a List<Material> materials. It's about 200 materials. I want to save those materials into my folder "Resources/Skyboxes". Is there a way to copy them with code?
AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(obj), "Assets/Resources/Skyboxes/" + fileName + ".mat"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh();
seems to do the job
👍
How can I run debug.line in the editor?
What's debug.line?
Sorry I'm on my phone, I ment Debug.drawline();
Use handles
Could you elaborate/link API doc?
👍 thank you
Hope it helps someone:
https://github.com/CyberFoxHax/Unity3D_PreviewRenderUtility_Documentation/wiki/PreviewRenderUtility
Can some one explain why this isint working
[CustomEditor(typeof(SnapPointConfigurator))]
public class SnapPointConfigurator
{
public Vector3 PointA, PointB;
void OnDrawGizmos()
{
Handles.DrawLine(PointA, PointB, 2);
}
}
OnDrawGizmos needs to be on your monobehaviour
A custom editor has to inherit from Editor
Well yes, custom editor can't be a monobehaviour
Than I set it to Editor and it dosent appear in my scripts
Has anyone actually worked with multicolumnheader before ?
What the fuck
@stark geyser I don't think this is okay
!warn 796214448301408266 Do not post offensive content on the server.
APEX#4607 has been warned.
Bruh
!mute 796214448301408266 3d
APEX#4607 was muted
Hello. This is likely straightforward but I can't really find documentation for a problem.
I'm creating scriptable objects in an editor script, and they have a list of sprite as member. If I try to load said sprite in code and assign them, they turn into null reference after the script finishes executing(as I would expected). How do I assign a reference to a sprite asset the way I would by dragging a sprite asset on a field in an inspector ? I assume it involve using a Serialized object after of before creating my SO asset, but I can't figure out how to set it up correctly.
Undo.RecordObject is the easy way
Otherwise create a serializedobject from your scriptableobject and then use findproperty/findpropertyrelative to find your array
Then use GetArrayElementAtIndex
I used GetArrayElementAtIndex and an so, but I think that when I load my sprites into my script, I lose the reference to their assets, they just exists in memory. Unless I should use another option than ObjectReferenceValue on the property ?
Show code
sure var result = ScriptableObject.CreateInstance<LevelInfo>(); var so = new SerializedObject(result); List<Sprite> imageResults; if (remote) { imageResults = await GetImagesRemote(result, ImagesPath); } else { imageResults = GetImagesLocal(result, ImagesPath); } var prop = so.FindProperty("Images"); prop.InsertArrayElementAtIndex(0); prop.GetArrayElementAtIndex(0).objectReferenceValue = imageResults[0]; prop.InsertArrayElementAtIndex(1); prop.GetArrayElementAtIndex(1).objectReferenceValue = imageResults[1]; prop.InsertArrayElementAtIndex(2); prop.GetArrayElementAtIndex(2).objectReferenceValue = imageResults[2]; prop.InsertArrayElementAtIndex(3); prop.GetArrayElementAtIndex(3).objectReferenceValue = imageResults[3]; so.ApplyModifiedProperties(); AssetDatabase.CreateAsset(result, DestinationPath + "/" + legacyInfo.Word + ".asset"); return result;
Ah yeah if your images are in memory only then you need to save them
Also, there's no need to use serializedobject if you aren't editing an existing one
I load them from assets though, should I duplicate them?
If they're from assets then that should work
Strange. Maybe the error comes from somewhere else. I'll debug it deeper and see anything else is off
yup, the image loading was silently failing
Unrelated question, I have a property drawer that displays a dropdown list of possible completions for a string field. it works fine, however if can't be drawn outside of whatever inspector it is in (so if the list should stretch over the next component in my game object, it gets cutoff). Is there something like EditorGUI.popup that behaves like everything else in that regard?
Hi, i want to add a tooltip for a menu item but i didnt found how to, is this possible?
this is my menu item
and i want this when the mouse over the item
That doesn't seem to be easily possible (none of the default menu item have tooltips), so I assume you'd need to implement it yourself, sadly.
oh well, ill try then
Godspeed
Not possible
Type : public class UnityEditor.PopupWindow
Unity Doc
Versions : 4.2.0f4 ⟩ 2021.1.0b3
Already tried, but thanks :). I'm retrofitting the addressable asset reference field search popup now. it's ludicrously complex for what it does but it should work out, eventually
Hi Guys, i am trying to create a post processing script for my fbx that i will bulk import, and i am failing to change the root node to : Rig > Root; here is my code any suggestions : https://pastebin.com/UVjVsn0j
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.
Hi, is there a way to iterate through all my textures and set the max size to 1024?
Assetdatabase
It' seems I don't need the attribute. Instead I can make the property drawer for a serializable class in order to get the approach I need. But I having some problems because I don't understand much about extending the editor and I'm just writing without know what I'm doing 😩
I'm triying to send a capture but discord is trolling me
[CustomPropertyDrawer(typeof(SceneBuild))]
public class SceneBuildDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var elements = SceneTools.GetAllScenesInBuild();
var sceneName = property.FindPropertyRelative("Name");
if (elements != null && elements.Count != 0)
{
var selectedIndex = Mathf.Max(elements.IndexOf(sceneName.stringValue), 0);
selectedIndex =EditorGUI.Popup(position, property.name, selectedIndex, elements.ToArray());
sceneName.stringValue = elements[selectedIndex];
}
else EditorGUI.LabelField(position, "No Scenes in build");
}
}```
[Serializable]
public class SceneBuild
{
public string Name { get; private set; }
public SceneBuild(string name)
{
Name = name;
}
}```
i've always wondered, why are SerializedProperties called that? if they are fields and not properties?
is that some C# terminology or something?
Idk, Unity being Unity
oh, so they just decided to name it that way just because i guess...
when I first learned about them i was extremely confused
even the docs don't mention that they work with fields...
SerializedProperty and SerializedObject are classes for editing properties on objects
ah well.. on the SerializedObject docs it says different
SerializedObject and SerializedProperty are classes for editing serialized fields on Unity objects
jeez 😓
you should probably report that as confusing by using the form at the bottom of the doc page
will do
@visual stag "leave feedback" or "report a problem on this page"?
oh nvm
(the latter)
the "leave feedback" link just scrolls the website to the "report a problem" link 😅
I don't know if this is in appropriate to do, but vertx, are you familiar with the issue I mentioned as being common, I honestly didn't know where to ask the question. It seems like if it was an issue it would be a really common problem
the dlls one? Not really, I don't use the asset store
I use packages only, and probably wouldn't publish anything on the asset store until it uses them too
everyone is moving over to assembly definitions and providing source access, so maybe its really just not an issue
oh, asset packages are package managers are fundamentally different systems aren't they
is it allowed to post questions here too?
Camera cam = SceneView.currentDrawingSceneView.camera;
Debug.Log("Mouse Position: " + cam.ScreenToViewportPoint(e.mousePosition));
if i write a editor script to turn the current mouse position into a viewport Point so it can be used to figure out where on a plane it would intersect it starts going wierd
in the top left corner its understandably 0, 0
but the bottom right isn't 1, 1 as expected
its .7, .7
dragging the mouse any further out stops the position logging because it then clips into the inspector
even popping out the scene view doesn't fix the issue
I've got a modifier system that involves creating empty game objects with components on them and registering them with a manager (Deformable). For a while I've been using a creator window that shows all of the creatable components. When you click one of the buttons, the window handles creating an empty object with the component and registers the created component with the manager.
Would it be possible to get this functionality in the GameObject create menu?
I know how to do it manually with MenuItem, but being able to automate this would be great
I've already got my own attributes (which the Creator window uses to find the components). Ideally I could use that attribute data to populate the Create menu, but am unsure if this is possible
Not without reflection.
Oooh, actually I just I just found UnityEditor.SceneManagement.SceneHierarchyHooks.addItemsToGameObjectContextMenu I have not tried it, but it may work! If it does let me know!
Yep, it should work!
Oh great! Thank you @gloomy chasm I will give it a try tomorrow
Looking for some editor scripting assistance
Cool
Right now I am manually deleting tracks from many animations, and trying to automate the task. For instance I want to delete the scale tracks because it just bloats the file size.
Was wondering if anyone could point me towards a way to Select the properties through code so i can gain some efficiency
or if there is a way to delete properties a different way
hi, i have some problem with my custom inspector. when i use OnSceneGUI i can't edit my custom inspector fields. any idea why this happens?
Not without seeing the code, nope. Maybe you are Use()ing an event?
can i copypaste the code here?? or is it a screenshot better?
Copy paste is always better. But if it is a lot, or even just a medium amount, use hastebin as to not 'spam' the chat, and because it is easier to read.
i suppose i uploaded it correctly
im using OnSceneGUI at line 93 and method GUIHandles used inside that is at line 315
So I managed to figure out a way to remove tracks/properties by using AnimationUtility.SetEditorCurve
if anyone is curious about the full script
BEWARE THO, deleted tracks is a PERMANENT change that cant be undone
Between Destroy(AGameObject) and DestroyImmediate(AGameObject), which one should I use in a Monobehaviour that has ExecuteInEditMode
I'm trying DestroyImmediate because the documentation tells me so, but the GameObject isnt destroyed
So I tried Destroy and it worked well, but the editor log a message telling me I really should use DestroyImmediate
so i don't know anymore
nevermind
i'm tired
I was trying to destroy a component instead of the gameobject
Hi guys I'm wondering if anyone's tinkered around with this system before https://docs.unity3d.com/ScriptReference/ExposedReference_1.html. In the docs it mentions that ". This can be used by assets, such as a ScriptableObject" What I'd like to do is I have a graph with a blackboard, I'd like to be able to add (scene) references to the blackboard which I can then add to my objects. The ExposedReference seems like the perfect fit, except I can't actually find how to implement the system. I've tried implementing IExposedPropertyResolver, however it seems like there's no appropriate time to call ExposedReference.Resolve() for scriptable objects. It looks like if I can find a way to use the resolver in the SO I'll be set, but I just can't figure a way. Anybody tried something like this?
So I'm trying to write some code to allow me to create and modify bezier curves in the editor. I'm trying to make it so I can place and position control points in the scene view like you do any typical Game Object, but I also don't want to have to write a new custom editor for any Monobehaviour that uses my BezierCurve class, which leads me to PropertyDrawers. Looking at the documentation though it doesn't look like PropertyDrawers can interact with the scene view in anyway which would require me to use a custom editor anyway, which goes against what I'm trying to achieve here. Is there anyway I can write a PropertyDrawer that will allow me to interact with the scene view to let me modify a curve, or am I doomed to write custom editors for any script that uses a curve?
At the very least it looks like I could use DrawDefaultInspector() to minimize work, but it's still not ideal
@long pebble why would you need to make custom editors for classes that use your bezier curve stuff?
if all you want is modify the curves in the scene view by dragging points around, you don't need a custom editor for that
unless you want to implement some other functionality
but in the most basic sense, all you'd need for the curve's data is an array for the points and tangents
I'm working on a custom editor window and I need to reference a game assembly. I've added an assembly reference by selecting the Editor -> Analyzers node in the Solution Explorer and via the Project -> Add Reference menu (in VS 2019). I've also ensured the project that the assembly is tied to is marked as dependency in Visual Studio. Whenever I open the Unity Editor though, I get the following error in my project: The type or namespace name 'PathSystem' could not be found (are you missing a using directive or an assembly reference?) any idea what might be going on?
aha! I need to do this inside of the Unity editor not VS. Please disregard
Well, how do I add that functionality to my curve? That's what I'm looking for. And I'm aware all I need is an array of points. I have that, but that's a terrible user interface. I want to be able to edit it visually for the same reason I use the transform widget to move game objects around instead of mucking with the coordinates all the time
@long pebble that's exactly why I asked if you really need to make a custom editor for it...
if all you need is to edit them on the Scene view you can do that with Handles, for example
Does anybody know how can I get a list of all my custom global EditorTools that I've added to the scene tools?
the Tools and EditorTools classes don't seem to have that info accessible
The easiest way to do handles is in a custom editor though...
@waxen sandal can't he use handles in a property drawer or decorator drawer if he subscribes a method to the sceneview.duringscenegui?
instead of making a separate custom editor for each class
PropertyDrawers and DecoratorDrawers don't have an entry/exit point
Only a gui draw method
Good luck subscribing and unsubscribing on that
yeah true
Trick it with static
I might just have to change my approach. I wanted the curve to just be a data type you could declare in a monobehaviour and the correct controls would always be there, but if I need any other scripts needs a curve I might just have it reference the game object with the curve script on it.
works great, thanks again 🙂
@graceful gorge Thanks again a ton for the tip on Freya's class, Ive made a ton of progress this week thanks to that little bit of insight 🙂
Is there a supported way to stabilize guids generated for an asset?
I am pretty sure asset guids are stable. Aren't they?
I don't know in general, I know dlls appear to get a random guid though
its been a constant thorn in my side
its possible there is something I'm doing that causes it to be a problem
some part of me feels like there must be
They're not stable
Or not deterministic is probably the better word
I replace guids for assets that I want to have deterministic guids generated based on path
Anyone know if it is possible to access the Game Window and force a specific display? (Editor only)
Probably if you get the editorwindow and then use either reflection or serializedobjects to change it
Solved it. Thanks for pointing me in the right direction 🙏
private void ChangeDisplay(int index)
{
var assembly = typeof(UnityEditor.EditorWindow).Assembly;
var type = assembly.GetType("UnityEditor.PlayModeView");
var window = EditorWindow.GetWindow(type);
var displayField = type.GetField("m_TargetDisplay", BindingFlags.NonPublic | BindingFlags.Instance);
displayField.SetValue(window, index);
}
You can also use Resources.FindObjectsOfTypeAll to find all windows
GetWindow actually opens the window so that might not be what you want
Oh. I did not know you can access windows from Resources.FindObjectsOfTypeAll. Opening the window is good enough for my use case.
👍
How does OnValidate work in EditorWindows? Does it only get called when the script is loaded?
This function is called when the script is loaded or a value is changed in the Inspector
Since EditorWindows don't interact with the inspector, I guess the second part doesn't apply in this case
can anyone confirm?
I don't think there's OnValidate in editorwindows?
and I'm able to access it on my EditorWindow scripts, it only seems to be called when the scripts are loaded
Ah
Probably when you change a serializedproperty on the editorwindow
E.g. make a serializedobject of your window, change aproperty and apply and it'll probably fire
ooh, that would make sense
gonna test it, brb
@waxen sandal correct, you were right
this makes a lot more sense now, thanks for the info! 😊
Is there any way to serialize a private field and find the property relative?
Yes?
I can with [SerializeReference], but I'm seeing if it's possible to make a nameof()
var sceneName = property.FindPropertyRelative(nameof(SceneBuild.Name));
SceneBuild.Name is the property, but I guess I cant fight against level protection XD
I know with properties don't work, it just that I have wrote that right now
@carmine furnace So this is a property within a property?
If I'm understanding you right you could use a recursive property finder or something to do this
I'm going to paste again the script and the property drawer to better understand
using System;
using UnityEngine;
[Serializable]
public class SceneBuild
{
[SerializeReference] private string name;
public string Name { get => name; set => name = value; }
public SceneBuild(string name)
{
Name = name;
}
}```
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(SceneBuild))]
public class SceneBuildDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var elements = SceneTools.GetAllScenesInBuild();
var sceneName = property.FindPropertyRelative("name");
if (elements != null && elements.Count != 0)
{
var selectedIndex = Mathf.Max(elements.IndexOf(sceneName.stringValue), 0);
selectedIndex = EditorGUI.Popup(position, property.name, selectedIndex, elements.ToArray());
sceneName.stringValue = elements[selectedIndex];
}
else EditorGUI.LabelField(position, "No Scenes in build");
}
}
This is an example ```csharp
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
[AddComponentMenu("abutoolkit/Scenes/Scene Listener")]
public class SceneListener : MonoBehaviour, ISerializationCallbackReceiver
{
public static List<string> scenesInBuild;
[SerializeField] LoadSceneMode sceneMode;
[SerializeField] protected SceneBuild scene;
public void OnAfterDeserialize() { }
public void OnBeforeSerialize() => scenesInBuild = SceneTools.GetAllScenesInBuild();
public void LoadScene() => SceneManager.LoadScene(scene.Name, sceneMode);
public void LoadSceneAsync() => SceneManager.LoadSceneAsync(scene.Name, sceneMode);
public void UnloadScene() => SceneManager.UnloadSceneAsync(scene.Name);
}```
It makes a enum of current scenes in build
and the result of a SceneBuild is a string
That works, but I don't know if I can do a nameof, instead hardcode the "name" string value
Why serializereference
And you can't replace it with nameof since it's not public
Or internal
Because private fields, and SerializeField return a NullReferenceException:
But internal...let me check out

No, internal is not in the level protection
In my case I generate Guids for assemblies by computing their filename into a stable hash, its not a perfect solution but I think it fulfills my requirements
However the issue I was trying to solve specifically was modifying m_script references to refer to the DLL rather than the script asset, which I think I have a path forward on, which amounts to replacing the assets m_script reference before building out a UnityPackage, build the package, and then revert the reference after the build
it still uses the code I use to hash for the dll, but I think in my use case that will be fine
Oh yeah I do something similar somewhere else
with remapping the script references? is that the basic workflow you use, and it works out?
I haven't had a chance to actually finish putting it together, would be nice to know if i'm basically on the right track
@waxen sandal is there a way to create a mesh that fits the terrain or obj under it in editormode?
im trying to make something like easy3droads but not sure how i generate a 3dmodel that is aware of textures
@severe python yeah it works, we do it to generate asset bundle variants which are based on other bundles for things like small config changes
@whole steppe raycasts
@severe python we just copy the file and check whether it had references to the old bundle and if so we look up the guid for the new copied file
when you say bundles do you mean asset bundles or Asset Packages e.g. *.unityPackage ?
We do for asset bundles but it shouldn't be any different for packages
Do you have to refresh the asset database after modifying the files, thats one thing I wasn't sure about
I just use serialized properties to fix references
But yeah you should refresh after editing files
Else they might not up date
oh do you get the monoscript property and set it directly?
I don't understand how that would work tbh
We mostly do assets but afaik it should work as long as the old script isn't missing
Replacing the GUID is not enough, you must replace the FileId too
oh I know, I got that part, I also discovered your recovery tool
If I am not wrong, my tool has an API inside that you can directly use
I was actually going to ask if that works basically how I expect, you parse the yaml files and determine what likely candidates for classes are by checking their serializable fields and then making recommendations?
Is your tool available via the package manager somehow?
I don't want to take on dependencies unless their acquisition can be automated
Yes.
Which unfortunately does not guarantee it will work
Any asset in the Asset Store is available in there no?
depends on the unity version unfortuantely
Understand, my tool is not exactly standalone, it needs my Core.
Maybe I should separate the API from view/Unity.
Understood, your tool does a lot of things that would be very useful for the target audience (modders) so I'd not really be against it
Dont know if you found this one:
<#700988556838961193 message>
link doesn't work for me
oh shit
oh yeah, this is what i'm using
I don't know which one you are talking about, but you can remove all the tools and only keep those you want (with the core indeed, as it is required by everyone)
I haven't gone over everything in NG Tools, you just solve a number of issues that would be useful for a modding environment, such as missing script recovery, there is also the remote server thing, there were others but I don't recall what atm
I got contacted by a modder one day, he said he used my tool to mod, first time I heard about modding with my stuff 🙂
but yeah, quite handy to debug/test/visualize
My project is basically to setup a tool that makes it easy to setup a modding environment for "any" given unity game, which really means 2018.1+ because I don't know how to make this work without Assembly Definitions
There is some overlap with NG Tools, but your stuff has tons of solutions for issues that frequently come up
How come? What about AsmDef?
So Preface, this stuff is hacky. However, in order for you to mod a game you need to have all its required assemblies in the unity project, I pull those in as a Unity Package and create a package.json for it.
Most games end up having a Assembly-CSharp.dll and if the game includes one you need to overwrite the Assembly-CSharp.dll in the ProjectRoot/Libraries/ScriptAssemblies folder in order for its scripts to function inside unity
Due to this, you can't pack your mod scripts into an Assembly-CSharp, and the only way to change that that I'm aware of is to use an AssemblyDefinition, which as I understand it, is an AsmDef?
So I don't know if its even possible to support a version of unity that doesn't include the ability to define your assemblies explicitly
Yep
hum... I guess it does not work if you simply rename it?
That thought actually just crossed my mind
I'm not sure, I think I've tried to do something like that in the past and it didn't work out
Did you think about altering the DLL? Via dnSpy or Cecil?
Trying to avoid that kind of thing, that seems like a maintenance nightmare to me
dnSpy is nice for manual hack
Cecil is the way to go for automatic (That's what Unity uses, and also I use for NG Unity Versioner)
yeah, I'd end up using cecil if I went down that road
I'd do discovery in dnspy first probably
The API is pretty solid and not too hard to grasp, I use it for discovery, not altering
dnSpy is funny, as you can directly write code
Those shits are powerful
oh its all the rage in the modding communites I've been in, Its a super powerful tool, but I honestly hate the way the interface setup, but there is no denying its utility
Never been into modding stuff, sounds interesting world
Its a million crazy hacks 😄 you always run into some special interesting problems and the constraints make for interesting programming work
its fun programming
I noticed that Unity updated list to be reorderable. Is it possible to get a reference to the List and subscribe to events? i.e: onSelectCallback
Sadly no, not without a bunch of reflection https://twitter.com/roboryantron/status/1349547960208662528
I'm running into an issue with multi editing on a custom inspector, I have what feels like a fairly hacky solution in place as is and im not sure if thats whats causing the problems or if its something to do with the property drawer im using for Textures? I'm using the serializedObject and property methods which according to what few resources I've found, should handle the editing of multiple objects at once but, alas, nothing. Anyone got anything I could look into?
Just as a note since the object im working with is a scriptable object that I need to be able to edit both when selected and when applied to a monobehaviour I have a custom editor aswell for the monobehaviour which instantiates an editor instance of the scriptableobject inside of it
Show code
I cant show too much unfortunately however heres part of the controller, there isnt any issues with multiediting passed this point
public class Class{
serializedObject.Update();
List<MaterialController> controllers = new List<MaterialController>();
for (int i = 0; i < targets.Length; i++)
{
controllers.Add(targets[i] as MaterialController);
}
MaterialController controller = target as MaterialController;
MaterialData data = controller.data;
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
base.OnInspectorGUI();
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
var editor = Editor.CreateEditor(data);
editor.OnInspectorGUI();
}
//extra stuff
}
serializedObject.ApplyModifiedProperties();
}
}
Is this in a propertydrawer?
editor.OnInspectorGUI();```
This is a memory leak
You know another way to display the objects editor inside an object in scene 😅 ?
[CustomPropertyDrawer(typeof(Texture))]
public class TexturePropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
property.objectReferenceValue = EditorGUI.ObjectField(new Rect(10, 10, 50, 50), property.objectReferenceValue, typeof(Texture), false);
}
}
You should use Begin/EndProperty
Can I use the PropertyDrawer outside of the scene?
I was being stupid I think
Because its a scriptable object I need to be able to edit it off the object as well unfortunately
I'm confused what you're actually trying to do
Here
On object the controller allows me to edit stuff for materials without actually using unity's materials
But i also need to be able to edit the master data aswell
Use hastebin
I could do that
And this is the editor for MAterialController?
Or what is it
Part of it yes
the other part works with multiediting and is irrelevant
its just when I have multiple controllers in scene and attempt to change say a Colour, it picks the first one
Sooo I should probably just disable multi editing?
And Vertx is right, you should fix that memory leak by creating it in onenable and destroying it in ondisable
Probably yeah
Alright thanks Navi
CreateEditor does have a version that takes mutliple targetObjects so I assume you could make it multi-edit by properly filling that out
I've never tried it though
Right, I forgot about that. Never used it either but worth a try
Oh youre right vert I didnt notice that, shouldnt be hard as im already using target
I think im relatively close, getting a null reference on multi edit, seems its not generating the editor? ima try a few more things and see
Maybe you need to specify the type of the editor
Holy shit thanks @waxen sandal and @visual stag
probably not the most efficient but ill fix that later
private void OnEnable()
{
datas = new List<MaterialData>();
controllers = new List<MaterialController>();
if (targets.Length > 1)
{
for (int i = 0; i < targets.Length; i++)
{
MaterialController cont = targets[i] as MaterialController;
controllers.Add(cont);
datas.Add(cont.data);
}
controller = target as MaterialController;
data = controller.data;
editor = CreateEditor(datas.ToArray(), typeof(MaterialDataEditor));
}
else
{
controller = target as MaterialController;
data = controller.data;
editor = CreateEditor(data);
}
}
Anyone know of a way to dock an editor window automagically? I'd like to launch two editor windows that are docked together
There's a overload for GetWindow
public static T GetWindow(string title, bool focus, params Type[] desiredDockNextTo); their is indeed, cheers!
I was designing a tool for handling game data and this question arised.
What is the generally accepted "best" way of handling reusable game data?
Prefabs or using serialization & scriptableobjects?
It seems like prefabs would cause a lot more work in certain situations, like big architecture redesigns
and serialization & scriptableobjects seem like a better choice for making custom tools and being able to edit data outside of the engine
the more i get into tooling and extending the editor, the more useless prefabs look...
what are you folks' thoughts on this topic?
What do you mean "reusable game data", and how does it relate to tooling in this case?
Generally for storing data that would be shared between objects you would use ScriptableObjects. Prefabs are not really meant for data storage.
by that I mean objects and data that is instanced and reused a lot in the game
I remember when I was learning how to use Unity years ago, that most tutorials relied on heavily using prefabs
so I was now wondering if prefabs are not really a good way of doing that, specially for "big" games
What sort of data are you instancing and reusing? What are the use cases?
nothing in particular, just most of the game's data
like items, enemies, etc, that sort of thing
this isn't for a particular tool or anything, I was just wondering if prefabs are not really the way to go
and they are just only useful for small projects and quick prototypes
They are not for data, most tutorials were wrong
yeah I didn't mean they used the prefabs for holding and saving the data. I mean for using it at runtime
so I was just thinking that instead of having for example prefabs for different enemies with different components and such. Why not just use serialized data to construct enemy variants
You need to differentiate between what you really want. Holding pure data, go for SO, if you need it through a GO, go prefab
I don't know if I'm explaining my thoughts correctly
Yes you can, going through factory is a way to go, more heavy/cumbersome
I personally have ScriptableObjects for items that store all the info for given item (name, price, UI icon, etc), since I need that info for inventories, and a prefab of the item when it is in world which is basically just a mesh renderer or two and maybe some collision stuff.
Enemies and other agents I normally just have as prefabs since I don't need info about them normally until after they spawn. Sometimes I will and so I will make a SO with any data about them I need.
I think somehow you are referencing MVC pattern
Where you will want to separate the stuff
probably, yeah. I'm not very experienced with architectural patterns
i don't know, I feel like using prefabs would only be useful for cases where the instanced data needs to have slight variations from the original
but I'd rather just keep everything serialized and construct my game entities by using the needed data
maybe I'm missing something, but I feel like prefabs are mostly useless for me 😅
I'm reading around the forums and I think this sums what I was trying to say well:
Now you want to create a variation of the same enemy with same everything, but different stats.
You could have a prefab for each variation, sure. Now later you decide to rework how the prefab is structured, you want to change hierarchy, add scripts, colliders, many internal changes. That would mean that to maintain that enemy you would have to manually process each variation and manually make changes to hierarchy etc, this is very time consuming and error prone.
Now instead of storing variations as prefabs you can have a single prefab for the enemy, and pull the variations from scriptable objects.
Lets say scriptables only contain fields like - health, armor, speed...
You instantiate your enemy, and you inject the scriptable object in it, and enemy uses the scriptable object fields as his own.
This way you have a single prefab that is easy to maintain and data that is agnostic of the type of object you want to inject it in.```
@gloomy chasm I feel like that's mostly what you said, right?
It sounds like maybe that was written before prefab variants, because they fix that problem. However, I do think that is a perfectly fine way to do it!
yeah i think it was written before prefab variants were a thing
I still feel like it's better to abstract the data as much as possible from the prefabs. I feel like making design tools for simple data is more straight-forward than having to deal with it on prefabs and whatnot
this whole discussion is probably very obvious for most people. But my experience with architectural patterns and things like that is not very strong, heh 😅
You're not alone, I have months without a prefab folder in my projects XD
I mean, I still use them, but mostly for simple things that won't change throughout the development and don't use tons of data
i use prefabs a lot for static things, like environmental props and backgrounds and things the player doesn't interact with
Me too, maybe bullets and something more without game data
I like the idea of have a script that has a reference to prefab and a SO for setting it (something like a factory of turrets for example)
I feel it too
Sometimes I see Unity pushing so heavily on the "official" way of doing things, that it feels like if I do something differently I'm doing it "wrong"
Maybe they shove prefabs on our faces because they are a good tool for simple things and user-friendly for beginner Unity users.
I feel they've been telling people to use prefabs a lot, specially since the new prefab system rework
they are great for prototyping, and for quick level design tho
Variants have been great in my experience for what was an otherwise unusable system yeah. It's still quite a specific use case but has application now
My guess is unity pushes prefabs because they're easy to understand and relatively user friendly for beginners, other options maybe not so much
SO still comprise like 95% of what I'm doing in unity engine it feels like xD
The first rule of Unity is to never listen to them :)
Listen to the feedback, way more reliable
yeah, whenever I'm learning a new Unity feature, or topic, my go to is googling
"should i use X"
"how to use X"
"pitfalls of using X"
etc
Does anybody know how can I hijack the Project Window top bar to insert a new button either on the left or the right of the search bar?
I know how to tap into the project window items with EditorApplication.projectWindowItemOnGUI
is there anything similar for that top bar? can't find anything
or if that's not possible, just add a new menu item on the project window context menu?
Not possible, it's hardcoded last time I checked
Yeah I'm looking into the source and it seems like I can't even do it using reflection
big sad 😓
If they converted to UI Element, you would able to do anything
i don't know if they'll ever rewrite all the internal editor code to make it use UI Elements
one can only dream of such things... 😩
They have actually said multiple times that their plan is to do just that. They are planning on doing a complete editor UI redesign, so I assume at that point they will do it. Like, they are redoing the sceneview to be UIToolkit.
Haha, yeah hopefully not.
Hi guys, I'm starting to learn addressables, the end goal for the system I'm working on is to distribute it as a package.
Here's where I'm at now, I have a system that is creating assets and I'd like them to be automatically added into an addressables catalog. I'd like to add them to specific groups automagically, but to do that those groups must exist -- so I started down the barbarian path:
https://hatebin.com/tjqqkqbqvz
This looks pretty terrible, and I don't like that this might mingle with other addressable systems. Does anyone know of a way to create a package-unique addressable bundle (The system seems like I should be able to drop something like that in place, but I can't seem to find how)? That way the addressable settings for the package are already configured and I don't need weird hacks to create the groups and etc, etc.
I've been trying to use the ScriptedImporter class to create a custom asset that Unity imports as a shader. Is this possible? I can't find a way to create a shader asset anywhere (thinking of something equivalent to MonoScript asset?)
aha I think I found it with ShaderUtil.CreateShaderAsset
ok next question (sorry) is there a way for me to detect when a MonoScript recompiles, and add a subasset to it if it's a subclass of a certain type?
I tried a AssetPostprocessor with an OnPreprocessAsset event function that checks if the importer is a MonoImporter, but the GetScript function is always returning null
This where I'm at, but script is always null
private void OnPreprocessAsset()
{
// Are we importing a script?
if (assetImporter is MonoImporter importer)
{
// Is there a script?
var script = importer.GetScript();
if (script == null)
return;
// Does the script have a class?
var type = script.GetClass();
if (type == null)
return;
// Is the script a C# shader?
if (type.IsSubclassOf(typeof(SomeSpecialClass)))
{
// Check if script has SomeSpecialAsset as a subasset
// and add one if missing
}
}
}
is the object null or is the importer null?
Is there any way to define new templates in the Unity Hub?
Nevermind, I figured it out, can do it, but its not really nice and possibly not worth it
There's no built in support afaik
no not really, you have to make a folder in a bunch of folders
Even then though, your ability to customize the template is limited, I wanted to reduce the base set of installed packages to only the things required, but that doesn't appear to be an option, its annoying having to uninstall all the Advertising and IAP crap every time I make a new project
question. unity have labels that you can drag and change value. i want similar thing for my stuff. how to do it?
Is it this maybe? I'm not sure: https://docs.unity3d.com/ScriptReference/EditorGUILayout.PrefixLabel.html
nope. thingy to drag not appearing. i kinda checked it already. checking EditorGUI.HandlePrefixLabel now but it's not really documented
Curious, does it work for https://docs.unity3d.com/ScriptReference/EditorGUILayout.PropertyField.html ?
I know that might not be an option but I guess it should probably work there at least
well. for default properties it ofc works. but i want to make bunch of PropertyAttribute's that change appearance of default drawers. for example i want int to be drawed as float but scaled with some constant. and some more complex stuff. right now it seems that mimic default implementation is easiest way.
Show your code
huh? it same as it CustomPropertyDrawer example. i just looking for ways to draw SerializedProperty but with fancy labels.
IntField and FloatField should both support that
lol i know. but i dont want field. i want label of that field.
also those fields is using some internal function "DoFloatField" and "DoIntField" as far i i know. not much ways to see how they are implemented.
lol. google tells me to get internal method through reflection and call it anyways. right.
Can I get a sanity check on this one? [HideInInspector] seems to break serialization.
[SerializeField]
public string GUID;
[SerializeField]
public List<RuntimeNode> outputConnections = new List<RuntimeNode>();
[SerializeField]
public List<RuntimeNode> inputConnections = new List<RuntimeNode>();
I have an editor window saving this to file using the asset DB, and like this it works fine.
Contrast:
[SerializeField, HideInInspector]
public string GUID;
[SerializeField, HideInInspector]
public List<RuntimeNode> outputConnections = new List<RuntimeNode>();
[SerializeField, HideInInspector]
public List<RuntimeNode> inputConnections = new List<RuntimeNode>();
This writes when the asset db creates the object for the first time, but is not serializing after being set dirty as expected, and as the above script does. Can I get a sanity check, this seems like a major bug.
I have multiple editor scripts that i had to remove [HideInInspector] from after updating to Unity 2020.2.3f1
they all seem to have this issue.
It shouldn't
SerializedField and Public is redundant

