Search Feedback

146
votes

Editor: Static variables editable in Inspector

General

-

-

Variables that are declared static in a script get hidden from the Unity Inspector GUI. It would be handy for it to be editable in the Inspector (its value would of course be the same in any instance of that script, it being static).

Comments (10)

  1. 3d8d3dd9b4e022b82a4d67b661889415?d=mm

    Draghi

    Dec 09, 2018 10:14

    This should absolutely be part of unity. I mean, certain statics can be easily set in code like strings, ints and list but it's impossible to reference assets from a static context.

    It's possible to work around this by using all kinds of strange workarounds, for example with singletons or ScriptableObjects in the resource/asset bundle system that're fetched before the game loads.

    But having to leverage and manage runtime loading systems to get this kind of basic feature feels wrong.

  2. 4c5c11109356867af825396731ea79fa?d=mm

    Lazy

    Jan 17, 2018 16:54

    You can try our new plugin for Unity, Static Inspector.
    https://assetstore.unity.com/packages/tools/utilities/static-inspector-88179

    If you just want to see and modify the static members in Editor. The free Demo will be good enough for you.

  3. C973622c448088e78bd15780c95c67a7?d=mm

    rrertgwe

    Jul 08, 2012 11:56

    it would be good so that static variables are displayed in the properties of the script and not in the properties of its instances

  4. 1d9a5d9d01f8d4a9518960e7db41bb2e?d=mm

    Kryptos

    Apr 18, 2012 08:02

    Static values are by definition not serializable. Thus not present in inspector. But you can easily create your own CustomEditor to handle them (for example to edit them at runtime). Anyway they will not be saved (not serializable).

    Therefore a singleton pattern is the best way.

  5. 435da42318f89258f5108d03cba18586?d=mm

    JasonRTBond

    Apr 17, 2012 19:02

    This is an old one, but still came up when I was Googling for a good way to handle static data.
    I find myself building singleton monobehaviours for this all the time. (MonoBehaviours because you can easily use the Inspector to adjust values this way.) It takes a little setting up each time though, making it a bit annoying. Also, you have to be careful to always have an instance (and only one) added to your scene (especially annoying when dealing with multi-scene games). It would be nice if we could have static (i.e. not scene-specific) objects which could be configured with extensions of a singleton version of MonoBehaviour.

  6. 340a2d6f5eaf25e631a5b422941e8a1c?d=mm

    Patrick Connor

    Oct 24, 2011 23:38

    This would be convenient.

  7. D491ba65793f8406ab7eb09133fd9836?d=mm

    Marble

    Feb 18, 2011 20:01

    This is especially important for classes that access static variables before they can be reliably set. e.g. "function OnEnable() { DoSomethingWith(MyManager.mystaticvar); }" is impossible because MyManager.mystaticvar is set in Awake().

  8. E10abfb6335d1b5d839b4a8b6bd341b2?d=mm

    regis.ramillien

    Dec 12, 2010 18:49

    I agree with this. I started my first game and this functionality is already missing. It means for me that this is a very basic one... Moreover, OMHO, it should be easily implemented.

  9. 213955fff77a980cc706ce8f930b3d70?d=mm

    Spk

    Jul 28, 2010 17:44

    I agree, this would also save quite a lot of memory on objects that are instanciated a lot (such as units in an RTS game) by moving some of the instance data to static data (for values that are not meant to change but need to be edited easily)

  10. Afcb21df3e59c7dbbaee630ad4da9d39?d=mm

    johan-skold

    Apr 27, 2010 23:50

    This would be awesome. As it is now, as a workaround, I have a behaviour whose only purpose is to set static variables in various classes and then destroy itself. It might be that I'm just missing a good way of doing it, but nothing could be better than simply showing static variables in the inspector.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(10750)

2D

(281)

Ads

(54)

AI & Navigation

(81)

Analytics

(130)

Animation

(395)

Asset Store

(355)

Asset Store Publisher

(15)

Assets

(543)

Audio

(184)

Cloud Build

(144)

Collaborate

(63)

Docs & Tutorials

(239)

Editor

(2507)

Everyplay

(17)

Game Performance Reporting

(21)

General

(978)

Graphics

(869)

GUI

(430)

Input

(172)

Licensing

(90)

Networking

(188)

Physics

(383)

Platforms

(440)

Profiling & Optimization

(84)

Runtime

(181)

Scripting

(1168)

Terrain

(170)

WebGL

(142)