i am making platform game in that game m using grappling hook so, player can grab platform but i want to identify platform which is grabbable or which is not
so, simply when the player over mouse on the object then mouse texture change so, player can identify grabbable or non-grabbable platform.
BTW am using custom texture
var cursorImage : Texture;
function Start() {
Screen.showCursor = false;
}
function OnGUI() {
var mousePos : Vector3 = Input.mousePosition;
var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height);
GUI.Label(pos,cursorImage);
}
thanks
simply change the texture of your mouse texture variable in OnMouseEnter and OnMouseExit events of your blocks.
they should have a collider for these events to fire up.
for example
you can have
var o : cursorDrawer;
var normalCursor : Texture2d;
var overCursor : Texture2d;
function OnMouseEnter ()
{
o.cursorImage = overCursor;
}
function OnMouseExit ()
{
o.cusorImage = normalCursor;
}
in this example cursor drawer is the script component that draws the cursor in the drawer object and normal and over textures are different textures that you want. then draw the cursorImage as you did before.
You didn't really ask a question, but i guess what you want to know is this:
public bool draggable;
function OnMouseStay()
{
if (draggable)
myCursor.SwitchTexture();
}
If your platforms have this script attached the cursor will change on mouseOver.
You'll have to implement the SwitchTexture function of course.
I know this is an old post but if anyone else is looking for a solution to changing a texture on mouse over they could try this javascript:
var initialShader : Shader;
function Start()
{
initialShader = renderer.material.shader;
}
function OnMouseOver()
{
renderer.material.shader = Shader.Find ("your desired temporary shader name");
}
function OnMouseExit()
{
renderer.material.shader = initialShader;
}
It wont necessarily change the texture but you can add a highlight or outline to alert the user of possible available actions on the object under the mouse cursor.
Hope it helps someone.