I made it like this and added it to the door who should trigger it, but i bet i missing some code to make it work since it dont work when the player comes close to the door.
using UnityEngine;
using System.Collections;
public class LoadSceneButton : MonoBehaviour {
public Canvas LoadScene;
void Start () {
GameObject go = GameObject.Find("LoadScene");
if (!go)
return;
LoadScene = go.GetComponent<Canvas>();
if (LoadScene)
LoadScene.enabled = false;
}
void OnTriggerEnter()
{
LoadScene.enabled = true;
}
void OnTriggerExit()
{
LoadScene.enabled = false;
}
}
EDIT:
Made the code like this and added a cube and unchecked collider and mesh, added the script to it, but still dont work.
using UnityEngine;
using System.Collections;
public class LoadSceneButton : MonoBehaviour {
public Canvas LoadScene;
void Start () {
GameObject go = GameObject.Find("LoadScene");
if (!go)
return;
LoadScene = go.GetComponent<Canvas>();
if (LoadScene)
LoadScene.enabled = false;
}
void OnTriggerEnter (Collider other )
{
if( other.tag == "Player" )
{
LoadScene.enabled = true;
}
}
void OnTriggerExit (Collider other)
{
if( other.tag == "Player" )
{
LoadScene.enabled = false;
}
}
}
EDIT 2:
I forgot to make the collision a trigger…Solved