testBuff.cs
在里面存储一些 自定义的 数据,变量
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class testBuff : MonoBehaviour
{
public string name_;
public int num_;
}
在test.cs中进行使用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
testBuff[] array;//怎么使用这种自定义变量
void Start ()
{
array = new testBuff[3];
for(int i=0;i< array.Length;i++)//遍历testBuff类型名字为array的变量,并对每一个进行赋值
{
buff = new testBuff;
buff.num_ = i;
}
}
public void test()
{
foreach(testBuff buff in array)
{
Debug.log(" :"buff.num_);//遍历数组,输出 在Start函数中赋值的 变量数据
}
}
}

博客提到在testBuff.cs文件中存储自定义数据和变量,这些数据和变量可在test.cs文件中使用,涉及文件间的数据交互。
301

被折叠的 条评论
为什么被折叠?



