Agreed.
Whatâs your question?
Where are you stuck?
Why is there a poll?
Why should we put more effort into responding to you than you put into asking for assistance?
We need more information.
Also⌠Avoid taking pictures of your screen and use the screenshot tools that your computer already has instead.
So, no scripts?
Thatâs right, you didnât post any.
I will repeat myself:
Or should I google that for you?
https://lmgtfy.com/?q=unity+progress+bar+tutorial
I am not really sure what you want / are looking for but perhaps this will help: LINK
Point 5 and 6:
Thank you!!!
And they run off into the ether never had learning anything except that begging works. Forever destined to be âthat developerâ who doesnât solve problems, but rather gets others to solve problems for them.
Most of those âdevelopersâ never release anything either, or they release junk that nobody plays.
So it may go in the indie game dev worldâŚ
but in the enterprise world I work side by side with them all day every dayâŚ
Lmao for real tho.
Next week: How do I get my character to do damage? Anyone?
ok,ok I got it!! As I said, I just started to learn about scripts and games (or Iâm saying this now), and for me the best way to learn something is by practice, so Iâm still a ,baby" in this. I tried to do it by myself, but it doesnât work. Iâm not sure but I think I have to use float, which Iâm still trying to figure it out how it works. The idea of my first game is to click the Buckets button on the screen and gaining xp by doing that, which is shown on the slider (xp bar), Until now I learnt just how to count the clicks and show it on a text display. The problem is that the fill doesnât change its value by clicking the button.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BucketsButton : MonoBehaviour {
public Slider sliderInstance;
public static int BucketsCount;
void Start()
{
sliderInstance.minValue = 0;
sliderInstance.maxValue = 100;
sliderInstance.wholeNumbers = true;
}
public GameObject textBox;
public void ClickTheButton ()
{
BucketsCount += 1;
}
public void SliderIncrease ()
{
sliderInstance.value = BucketsCount;
}
}
This is the appropriate way to ask a question.
Explain your problem - check
Show code that you currently have - check
Demonstrate to the community youâve put in effort - check
If Iâm following correctly, when you say: âThe problem is that the fill doesnât change its value by clicking the button.â Are you still having problems?
If so, when/where do you call both ClickTheButton and SliderIncrease?
Personally Iâd suggest âSliderIncreaseâ should actually be called something like âUpdateSliderDisplayâ or something since it doesnât actually increase anything (and could decrease depending on what BucketsCount is)⌠but rather its job is to update the slider (display) with the current BucketCount.
Similarly the âClickTheButtonâ⌠thatâs more what gets done when click. It increases the BucketCount. And it probably should call âSliderIncrease/UpdateSliderDisplayâ so the display is up to date always.
But yeah⌠where do these methods get called?
thanks, but still not working
Here is what I did:
first, changed the code as you said
created a âGameLogicâ folder
moved the script, slider instance and button in it
put the âGameLogicâ as a game object in Slider and selected the Dynamic float-âUpdateSliderDisplayâ function
put the âGameLogicâ as a game object in Button and selected the ClickTheButton () function
and the script looks now like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BucketsButton : MonoBehaviour {
public Slider sliderInstance;
public static int BucketsCount;
void Start()
{
sliderInstance.minValue = 0f;
sliderInstance.maxValue = 100f;
sliderInstance.wholeNumbers = true;
sliderInstance.value = 20f;
}
public GameObject Button;
public void ClickTheButton ()
{
BucketsCount += 1;
}
public void UpdateSliderDisplay(float value)
{
Debug.Log (sliderInstance.value += BucketsCount);
}
}
Of course itâs still not working, because my post wasnât solving your problem. My post had a question in it.
You didnât answer that questionâŚ
When and where do you call âClickTheButtonâ and/or âUpdateSliderDisplayâ?
Those methods are what update your BucketCount, and your slider, respectively. If no other code calls them, they never do anything. You need to call them somewhere. Where, if anywhere, do you call those functions?
So should I introduce an API?
You should answer my question.
Call them to a class