Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 antx · Dec 07, 2015 at 04:31 PM · functionexecution

Problem initialising slider value from code

I spend the whole day trying to fix a bug and with Debug.Log() calls I managed to isolate it.

I'm modifying and displaying 2 variables of an object (h and v angles), however only the first comes through for some reason:

             clickableBoxRotVSlider.value =     core.currentClickable.rotV;
             clickableBoxRotVText.text =     core.currentClickable.rotV.ToString("0.00");
 
             clickableBoxRotHSlider.value =     core.currentClickable.rotH;
             clickableBoxRotHText.text =     core.currentClickable.rotH.ToString("0.00");
 

When I at the end of my debuging tried to exchance the two, the other one got through. It seems like the code execution stops right there beween those to blocks of code.

I have no idea why this would happen.

(Moderator changed question title from "Is there such a thing as a function call limit or a stack limit in unity?" to better reflect the content)

Comment
Add comment · Show 4
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 Bonfire-Boy · Dec 07, 2015 at 04:54 PM 0
Share

Given you've spent so long on it I'm assu$$anonymous$$g this isn't the case, but just to get it out of the way... are there any errors in the console/log at all? The most obvious cause of what you're describing I$$anonymous$$O would be that some unassigned reference is throwing an exception in the text-setting line (and that the unassigned reference is common to both V and H cases hence the exception gets thrown the first time it hits either one of those lines).

avatar image antx Bonfire-Boy · Dec 07, 2015 at 05:37 PM 0
Share

no, my console is absolutely clean. No errors, no warnings. (and yes they are turned on).

The code is just as that above, but clickableBoxRotHSlider.value stays on its old value while the new value is diffenent. When I cut the first 2 lines and past them unter the other two, then those don't seem to be executed. Thats really weird.

avatar image Pranav1234 · Jul 27, 2021 at 10:02 AM 0
Share

Hi i am getting a similar behaviour. Can you please help me?

avatar image Bonfire-Boy Pranav1234 · Jul 27, 2021 at 12:19 PM 0
Share

If the cause is the same then the solution will be the same. If it's not then you need to provide more details.


With regard to the solution posted here (in the OP's own Answer) - this is a common pitfall. If the slider already has a callback assigned, then that callback will be called when you set the value through code, and this can lead to complications. You could probably diagnose it with lots of Debug.Logs telling you the value of the slider(s) before and after each assignment, and within the callback function.

Sometimes it can make sense to add the callback function through code, following initialisation, so that it's not invoked on initialisation. In the OP's situation it looks like the two sliders' values are dependent on each other, and it makes sense that that would create a need for more complex logic.


If that doesn't help, you should create a new question, with details of your set-up/code and problem (and link to it from here).


PS I've converted your Answer to comment because Answers are for answers to the question posted, not comments or follow-up questions.

1 Reply

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

Answer by antx · Dec 08, 2015 at 12:37 PM

Okay, I found out that the moment I set the value of the first slider it fires its callback function for changed value. This callback function got executed before the next line of code and alters the variable that I was going to initialize the second slider with. That way it looked like the following code is not being executed anymore.

Comment
Add comment · 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

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

32 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

Related Questions

Execution sequence of functions? 1 Answer

How can I stop executing a Function in a void Function? 1 Answer

is it possible to use a rotation on a Vector3? 3 Answers

accessing a function? 1 Answer

How do I make a callback run? 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