New answers tagged

1

You can use my singleton class. It is a singleton MonoBehaviour. Use it by extending it: public class MyClass : MonoBehaviour<MyClass> The most current version is available on GitHub, but here is the current version of it: using System.Text.RegularExpressions; using UnityEngine; /// <summary> /// Extending this class creates a MonoBehaviour ...


1

In Javascript, a property can also be a function. Don't make enemyType a string. Make it an object which has multiple methods for different interactions. violetThing = { name: "violet", sprite: "violetThing.png", onTouchFunction: setMagnetic, color: '#ffdd22' } yellowThing = { name: "yellow", sprite: "yellowThing.png", ...


0

There is actually a pseudo official way to use Singleton in Unity. Here is the explanation, basically create a Singleton class and make your scripts inherit from that class.


1

I wrote a singleton class that makes easy to create singleton objects. Its is a MonoBehaviour script, so you can use the Coroutines. Its based on this Unity Wiki article, and I will add option to create it from Prefab later. So you don't need to write the Singleton codes. Just download this Singleton.cs Base Class, add it to your project, and create your ...



Top 50 recent answers are included