unity3d 帮助引导

来源:互联网 发布:人工智能 场景 编辑:程序博客网 时间:2024/05/29 09:44
/*Author:AndySun * Time:2013/8/19 * Function:Loader Help Image * Version:003 **/using System.Collections.Generic;using UnityEngine;[RequireComponent(typeof(GUITexture))]public class Loader : MonoBehaviour {    [System.Serializable]    public class Group {        public Texture2D texture;//The Textures to show the Description of the UI button        public Rect position;//The position of the UI button    }    public Group[] item;public Texture2D cursor;//The texture that change the cursor style//The count of the current imageprivate static int count = 0;//The position of the mousebuttonprivate Vector3 mousePosition;//The Level to be Loadedpublic int loadLevel = 1;void OnGUI(){guiTexture.texture = item[count].texture;//Change the help image//Show the button to change help imageif(GUI.Button(item[count].position,"")){count++;}//If the help image is over,load the first level.if(count == item.Length){Application.LoadLevel(loadLevel);}}void Update(){mousePosition = Input.mousePosition;//If the mouse is on the rectangle        if ((mousePosition.x > item[count].position.xMin) && ((Screen.height - mousePosition.y) > item[count].position.yMin) && (mousePosition.x < item[count].position.xMax) && ((Screen.height - mousePosition.y) < item[count].position.yMax))        {Cursor.SetCursor(cursor,Vector2.zero,CursorMode.Auto);//Change the cursor}else{Cursor.SetCursor(null,Vector2.zero,CursorMode.Auto);//Set the cursor to default cursor}}}

原创粉丝点击