Is there a way to expose static variables in the inspector?
I would like to make static texture map assignments. The only way to make texture map assignments is by dragging in the inspector, and it seems that only non-static members are exposed.
Thank you.
What you could do that is kind of like this is to assign Default Properties to your script. Select your script in the project view and then drag and drop textures to the appropriate properties. Now when you assign that script to an object it’ll have those textures in there by default.
-Jon
Thanks, Jon. It seems that Default Properties are meant to accomplish a similar purpose.
I am using AddComponent(Script) to add script (objects) to new game objects.
It appears that using AddComponent may not copy the Default Properties objects to the newly instantiated component. Please let me know if you believe otherwise. Thanks.
Never tried that I’m afraid, but I am pretty sure this should be treated as a bug if it is the case. It was probably an oversight when default properties were added.
Maybe there is a different approach you could use than adding scripts at runtime… (maybe not too) you’d have to elaborate on what you’re up to.
Good luck!
-Jon
It’s by design but it is kind of confusing at times.
The problem is this. When building a game we detect which assets are used automatically. This allows you to drop a lot of assets and scripts into your project folder without you ever having to pay for the cost in distribution size.
This matters a lot for web players and is becoming more and more important as we increase the amount of standard assets that ship with Unity.
If you use a lot of default properties and you allow assigning default properties from game code, then we need to ship those assets with every build because you never know in advance if you will use AddComponent on this script or not. Which means all assets referenced from default properties always need to be included in all builds. Otherwise you would sometimes end up with a case where it works in the editor but doesn’t work in the player.
It’s a tradeoff between inconvenience/confusion VS distribution size/ rendering the standard assets / premade scripts assets useless because you will have to manually take care of them.
Thus we decided that default properties are an editor only feature.
It’s one of the design decisions I was never 100% happy with. If someone can show me the light, i’d be happy.
That said, cant you just drag that script on an empty game object in the editor?
Yes, I could drag and drop. In this case I was creating objects and components from script. Please see http://forum.unity3d.com/viewtopic.php?t=2397 to see what I was attempting. In fact, I would like to draw together these two threads in this reply.
I was perhaps trying to do too much in script (where is my comfort zone?).