Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by appferreira · May 29, 2012 at 01:25 PM · mouseflashpointer

MouseCursor > FlashPlayer

Hello.

I've correctly changed my game's mouse cursor using this piece of code :

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); }

function Start() { Screen.showCursor = false; }

This works fine when im in the editor and so on, but when i export to flash player, i always get the default mouse cursor (pointer) anyway.

How can i change the mouse cursor affecting the flashplayer export too ?

Thank you in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by catburton · May 30, 2012 at 03:54 PM

You could hide the mouse cursor using ActionScript. Instead of having the line:

Screen.showCursor = false;
in your Start method, I would instead create a helper C# class to do this for you. You can then implement the same logic in ActionScript for the Flash export.

E.g.:

void Start()
{
    CursorHelper.Hide();
}

Then implement the CursorHelper C# class as follows. This C# implementation will be used in-editor and when you build to targets other than Flash:

using UnityEngine;

[NotConverted] [NotRenamed] public class CursorHelper { [NotRenamed] public static void Hide() { Screen.showCursor = false; } }

Now make the same class in ActionScript (which will be used when you publish to Flash) and place it in a folder called "ActionScript" in your project:

package { import flash.ui.Mouse;

 public class CursorHelper
 {
     public static function Hide() : void
     {
         Mouse.hide();
     }
 }

}

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image appferreira · May 30, 2012 at 08:38 PM 0
Share

Thank you very much, Your code worked like a charm, and better, i understanded very well how to integrate AS with Unity - a thing that i was lookinng forward for something like 2 weeks :S

Thank so much for the solution , and for the "lesson" :)

avatar image MadalinStanciu · Nov 28, 2012 at 11:25 PM 0
Share

Thank you !

avatar image
0

Answer by BigBlob · May 29, 2012 at 03:58 PM

Here a script for you to try im not sure if it works because im at school(im 13)but im sure it will work for you

 var originalCursor : Texture2D;
 
 
 var cursorSizeX: int = 32;  // set to width of your cursor texture
 var cursorSizeY: int = 32;  // set to height of your cursor texture
 
 static var showOriginal : boolean = true;
 
 function Start(){
 Screen.showCursor = false;
 //Screen.lockCursor = true;
 }
 
 
 function OnGUI(){
 
     if(showOriginal == true){
         GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX/2 + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY/2 + cursorSizeY/2, cursorSizeX, cursorSizeY),originalCursor);
     }
 
 
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image appferreira · May 29, 2012 at 06:41 PM 0
Share

Hello.

Thank you for your answer. I tryed your code but i get the same problem. $$anonymous$$aybe i havent explained the problem good enough ... when i export to flash, my mouse cursor gets the texture i want, but on top of the texture i have the normal browser arrow ... i mean, my mouse cursor on the flash player is the Operative System cursor pointer plus the texture :S

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to throw a rigidbody toward the mouse? 1 Answer

My mouse pointer is slow 3 Answers

Get mesh name with mouse click, then change color (and other properties) of mesh 2 Answers

Get object at mouse position? (UI) 0 Answers

Mouse Pointer Transform.Position? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges