Just wondering what people thought about using a scriptableObject to store a static string list of environment prop name that will be using by a terrainManger/poolingManager at run time to randomly popular tiles with props.The tiles will repeat but props should have different positions. Also worth mentioning the ScriptableObject class inherites through different bio domes eg desert/forrest/city
If by “static” you mean globally accessible then yes…sort of. Nothing stops you from having a private const in which case it’s scoped just like any other variable. The key difference in const is that the compiler basicaly does a “find-replace” at compile time. Also, static does not imply read only (that’s what readonly is for) whereas you cannot assign back to a const value.
I am not an expert in c#, but to me static readonly is similar to const, with the difference that as you said const is replaced by compiler whereas static readonly would be a reference still (and would work with other than strings, Int, etc…) - am I getting this right?
const works with any primitive value type and must be provided a value when declared. readonly basically gives you “one shot” to provide a value - either in the declaration or the constructor. Once a value is assigned a new one cannot be assigned.
And yes, static readonly would still refer to the value in memory but with value types you’d get a “copy” of the value back anyway.
Digging deeper into this it seems like I need to traverse over the data inside this ScriptableObject. I don’t really want to implement an iterable class. Maybe I need to abandon the ScriptableObject
Currently I have :
A ScriptableObject Class containing all names of the models the PoolingManager needs to create a set amount of instances from. Usually I would implement a reference to a struct array to keep it clean and efficient(C++).
Rethinking it should I just have a single instance with a list of gameObject for the PoolManager to use. Maybe Im overthinking this whole thing lol.
Also new to C# and scriptable object. Bread and butter is C++ so apologies for any excessive questions