- Home /
Question by
Detinator10 · Jun 29, 2014 at 06:28 PM ·
texture2dnamespaceunitygui
Why can't I use Texture2D?
I'm trying to use a Texture2D with UnityGUI to create a button with an icon. However, Unity says that it can't find the namespace for Texture2D. I looked up the namespace and it says it is UnityEngine which I am using I think:
using UnityEngine;
So what am I missing here? How do I use Texture2D? Here is my code:
using UnityEngine;
using System.Collections;
public class ButtonScript : MonoBehaviour {
public Texture2d icon;
// Use this for initialization
void Start () {
}
void OnGUI()
{
if (GUI.Button (new Rect (10, 10, 10, 10), icon))
Application.LoadLevel ("LevelSelectScreen");
}
// Update is called once per frame
void Update () {
}
}
Comment
Best Answer
Answer by meat5000 · Jun 29, 2014 at 06:32 PM
Texture2d
Case sensitive. Look Again
Just in case, for the OP, another hint is to reread your 1st two sentences, where you write out texture-two-dee. The way you wrote it up there is correct.
Your answer
Follow this Question
Related Questions
Texture2D Power of 2 0 Answers
Sprite Rendering Cost Calculation 1 Answer
Is it possible to make guitexture above gui.drawtexture? 0 Answers
An weird question! 1 Answer
UnityEngine could not be found? 7 Answers