300円位のジョイスティック mocute-032 を購入したが、実際のボタンの値が分からず確認の為のスクリプトを作成
おそらく、汎用的に確認できます。

この値段で充電式は、驚き!

モードはゲームモードでAndroid 

void Update()
    {
        UpdateGetKey();
        // UpdateKey();
    }    

void UpdateGetKey()
    {
        float horizontal = Input.GetAxis("Horizontal");     // joystick horizontal
        float vertical = Input.GetAxis("Vertical");      // joystick vertical

        Debug.Log("x y:" + horizontal + "," + vertical);
        foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
        {
            if (Input.GetKey(value))
            {
                String name = Enum.GetName(typeof(KeyCode), value);
                Debug.Log("Input.GetKey:" + name);
            }
            if (Input.GetKeyDown(value))
            {
                String name = Enum.GetName(typeof(KeyCode), value);
                Debug.Log("Input.GetKeyDown:" + name);
            }
            if (Input.GetKeyUp(value))
            {
                String name = Enum.GetName(typeof(KeyCode), value);
                Debug.Log("Input.GetKeyUp:" + name);
            }
        }
    }
adb logcat | grep Joy

02-24 13:42:55.463  1346  1358 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 
02-24 13:45:54.033  2993  3016 I Unity   : Input.GetKey:JoystickButton2 
02-24 13:45:54.033  2993  3016 I Unity   : Input.GetKeyDown:JoystickButton2 
02-24 13:45:54.033  2993  3016 I Unity   : Input.GetKey:Joystick1Button2 
02-24 13:45:54.033  2993  3016 I Unity   : Input.GetKeyDown:Joystick1Button2 
02-24 13:45:54.051  2993  3016 I Unity   : Input.GetKeyUp:JoystickButton2 
02-24 13:45:54.051  2993  3016 I Unity   : Input.GetKeyUp:Joystick1Button2 

02-24 13:45:55.333  2993  3016 I Unity   : Input.GetKey:JoystickButton0 
02-24 13:45:55.333  2993  3016 I Unity   : Input.GetKey:Joystick1Button0 
02-24 13:45:55.352  2993  3016 I Unity   : Input.GetKey:JoystickButton0 
02-24 13:45:55.352  2993  3016 I Unity   : Input.GetKey:Joystick1Button0 
02-24 13:45:55.367  2993  3016 I Unity   : Input.GetKey:JoystickButton0 
02-24 13:45:55.367  2993  3016 I Unity   : Input.GetKey:Joystick1Button0 
02-24 13:45:55.383  2993  3016 I Unity   : Input.GetKey:JoystickButton0 
02-24 13:45:55.383  2993  3016 I Unity   : Input.GetKey:Joystick1Button0 
02-24 13:45:55.402  2993  3016 I Unity   : Input.GetKeyUp:JoystickButton0 

 

項目を動的に変えてデータを取得

void Start()
{
	dbManager = this.GetComponentInParent();
}

public int GetScore(int id, ExeMode method)
{
	string item = CommonDao.GetScoreItemName(method);
	string sql = $"SELECT {item} FROM LessonTable WHERE ID=?";

	SimpleDataTable lists = dbManager.QueryGeneric(sql, id);

	if(lists.rows.Count ==0 ) {
		return 0;
	}
	return int.Parse(lists.rows[0][0].ToString());
}
© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha