Hey guys, I have a small question regarding a proper setup.
I am working on an app with has a scene filled with interactable images, like a hidden Object game. Each scene has various play modes and based on the selected play mode, each object might peform a different funtion / play a different audio.
E.g. While in exploreMode tapping a tree will play an ambient sound, where as in riddleMode tapping the tree tell me a story about the tree…
I have a sceneManager attached to the scene which contains a list allowing me to select x play modes which can be used in the current scene.
What I am looking for now is to define which objects the player can interact with during each play mode… Is it best to use a list within the list or are the better solutions ?
In the end I would like to be able to assign via the inspector which play modes can be used in a scene and which objects are interactable for each play mode (noting some objects might be interactable during multiple play modes)
The list of lists approach should work find here. You would declare a
Dictionary<int, GameObject> or something similar and use that to indicate which game objects are interactable during different play modes.
A more “Unity-like” approach that I would recommend would be to create a very simple object data script that you attach to every gameobject in the scene that could be interacted with in any mode. Expose public variables to set which modes that object is interactable in, then compile the total list when the scene loads:
public class ObjectData : MonoBehaviour
public static HashSet<GameObject> allInteractableObjects = new HashSet<GameObject>();
public List<int> modesInteractable; // or a corresponding enum
int currentMode = SomeFunctionToGetCurrentMode();
Now the static variable
allInteractableObjects will contain the correct collection of gameobjects after the scene is initialized.