下边是我学了静态类之后的一些对静态类的一些进阶使用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
static class Tools
{
public static void SpeakValue(this int value)
{
Debug.Log("我为int拓展的方法" + value);
}
public static void SpeakStringInfo(this string str,string str2,string str3)
{
Debug.Log("唐老师为string拓展的方法");
Debug.Log("调用方法的对象" + str);
Debug.Log("穿的参数是" + str2 + str3);
}
public static void Fun2(this Test t)
{
Debug.Log("为test拓展的方法");
}
}
class Test
{
public int i = 10;
public void Fun1()
{
Debug.Log("1234");
}
public void Fun2()
{
Debug.Log("456");
}
}
public class MyTestFavourite : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//int i = 10;
// i.SpeakValue();
//string str = "0000";
//str.SpeakStringInfo("222", "333");
Test t = new Test();
t.Fun2();
}
// Update is called once per frame
void Update()
{
}
}