#↕️┃editor-extensions
1 messages · Page 45 of 1
I'm currently trying to make a custom property editor but every time I press play, the values keep resetting. Is there something I'm probably missing?
Can you post the code @bright cosmos
There is no reason to ApplyModifiedProperties
I don't think it'd break anything, but that's done for you
you never serialize that boolVal and that will definitely reset. Not sure if it's possible to serialize inside of a property drawer without some painful stuff, but I may be wrong on that behalf
Yeah, I just tried the ApplyModifiedProperties in hopes of fixing the problem. I'll try serializing the boolVal and check if it works out.
Any reason why you don't just set the value back to the useConstant SerializedProperty?
just do that, after the logic is run, instead of trying to do it across the repaint
any thoughts on how to make a button that spawns a field? Like I click the button, the button moves down and spawns a field
In IMGUI you just... draw the fields in a loop and add to the loop from the button
What lol 🤔?
I'm just starting out with editor scripting so I'm not really sure with what I'm doing hahaha
Just cache the useConstant serializedProperty, and reassign back to it after the popup
Yeah that's what I did and it worked
and make the boolvalue int just local 👍
Thanks ! 😄
I've seen this searchable dropdown in a few places before. Does anyone know more about a related API?
The "Add component" menu is similar. But I think Odin is responsible for drawing it this way, in this case
Yeah, that's odin, hence why I asked
but the add component menu has its own API now of 2019
I'll find it for you
Thanks! I'll take a looksie
Oof, I'm locked to 2018.2, so looks like I have my work cut out for me 🙃
I'm getting this error and I don't know how to fix it
Rotation quaternions must be unit length.
UnityEngine.Rigidbody:set_rotation(Quaternion)
CuestickMovement:FixedUpdate() (at Assets/Scripts/CuestickMovement.cs:30)
Here's my code
Oh and it does compile, it just shows that error when I press 'q'
You shouldn't set Quaternions directly if you don't understand how they work. There are methods and properties that will interpret angles in degrees into them for you https://docs.unity3d.com/ScriptReference/Quaternion.Euler.html
@grizzled minnow You wanted to use it for the editor? If so I have this public class that allows to use Unity label window: https://gitlab.com/RotaryHeart-UnityShare/LabelWindow
oh wow this sub exists... can i showoff few screen shots of stuff that i made here ?
go ahead
#💻┃code-beginner is a better place to ask
This channel is meant for code extending teh editor
Has anyone done extensive timeline customization?
just wondering if anyone around is available to ping for issues I run into with the things I'm attempting to do.
hey folks. any idea how to change the font used for displaying popup options? I can change the font used for the combo box when it's just inline, but not for when you click it and show the options
Anyone knows how to do AddComponent to my prefab in the Editor? I keep getting an error that it can’t be edited
I've just pinned a resource that should help you out; it's at the bottom of the list
Sorry was it to me?
Yup
The "I want to change a flag on multiple prefab assets" could be relevant. Just replace the flag modification with your add component call.
There's a lot of different ways to do modifications depending on whether you're dealing with assets, instances, etc
Ah yeah sweet
It needs a static editor flag which is probably not what I want Vertx
I will prolly load the prefab and do my edits
Either way, that resource is where I would be looking for code examples
var path = AssetDatabase.GetAssetPath(myPrefab);
var root = PrefabUtility.LoadPrefabContents(path);
root.AddComponent<MyScript>();
PrefabUtility.SaveAsPrefabAsset(root,path);
PrefabUtility.UnloadPrefabContents(root);
Nothing 🤔
):
Had to delete the prefab and do it again
Hey all, does anyone if there is a scripting define symbol that indicate a specific playback engine is installed?
I'm writing some PostProcessBuild hook that alters the XCode project using the PBXProject api. Sadly this api is only available if iOS support is installed.
I tried using UNITY_IOS but it seems this won't work if I compile for iOS using BuildPipeline.BuildPlayer while not starting with the Editor in iOS platform mode.
Hey, can someone help me? I'm looking for some class to inherit or a method to call where when an custom asset is created, I can modify its properties.
How do I use property drawer with UIElements inside the inspector window?
does any fo the previews have the inspector a UIE? or are they all Immediate mode?
The docs have been updated in terms of property drawers and UI elements, though I haven't looked into implementing anything as of yet
Fairly certain 2019.2 would be UIElements as it's got the UI refresh in it
but again, you'd have to look for yourself
the UI Element debugger helps with that
Anyone knows how those preview windows for 3D models are made?
@random flume I think it is with UnityEditor.ObjectPreview or UnityEditor.AssetPreview
heya guys
If i have a class that contains a List<> made from a sub class within that class, how can i serialize the list items in an editor script?
if i serialize the List<> property itself, it just shows up by name on the inspector, but empty.
Can you post some code to hatebin? @prisma falcon
You're likely just missing a [System.Serializable] somewhere
@sleek berry There's a function you can use to see if a BuildTarget is installed. However, it is not publicly available so you would have to use reflection. The function is called IsPlatformSupportLoadedByBuildTarget and is located in the ModuleManager. You can check the C# reference over here: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Modules/ModuleManager.cs
@drifting crescent Sadly this won't resolve the issue, as at this point the code would have already failed to compile
The trouble is that the PBXProject references are all from the iOS platform support DLL's. So the compile of the binaries will straight up fail if the user does not have it installed
and I cannot restrict an assembly definition to only compile for Editor AND if iOS support is installed.
For now, I've rewritten the entire routine to be done through reflection
To give some background on the issue I tried to solve. I have a library that needs static linking for iOS. Call it thingy.a. I have an x86 and an arm build of this library, in 2 different folders, for the Simulator and device targets
but Unity doesn't allow me to specify on each of these "Plugins" which target they belong too
I use the PBXProject API to alter the xcode project during PostProcessBuild to remove the references to these folders from the global LIBRARY_SEARCH_PATHS, and add the project specific search paths back in
I'm getting some weird behaviour when setting any field in a property drawer
property height is EditorGUIUtility.singleLineHeight * 2.0f;
but its keeps kinda rubberbanding whenever I change the values on any input field
it draws okay when there is no change in value (2nd component), but when moving the slider or typing on the inputs this huge empty space shows up
anyone know what might be?
Im looking to change a value in a prefab component from a library scriptable object, and cant seem to get my changes to stick. Anyone know the process to change a component on a prefab in the OnValidate of a scriptableobject's editor?
I can change it, read it back, debug it, but in the end the prefab is not changed
Is it normal, that Unity's Gizmo.DrawMesh function draws a lot of CPU with about 30 vertecies?
Like i am only doing a color set and the drawing per draw
nö
Writing a custom inspector. Is there an easy API to check if the gameObject I have selected is in the game hierarchy or a selected prefab?
I tried using scene.IsValid or scene.IsLoaded but sadly those also cound for the prefab edit scenes
Not entirely certain, but I think EditorUtility.IsPersistent will check whether it's an asset or not
I imagine it'd return false if it's in the scene
but I could be wrong about that and would have to test it
My issue seems to have been a unity bug, sent report. It is apparently possible to fully desync prefab properties permanently editing values through editor code.
I made a prefab that you can drag into the scene with completely different properties than clicking into the prefab editor
making it impossible to ever resync
Quick question:
prop = serializedObject.FindProperty("unityEvent");
``` Finds a property(field) in my targetscript which works fine, but what about finding a propery in an external script.
Depends on what your use case is.
As you can see the Property is in the ListTemplate class instead the targetscript (EventListener)
@whole steppe can you explain what it is you are wanting to do?
I am just trying to draw the UnityEvent field thats all
The 2 other fields i can already draw , it works perfect
So if I am understanding this right. You have an EventListener class that has a list called list of ListTemplate?
If that is the case @whole steppe , this is how you get it if memory serves.
serializedObject.FindProperty("list").GetArrayElementAtIndex(index).FindPropertyRelative("unityEvent")
I am pretty new to it.
@sleek berry Odin can determine if something is a prefab or a scene object, so i theoretically should be possible
unsure if this belongs here but I keep getting this error constantly and it makes me so upset because it interrupts my workflow
Copying assembly from 'Temp/Assembly-CSharp.dll' to 'Library/ScriptAssemblies/Assembly-CSharp.dll' failed
I have tried making my protections make an exception to my game folder and the unity folder, unsure what else I can do other than restart the program
hey people, I want to create a node based dialogue system but have zero experience creating tools in unity. I suppose that this is a solved problem - so does anyne know of a good resources to get started with this or something similar? I mean at the end of the day I jsut need to have a graph of nodes, where each node, knows its childnode to call it on a specific action. getting a visual representation of that graph an creating a parent child relation on connection is where I am currently stuck....
I think there are a few tutorials if you google unity node editor
@sleek berry EditorUtility.IsPersistent(uo); will return true for assets, false for anything scene-bound.
@unkempt depot Unity has an internal GraphView API and it's semi-documented; it's for stuff like ShaderGraph and VFX graph. You could start from there: https://docs.unity3d.com/ScriptReference/Experimental.GraphView.GraphView.html
@pure ridge Does this include things in the Prefab edit scene?
Sadly, it returns false it seems
@pure ridge thanks a lot 😃
yeah I found a lot of stuff actually :D
was quite easy to create a custom node editor :))
the only problem that remains is that my custom editor has a single instance which can be opened under the window tab. is there any way to attach my custom editor to a scriptable object for example?
always amazed how easy unity makes most things 😄
Lol, this last sentence is full of cuteness :D
😃
hey, I did c++ before - its so great to not compile for hours and be able to just go and build stuff haha
h-e-l-p
This channel is for modifying the editor. #💻┃code-beginner is for general code questions.
Please tell me someone has made an editor extension that makes it easier to work with the layer matrix?? Just something like drag / drop to rearrange the layers would be great.
No one did that X)
But doing it is easy :)
Hello, does anyone know a way to overwrite the built in UI Editors? like extend the inspector for the Image Component or does it really only work with sublcasses?
Or is it maybe possible with UI Elements?
You can make an Editor with the CustomEditorAttribute of your type,
Then you can do something like this for example:
private Editor defaultEditor;
void OnEnable {
if(defaultEditor == null)
defaultEditor = CreateEditor(targets, Type.GetType("UnityEditor.AnimatorInspector, UnityEditor"));
}
public override void OnInspectorGUI()
{
defaultEditor.OnInspectorGUI();
//My extended editor stuff here
}
void OnDisable {
MethodInfo disableMethod = defaultEditor.GetType().GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (disableMethod != null)
disableMethod.Invoke(defaultEditor, null);
DestroyImmediate(defaultEditor);
}```
This is all code I wrote a long time ago so take it with a grain of salt
Point being, you can do it all normally, but you need to do all or some of that garbage if you also want to draw the default inspector
Thanks. Well I've been overwriting the normal inspectors (e.g. for Transform) with CustomEditor Attribute with no problem but trying to overwrite the Image Component for example doesnt work and subclassing "ImageEditor" doesnt work as well
If nothing has changed it looks like it's not possible. This question is quite old but I tried a lot of approaches now and I guess it is not worth it:
Everything is possible. Replacing an editor was quite easy in the old system. I don't know about UI Element, but I guess it didn't change much
There is a dictionary that you need to alter. It is lazy initialized, after that update it and it should now use your custom editor
I can't show you code, I don't have my computer near me
Not sure, I don't recall which class holds the dictionary, you need to dive into the code
I dropped the code in this channel a long time ago
Maybe if you lookup you might find it
So I have this to make a rainbow color but its going kinda fast and i need it to be slower but I cant think I anything to make it do that cause my editor says everything will not work "Color.HSVToRGB(Time.deltaTime % 1f, 1f, 1f);"
ran into a very odd unity gui bug just now that's blocking me from working. wondering if any of you have ran into this
links are missing in the scene, but not in the prefab, and there aren't any scene overrides. if i re-add the PaletteView prefab to the scene i get the error in the second image (associated to how unity is building the treeview in the hierarchy; probably hitting that error and not finishing re-tying the links in the gui; weird that it's only happening in the scene though and not in the prefab view)
Is EditorPrefs constant across projects or just the project it was called in? So like if I had "Project 1" in 2018, and "Project 2" also in 2018, and I call EditorPrefs on my Project 1, will I be able to pull that data stored from Project 1 into Project 2? And out of curiosity (less important), is it persistent across versions? So if I had Project 1 in 2018, and Project 2 in 2019, would I be able to pull the data from the 2018 "Project 1", into the 2019 "Project 2"?
Ah ok, thanks
@shadow violet if I recall correctly, it is per company/project name.
(need to confirm)
How can I solve the "cannot build Gradle" when I am trying to build all?
Apk*
Build app*
Hello. I want to make a box that has a label in it and a toggle. The toggle should be aligned to the left corner of a box, while the label should be at its center. The box is intended to be stretched horizontally. How do I do this?
What to do?
Do i need replace the script with something
https://pastebin.com/0iu9Jkvk this is fulls cript
How did you ping me @whole steppe ??
accidentily mate
You didn’t even edit your message
???
Its possible i pinged multiple people
2019.1.11f
But i alreaday fixed that thank you
Assets\RealisticCarControllerV3\Scripts\RCC_GetBounds.cs(3,7): error CS0246: The type or namespace name 'ParticleSystemRenderer' could not be found (are you missing a using directive or an assembly reference?)
You shouldn't need that using up there
With the ParticleSystemRenderer
Oh, uh ping @whole steppe
I've got a question for people who are AssetDatabase savvy!
A: Why is it not possible to add sub assets to shaders?
Or B: Why can't shaders be sub assets of a custom ScriptableObject asset?
They both lead to different issues. In the case of A, an error is thrown about serialization version not matching (likely not the actual issue), and the sub asset isn't added
In the case of B, the shader is added as a sub asset, but, it loses all its code and it's basically not a shader anymore, just an empty vessel
Sounds like a question for Richard Fine 😛
Basically I'm trying to find a way to combine a shader and my own data / objects into a single asset object
Does it have to be its own singular file?
Preferably, yeah, I don't want to juggle multiple assets
Which makes me wonder - how does Shader Graph do it?
Just hide your shaders somewhere and get a reference to it
No, I want them to be visible in all the ways people expect, for things like drag and drop references etc.
Presumably Shader Graph has node metadata and the actual shader in a single file, right?
Haha, me neither
I'm curious though so I'm booting up my decompiler 😛
I guess I should have~
I'm a little surprised you haven't
I guess I should be too
I think I've never had a use for it, as I've just either maintained my local version of Shader Forge, or just hand-written shaders
Seems like Shader Graph has some experimental render pipeline requirement?
Rather than, just working with the standard render pipe
I could be wrong, haven't really looked into it proper
I asked Richard Fine on Slack, I'm sure he knows something about that
Ah, thanks!
Hmm
He doesn't know offhand, but apparently they're kind of in a weird place because they're more like script assets and less like "normal" assets
Yeah, they're not yaml serialized and all that
I guess I have to do the thing I did for Shader Forge
Serialize all the metadata in the .shader file itself as text
But yeah, thing I wish I could do:
Make all materials using a specific shader automatically be a sub-asset of that shader
So all your materials are nested under the corresponding shader
But alas
Yeah I recall that's how it worked in ShaderForge
Although for some reason I was using my own hierarchical .csv-like serialization which I definitely shouldn't have
I should've just used json
Looks like ShaderGraph has its own asset format, and the .shader file itself is nowhere to be seen. I'm guessing it generates the .shader into the library folder or something
Yeah
But if you look at the assetimporter
It looks like it ads the shader to the main context as main object
ctx.SetMainObject(shader);```
@blissful burrow Random question in between, are you still streaming often?
I've forgotten to pop in for ages
Tomorrow is the one day I'm busy 😛
As Navi stated, Shader assets have a 'real life' content (like other types of assets such as text, script, image), which is code.
Prefab in the other hand (or ScriptableObject, scene or any Unity-related assets) are understandable by the serializer, and be converted to yaml.
Adding the latter as sub-asset makes sense.
Adding a C# file under prefab or SO is physically not doable (for the example).
So, I'm curious how you saw that in shader Graph
Saw what in Shader Graph?
I'm looking at the code from the scriptedimporter for the shadergraph asset
I was looking at this just now https://github.com/Unity-Technologies/ShaderGraph/blob/master/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
And it's literally loading the same asset as a shader somehow
'Which makes me wonder - how does Shader Graph do it?'
Ah! I meant "do it" as in, "solve this problem", not as in "nest .shader assets"
I feel like ShaderGraph is just a normal asset that is deserialized as json then the nodes get parsed and converted to raw shader
Which is then handed as normal by the AssetDatabase
I suppose, yeah, and that is then imported into the Library or some other cached folder?
It seems super hacky, but, makes sense I guess?
I think it might just be an in memory thing
Well, I doubt it would have to recompile all Shader Graph shaders as you open your Unity project
That can't be the way they designed it
It's interesting, I'm curious to play around with this myself now
It starts by loading the old shader
What is the "old shader" in this case?
Which is then not really used
Library is for existing assets.
If their trick is a post-deserialization convertion, Navi is right, it will be memory only
If you look at ShaderGraphImporter:59
They're imported the same asset through the assetdatabase, the assetdatabase probably cached it in the backend of things
@onyx harness Not sure what you mean
Library is for existing assets, sure, and a shader you already compiled would likely be placed in there, as an existing asset, and loaded on demand when needed
Which is what I presume it does
I really don't think Unity reconstructs all shader graph shaders on load just because it has to lie in memory and can't be cached
What I think is happening is that the import asset triggers the custom importer, which then parses the shadergraph file manually and generates the Shader asset.
The generated shader then gets set as the main asset of the AssetImportContext. This in turn causes it to be seen as a normal asset and cached somewhere in the Library folder for persistance.
Hum... I'm sorry I don't have a pc to look into Shader Graph, I would have gladly dive into this question
@waxen sandal Yeah
I think it has to do with how ScriptedImporters work
Which should totally be doable for your own thing
Wish I would have time to do that as well 😄
I was going to say that neat is an understatement but you know neat corporation 😄
✨
Anyways, will you be streaming on Friday as well?
Like the new pic @shadow violet xD
If so, I'll try to remember to pop in and say hi
Thanks fam o.o @random flume
Lol, rip :p but actually I might have an asset in a few days I'll need testing o.o
I'll probably be streaming Friday too @waxen sandal ! Feel free to join
Alright, sure
@blissful burrow Lets hope I don't forget this time 😄
You won't miss too much, it's mostly this https://twitter.com/FreyaHolmer/status/1153019804065779713
Haha, that's actually so accurate :p - when do you stream? Like what time (and timezone)? @blissful burrow
Haha, happens to the best of us 😃
Uh, it varies a lot unfortunately, and I live like 50/50 in Seattle and Sweden. Currently in Seattle. But, around this time Tomorrow and Friday I would guess?
I didn't know you lived in Seattle 😮
Technically/legally I still live in Sweden, but have very long visits to Seattle
Ah ok, understandable, I'm close to finished work around this time so hopefully I can catch it
Feel free to join! I stream dev on my own game, while also answering any questions you might have, explaining what I do as I go along! I try to make it a tutorial-like thing, especially when people are asking stuff
That's good! Those type of streamers tend to be the most engaging imo, excited to see your progress and such
@shadow violet Example of stream shenanigans: https://www.youtube.com/watch?v=_k28qTMIOWQ
⬇️ Click for info How to physics Twitch ❱ https://www.twitch.tv/acegikmo Twitter ❱ https://twitter.com/FreyaHolmer Discord ❱ https://discord.gg/v5VWuga Insta...
Anyhow, sorry for going a bit off-topic, I don't want to displace people who have actual editor scripting questions 
Is it possible to use IMGUI outside the OnGUI function ? I want to draw UI with Code in 3D space ? Perhaps draw it on a plane ?
@blissful burrow I don't know if this was properly answered, but I believe you can only add sub-assets to assets that are imported directly into the Library by Unity. .shader files, like image files, are imported as conversions of their original source. The Importers re-write the entire file to the library when they run.
To add sub-assets you would have to write your own importer, and it would operate on the .shader source file to generate those assets.
To add a sub-asset is to literally write the data into the asset file itself, so that when it's imported it contains that data.
To do that to something that is an external source file doesn't really make much sense.
Gotcha, thanks!
Is there any way to use a # to check the scripting runtime version of a project? Like there is PlayerSettings.scriptingRuntimeVersion but am I able to basically say something like
#IF PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest
//do 4.6 language-specific code
#ENDIF
? I have some code in one of my editors that use the dynamic keyword as a solution to a work-around problem, but projects using 3.5 scripting runtime, will get an error, whereas projects running 4.6 is perfectly fine (since "dynamic" keyword is I think language 4+) so I wanna make sure the code is ignored if thats the case and just display some sort of "sorry we cant give you this feature in the current version of your project" or something
Awesome, thanks!
Hey, does anyone have experience with the AssetPostprocessor?
I have this script in the Editor folder, but it doesnt trigger any of the ProcessModel methods, when i import a new fbx file or reimport an existing one. Also tried restarting unity/ other unity version (im using 2019.1.7f1)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class FBXImport : AssetPostprocessor
{
void OnPreProcessModel()
{
Debug.Log(assetPath);
}
void OnPostProcessModel(GameObject g)
{
//Only process fbx files
if (assetPath.Contains(".fxb"))
{
Debug.Log("Processed "+assetPath);
}
else
{
Debug.Log("Imported non fbx file");
}
}
}
@hushed sentinel You're checking for .fxb instead of .fbx 🤓
xD oh... yeah thats a mistake... still it should trigger the other debug.log, right?
@grizzled minnow
I'm trying to understand how to add extra columns to ReorderableList, I never knew it was an option until the RPG Creator's kit. Here's a screenshot of the component: http://prntscr.com/ok73jh By multiple columns, I mean the "A.0, Hello Traveller..." being two different entries. Here's a pastebin of ScriptableConversationEditor.cs : https://pastebin.com/WKAPFJaw , which should be the relevant file here I think. My Google Fu is failing me on this one, is it a new feature? I THINK the relevant section
*I THINK the relevant section is OnDrawElement(), but I'm not sure about what's even going on well enough to be sure. Can someone explain how it's doing it or point me in the right direction?
Hi is there a way to serialize a list of abstract classes ?
Like a list of their types?
What exactly are you trying to serialize
Instances of derived classes?
there's a new feature that let's you serialize instances with type information in 2019.3 [SerializeReference], but you can't explicitly create or serialize instances of abstract types, only concrete types.
Forum post:
https://forum.unity.com/threads/serializereference-attribute.678868/
Is there a way to find all monoscripts in a project including the ones in packages?
Oh nevermind, I already got it
This project just has surprisingly little scripts
AssetDatabase.FindAssets("t:MonoScript, new[] {"Assets", "Packages"}); via code
AssetDatabase.FindAssets("t:monoscript") works as well
That wouldn't get in packages by default I think? Not certain if that's changed
Apparently it does
Must have changed then
Or I might be doing something else wrong
@visual stag It definitely does work without specifying Assets and Packages
i need help im trying to install lightweight rp
but im afraid something would go wrong and my assets would dissapear
are you using git ?
well i was trying
i followed the tutorial
but it didnt work
its not that it didnt work'
its that when i followed it the files wasnt there
what you can do is : push your project on the cloud, then install what you want and if it messes the things up you can just revert the changes and get back the original project
and since im using the collaboration thingy it said version control something something
This channel is for extending the editor, not for general questions. #💻┃unity-talk is a better place to ask about source control with unity.
o
so I wanted to have this message occur only in edit mode when destroying the component. I can check for Application.IsPlaying and EditorApplication.IsPlayingOrWillChangeState
but unfortunately the message still appears when quitting unity with this inspector open
or when unloading the scene
what are you thoughts about handling this? I don't want to just not tell the user about the extra components, i doubt they'll notice an error message in the console, and working around the ondestroy issue or on application quit issue both involve creating a separate class that listens for these events and doesn't seem worth it if i'm going to do this more than once
i can subscribe to the editorapplication.quitting event but i wanna avoid having a a whole bunch of editor scripts subscribing and unsubscribing all the time and making listening functions for them
I also can't seem to find any way to know if the OnDestroy() is being called by the scene being unloaded or reloaded
Not really a known solution for detecting if the editor's changing scenes, though
For a editor script, is saving JSON/text files to be read in by the asset, to the "My Documents" folder the best thing to do? I was thinking of putting it in the actual Unity installation folder, but I want it to work across multiple Unity versions so that wouldnt wok, and I donno if its weird for an asset to go into a users Documents folder o.o basically these are "templates" that come with a few default ones, but the user can also create and modify their own templates, that are automatically added to a folder, and then choose which template is used by the asset, in any project they want, and the asset will work based off that template
@shadow violet what about reaching the user"s projects folder and creating a folder named templates there?
It could work as long as the user didn't have multiple different folders for unity projects and no project name template
@shrewd hatch if im understanding you correctly, that would assume the user has 1 common folder they put ALL their projects in? What if they dont? I do some freelance work for this one guy who for whatever reason, has like 12 projects on his desktop, and a bunch of a external drive, and just a few in the Documents folder, but hes not really a developer, per-say, he may be a special case o.o
Yes I'm assuming that
And the funny thing is that I do have more than 1 folder with projects but I assumed I was a special case as well 😅
Lol :p fair enough - that does give me an idea tho... What I could do is default to "My Documents" and allow them to enter a specific path where they want my templates to exist, and then move the contents already saved from My Documents to that specific path, and then save in My Documents a text file that contains the specific path they always wanna access templates from, that way across projects when they start it up, I just pull the path from that, unless I can somehow save that path in like a registry and pull from that across projects, but EditorPrefs I was told, is per-prooject
Also, what about that folder under the user folder, AppData I think? I believe it's purpose is to store this type of stuff
But yeah I like that solution
Made a grid editor that allows me to "edit coordinates" in different list based on height, along with control hotkeys. Using this to edit both walkable path and collision layer.
Quick question. Is there any place with up to date Unity tutorials that aren't videos and focus on scripting?
I'm going nuts trying to learn how to create procedural UI in Unity, because I work 10 to 12 hours per day. I really can't spend an hour listening to someone stumble through nibbles of information. I'd reach what I need per hour on a per month basis.
IMGUI does what I need, but looks terrible. And drawing to a Canvas object is so poorly documented that it makes me want to chew my own face off trying to do it.
@whole steppe This channel is for extending the editor, not for general questions. #💻┃unity-talk is a better place to ask about tutorials.
Or #📲┃ui-ux if you want to be specific
@shrewd hatch I think that AppData folder is still project specific tho, cause when you navigate to it, its something like C/Users/[Computer]/AppData/LocalLow/Company/Project/file.json, tho I guess I can just navigate backward and cut off the "/Company/Project" part, so it saves directly to LocalLow... That could actually be a viable option too now that I think about it, im gonna give that a try - thanks for the idea on it :)
You welcome and that's what I was considering, maybe even making a folder with your asset's name in LocalLow
Yeah, im gonna try "Roaming" since on Windowss, thats across all profiles/accounts, and then test with people on Mac and Linux, since they dont have a "AppData" folder at all, ill have to tweak it for those platforms
look into persistentDataPath
https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html
Does by any change anyone know if the checkered background used for transparent images is accessible anywhere? Would like to use it in a UI
Hey, I'm trying to figure out UIElements, any idea how to detect button click?
MouseDownButton doesn't work
@zealous coral yeah, thats what im using now, but the problem is, that AppData is Windows-specific, Macs dont have a AppData folder, and it points to somewhere else different, so I cant use my logic of removing "company name / product name" to get to the root AppData folder - and basically what I have right now, I know will only work on Windows, so im not sure what will happen on Mac/Linux, but my guess is itll just throw a error saying the path doesnt exist:
static string templatesPath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.IndexOf("AppData") + 7) + "/Roaming/Unity/Project Templates"; //%AppData%/Roaming is a consistent path across PC profiles
Application.persistentDataPath is platform dependent, it changes automatically, u dont have to force it use "AppData" at all
unless u are trying to make some weird sharing/reading behaviour that somehow would read different platforms sometimes
if necessary, u can handle each of the platforms separately using preprocessor directives
#if Windows
#if Mac
etc etc (Windows and Mac is not the way to type it but u get wad i mean)
https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
@zealous ice from my previous testing, i found one way
Button button = new Button(()=>{printf("button clicked");});
there is also button.RegisterCallback, but i didnt look too far into it
I done it using register callback, trick is to find correct event
MouseCapturedEvent in this case
also, new Button doesn't work with uxml
what do u mean doesnt work ? i am still extremely new with UIElements too so i am just trying to help as much as i can
@zealous coral yeah thats what I planned to do using preprocessors, but the problem is, I want it in the root directory of where that platform saves persistent data path files to, and I only know how it works on Windows cause I own a Windows PC, so my logic with that bit of code wouldnt work on the other platforms, so id have to use preprocessors most likely anyway - what im trying to do is basically save text files to a location that will be common/persistent across any Unity project and Unity version, the full path for persistantDataPath, is project specific, and since I know exactly how the path works on Windows, I can go to the root of that and save there for Windows computers, I donno if that makes it more clear or more confusing o.o
How can I go about getting the name of a scriptableobject for a custom editor? I am wanting to save myself a little time by setting a string to that name for items in my game.
hi 😃
when I have something like a public gameobject on a class, it will show up with a file navigation and a little circle in the inspector
what function is that in a custom editor window?
An objectfield?
@static nexus If you have a serialized object then you can just so.FindProperty("m_name")
thanks navi
Not that I know of @static nexus
Ah, well thanks.
thanks vertx 😃
so I can get one object with objectfield, how do I populate a list with objectfield
Like... Do you mean selecting an object with object field and then adding to a list after that 1 object selection? Or like selecting multiple object fields at once or something and adding each to a list?
more of the first I think
anyone trying new UIElements?
I have some trouble with binding
without UnityEngine.Object
or there's way to tracking undo/redo in UIElements has no bind?
um nevermind :/
@full flax you could do like:
static List<string> whatever = new List<string>();
static Object obj;
void OnGUI()
{
obj = //your ObjectSelector line;
if(obj != null)
{
foreach(string s in (desiredType)obj.propertyWhereListIsContained) {whatever.Add(s);}
}
}
If I understand you correctly - though I guess youd wanna store "desiredType" as the actual type, if you know exactly what your accessing, otherwise it would be generic and you probably wont be able to get the exact variable from the object your looking for, without casting it first
How do I display unityevents in the editor window, I have looked and cant find a good answer.
I think propertyfield can draw them
EditorGUI.PropertyField?
It says it cant convert unity event to serialized property
Do you mean in the inspector, when you have an object selected?
Or in a custom editor?
Custom editor window
var serializedObject = new SerializedObject(objectWithEvent);
var property = serializedObject.FindProperty("eventName");
EditorGUI.PropertyField(Position, property);
@timid cobalt
Yup
You need to replace objectWithEvent with your object reference, and eventName with the name of the UnityEvent field
The add to list button now dosnt work
dibbie: thanks 😃
hi!
i'm trying to make this current object just follow my cursor
but it's not showing on my cursor :(
You want ScreenToWorldPoint for a start https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html
But this channel is for extending the editor, #💻┃code-beginner is for runtime scripting. @edgy lake
Yep you got it backwards.
Anyone know if there's an easier way than the TreeView "tutorial" on making a foldout-toggle? Iv tried basically recreating it with just those 2 parts I need and I can't seem to get the repositioning correct when expanding collapsing (I'm on mobile atm so I can't get to my code, but if needed later today I can show the code iv tried), or if there may be a better way to display a hierarchy of folders and files the user can decide to toggle if they wanna include or exclude?
TreeView is the best option imo
But you can roll your own thing using https://docs.unity3d.com/ScriptReference/EditorGUILayout.Foldout.html
I tried working with it but it has so much extra crap I don't want or need and can't seem to hide the stuff I don't want, like I don't wanna show the top columns bar at all, just the content, and I tried rolling my own solution, after work, I can post my code that uses toggle and foldout, and hopefully it'll be understandable, cause it's a bit... Weird imo
Hmm, is there a way to turn example 1 into a toggle foldout, similar to the "import asset" window? Cause I couldn't find where it was actually drawn to extend it, later im gonna try to add some buttons to certain ones and such and it seems so deeply rooted, that it's kinds "this is what you get", but I was looking at the transform view at the time
I think you can provide a template for the items
I'll take another look then when I get home from work, and if I can't figure out how to modify the template being used, I'll show you the code I had - do you know if there's anywhere online that talk about the templates?
If you scroll down on the same page to Customizing the GUI
Alright, I'll take another look then, and be back if I have issues, thanks for the guidance/direction
can any of you know why it's not working? https://pastebin.com/e8GKqQeq
here what i got: Assets\Resources\Scripts\CharactersScripts\Editor\SkinsChangerEditor.cs(31,35): error CS0115: 'SkinsChangerEditor.CreateInspectorGUI()': no suitable method found to override
decided to trash that code, it's not working like i wanted pfff
Can you create a script that will automatically edit a polygon collider to match the outline of the shape displayed in the sprite renderer?
Isn't that a thing it automatically does
If you tick Generate Physics Shape on the Sprite Importer
It's not accurate from my testing
You can make such a script, but it wouldn't really be trivial
Assuming it goes by color or the alpha of the pixels on the texture
I'm very new to unity, do people just usually use the manual edit collider feature? It seems very impractical and I can't find any way to snap to the edges of the sprite etc
It depends on how accurate you really have to be...polygon colliders are a lot more resource-intensive for collision detection than simple colliders
I usually stick to simple colliders if I can help it
Even two or three colliders is still better than one polygon collider, to my understanding
My shapes are very simple, such as T shape object. It won't take too long to do manually but it's difficult to get straight edges because I can't find a snapping feature
If it's a simple shape, use two rectangle colliders instead
Two box colliders, that is
Wouldn't that mean I would have to use 4 colliders? I use the colliders with 'Is Trigger' selected and I have found that the the objects just fall through each other if you don't have any box colliders attached to your object without 'Is Trigger' enabled. Not sure if that makes sense
Why do you need both triggers and regular colliders?
If that's something you need to do, yes, you'd need 4 colliders, and it is something that's needed sometimes
because if i have a object with a single collider with 'Is Trigger' enabled, it will just fall through objects regardless.
There's a special component that will blend your simple colliders together, too
This is kinda getting outside the scope of this channel now, might be worth taking it to #💻┃unity-talk #⚛️┃physics or #archived-art-asset-showcase
Sorry vertx, one last question because it's relevant to the previous message. Dameon, do you know what component that is?
Composite collider
Thanks
Hi everyone! Super excited to be here! Just finished the complete Unity udemy course!
Possible or existing simple fix to darken or replace the checkerboard backgrounf, so it's easier to seee filesize info:
alternatively, change font color of that info.
is there a way to use this csharp EditorGUI.DrawPreviewTexture(new Rect(25, 60, 100, 100), sprite);
with UIElements?
Use an IMGUIContainer
Can you extend the elusive hierarchy search?
it's really taking place with these many ^^;
so, i was thinking with image, it could help me greatly
@grim walrus not sure, but you may have more luck making a provider for the QuickSearch package
so far, here what i managed to do: ```csharp
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
public class SkinsChangerEditor : Editor
{
//[MenuItem("Window/UIElements/SkinsChangerEditor")]
[CustomEditor(typeof(SkinsChanger))]
Texture2D sprite;
private SkinsChanger _skinschanger;
private VisualElement _RootElement;
private VisualTreeAsset _VisualTree;
private List<Editor> objectPreviewEditors;
public override VisualElement CreateInspectorGUI()
{
var vis = new VisualElement();
return vis;
}
public void OnEnable()
{
_skinschanger = (SkinsChanger)target;
_RootElement = new VisualElement();
_VisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Resources/Scripts/CharactersScripts/Editor/SkinsChangerTemplate.uxml");
//Load the style
StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/Scripts/CharactersScripts/Editor/SkinsChangerStyles.uss");
_RootElement.styleSheets.Add(stylesheet);
}
public void AddButtonIcon()
{
IMGUIContainer icon = new IMGUIContainer(() =>
{
EditorGUI.DrawPreviewTexture(new Rect(25, 60, 100, 100), sprite);
});
}
}```
well ya gotta make some queries and add that container to an element. I've only done direct stuff though, so can't really help around UXML
for that part, i managed to do this: ```xml
<VisualElement class ="row">
<Label text="List of Momoo looks" class="header"/>
</VisualElement>
<VisualElement class ="row">
<Button name="momoo_Flat_C" class="overrideController-button">
<VisualElement name="Icon" class="overrideController-button__icon" />
<Label text="Momoo Big Udder Clothed" class="overrideController-button__label"/>
</Button>
</VisualElement>
</UXML>```
and the CSS: ```css
.row
{
display:flex;
flex-direction: row;
justify-content: center;
}
.header
{
font-size: 15px;
color: #ffd800;
}
.overrideController-button
{
height: 125px;
width: 125px;
margin: 5px;
justify-content:flex-end;
}
.overrideController-button__icon
{
pointer-events:none;
}
Label
{
font-size:12px;
}```
i'm very familiar with css and xml but not much with c# 😬
Took me a while to find this one... var pinfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath("Packages/package.name/asset");
Why does it have to be so hidden
Hi all, is any chance in UnityEditor draw line between 2 objects?
Is possible use in unityeditor this?
Can you not use Debug.DrawLine or Gizmos.DrawLine?
@visual stag I will try when I alive at home
Is there an event that gets called when a script is created?
AssetModificationProcessor.OnWillCreateAsset doesn't get called for scripts
Hi guys. Anyone using VS Code?
In Unity 2019 you can double click in console the stack trace, but it doesn't seem to work for VS Code. I remember it worked when i's still using VS
@real ivy maybe this? https://answers.unity.com/storage/temp/77843-untitled.png
I did that. VS Code works when i double click console debug or the monobehavior. It's just the new 2019 feature where the stack trace is colored blue and u can click on those to get to each stack trace
Then I dont know 😦
Hmm thx anyways
I only started using VS Code like a few months. While i like it, i think i'm going back to VS because it's more hassle free and more "built in"..
I still using VS2013 😄
I would like to have a settings class (in editor) that manages persistent data. I would like to:
- serialize/deserialize this data,
- benefit from Unity's undo/redo system,
- display it as one of the "Project Settings", and
- read these values from "InitializeOnLoad*" functions/methods.
All of the examples related to SettingsProvider show ScriptableObjects, but ScriptableObjects don't allow for #4.
Does anyone know how the internal "Project Settings" are handled?
I tried to switch from vs 17 to 19 but 19 didn't have intelisense for whatever reason so i switched to vs code which i am glad i did since it looks much better
Also is switching to jetbrains rider worth it?
@tough cairn it will be on 2019.3
@young falcon actually you can read from there, just use EditorJsonUtility to read the values from there
@whole steppe I switched Rider has been one year and I don't regret, it has a ton of cool features that now I missed when I tried VS 19, but I do recommend to install it on a SSD to speed up when starting it
@regal jasper do you have the student license ?
does rider didn't do like vs 19 by installing 32gb of stuff?
what do you mean
augh my english...
it takes 30 gb?
vs19 yes
@whole steppe I've used the studant license by 6 month, then I upgraded to the personal one (it has a cool discount if you do that :p )
@idle anvil no, Rider is like 5 or 10gb at worst if I am not mistaken
oof, that is alot too but much less than from microsoft apparently
and yes that is what i'm using vs code
good,
after i dished it but unfortunately, i had no idea where the rest of stuff came from...
which i was forced to buy a new SSD
it was 128gb
now i'm using 512gb
My Rider folder is only 3.23 gigs
@idle anvil is that your only disk?
nope, i do have 4 HDDs
SSD is mainly for Operating System
would you please stop joking...
like i was going to said, i also use SSD for my 3D softwares well some art software for them already
the rest of HDDs are mostly my art datas as well my games and musics
top kek
also, i can't afford to get these 2TB for SSD back then, i'm not THAT rich you know?
Hello fellow devs!
I have a problem with Handles...
Like in the image pictured, ProBuilder draws it's vertex handles/wireframe hints - cool.
I have a script that analyzes PB vertices and draws a circle around some of the vertices.
Apparently, the circle is getting drawn behind the PB vertex handles and PB wireframe.
Is there a way to draw handles with specific depth, as to draw my circle on top of PB stuff?
Does anyone know of a way to force a Repaint in a window derived from PopupWindowContent?
I'd imagine you just repaint the attached editor window
well it's being created by a property drawer
oh you right, PopupWindowContent gets a reference to the window it's in
👍
Editor serialization is uh
quite the thing
this is fine 
Trying to figure out a nicer way to do it compared to my old method of making almost everything UnityEngine.Objects, but I fail to think of any
Big complex plugins really need object references to be serialized, heckity
Unity doesn't do polymorphic serialization, which definitely sucks
No Interfaces, no generics, no polymorphic arrays
It does serialize with polymorphism if you derive from UnityEngine.Object though
I really wish they'd fix their serialization...it's so annoyingly limited
Yeah it's pretty crazy
It hasn't changed from what I can tell ever since Shader Forge, and that was like, a scary amount of years ago
I don't think it'll serialize polymorphic arrays is the problem. A List<UnityEngine.Object> will just get cleared out when the editor reloads, from what I remember
Pretty sure that one is fine
Yeah, I wish I could just circumvent it and use SharpSerializer or whatever
Hehe, yeah
I thought of doing that
But then undo might be an issue?
Since it relies on the serialized data and all
Or rather - relies on it having to be Unity-serializeable
To make the editor use entirely different serialization would be a pretty extensive overhaul, no idea about undo
Undo works fine on just regular objects marked Serializable
One approach I've played with is to keep your classes 90% plain C# classes, and have very limited interaction with the editor, and use custom serialization
Undo.RegisterObject only works with UnityEngine.Object, but I'm guessing you're talking about non-UnityEngine.Object derived serializeable fields in them
Yeah
Ah, neat, did it work out?
It's got its upsides, but winds up working around the editor a lot, which kind of defeats the purpose of having the editor
Hm, alright
But opens up all kinds of modding possibilities, and lets you freely use Interfaces and events and all to your heart's desire
ScriptableObjects are my life
I'll probably just end up using the same method I did for Shader Forge ¯_(ツ)_/¯
ScriptableObjects just suck because they suffer from all Unity's serialization limitations
Which is, yeah, that, ScriptableObjects everywhere
ScriptableObject has less limitations, no?
You can have actual object references
With no duplication shenanigans
Just put a scriptable object inside of a scriptable object and then you have less everywhere
Yeah
Still can't do Interfaces, or generics (without making a concrete implementation)
I feel like those are the limitations you just live with and work around when working in Unity
Ah, well, yeah, but that's a limitation for any serialized type, not just ScriptableObject, no?
Unless you want a custom serializer and deal with nobody being able to use your product
(by that I mean, like Odin, custom file writing is fine, just a pain :P)
Yeah, it's best to just live with the lack of Interfaces and generics; I've learned to deal with it
I usually don't use interfaces anyway~
I've always found that I want them to me multiple inheritance rather than what they are
At least when they introduced UnityEvents it was a big boost for being able to decouple
I want Interfaces with method bodies and fields ✨
I love Interfaces...I believe using abstractions is really helpful
I've almost never needed that, but maybe it is because I don't see the cases where it would be beneficial
or because Unity has made me used to not trust them and so I don't think they exist
They're great for decoupling, so you don't have to rely on a concrete implementation, which has a lot of benefits
I use them often enough, though I definitely find myself making classes first 😛
I've come to be really into UnityEvents as a way to decouple, they're really a pretty powerful tool
I love and hate them
It's essentially Dependency Injection
They make following behaviour really difficult, but they're great for artist implementation
Even with the visualiser (https://github.com/MephestoKhaan/UnityEventVisualizer) they're still difficult to debug at times
Yeah, events can be a pain to visualize, although not so bad if you follow in the debugger
Despite the downsides, I still feel like they bring a lot of benefit by essentially giving you a Dependency Injection framework, and yeah, by making it easy for designers and artists to do a lot of neat things without having to bug you to make special code
As long as you don't go changing the event's type to add another parameter after you make it the first time, leading to a bunch of prefabs breaking and having to be have all their events wired up again
watcha buildin'
Basically each class that requires referencing, extends a type that extends ScriptableObject, and that type keeps track of its child objects, so that when the parent is destroyed, the children are too
Also with undo support, optionally
I'm tinkering with some ideas for Shader Forge 2
Although it's mostly noodling around at this point, but I've written a bunch of design notes
I've got a pretty good grasp of what I want to do and why it has value, even with Shader Graph being a thing that exists
Interesting, I would have thought the time's wouldn't have been kind seeing as there's Shader Graph and Amplify
SF/SG/Amplify all occupy the same space
So, uh, let's see if I can stitch together an elevator pitch 🤔
The above editors, are all super neat, and user-friendly, and great! They allow artists to super easily and quickly make something pretty and good with shaders. But, as soon as you want to create specialized shaders, or advanced multi-pass shaders with very precise optimization - you need to hand-edit
That's what I do today basically
But!
What if, there was a node based shader editor, that was just as low level, and gave you just as much control, but with the convenience of all the things node editors give you?
That's the space I want SF2 to sit in
Sounds very cool, I definitely see that space as lacking
but I wonder if Shader Graph will head there soon enough
Yeah, I find myself using SF a ton, until I need those types of shaders. And it's frustrating, because it's so much slower to hand-edit shaders
They might, and I should probably ask Unity to see what their plans are
Before committing to this
But I doubt they would make a shader editor go more low-level, I'd guess they would push more for the artist and ease-of-creation audience, since it's more popular and easier to market
That'd probably be my thought, I've got a similar situation where I wanna make stuff but am afraid I'll just be competing
Yeah
I actually had this happen very recently
It made me really hecking sad : <
I doubt it'll be a priority for them, but I can imagine them heading that direction
The extent of VFX graph really surprised me in the level of control a node graph can have as developed by Unity
I had been working on a recorder plugin for Unity for several months, you know, to record .gifs/.avi from the editor, but then as you already know, Unity released their own recorder, and it matched my feature set to 95%, so there's no way I would be able to have people use mine, and the 5% uniqueness of mine is probably not enough to sell people on it 😦
Which sucks because I was so hecking happy with the results of it
I was working in the virtual production space when it happened and it was very good because it was like "yaaaaay I don't have to use my hack any more!"
So many tools I made just got rolled into the editor in the space of a year
But in my case there were so many things on the go it was good to not have to be in control of more software 😛
Hehe, I can imagine
Motion blur - useful even at 60 fps ⚡️ https://t.co/5lVyUayiGi
334
2345
This was recorded with my recorder
I remember seeing these tweets
The one feature I had that Unity's didn't, was temporal interpolation, or, actual real motion blur
At least I don't think they had that
I think they were just relying on the post effect
Yeah, which isn't as neat!
Also outputting the vectors and stuff and doing it externally
How does that stuff even work? I assume you're still using velocity vectors?
Seeing as it's radial and all...
I render subframes!
You specify quality of blur, which is the number of subframes per frame
Ah, so similar to what Unity's done with Sherman
Ah yeah! Sounds about the same
Though you must note that theirs does not do it automatically, and you actually have to type in "960" into the rendering settings and swap it back by hand
Oh, haha
This is one of my favs, showing the motion blur in action proper, haha
That's awesome
Do you have any screenshots of the UI or is that not much to look at 😛
Ah the ol' helpbox vertical scope, my favourite 😃
Augh, still makes me sad, I spent so much time writing this
All I had left was to polish up the real-time recording, and record audio too
It was low prio, I might've skipped it depending on how tricky it would be to get that right in combination with the throttling to render all the blur frames and whatnot
I wonder if any of the audio stuff gets better now with DSP Graph...
your recorder window looks easier to read than unity's
also the idea of a SF2 filling that gap where resorting to hand-writing code usually occurs is great.
I think any sort of useful visual debugging in-graph (similar in spirit to some of what unreal offers) would be nice too.
Most of my shader work now involves bouncing between code and renderdoc captures just to verify how certain things look and check values.
(and also fixing my dumb mistakes)
Is it possible to default Unity to place new gameobjects at the bottom of the hierarchy when they are dragged into scene?
When they get added to the top they get mixed in with my managers etc, which I don't want to delete by mistake.
Thanks for the feedback @humble remnant !
To be fair, if SF2 was just a visual debugger for shaders it would be amazing
What do you mean by visual debugger in this case? Like, being able to see each step along the way?
But yeah, that would involve writing a CG/HLSL parser, which is quite a lot of work
I didn't say it was easy 😄
Hehe
That being said, I'd love to write my own shader language, that would be a super interesting challenge!
Although nobody would use it, but, still!
I've got a slider set for 0-100 but I can only start moving it if I click around 12 first. I can't select the slider before that
Anyone seen this before?
Sounds like the width of the element might be too small or something?
Even though it visually spans a larger area
How do you define the slider?
I just created it in the editor
How?
Which UI do you mean?
right clicked on Canvas > UI > Slider
Ah, that would be under #📲┃ui-ux
Since this channel is more specifically editor scripting
Ah okay, this channel is for extending the editor. You're more likely to find help in #📲┃ui-ux or #💻┃unity-talk
ah ok
I'd guess something is on top of the first part of the slider though
so many channels here... hard to decide
#💻┃unity-talk Is often a good place
@waxen sandal you are right actually! I see my text label is too long DOH!
✨
sometimes it's the simple things
So, to return to the channel topic - in UIElements, how do I get a MouseUp event that isn't bounded by the element?
For instance, right now I'm making a draggable thing, and I want to stop dragging it OnMouseUp
But the problem is that OnMouseUp can happen outside the thing, and the event won't fire
I basically need a global OnMouseUp regardless of where you released
Can you subscribe to the mouseup of the root object?
Hm, I guess, seems a bit, oddly convoluted though
Otherwise good old Event probably works
Wish there was like a, RegisterRawCallback or something
But then I'd need an OnGUI loop
I'll go for the root mouse up for now!
It's, pretty involved, seems easier to just roll my own!
I didn't look this up specifically though, I probably should
Haha yeah
@blissful burrow https://docs.unity3d.com/Manual/UIE-Events-DragAndDrop.html
Make the drag specific events?
Those are for drag and drop functionality specifically though
That's what I was assuming you were doing 😛
Drag and drop as in, assigning data by dragging an item with said data to some container target
Oh
I want to just drag it to change its position!
That's confusing
Ah! Found a thing
elem.CaptureMouse
heck yeah that works
Okay, so, calling CaptureMouse() on press, seems to imply that you get all mouse events regardless of where they happened, until you call ReleaseMouse()
Yeah
Thanks for letting me know 😄
Can someone let me know why two objects with the same coordinates aren't instantiated in the same position?
@full lagoon There could be number of reasons for this. Please use #💻┃code-beginner to show the code how you are instantiating them. This channel is for extending the Editor.
Does anyone know how to edit the search field in the hierarchy programmatically?
When I try building my game it fails because of these errors, however I don't get these errors while the game is running or when working in the editor.
Well I'm an idiot, the folder the scripts were in was called "EditorScripts" instead of "Editor", problem solved.
alright, it seem i managed to fix most of bugs but i have no idea why i got this:
Anyone have any ideas of how to copy a serialized property in the editor, and paste it into another serialized property of the same type on a different object? Similar to copy component values on the inspector but instead for structs / classes that don't inherit from UnityEngine.Object
@idle anvil that's most likely a Unity bug
how interesting
all the code in the stack trace is from Unity
is there a way to know which version of .net is?
restart might help
.net version is set under Player settings
just note that .net standard 2.0 is newer than .net 4.x
I am trying to display a unity event in an editor window and I have it shown but when I hit the + button on the unity event it says add to list but nothing else happens and it doesn't add a new event.
It might be tied to code that expects it to be in a custom inspector...could be the only way to get it working would be to recreate the functionality
It wouldn't be something that's easy to do, or summarize how to do
Ha, found a page with a solution, but it looks like you already found it and it doesn't work
Ok
Do you know any place where I could find how to do it
@cedar reef
I have looked around
https://docs.unity3d.com/ScriptReference/AssetDatabase.AddObjectToAsset.html
Is there a way to add GameObjects/Prefabs as sub-assets of other assets? The above method apparently works for everything except for GameObjects.
The documentation does mention You can not add GameObjects; use PrefabUtility instead. which makes me think it is possible, but unfortunately it doesn't mention how exactly.
Does anyone know how to have a place where you can drag a script in a custom window.
I don't know the technical name for it
I think EditorGUILayout.ObjectField is worth a try
Hi, opening Visual Studio after a compile takes 10 secs.
I think that its because it syncs all the assembly data to allow a nice debugging.
mi questions: There is a half-way, between attaching editor to VS and disable the debugging,?
For example a manual sync, just before debbuging?
attempting to snap all of the prefabs to ground with this script and the y value is all set to -49.95 or something like that
which is quite incorrect, not even close
however the code works fine when used singularly and not in a for loop
if you have any idea how to iterate through some terrain snapping action without getting this inexplicable glitch, ping me plz
rlly hate doing that manually
makes no difference at all
just tried it
still flattens the prefab way below the terrain, does not snap them to it.
changes nothing at all
What the... You can't even modify SphericalHarmonicsL2 struct?
Who came up with this decision?
It's extremely baffling. How am I supposed to do light probe editing then?
Can we at least get the data that is stored in those structs in order to wrap them around our custom structs?
And hey, look, someone actually COULD modify the coefficients on github, but the api is completely obsolete and the new one points to SphericalHarmonicsL2 structs, which are, again, not explicitly modifiable
And there is no proper constructor for the struct
I really, really want to know the logic behind this decision.
I've got no clue about spherical harmonics, but looking at the source, can you not index into it like an array?
All of it is private, so no I guess
Wonder why there was no info in the docs that it has a multidimensional array accessor
I'm genuinely sorry
Hah, it looks like you've genuinely looked at least :P
We all make mistakes
Hey guys, can anybody help me out. I'm trying to write a little assetPostprocessor script to help me out.
I have this fbx file containing various meshes. I want to create prefabs for each of these meshes, so a unique prefab for each mesh.
I have so far succeeded in creating a prefab for the whole thing using PrefabUtility, but this contains the whole fbx with all meshes etc.
What would be the best way to do this? Should I create a new object, add a meshfilter to it, copy over the data from the source, and turn this into a prefab etc, would that work? Is there a better way? Thanks
Does anyone know of a good way to hide a GameObject in the hierarchy but allow it to be selectable and select the parent instead when clicked in the SceneView?
does anyone have a good library for adding reorderable lists in editors?
I'm looking for something clean and simple, does not have to have a lot of features
I'm actually looking for a pretty native looking list
like this one, but I think I'm just going to dig into the unity code on github and check how they do it 😃
after all there is a ReorderAbleList class
Hello, does anybody know if its possible to get a global callback when a user clicks on a property in the inspector? (not a custom inspector, but any inspector)
Is there a way to make an actual native looking 'component' like the Line Renderer for example
so complete with icon, checkbox and without the '(Script)' behind it
@lucid hedge not sure about removing the (Script) from it, but to change the icon is very simple: https://docs.unity3d.com/Manual/AssigningIcons.html
For the checkbox, it automatically appears if you have OnEnable/OnDisable/Start/Update/etc funcions on your script (as it is directly equivalent to the enabled property, which only makes sense on the presence of those Unity methods)
thank you!
And I have another question regarding handles
I draw these white handles in the scene and I want to know when my mouse is going over them
I can use Event.mousePosition and then convert that 2D position to a world space ray
but how do I check for intersection?
or should I convert the 3d position of the handles to 2D position and compare those with Event.mousePosition?
You can create a new "selection" Rect of 10-20px at the handle location in screen-space, then check Rect.Contains(mousePosition) to see if the mouse is hovering over it
hi, can someone explain what does this mean =
NullReferenceException: Object reference not set to an instance of an object
PlayerMovementScript.Awake () (at Assets/Scripts/PlayerMovementScript.cs:19)
guys so i have a problem with a script
I am trying to make a simple script that changes the color in the sprite renderer (im in 2D)
after trying a lot of things it didnt work
if anyone can help i will show him the script
@visual portal @whole steppe This channel is for extending the editor. General code questions should go to #💻┃code-beginner
Ok
@grizzled minnow thanks! I already have another way to handle it but I'm gonna try that too
How would I create an editor window similar to the sprite editor?
As far as I can see, EditorWindow can do buttons, inputs, etc. but how would I be able to do things like drawing a sprite, handling mouse input for things like dragging/removing/adding points?
Does anyone know if theres an asset that acts like the old prefab system? Im thinking of making one to solve a few annoying issues I have with the current system to work as closely and efficiently as the old one, but if theres already one that exists, ill just import and use that
Hey can anyone help me?
@broken helm Don't ask to ask across multiple channels, pick one relevant to your issue and ask the actual question.
@brittle cosmos there is a way to get the mouse input, iirc it can be accessed via Event.current
Also u can draw textures on GUI
But it might be very CPU demanding ( depending on the size and draw frequency ofc... )
In that case, you might want to use smaller textures and scale them up
GUI.Label (Rect (200, 200, 32, 32), textureToDisplay);
GUIUtility.ScaleAroundPivot (Vector2(1,1), Vector2(3,1));
Thanks that thread seems useful.
And it seems you can use GL commands
I am running into a problem though with a scroll view (https://docs.unity3d.com/ScriptReference/GUILayout.BeginScrollView.html)
The GL commands work, but they're not masked by the scroll view, eg.
@brittle cosmos you need to provide a shader with the following additions:
sampler2D _GUIClipTexture;
uniform float4x4 unity_GUIClipTextureMatrix;
struct v2f {
float2 clipUV : TEXCOORD1;
}
v2f vert (appdata_t v) {
float3 eyePos = UnityObjectToViewPos(v.vertex);
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
}
fixed4 frag (v2f i) : SV_Target {
col.a *= tex2D(_GUIClipTexture, i.clipUV).a;
}```
You can see that in context in the built-in shaders
Perfect thanks
Why doesn't GUILayout.EndScrollView(); have the handleScrollWheel option?
It's all good, Event.Use does the trick if I want to use the scroll wheel for something else
Why are my scrollbars cutoff slightly, and the toolbar at the top has some extra spacing on the left and right?
This is all I've got:
GUILayout.BeginHorizontal(EditorStyles.toolbar);
_options = GUILayout.Toggle(_options, "Toggle Me", EditorStyles.toolbarButton);
GUILayout.FlexibleSpace();
GUILayout.Toggle(_options, EditorGUIUtility.IconContent("d_PreTextureAlpha"), EditorStyles.toolbarButton);
GUILayout.EndHorizontal();
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
So I'm not sure what could be causing it
Use the GUIView/IMGUIDebugger to figure out what's causing what
Info about it is pinned
Hmmm, that hasn't really helped me.
scrollPosition = GUILayout.BeginScrollView( scrollPosition, GUILayout.Width( Screen.width ), GUILayout.Height( Screen.height ) );
@brittle cosmos adjust width and height as needed
But that just creates one of fixed size. I'm using GUILayout so it automatically fills available space.
I would wrap it around another container and give it extra space on the edges
GUILayout.BeginHorizontal();
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
GUILayout.Space( 10 );
GUILayout.EndHorizontal();
then wrap it again with vertical layout, etc...
Everyone should use the Scope versions of these functions, they're so much nicer 😛
Also if you dislike how amazing this looks, it is also possible to give margin / padding ( don't remember which one is supported ) via GUIStyle
@visual stag ah yes, my code is full of those
i find them very flexible
Well the spacing thing worked I guess. I'm not going to fuss over it too much.
?
Yes, that and HorizontalScope, and VerticalScope
So what's the advantage of using that?
You cannot fail to close them
they come with the indent of a using block so it's more visually apparent
That's about it really
I used to do this before
GUILayout.BeginHorizontal();
{
GUILayout.Space( 10 );
}
GUILayout.EndHorizontal();
Ok I'll keep that in mind
So do I split up code based on the event type?
Eg. should I only use GUILayout.XXX during a layout event?
And only handle input during MouseDown, MouseDrag, etc?
And what's the repaint event for?
Some code needs to be split, but most of the general functions don't
The layout stage is a pre-processing stage where the rects are calculated for the repaint stage where everything is drawn. The repaint stage cannot differ in draws from the layout stage
Thanks I'll give it a read
Can you somehow add buttons here?
Not sure if it's relevant but i do remember finding a repo on github that had showed custom irons in the hierarchy view
If you hack/override the panel or clone it, then it should be possible
( that's jump my opinion i didn't check my claim )
I have some ScriptableObjects that I would like to auto-save to disk when the values change in the Inspector and/or Editor Window. Right now I am using the OnValidate() callback on the ScriptableObject and then calling EditorUtility.SetDirty() & AssetDatabase.SaveAssets(). I think this rewrites the whole asset file though. Is there a more efficient way to do it where only the modified values are written to the asset?
Is it ok if I draw handles in OnDrawGizmos or do they need to be drawn in OnSceneGUI?
Hey guys,
I put an array in the EditorWindow like this;
public class Example : EditorWindow
{
public Sprite[] sprites;
private ScriptableObject _target;
private SerializedObject _serializedObject;
private SerializedProperty _spritesProperty;
[MenuItem("Tools/Example")]
public static void ShowWindow()
{
GetWindow<FillFields>("Example");
}
void OnEnable()
{
_target = this;
_serializedObject = new SerializedObject(_target);
_spritesProperty = _serializedObject.FindProperty("sprites");
}
void OnGUI()
{
EditorGUILayout.PropertyField(_spritesProperty, true);
_serializedObject.ApplyModifiedProperties();
}
}
The problem is when I drag and drop some sprites together into the array, the order is not same as in Project window. What is the problem ?
The Project view is always in alphabetical order to my knowledge, selection arrays will always be in the order you select in, and if you shift-select, it's always reverse for some reason, so you could use linq and sort it alphabetically if that's what your going for o.o
I've never seen it in reverse or anything. It is always in alphabetical order in Inspector.
Project Order:
Inspector Order:
Editor Window Order:
But order for scriptable objects which I've created before is correct in Editor Window.
For scripting mesh access, there seems to be some peculiarities around mesh.isReadable. In Edit Mode it does not matter (always readable as per the docs), but in Play Mode meshes are always accessible from the editor but actually use isReadable inside the Game Loop.
I found "Mesh.canAccess" in the CsReference, but that is internal. Is there any way to figure out whether a call is currently inside the GameLoop?
Is it not possible to modify the values of Occlusion Portal from the script?
The only public value related to the component is "open". It doesn't seem that it's possible to edit its bounds
Why is that?
@smoky radish I think you'll just need to call a linq order by, or a generic collections list sort on it, before you display it, if you Havnt fixed it already
hello...editorWindow has common problem of not saving values i used serializing to save my static class data which works fine in editor and playmode but...when building the data from editor isnt loaded why? :/
Uhh... Is this the correct way to save variables in a Editor window, or is there a better way? O.o
https://hatebin.com/entjgqdpjd
Hey, can you somehow detect changes made to Tilemap? I want to run some code when Tilemap's content is changed
@shadow violet i searched alot for it, and yes there is other one its serilization or something like that and its easier, i finally managed to fix the problem thx :)
@tribal skiff mind sharing the solution? If be interested in trying it with some of my assets if it's better o.o
oh yee
np man
w8 not finished
@shadow violet um... ur using static or just public and private fields? uhh nvm i will share the solution for the two, so no gets the pain of passing a day searching on google xD
Case 1 :
in the case your having a variable that can be serialized (https://docs.unity3d.com/Manual/script-Serialization.html in Serializable rules) i havn't tried it yet but i think it may work just do :-
***public or private*** ***your type*** *your variable name*;```
__**Case 2**__
in case your variable cant be serialized like my case, then you gotta create a serializable clone for your original variable :-
```[SerializeField]
***private or public*** ***your original variable type*** *your original variable name*;```
add the `, ISerializationCallbackReceiver` it should look something like :
``` public class SerializationTest : EditorWindow, ISerializationCallbackReceiver```
finally do :
```public void OnBeforeSerialize()
{
cloneVariable = Original;
}
public void OnAfterDeserialize()
{
//Original = cloneVariable ; // uncomment this if you want the field to reflect the value of the static field on playmode
}```
case 2 is from https://answers.unity.com/questions/1551266/serialize-static-fields.html and https://answers.unity.com/questions/1238007/editor-window-serialization-not-working-as-expecte.html
Thanks for sharing that, ill have to check it out and try it tomorrow, but at least for me, its a lot of "user preferences" like a toggle "sort alphabetically" for example, so when they re-compile, that "sort alphabetically" state should persist - a lot of my variables are static cause the functions that need to call them are also static, and if I made them non-static I cant remember the issue I got, but I think certain functions just had compilation errors, but ill double-check tomorrow when I can work on it to confirm - thanks again for sharing n im sure itll help out others too
np
I'm having an Issue where my color field is not displaying the correct color
this is the code I'm using
coresTilesCorredor.TetoFEColor = EditorGUI.ColorField(recColor, GUIContent.none, coresTilesCorredor.TetoFEColor, false, true, false);
the colors it should display
the ones it is displaying
there is nothing under it, the slight red line is just my bad skill at cropping since these two aren't side by side :B
well, it started working with the addition of another undo.recordObject 😑
now I have two of them right next to each other, as long as it works?
https://docs.unity3d.com/2019.3/Documentation/ScriptReference/UIElements.Focusable.Blur.html
Whose idea of a joke is this?
@zealous ice also you could extend an existing project -> https://github.com/SubjectNerd-Unity/QuickToggle
someone at unity thinks they're funny
but it says exactly what it does. .. doesn't it ?
bluring is not the same as removing focus
Many APIs use Blur to mean unfocus
semantics
cameras blur
context awareness
if you went to an eye doctor and they said "focus on the text" "good, now blur" you wouldn't think they were saying you could look somewhere else now
no, it's confusing
development is UIElements is at 1/8th speed because it's so confusing
and this kind of crazyness doesn't help
the problem in general when learning new stuff is the challenge of unlearning old stuff , anyway this is getting off topic 😛
the problem with learning new stuff is that the new stuff isn't documented very well and uses terms that aren't very descriptive
tru
how do i acces a gameobject from another scene trough script
Hey, is there a way to make a serializable color? I'm struggling to make a class/struct inherit from Color
really? I don't get why my script is not saving it then, it is saving everything else, but my struct with a bunch of colors inside
I'm using [System.Serializable] so that is not the problem, and it has the proper Undo.RecordObject, I have no idea what else it could be
hey all anyone had many dealings with exoplayer?
Ok, just to be sure, when I'm saving an asset, I do it like this:
Undo.RecordObject(target, "saving dictionaries");
//make the changes
AssetDatabase.SaveAssets();
right? because when I change the colors on debug mode they carry on, whe I change on my inspector they appear differente, even on the debug, but don't carry on
Dictionaries are not serializable
You would need to implement serialization with ISerializationCallbackReceiver if you're working with dictionaries
yeah, I have that, but in this case I'm changing just a struct with a bunch of colors inside it
If they're plainly appearing in the inspector without a custom UI (can check in debug mode) then they're serializable
So if that's happening you write it off as not that
they do change, but if I copy them or reopen unity they go back
I'm saving exactly as I said up there, I'm kinda desperate right now, I have 0 clues to what is going wrong
I think the only way to get to the bottom of it at this point would be to link to more code
You shouldn't really need to even call SaveAssets, as usually Unity kinda expects users to manually save changes to assets at some point
which can be a little volatile at points
here is all the saving I'm doing, those are serializable dictionaries
myScript is the target
and everything in myScript is serializable as well, I tested it out of this asset
Undo.RecordObject(myScript, "saving dictionaries");
myScript.Test = Color.blue;
if (myScript.myColorDictionary == null)
myScript.myColorDictionary = new TileColorDictionary();
if (myScript.mySecondTileTypeDictionary == null)
myScript.mySecondTileTypeDictionary = new TileTileTypeDictionary();
myScript.myTileDictionary = tempTileDic;
myScript.myTiletypeDictionary = tempTypeDic;
myScript.myColorDictionary = new TileColorDictionary();
myScript.mySecondTileTypeDictionary = new TileTileTypeDictionary();
foreach (Color c in keysUsed)
{
Tile comparer;
Tiletype thetype;
tempTileDic.TryGetValue(c, out comparer);
tempTypeDic.TryGetValue(c, out thetype);
if (comparer != null)
{
myScript.myColorDictionary.Add(comparer, c);
myScript.mySecondTileTypeDictionary.Add(comparer, thetype);
}
}
myScript.TilesCorredor.MyColors = coresTilesCorredor;
myScript.TilesFase.MyColors = coresTilesFase;
myScript.TilesCorredor.MyTypes = tiposTilesCorredor;
myScript.TilesFase.MyTypes = tiposTilesFase;
serializedObject.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
Debug.Log("Saved " + myScript.name + " successfully");
You cannot mix serializedObject.ApplyModifiedProperties and Undo
It's one or the other
either you're modifying SerializedProperties
or you're modifying target
Good to know, I read on the site documentation to use Undo and also use the serializedObject.ApplyModifiedProperties()
but after the undo, do I do something else?
It shouldn't need anything else
Been a while since I've done any video work in Unity and am tasked with building a desktop application that makes heavy use of video.
What currently is the best codec to use? Should I go with a lossless codec like HAP (larger file size)or stick to H.264? Also is there currently still any advantage in using a 3rd party video playback asset like AVProVideo(for Windows) ?
I kinda lost some debugging lines when refactoring that made my object act weird like that, damn I hate the way I did this, should've stayed with lists instead of structs
wow, that developer mode is a wild easter egg
how do you turn it off once you've turned it on?
same way you turned it on
👍
hey all anyone had many dealings with exoplayer? looking for a little advice