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 Hiondeux · May 06, 2011 at 02:04 AM · javascripteditor

JavaScript issue: apparently invisible variables

Hello. Below, the first index of "uvs" which is assigned a value is uvs[7] and the value is Vector2(1.0, 1.0). The Debug.Log below confirms this. However so does not the corresponding value of uvs displayed in the editor, which displays (0.1666667, 0.33333333). At the same time the visual consequence of the code supports the "wrong" editor value and not the value displayed by the Log. Am i doing something wrong?

(The missing declarations for vv, uphi and dtl are done at the start of the original script as float, float and integer respectively. None of the present values are used anywhere else in the script and Ugen() is called from Start(). This is the only custom script in the scene, assigned to an empty object.)

function UGen(){ uvs = new Vector2[Verts.length]; vv = 1.0; uphi = 1.0; dtl = 6;

for (var zz=0; zz < dtl - 3; zz++){

vv = 1.0 - ((1.0 / (dtl -3))*zz);

for (var k=0; k < dtl; k++){ uvs[k+dtl+1] = Vector2(uphi, vv); Debug.Log(uvs[k+dtl+1]); uphi = 1.0 - ((1.0 / dtl) * k); } }

}

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

1 Reply

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

Answer by loramaru · May 06, 2011 at 02:32 AM

The index you are assigning to, k+dtl+1, in uvs does not use zz in its computation. Therefore every time through your outer loop, you will assign to the same set of indexes. So the (1.0, 1.0) Vector2 that you see in the log is the first value assigned to index 7, from the pass where zz = 0 and k = 0. The (0.1666667, 0.33333333) Vector2 you see in the inspector is the final value assigned to index 7, from the pass where zz = 2 and k = 0.

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 Hiondeux · May 06, 2011 at 03:50 AM 0
Share

Thanks, i was thinking too much about the effect i was trying to produce and not enough about the code itself. This also exposes my faulty debug method.

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

No one has followed this question yet.

Related Questions

What is a good Javascript editor, with Syntax highlighting and checking? 5 Answers

Running a script in editor mode 2 Answers

Writing with c# and javascript simultaneoulsy 3 Answers

Inspector Assigned Variables Not In Both Scenes 1 Answer

Road Texture Is Stretching 3 Answers


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