//If an instance of this singleton exists, then destroy the gameobject (this means there are more than one)
 //If an instance doesn't exist, create one
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Debug.Log("Warning: found more than one instance of PlayerColorController Singleton. Destroying " + gameObject.name + " gameobject.");
         Destroy(gameObject);
     }
     else
     {
         Instance       = this;
         Instance.Color = new ColorModel();
     }
 }
Ejemplo n.º 2
0
    void Awake()
    {
        // We need to change to a canvas
        //crossHairRender = crossHair.GetComponent<SpriteRenderer>();
        playerColor = GetComponent <ColorState>();

        // Get component references
        // add to the color swap events
        GetComponent <ColorState>().onSwap += PlayerSetColor;

        // Only one player can exist
        if (singleton == null)
        {
            singleton = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }