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 /
  • Help Room /
avatar image
1
Question by Eclipse23 · May 03, 2021 at 06:27 PM · variablestringcursoreventsystemfix

String Variable Not Changing From Starting Value,

Hi, I have been trying to make a cursor change script for a while now, and even after re-writing the whole script I am still having troubles.


The cursor script is intended to change cursor sprite when called from the card's event system (which i will expand later). The cursor sprites are changing how they should, but the currentCursorState variable will not change, in the editor and debug it remains on normal, as shown in the video, even though it should not be changed.


Is this an issue with how I am assigning the strings? I have changed the string to an int (because I thought it may have something to do with immutability), and the same problem persists.

I mostly just hope that the problem isn't some dumb mistake I have made.....


Here is the error in action:

https://youtu.be/CMnjxMwsK1U

Here is the Event Trigger System on the Card that is spawned alt text

Here is the script:

 public class CursorControlV2 : MonoBehaviour
 {
     public Texture2D cursorNormal;
     public Texture2D cursorDown;
     public Texture2D cursorHover;
     public Texture2D cursorEnemyHover;
 
     public string currentCursorState;
 
     public CursorMode cursorMode = CursorMode.Auto;
     public Vector2 hotSpot;
 
     public bool debugCursorEvents = true;
 
     
 
     void Start()
     {
         hotSpot = new Vector2(9, 4);
         QualitySettings.vSyncCount = 0;
         CursorNormal();
     }
 
     public void CursorHover()
     {
         if (currentCursorState != "cursorDown")
         {
             currentCursorState = "cursorHover";
             Cursor.SetCursor(cursorHover, hotSpot, cursorMode);
             if (debugCursorEvents) { print(currentCursorState); }
         }
         else
         {
             if (debugCursorEvents) { print("Attempted hover, but cursor was down"); }
         }
 
         if (debugCursorEvents) { print("CursorHover() has been called"); }
     }
 
     public void CursorStopHover()
     {
         if (currentCursorState != "cursorDown")
         {
             CursorNormal();
         }
 
         if (debugCursorEvents) { print("CursorStopHover() has been called"); }
     }
 
     public void CursorUp()
     {
         currentCursorState = "cursorUp";
         CursorHover();
     }
 
     public void CursorDown()
     {
         Cursor.SetCursor(cursorDown, hotSpot, cursorMode);
         currentCursorState = "cursorDown";
         if (debugCursorEvents) { print("CursorDown() has been called"); }
     }
 
     public void CursorNormal()
     {
         Cursor.SetCursor(cursorNormal, hotSpot, cursorMode);
         currentCursorState = "cursorNormal"; // removing this line causes it to get stuck on cursorHover instead
         if (debugCursorEvents) { print("CursorNormal() has been called"); }
     }
 
     void Update()
     {
         if (debugCursorEvents)
         {
             print("Current Cursor State is " + currentCursorState);
         }
     }
 }


event-system.png (30.1 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

167 People are following this question.

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

Related Questions

[Help] Getting variable based on string value. 2 Answers

how to find gameobject using a varable 1 Answer

How to find a variable int with a string? 1 Answer

use the tag of a gameobject to assign a string variable 1 Answer

change variable from textAsset in dictionary 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