- Home /
Abstract Inspector-Manipulable Objects that aren't GameObjects?
I'm currently trying to defer as much work to the design team as I can so I'm creating manager classes that objects can be added to in the inspector.
The way I do this right now is to create an empty GameObject in the world and then drop a script onto it and make the resulting entity a prefab, dragging this back into my project hierarchy for later use.
The thing is, a GameObject just seems like it's carrying too much unnecessary baggage with it.
For example, I've got a 'Missions' manager which I want to hold a bunch of 'Missions' - intangible abstract types - which come in a variety of flavours and I want the designer to be able to compile and curate this lot all by himself, so I'll create some prefabs 'MissionTime', 'MissionDistance' and stuff like that and he can just drop them into an array within the manager prefab and fill in all the information pertaining to each.
None of these 'Missions' need to exist in the world, they just need the bare bones of being able to exist in the Inspector. Maybe I'm fretting over nothing and the overhead is minimal and I should just go ahead with using GameObjects but it just seems a bit of a bloated way of doing things?
Cheers. Rob.
Answer by Loius · Jun 28, 2012 at 06:31 PM
if you have a
class Mission {
var enemies : int;
}
and a
class MissionManager {
var missions : Mission[];
}
then you can build one GameObject such as
[GameManager.js]
var missionManager : MissionManager;
And MissionManager and all its Missions will be Inspector-able. You can also extend the inspector as necessary using CustomEditor and OnInspectorGUI. You still need a GameObject to have access to the Inspector, but just one.
You can also use EditorWindow to build, well, new Editor windows to access these intangible classes without using any GameObjects at all, though that's generally more complex than necessary.
Edit: It sounds like you want prefab-intangibles, which I accomplished in my project by saving/reading to files directly, which could be done in either method.
EditEdit: Or you could build a PrefabMissions object that just has a bunch of Missions and then use OnInspectorGUI to build a way to easily select these from the actual Manager object.
Answer by Eric Farraro · Nov 17, 2013 at 08:06 PM
I had to add [System.Serializable] to the top of my non-gameobjects to accomplish the desired behavior.
See http://forum.unity3d.com/threads/46675-User-defined-class-not-inspectable-in-C
Your answer
![](https://koobas.hobune.stream/wayback/20220613073418im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to link objects in the inspector on load level 1 Answer
List of Inherited abstract Objects assigned via Inspector 1 Answer
Bullet Prefab not instantiating 1 Answer
GameObject variable not appearing in Inspector? 1 Answer
Is an object created when dragging a prefab to a GameObject script field 1 Answer