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 kcff000k · Sep 20, 2019 at 03:13 AM · programmingplaymaker

is there a way to select the objects and highlight it when it meets the minimum condition from several slider?

alt text

Each blocks (game object ) will have 3 variable(Sq ft, No. of rooms, and price).
How do i make them highlight itself when they meet the minimum condition which is set by a slider?

For Example, if the slider is set to 900 Square ft, 3 rooms and 500k.

Anything above 900ft, 3 rooms and below 500k will be highlighted

test.jpg (18.9 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

1 Reply

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

Answer by WarmedxMints · Sep 20, 2019 at 04:51 AM

You could populate an array of the blocks and iterate through them when any slider is changed

 public class Block : MonoBehaviour
 {
     public int SqaureFt;
     public int RoomCount;
     public int Price;
 
     public void Highlight(bool highlight)
     {
         if(highlight)
         {
             //Set highlight colour
             return;
         }
 
         //Set normal colour
     }
 }
 
 public class Sliders : MonoBehaviour
 {
     //Populate list of blocks
     public List<Block> Blocks;
 
     public Slider SqFt, RoomCount, Price;
 
     //Pass this method to all 3 sliders changed event
     public void OnSliderValueChange()
     {
         if (Blocks == null || Blocks.Count == 0)
             return;
 
         var count = Blocks.Count;
 
         var sqft = SqFt.value;
         var rmCount = RoomCount.value;
         var price = Price.value;
 
         for(var i = 0; i < count; i++)
         {
             var block = Blocks[i];
 
             var highlight = block.SqaureFt >= sqft && block.RoomCount >= rmCount && block.Price <= price;
 
             block.Highlight(highlight);
         }
     }
 }

Comment
Add comment · Show 6 · 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 kcff000k · Sep 20, 2019 at 07:55 AM 0
Share

alt text

everything seems to be working, however, 'Slider' can't be referenced.
"public Slider SqFt, RoomCount, Price;"
Do you know why?

test02.jpg (173.8 kB)
avatar image WarmedxMints kcff000k · Sep 20, 2019 at 08:12 AM 0
Share

If you are using Visual Studio, it will have a little light bulb icon which will give you a fix or you can press alt + enter with the default shortcuts.

You are missing;

using UnityEngine.UI;

avatar image kcff000k · Sep 20, 2019 at 09:21 AM 0
Share

Nice! There's no more error so far. You've been a great help! However. when i test play, the color does not change no matter how i slide. Am i missing something? Hope you can have a last look before i reward you :P.

alt text

alt text

debug01.jpg (191.5 kB)
debug03.jpg (146.0 kB)
avatar image kcff000k kcff000k · Sep 20, 2019 at 09:28 AM 0
Share

alt text

I did everything u double slash except passing the method to those 3 sliders. How do i pass the method to those 3 sliders? Sorry for being a noob. :P

avatar image WarmedxMints kcff000k · Sep 20, 2019 at 10:40 AM 0
Share

You either assign the method to the event via the inspector on the Slider component or you can do it in the Start method of the slider class with slider.onValueChanged.AddListener();

As for the colour change, you would have to implement that depending on your setup. Looking at your screenshots, I am guessing you just wish to swap materials which is done via the mesh renderer.

Show more comments

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

125 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

Related Questions

Multiple Cars not working 1 Answer

Prior Knowledge 0 Answers

Make a game in C# 0 Answers

How to start in Unity? 1 Answer

Mecanim Jump up HELP!! 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