unity 脚本组件
Download the sample files here.
在此处下载示例文件 。
You can use Macromedia Flash UI components to quickly and easily add simple user interface elements to your Flash document.
您可以使用Macromedia Flash UI组件快速轻松地将简单的用户界面元素添加到Flash文档中。
In this tutorial, we’ll look at how easy it is to use the button component.
在本教程中,我们将研究使用按钮组件有多么容易。
1. Open the components panel by clicking ctrl+f7.
1.单击ctrl + f7,打开组件面板。
2. Drag the Push Button component onto the stage.
2.将“按钮”组件拖动到舞台上。
3. Select the Push Button component in Frame 1. The component’s parameters are displayed in the Property inspector.
3.在框架1中选择“按钮”组件。该组件的参数显示在“属性”检查器中。
4. To name the component, type "btn1" in the Property inspector Instance Name text box.
4.要命名组件,请在“属性检查器实例名称”文本框中键入“ btn1”。
5. Type "f1" to name the Click Handler. Later you can write ActionScript to define exactly what the Click Handler should do.
5.键入“ f1”以命名单击处理程序。 稍后,您可以编写ActionScript来确切定义Click Handler应该做什么。
6. Select the first key frame from the existing layer, and press f9 to open the actions box.
6.从现有图层中选择第一个关键帧,然后按f9键打开操作框。
7. Insert the following action:
7.插入以下操作:
function f1(name) { if(name == btn1) {btn1.setLabel("Button Pressed ")} }This action is simple — when you press the button, it calls the function f1().
此操作很简单-按下按钮时,它将调用函数f1() 。
8. The function has a parameter name which takes the Instance name of the button — in this case, btn1.
8.该函数具有一个参数名称,该参数名称采用按钮的实例名称-在这种情况下为btn1。
9. The If condition checks to see if the event is from btn1. If it is from btn1, it sets the label of button to "Button presed".
9. If条件检查该事件是否来自btn1。 如果来自btn1,它将按钮的标签设置为“按钮已设置”。
This is just a simple example. You can insert any number of events in the If block — experiment and see what you come up with!
这只是一个简单的例子。 您可以在If块中插入任意数量的事件-实验一下,然后看看结果如何!
翻译自: https://www.sitepoint.com/building-button-component/
unity 脚本组件
相关资源:jdk-8u281-windows-x64.exe