https://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html
https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeApp : MonoBehaviour {
public BoxCollider box;
public bool lll = true;
// Use this for initialization
void Start () {
AppMain.kaishi += kaishi;
box = this.gameObject.GetComponent<BoxCollider>();
}
public void kaishi(string name)
{
this.transform.Rotate(Vector3.up*10);
if (lll == true)
{
box.enabled = true;
lll = false;
}
else
{
box.enabled = false;
lll = true;
}
Debug.Log("開始~~~~"+name);
}
// Update is called once per frame
void Update () {
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public delegate void KaiShiEventHandler(string name);
public class AppMain : MonoBehaviour {
public static event KaiShiEventHandler kaishi;
public Button but;
public int i = 0;
// Use this for initialization
void Start ()
{
but.onClick.AddListener(OnClick);
}
public void OnClick()
{
kaishi("ddddddddd~");
}
// Update is called once per frame
void Update ()
{
}
}