mimic iii_NinjaCamp III:“新脚本”对话框

mimic iii_NinjaCamp III:“新脚本”对话框

mimic iii

Update: The Create Script Dialog is now on the Asset Store

更新: “创建脚本”对话框现在位于资产商店中

As our NinjaCamp project Bas and I decided on a cause a bit humbler than many of the other projects going on here: We just want to improve the workflow of creating a new script in Unity.

与我们的NinjaCamp项目Bas相比,我在事业上的决定比在这里进行的许多其他项目要谦逊一些:我们只想改善在Unity中创建新脚本的工作流程。

The current way to make a new behaviour for a GameObject in Unity is like this:

在Unity中为GameObject做出新行为的当前方法是这样的:

  • Create the script in the desired folder.

    在所需的文件夹中创建脚本。
  • Rename the script.

    重命名脚本。
  • If it’s a C# script, rename the class to match the file name.

    如果是C#脚本,请重命名该类以使其与文件名匹配。
  • Drag the script onto the GameObject.

    将脚本拖到GameObject上。

With the solution we’re working on, you can instead just choose “New Script” from the Components menu, and you’ll get this:

使用我们正在研究的解决方案,您可以仅从Components菜单中选择“ New Script”,然后您将获得以下信息:

mimic iii_NinjaCamp III:“新脚本”对话框

This is a work in progress, but much of the base functionality is already there. While the window is open (which will float on top) you can optionally click any GameObject or Prefab to make the script be attached to that, and you can click any folder in the Project view to save the script in that folder. You can also pick which of the built-in callback functions you want included from the beginning (we only have four right now but we’ll add the others as well).

这是一项正在进行的工作,但是许多基本功能已经存在。 窗口打开时(它将浮动在顶部),您可以选择单击任何GameObject或Prefab使脚本附加到该对象,也可以单击“项目”视图中的任何文件夹将脚本保存在该文件夹中。 您还可以从一开始就选择要包含哪些内置回调函数(我们现在只有四个,但也将添加其他回调函数)。

When you click “Create and Attach” the script will be created with the right file name and class name, compiled, and then added to your selected GameObject or Prefab if you chose one.

当您单击“创建并附加”时,将使用正确的文件名和类名创建脚本,进行编译,然后将其添加到所选的GameObject或Prefab(如果选择了一个)。

We’re also adding this partially related button:

我们还添加了这个部分相关的按钮:

mimic iii_NinjaCamp III:“新脚本”对话框

  The idea here is to just make it more obvious and simpler how to add a component to a GameObject – no need to reach for that menu anymore. And no, the button is not part of the AudioSource component, it’s below it and is still missing some style work and a separator line above it. It’s a work in progress!

这里的想法是使如何向GameObject中添加组件变得更明显,更简单-不再需要该菜单。 不,该按钮不是AudioSource组件的一部分,它它的下方 ,并且仍然缺少一些样式工作,并且在其上方缺少分隔线。 这项工作正在进行中!

We’re still missing more work on the script template building options, but I can already see that this thing will save me time in the future, if nothing else. ;)

我们仍然缺少有关脚本模板构建选项的更多工作,但是我已经看到,如果没有其他事情,这件事将为节省时间。 ;)

翻译自: https://blogs.unity3d.com/2011/03/23/ninjacamp-iii-new-script-dialog/

mimic iii