Guide:Unity 3D GUI

From Game Making Tools Wiki
Revision as of 10:26, 16 October 2016 by Rjt (talk | contribs) (Added cursor stuff (might be outa date?))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Cursor


function Start() {
	Screen.showCursor = false;

This little script will prevent the mouse cursor from being shown. Note that when previewing the game in Unity the cursor will still appear.

If you wish to control when it it shown or not, for example when a menu appears, simple set Screen.showCursor to true when your menu is called.

You can also lock the cursor in place using Screen.lockCursor.



Here's a kinda clunky little typewriter effect I found somewhere. Still trying to fidn where so I can give credit :( I've modified it slightly.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TypeWriterEffect : MonoBehaviour {

	public float delay = 0.1f;
	public string fullText;
	private string currentText = "";

	void Start () {

	IEnumerator ShowText(){
		for(int i = 0; i < fullText.Length; i++){
			currentText = fullText.Substring(0,i);
			this.GetComponent<Text>().text = currentText;
			yield return new WaitForSeconds(delay);