Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 kinkersnick · Oct 05, 2011 at 02:19 PM ·

minmaxslider problem (Javascript)

Hi,

I using a custom editor script, and want to modify two variables at the same time using a minmaxslider. Here's the code for the line I'm using:

 EditorGUILayout.MinMaxSlider(target.elementArray[i].randomYFOstart, target.elementArray[i].randomYFOend, 0.0, 1.0);

Both of the first two things are variables from an array of objects, but I get the following error code:

 No appropriate version of 'UnityEditor.EditorGUILayout.MinMaxSlider' for the argument list '(System.Object, System.Object, float, float)' was found.

I don't understand why Unity thinks those first two things are System.Object when they are defined and set up as float variables in the main script this editor script refers to. I have loads of other variables, set up in the same way, feeding perfectly into the editor script as IntSliders, Sliders, TextFields etc. etc. What am I doing wrong? I read on here (in the only other question relating to minmaxsliders) that in C# you need to add 'ref' to the beginning of the first two items, but that confuses the hell out of Unity. Anyone help me? Thanks!

Comment
Add comment · Show 2
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 syclamoth · Oct 05, 2011 at 02:30 PM 0
Share

Are they Objects or GameObjects? You may be missing an explicit cast somewhere. The fact that this stuff is not exactly clear is why I don't use javascript, btw.

avatar image kinkersnick · Oct 05, 2011 at 03:01 PM 0
Share

Hmmm. $$anonymous$$ay show my igonrance here: elementArray is a builtin array of GameObjects which are a class with a number of variables in. Does that answer the question. $$anonymous$$now I'll probably have to learn C# one day. But only started program$$anonymous$$g about 4 months ago, so one language at a time!

2 Replies

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

Answer by aldonaletto · Oct 05, 2011 at 03:41 PM

This error usually appears when Unity doesn't know the argument type - specially when you use #pragma strict in your script. You can assign the values to two float variables and use them in the function:

var start: float = target.elementArray[i].randomYFOstart;
var end: float = target.elementArray[i].randomYFOend;
EditorGUILayout.MinMaxSlider(start, end, 0.0, 1.0);
And don't abandon Unityscript so soon! It's easier and much more concise - the ideal language for scripts, in my opinion. C# requires much more writing, and is like a cranky old aunt, complaining all the time about everything: hey, you must write "0.5f", not "0.5", stupid! you must declare "new Vector3(x,y,z)", not just "Vector3(x,y,z)", you incompetent! and so on...
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 kinkersnick · Oct 05, 2011 at 03:49 PM 0
Share

That works for showing the $$anonymous$$maxslider, but unfortunately it isn't editable - I can't drag the ends of the slider to adjust the values. If I edit the two variables it's showing (target.elementArray[i].randomYFOstart and target.elementArray[i].randomYFOend) by another means (ie. with their own slider) then the $$anonymous$$maxslider does update to show the right values. How can I make the $$anonymous$$maxslider be the thing that changes the values it represents? Thanks for your help so far though :)

avatar image aldonaletto · Oct 06, 2011 at 12:20 AM 0
Share

If randomYFOstart and randomYFOend are both explicitly typed as floats, $$anonymous$$in$$anonymous$$axSlider should work (I mean, if they are declared like "randomYFOstart: float", not like "randomYFOstart = 0.0;")
Anyway, I believe that something like this could work:

var start: float = target.elementArray[i].randomYFOstart;
var end: float = target.elementArray[i].randomYFOend;
EditorGUILayout.$$anonymous$$in$$anonymous$$axSlider(start, end, 0.0, 1.0);
target.elementArray[i].randomYFOstart = start;
target.elementArray[i].randomYFOend = end;
I don't know how $$anonymous$$in$$anonymous$$axSlider works internally - if each user action takes more than one OnGUI cycle to become effective, this will fail miserably.
avatar image
0

Answer by kinkersnick · Oct 06, 2011 at 09:04 AM

That did the trick perfectly, than you so much!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to import the object from server to unity 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

Material doesn't have a color property '_Color' 4 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