2D Toolkit Forum

2D Toolkit => Support => Topic started by: covcomm on October 24, 2012, 02:43:15 pm

Title: tk2dButton could not be found?
Post by: covcomm on October 24, 2012, 02:43:15 pm
Hi,

I just bought 2D Toolkit and I'm trying to get some multitouch buttons set up. I keep getting this error when I try to add a script:


"Assets/Standard Assets/Scripts/Button Scripts/JumpButton.cs(17,28): error CS0246: The type or namespace name `tk2dButton' could not be found. Are you missing a using directive or an assembly reference?"

Code: [Select]
using UnityEngine;
using System.Collections;

public class JumpButton : MonoBehaviour {

tk2dButton button;

// Use this for initialization
void Start () {
button = GetComponent<tk2dButton>();
button.ButtonPressedEvent += ButtonPressed;
button.ButtonAutoFireEvent += ButtonAutoFire;
button.ButtonDownEvent += ButtonDown;
button.ButtonUpEvent += ButtonUp;
}

void ButtonPressed(tk2dButton source)
{
Debug.Log("Pressed");
}

void ButtonAutoFire(tk2dButton source)
{
Debug.Log("Autofire");
}

void ButtonDown(tk2dButton source)
{
Debug.Log("Down");
}

void ButtonUp(tk2dButton source)
{
Debug.Log("Up");
}

// Update is called once per frame
void Update () {

}
}

Is there a simple way to get rid of this error?
Title: Re: tk2dButton could not be found?
Post by: unikronsoftware on October 24, 2012, 04:37:46 pm
Yes, move your script out of Standard Assets. Scripts in those folders get compiled before the tk2d ones and as such wont be able to see them.
Title: Re: tk2dButton could not be found?
Post by: covcomm on October 24, 2012, 04:45:20 pm
Thanks! It worked!