Skip to content

Instantly share code, notes, and snippets.

@hidsh
Last active January 2, 2021 21:25
Show Gist options
  • Save hidsh/dbbeec9012959dbd2c570a5adf7fff11 to your computer and use it in GitHub Desktop.
Save hidsh/dbbeec9012959dbd2c570a5adf7fff11 to your computer and use it in GitHub Desktop.
unity test: UnityのUIを作ってみよう https://dkrevel.com/makegame-beginner/ui-beginner/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void TestClick()
{
// publicなメソッドなので、このファイル外から呼べる
Debug.Log("ボタンが押された!");
}
}
@hidsh
Copy link
Author

hidsh commented Jan 2, 2021

このスクリプトをなんかのゲームオブジェクトに貼り付けて、
インスペクタでボタンのOnClick() のところで+を押して、
そこにさっきのゲームオブジェクトをドラッグして、
その右上の No function のところで スクリプト名.cs > TestClick を選択

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment