MENU

unityのイベントリスナーにメソッド、プロパティを指定する

インスペクターから値を設定できるのは

  • staticでない
  • publicである
  • consutでない

プロパティ

int型 スライダー発火でtrue インスペクターで設定された値が初期化

float型 dynamic 可変するみたい。 0~1までのスライダーの位置を正規化された値を初期化

メソッド unityAction型 引数 float型 1つ スライダーの値を正規化されたものが引数に初期化される

注意*

aプロパティは画像では0だが5に入れなおしている
staticなどはシリアライズしてもインスペクターから値を変更できない




String peace = "azatoi";using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class slidervalue : MonoBehaviour {

	public int test ;
	[SerializeField]
	public static int ArrayCount ;

	public Slider slider;

	public float SliderValue{ get; set; }

	public int a{ get; set ;} 

	public Text[] text = new Text[ArrayCount];

	public static string s = "0";

	public void ChangeValue(float value){

		s = ((int)(Mathf.Lerp (1, 10, value))).ToString ();
		Debug.Log (a);

	}
		

	// Use this for initialization
	void Start () {

		for (int i= 0; i<text.Length ; i++){

			text[i] = text[i].GetComponent<Text> ();
		}

	}
	
	// Update is called once per frame
	void Update () {
		text[0].text = s;
		text [1].text = a.ToString();
		text [2].text = SliderValue.ToString();
		//Debug.Log ((int)SliderValue);

	}
}