Hello fellow coders,
I currently trying to develop my weapon system and for the project view it would be nice, if I could f.E. have my weapon-scriptable object and the prefab for the weapon visually connected, similar how the import of meshes show all imported meshes, animations and materials.
Is there a way how to do that with ScriptableObjects?
You can make a reference from your ScriptableObject to your prefab.
Beware that loading the ScriptableObject WILL also load the prefab.
Beyond that you can also make custom editor inspector windows for your weapons.
You can make your own sub assets of assets with the following editor scripts:
DO NOTE this is a pretty half baked feature from Unity. You are 100% responsible for keeping references to the sub assets in your SO or other Object as there is presently no way to easily find sub assets if you don’t have a reference to them.
Definitely play around with it in a test project to see if it works for you before you start using this in your project proper.
5 Likes
That was excatly what I was looking for. Thank you.
I will test it in my test project.
It worked lovely.
Sadly prefabs don’t work with that. At least, when I tried it, it said, that I had to use “PrefabUtiltys” and in there I haven’t found any method that is similar to “AddObjectToAsset”.
(yes the gun the prefab is using the material. Something did went wrong with the rendering of the project view, but when I open it its the material.
And yes the shader for the material is the particle shader, because its the only Unlit-shader with HDR in LRP)
