Linked Questions
19 questions linked to/from In Unity, how do I correctly implement the singleton pattern?
5
votes
3
answers
12k
views
Unity prefab script "GameObjects" can't be ones on the scene?
Currently, I have an object on the scene, and one in prefab. I want the prefab's script to reference to the object on the scene through the
public GameObject obj;
...
2
votes
2
answers
3k
views
How to make a singleton "game manager" object/class that only loads once and can be accessed from any scene?
I would like to have a single "Game Manager" game object or class that contains numerous parameters and tweens or other functions that would be necessary to access throughout my app across ...
1
vote
2
answers
1k
views
Efficient way to implement a lot of singletons
I just came upon programming patterns and learned about singleton. I'm in the process of creating my first game and it contains several managers:
I wanted to implement singleton on each of the ...
0
votes
1
answer
2k
views
should my static class be derived from UnityEngine.MonoBehaviour instead?
I am working on creating an object to maintain state of the game, player data, etc. It is static (singleton lifecyle) through the life of my game.
I started down the path of a static class, with a ...
1
vote
1
answer
1k
views
How to assign game object references to a class instance created at runtime?
I'm creating a game where I have an Entity class that contains basic entity info (pos, health,..) and some functions. Enemies and Player later on inherit from this class.
...
1
vote
1
answer
609
views
Saving score in Unity [duplicate]
I have the following script which I use for calculating the score
...
0
votes
1
answer
434
views
Singleton call twice when I switch to another scene and return back
I'm working on a Unity project where I have a Singleton class, XPmanager, which is responsible for managing XP data across multiple scenes. I'm using the ...
0
votes
2
answers
279
views
How to number tiles?
I want to number tiles and when gameobject moves, the gameobject should know which tiles it's in. I dont want to use collider. How can I do that ?
This is my game area. For example tile numbers ...
0
votes
1
answer
346
views
Implement Singleton that loads before Awake
I would have liked to comment on this answer, but I don't have enough reputation so I had to open this new one. The issue with it (and with the rest of the answers) is that it doesn't work well if ...
0
votes
1
answer
269
views
Point System Using a GameManager?
I am trying to use a GameManager script to store and hold my players points, across multiple levels. The problem is that I have no idea how I should implement this. Should I declare the points ...
0
votes
1
answer
293
views
Should I use singleton or object persistence?
I have a situation where I have levels in my game and a start screen. For the levels, there is a persistent empty GameObject. My code for setting the game over and level complete canvases active (Also ...
0
votes
1
answer
189
views
Is there a good practice for defining names programmatically?
In my use of Unity so far, I've been defining element names programmatically with classes like this:
...
0
votes
1
answer
180
views
How to reference a script that's on just one object in the same scene via code?
private TileMovement tileMovement;
As you can see in the code above I am trying to reference a TileMovement script, where I ...
0
votes
2
answers
139
views
Limiting number of Game Object
So I have this script that summons a stationary laser that the player is supposed to not get hit by, but since there's multiple game object with the code and they can all trigger at making it ...
0
votes
2
answers
158
views