接口有些类似抽象类
代码
=========================================================================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//一个公开的接口
public interface JK//接口默认是Public(公开)的
{
//C# 是单继承,接口是解决 C# 里面类可以同时继承多个基类的问题。
string name { get; set; }
void A();
int B();
}
public class GameManager_2 : MonoBehaviour, JK
{
public void A()
{
Debug.Log("实现接口A");
}
public int B()
{
int num = 100;
return num;
}
// Start is called before the first frame update
void Start()
{
A();
Debug.Log(B());
}
// Update is called once per frame
void Update()
{
}
}