I am trying to draw an image to the screen with the new UI, and I've reached a blockade. I can't seem to find any decent tutorials, so I'm stuck. Basically, I have a canvas with an image attached to it. I need to know how to script it so that the canvas only appears on keypress 'E', and draws the image. How do I do this?
Essentially you would position the image where you want in the editor, then make a reference to that image in your script. At Start() time in your script you would disable that image (set its .enabled property to false). At Update() you would check for the E key and when it is pressed, you would enable the image. If you need it to only appear when the E key is BEING held, then you can do away with anything in Start() and simply copy through the current state of the E key being up/down into the image's .enabled property.
Ah, gotcha. Put the image in the scene when you lay out your scene. Then in your script you would have a public variable: Code (csharp): public Image myImage; Once that script has been placed on a game object in the scene, you can select that game object in the editor, and drag the game object containing the Image onto the public field, which should now be visible in the inspector window.
Code (JavaScript): public var TableNote : Image; Almost positive this is the JS equivalent, however, my images I am trying to display won't drag into the inspector. It says that they aren't compatible. Should they be sprites, textures? What should I set the images as themselves so they work in the inspector?
You should not be dragging the texture from in the project folder. That is the actual asset and should be imported as a sprite in order to work with the UI system. You need to put that texture on a Unity UI Image component in your scene and make it look how you want. What you drag into that field on your script is the specific GameObject in your scene, the one with the Unity UI Image that contains a reference to your texture/sprite.
First off you use C# for the UI as far as I know and to get it working... maybe try Code (CSharp): using UnityEngine.UI; public Image imageShown;
Ah, ok. That was what I was misunderstanding. Putting an image on a canvas and disabling the image worked flawlessly. Thanks guys!