Saturday 4 April 2015

Unity3D tutorial 2/24 Custom Cursor

Unity3D tutorial Custom Cursor

Easter video series !






THIS IS C# script: GOOD 4 2D GAMES AND 3D GAMES !
----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------

DIRECT DOWNLOAD HERE




Unity3D turtorial  Custom Cursor

THIS IS BACKUP  IN TEXT FORM

1. Create New C# and name it : CustomCursor


2. Copy & Past this text and save C# :
----------------------------------------­­­­­------------------------------------­-­-­-­-­-


using UnityEngine;
using System.Collections;
 
public class CustomCursor : MonoBehaviour  
{
    //The texture that's going to replace the current cursor
    public Texture2D cursorTexture;
 
    //This variable flags whether the custom cursor is active or not
    public bool ccEnabled = false;
 
    void Start()
    {
        //Call the 'SetCustomCursor' (see below) with a delay of 2 seconds.  
        Invoke("SetCustomCursor",2.0f);
    }
 
    void OnDisable()  
    {
        //Resets the cursor to the default
        Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
        //Set the _ccEnabled variable to false
        this.ccEnabled = false;
    }
 
    private void SetCustomCursor()
    {
        //Replace the 'cursorTexture' with the cursor  
        Cursor.SetCursor(this.cursorTexture, Vector2.zero, CursorMode.Auto);
        Debug.Log("Custom cursor has been set.");
        //Set the ccEnabled variable to true
        this.ccEnabled = true;
    }
}







 ----------------------------------------­­­­­------------------------------------­-­-­-­-­-

1 comment: