Hi guys, I’m gonna start off saying I’ve looked through similar topics yet I could not find any solution to this…
BuildManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BuildManager : MonoBehaviour {
public static BuildManager instance;
public Texture2D empty, fire, ice, lightning, magic, timestop, blades, warp, gold, scaler;
public Texture2D[] TDTxt;
public int currentSelection = 0;
void Start()
{
Debug.Log(instance.currentSelection); // Even this doesn't work
TDTxt = new Texture2D[] {empty, fire, ice, lightning, magic, timestop, blades, warp, gold, scaler};
}
void Update()
{
Debug.Log (instance.currentSelection); // Neither does this...
}
public Texture2D GetTowerTexture()
{
return TDTxt[currentSelection];
}
public int GetTowerType()
{
return currentSelection;
}
public void SetBuilding(int _toBuild)
{
currentSelection = _toBuild;
}
}
Node.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Node : MonoBehaviour {
public int towerType = 0;
private Renderer rend;
BuildManager buildManager; //
void Start () {
rend = GetComponent<Renderer> ();
buildManager = BuildManager.instance; // at this point I would normally think that this would work, but for //some reason it doesn't...
}
void OnMouseEnter()
{
transform.localScale = new Vector3(1f, 1f, 1f);
}
void OnMouseExit()
{
transform.localScale = new Vector3(1f, 1f, 0.6f);
}
void OnMouseDown(){
Debug.Log ("LOL");
rend.material.SetTexture ("_MainTex", buildMa nager.GetTowerTexture());
towerType = buildManager.GetTowerType ();
}
void Update () {
}
}
The error is
And I have absolutely no idea what causes the problem.
Can someone help me out? I’ve been stuck at this point for almost a day.
Cheers