Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
Birb
Commits
8d13b79d
Commit
8d13b79d
authored
Feb 05, 2017
by
Tanner Grehawick
Browse files
add SingletonBehaviour usage example
parent
df4aa5ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Assets/Scripts/Util/SingletonBehaviour.cs
View file @
8d13b79d
...
...
@@ -21,3 +21,30 @@ public abstract class SingletonBehaviour<T> : MonoBehaviour where T : SingletonB
}
}
}
/* Usage example
// SomeManager.cs:
// A singleton script that manages something
public class SomeManager : SingletonBehaviour<SomeManager> {
public void DoSomething(MonoBehaviour someScript) {
// some code here, just like any other behaviour might have
}
}
// SomeNormalScript.cs:
// A normal script that needs to access the single instance of SomeManager that should be present
// in the scene
public class SomeNormalScript : MonoBehaviour {
void Awake() {
SomeManager.instance.DoSomething(this);
}
// more behaviour code
}
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment