UI image component problems with Character Creation....
I am having trouble on finding out how to make my class slider work. It's a slider thats SUPPOSE to change the sprite image of the UI Image Component and is using static components for the character creation menu I'm making for it. The only problem is, it cant find the UI Image component and cant override the sprite. So Heres My Script and I just need to check if this would work.
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class ClassSlider : MonoBehaviour {
private float HSliderValue = 0.0F;
private bool Slidervalue1;
private bool Slidervalue2;
private bool Slidervalue3;
public Image CharacterDisplay;
public Canvas Canvas;
void ONGUI()
{
if (HSliderValue == 0.0F)
{
Slidervalue1 = true;
Slidervalue2 = false;
Slidervalue3 = false;
}
if (HSliderValue == 1.0F)
{
Slidervalue1 = false;
Slidervalue2 = true;
Slidervalue3 = false;
}
if (HSliderValue == 2.0F)
{
Slidervalue1 = false;
Slidervalue2 = false;
Slidervalue3 = true;
}
}
public void ModernNinja(float newValue)
{
if (Slidervalue1 == true)
{
CharacterDisplay.sprite = Resources.Load<Sprite> ("Players/Models/MilitaryNinja/Display")as Sprite;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612055853im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How To Make Healthbar Value Slowly Decrease? 1 Answer
UI Button Doesn't Render [C#] 0 Answers
UI button class 1 Answer
How to change a button image with script? 1 Answer
How to make a sprite stretch to fill the play space? 1 Answer