Hello Guest

Author Topic: tk2dButton could not be found?  (Read 3990 times)

covcomm

  • Newbie
  • *
  • Posts: 2
    • View Profile
tk2dButton could not be found?
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dButton could not be found?
« Reply #1 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.

covcomm

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: tk2dButton could not be found?
« Reply #2 on: October 24, 2012, 04:45:20 pm »
Thanks! It worked!