public object component;
我试图使用这个对象作为一个对象,可以保存你给它的任何类的对象.例如
unit c = new unit(...)gameObject test = new gameObject(...)test.component = c;
我想通过组件对象使用c对象.例如
if(test.component==typeof(unit)) test.component.Draw();//draw is a function of the unit object
这可能吗?我该怎么办?
解决方法@H_404_29@ 是的,它被称为铸造.像这样:if(test.component is unit) ((unit)test.component).Draw();总结
以上是内存溢出为你收集整理的c#中的变量对象全部内容,希望文章能够帮你解决c#中的变量对象所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)