U3D copy component是什么意思有什么用

U3D里UI相关逻辑和文件的组织关系的各种形式的比较
代码和资源的组织关系
我觉得,做UI逻辑的时候,
在IDE里将脚本挂载到对象是个错误的方式。
因为不利于UI制作人员和程序员的工作分离。
不断的import和export&package,会让程序员的代码遭遇版本问题
如果程序使用了particle class 特性,也会让UI制作人员那边运行不起来
解决方案:
本质是使用AddComponent,在运行期组织对象和脚本的关联关系。
具体形式为:
在UI的root对象上挂载一个入口脚本
脚本类容形式如下:
class StartScript : MonoBehaviour
&&& string [] scriptList =
&&&&&&&&&&&&mainLogic.cs&,
&&&&&&&&&&&&UIMail_List.cs&,
&&&&&&&&&&& &UIMail_Write.cs&,
&&&&&&& };
&&&&&&void Awake()
&&&&&&&&&GameObject owner = transform.gameO
&&&&&&&&&foreach(string scriptName in scriptList)
&&&&&&&&&{
&&&&&&&&&&&&&&&owner.AddComponent(scriptName);
&&&&&&&&&}
AddComponent 的时候会触发脚本组件的Awake函数调用。
Awake里不能引用其他脚本内的实例对象和函数,因为和AddComponent的顺序有关,这样是为了避免引入顺序问题。
Start的时候就可以随便引用了。
策划先搭大概,导出
再将入口脚本补进去,顺便检查下层级结构什么的。导出给策划,同时进行功能开发。
策划再导出,调整,给程序
程序再导入进来,功能也做完了,发布
只要入口脚本写完了,就可以随时导入导出了。双方不受影响
我这个实现里,入口脚本里还有一个文件列表。这个关联都不应该在其中的
可以写一个静态类,在那里包含,这样可以进一步避免交换包的时候导致的代码版本问题。&
// 入口脚本文件,挂载到场景的根对象上。
class StartScript : MonoBehaviour
&&&&&&void Awake()
&&&&&&&&&GameObject owner = transform.gameO
&&&&&&&&& ScriptList.Init(owner);
// 逻辑脚本文件,不挂载到任何对象。程序自己控制
static class& ScriptList
&&& static string [] list =
&&&&&&&&&&&&mainLogic.cs&,
&&&&&&&&&&&&UIMail_List.cs&,
&&&&&&&&&&& &UIMail_Write.cs&,
&&& public static void Init( GameObject owner)
&&&&&&&&&foreach(string scriptName in scriptList)
&&&&&&&&&{
&&&&&&&&&&&&&&&owner.AddComponent(scriptName);
&&&&&&&&&}
这样和策划的交集就只有一句话了:
ScriptList.Init(owner);
而这个是只要写成就不需要变动的。正好适合和包走.
定位控件的方式:&
1、使用public定位控件
2、使用pathName定位控件
方式2明显优于方式1,而且方式2还可以配合上面说的解耦方案。
文章评论 以下网友留言只代表其个人观点,不代表本网站的观点和立场。Version: 5.3 ()
LanguageEnglish
Script language
Select your preferred scripting language. All code snippets will be displayed in this language.
UnityEngine
Inherits from:
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Sumbission failed
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Your email
Suggestion *
Submit suggestion
Description
Base class for everything attached to s.
Note that your code will never directly create a Component.
Instead, you write script code, and attach the script to a .
as a way to create scripts that do not attach to any .
The game object this component is attached to. A component is always attached to a game object.
The tag of this game object.
The Transform attached to this GameObject (null if there is none attached).
Public Functions
Calls the method named methodName on every MonoBehaviour in this game object or any of its children.
Is this game object tagged with tag ?
Returns the component of Type type if the game object has one attached, null if it doesn't.
Returns the component of Type type in the GameObject or any of its children using depth first search.
Returns the component of Type type in the GameObject or any of its parents.
Returns all components of Type type in the GameObject.
Returns all components of Type type in the GameObject or any of its children.
Returns all components of Type type in the GameObject or any of its parents.
Calls the method named methodName on every MonoBehaviour in this game object.
Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
Inherited members
Should the object be hidden, saved with the scene or modifiable by the user?
The name of the object.
Public Functions
Returns the instance id of the object.
Returns the name of the game object.
Static Functions
Removes a gameobject, component or asset.
Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
Makes the object target not be destroyed automatically when loading a new scene.
Returns the first active loaded object of Type type.
Returns a list of all active loaded objects of Type type.
Returns a copy of the object original.
Does the object exist?
Compares if two objects refer to a different object.
Compares two object references to see if they refer to the same object.想问问如果学U3D游戏特效.需要先去学习编程语言吗._百度知道
想问问如果学U3D游戏特效.需要先去学习编程语言吗.
想问问如果单独只做游戏特效的话。有必要学习编程语言吗.可是对U3D 还有编程这一块没有接触过.学哪一种比较好小弟目前想发展U3D游戏特效这方面。 对3DMAX AE PS 有些基础.如果需要学习
游戏对象(GameObject),帮助(Help),在做游戏的过程中会更加顺手,y。熟悉坐标。当然一个菜鸟刚开始学U3D。 第三,一定要对坐标(Coordinates)有个了解,场景中的游戏对象都列在这里,z)的顺序排列的,组件(Component),一些资源的列表。 第四,熟悉这些菜单每一个命令对以后的游戏制作大有帮助:场景(Sence),入门是比较难的。 第一,演示窗口,特效很多编程实现的,窗口(Window):文件(File),构建游戏的地方。 第五,地形(Terrain); 第二,资源(Assets),U3D的坐标点是以(x:层级(Hierarchy)。
然后了解主菜单栏的八大菜单:检测面板(Inspector),切记:项目 (Project),当前选中的资源或对象的设置,仅在播放模式中演示:游戏(Game),是一些变量和组件的集合,和库的概念一样,如果不是3d特效就不需要学习,u3d主要是做3d类的特效您好,首先要了解U3D最重要的五大界面。 在U3D中,编辑(Edit)
其他类似问题
为您推荐:
编程语言的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁u3d 怎么用代码增加和删除 gameobject_百度知道
u3d 怎么用代码增加和删除 gameobject
提问者采纳
再将这个图片添加给Sprite是吧; sprite兄弟;.spriteName = &XXX&quot.GetComponent(), 这个是可以的 UISprite sprite = gameObject,其实你的意思应该是从图片集中获取某一张图片吧
来自团队:
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 copy component 的文章

 

随机推荐