Land Issues. 18th Ls-Land.Issue.19-911.08.
@theReviewList. New post, "Ls-Land.Issue.19-911.08" - 4:30 AM
List of Notable Land Issues
See also
Culture of Scotland
:Category:Lists of issues
References
LandQ:
Unity - Changing custom components
I want to create a custom button component, I am following a tutorial where they create one.
The code in the tutorial is:
using UnityEngine;
using UnityEngine.UI;
public class Button : MonoBehaviour {
public Image Image;
[SerializeField] public int Opacity;
void OnMouseDown() {
if (Event.current.type == EventType.MouseDown) {
Color colour = Color.Lerp(Image.color, Color.red, (float)Opacity);
Image.color = colour;
}
}
}
It has a public Image property Image;, and a public int property Opacity;
What I don't understand is, in the code below, how would I access these properties:
using UnityEngine;
using UnityEngine.UI;
public class Button : MonoBehaviour {
public int Opacity = 1;
public Image Image;
[SerializeField] public int Opacity;
[SerializeField] private GameObject Image;
[SerializeField] private Text gameText;
void OnMouseDown() {
if (Event.current.type == EventType.MouseDown) {
Color colour = Color.Lerp(Image.color, Color.red, (float)Opacity);
Image.color = colour;
gameText.text = "You pressed me!";
}
}
} ac619d1d87
Related links:
Comentarios