Unity脚本生成插件:Script Create Dialog

news/2024/6/29 14:13:01

最近写代码又犯懒了...
感觉每次新建脚本都要写一堆简单重复的东西好无聊,所以搜索了一下有没有自动生成脚本的插件。结果还真被我发现了,官方在N久之前就制作了自动生成脚本的插件[Script Create Dialog],大概是名字起的和脚本生成器相差太多,现在的开发工具又太强大,所以被埋没了。所支持的Unity版本 3.4.2及以上,远古时期遗留的资源。试用了一下,感觉要是刚学Unity脚本的时候有这个插件,能省下很多读API的时间。

插件效果

插件UI

使用方式

1.下载我修改后的插件
链接:https://pan.baidu.com/s/1oa8r... 密码:6zln

2.下载官方插件并修复脚本错误
官方下载地址:https://assetstore.unity.com/...

如果导入插件后出现以下错误:
错误提示
Assets/CreateScriptDialog/Editor/NewScriptWindow.cs(454,47): error CS0117: UnityEditorInternal.InternalEditorUtility' does not contain a definition for AddScriptComponentUnchecked'

把错误部分代码改为:

if (CanAddComponent()) {// Need to use reflection to access this now (it is internal)MethodInfo addScriptMethod = typeof(InternalEditorUtility).GetMethod("AddScriptComponentUncheckedUndoable",BindingFlags.Static | BindingFlags.NonPublic);addScriptMethod.Invoke(null, new Object[] {m_GameObjectToAddTo,AssetDatabase.LoadAssetAtPath(TargetPath(), typeof (MonoScript)) as MonoScript});
}

3.右键使用
Assets窗口下右键>Create>Script...打开窗口使用。
右键打开窗口

UI窗口

4.可以自定义新的脚本模板
使用说明在ReadMe.html中可以看到。
方法模板在MonoBehaviour.functions.txt中可以看到。可以根据规则添加自定义模板。

BASECLASS=MonoBehaviour
using UnityEngine;
using System.Collections;
using System.Collections.Generic;public class $ClassName : MonoBehaviour {$Functions
}
void Awake() Awake is called when the script instance is being loaded.
DEFAULT void Start() Start is called just before any of the Update methods is called the first time.
DEFAULT void Update() Update is called every frame, if the MonoBehaviour is enabled.
void LateUpdate() LateUpdate is called every frame, if the Behaviour is enabled.
void FixedUpdate() This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
void OnGUI() OnGUI is called for rendering and handling GUI events.
void OnEnable() This function is called when the object becomes enabled and active.
void OnDisable() This function is called when the behaviour becomes disabled () or inactive.
void OnDestroy() This function is called when the MonoBehaviour will be destroyed.
void Reset() Reset to default values.
HEADER Physics
void OnTriggerEnter(Collider other) OnTriggerEnter is called when the Collider other enters the trigger.
void OnTriggerExit(Collider other) OnTriggerExit is called when the Collider other has stopped touching the trigger.
void OnTriggerStay(Collider other) OnTriggerStay is called once per frame for every Collider other that is touching the trigger.
void OnCollisionEnter(Collision collision) OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
void OnCollisionExit(Collision collisionInfo) OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
void OnCollisionStay(Collision collisionInfo) OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
void OnControllerColliderHit(ControllerColliderHit hit) OnControllerColliderHit is called when the controller hits a collider while performing a Move.
void OnJointBreak(float breakForce) Called when a joint attached to the same game object broke.
void OnParticleCollision(GameObject other) OnParticleCollision is called when a particle hits a collider.
HEADER Mouse
void OnMouseEnter() OnMouseEnter is called when the mouse entered the GUIElement or Collider.
void OnMouseOver() OnMouseOver is called every frame while the mouse is over the GUIElement or Collider.
void OnMouseExit() OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider.
void OnMouseDown() OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.
void OnMouseUp() OnMouseUp is called when the user has released the mouse button.
void OnMouseUpAsButton() OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed.
void OnMouseDrag() OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.
HEADER Playback
void OnLevelWasLoaded(int level) This function is called after a new level was loaded.
void OnApplicationFocus(bool focus) Sent to all game objects when the player gets or looses focus.
void OnApplicationPause(bool pause) Sent to all game objects when the player pauses.
void OnApplicationQuit() Sent to all game objects before the application is quit.
HEADER Rendering
void OnBecameVisible() OnBecameVisible is called when the renderer became visible by any camera.
void OnBecameInvisible() OnBecameInvisible is called when the renderer is no longer visible by any camera.
void OnPreCull() OnPreCull is called before a camera culls the scene.
void OnPreRender() OnPreRender is called before a camera starts rendering the scene.
void OnPostRender() OnPostRender is called after a camera finished rendering the scene.
void OnRenderObject() OnRenderObject is called after camera has rendered the scene.
void OnWillRenderObject() OnWillRenderObject is called once for each camera if the object is visible.
void OnRenderImage(RenderTexture source, RenderTexture destination) OnRenderImage is called after all rendering is complete to render image
HEADER Gizmos
void OnDrawGizmosSelected() Implement this OnDrawGizmosSelected if you want to draw gizmos only if the object is selected.
void OnDrawGizmos() Implement this OnDrawGizmos if you want to draw gizmos that are also pickable and always drawn.
HEADER Network
void OnPlayerConnected(NetworkPlayer player) Called on the server whenever a new player has successfully connected.
void OnServerInitialized() Called on the server whenever a Network.InitializeServer was invoked and has completed.
void OnConnectedToServer() Called on the client when you have successfully connected to a server.
void OnPlayerDisconnected(NetworkPlayer player) Called on the server whenever a player disconnected from the server.
void OnDisconnectedFromServer(NetworkDisconnection info) Called on the client when the connection was lost or you disconnected from the server.
void OnFailedToConnect(NetworkConnectionError error) Called on the client when a connection attempt fails for some reason.
void OnFailedToConnectToMasterServer(NetworkConnectionError info) Called on clients or servers when there is a problem connecting to the MasterServer.
void OnMasterServerEvent(MasterServerEvent msEvent) Called on clients or servers when reporting events from the MasterServer. 
void OnNetworkInstantiate(NetworkMessageInfo info) Called on objects which have been network instantiated with Network.Instantiate
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) Used to customize synchronization of variables in a script watched by a network view.

自定义功能

修改后的插件:链接:https://pan.baidu.com/s/1oa8r... 密码:6zln
修改或增加了以下功能:
1.修复了"UnityEditorInternal.InternalEditorUtility"的错误。
2.新增模板MyMono(拷贝C#的MonoBehaviour模板)。
3.默认选择自定义模板MyMono。
4.增加了当前创建日期。
5.可以删除注释(以前删除注释还会有//)。
6.增加了对访问修饰符的支持。
7.重新排序API。
8.打包版本Unity5.3.4。

自定义功能


http://lihuaxi.xjx100.cn/news/246579.html

相关文章

(DBA之路【五】)关于锁的故事

首先很抱歉:这篇文章我其实整合了很多别人的文章,但是因为太多,一开始被没留意出处所以很难声明来源,很抱歉,但是这篇文章只用来作为学习笔记,作为新手,我以后会注意的。(一&#xf…

c基础知识复习

C的发展历程 C原本是为了开发UNIX操作系统而设计的语言;如此说,应该C比UNIX更早问世,而事实并非如此,最早的UNIX是由汇编写的; C语言本来是美国人开发的,解读C的声明,最好还是用英语来读&#x…

android 动态获取权限有哪些,Android 6.0+ 动态获取权限

Android 6.0 动态获取权限这里有一个现成的库,可以直接拿来用。方便简单1.向app下的gradle添加依赖:dependencies{// android 6.0 动态获取权限compilecom.master.android:permissionhelper:1.3}2.在你的app启动的第一个activity中进行初始化private sta…

自动驾驶之时间同步

1. 时间同步背景 自动驾驶里的域控制器和传感器若都采用内置的硬件时钟,同样会存在不同硬件时间存在偏差的现象。试想在感知融合阶段,左侧车道有一辆时速80km/h的车辆正准备超车变道,由于没有时间同步,激光300ms前的点云数据与相…

粒子群算法(1)----粒子群简要

一、历史粒子群算法从复杂适应系统衍生PSO算法(Complex Adaptive System,CAS)。CAS理论于1994年正式提出,CAS中的成员称为主体。比方研究鸟群系统,每一个鸟在这个系统中就称为主体。主体有适应性,它能够与环境及其它的…

领克汽车是用鸿蒙系统吗,领克全新旗舰SUV将在上海车展首发亮相

作为和吉利与沃尔沃汽车联合打造的品牌,领克已经在高端品牌领域逐渐站稳脚跟,甚至销量已经反超部分合资品牌。当前,领克已经推出了领克01、02、05等SUV,主要集中在紧凑型或小型级别车型,这种打发虽然很走量&#xff0c…

wifidog接口文档(转)

目录(?)[-] 网关心跳协议 请求信息 回复格式 例子用户状态心跳协议 请求格式 注意 回复格式 状态码 例子跳转协议 请求格式 例子注册协议 请求格式 例子wifidog是搭建无线热点认证系统的解决方案之一,他比nocat更适合互联网营销思路。目前支持openwrt系统&#xff…

unity加载ab后,场景shader不起效问题(物件表现黑色)

需要把unity自带的shader,加入到默认列表转载于:https://www.cnblogs.com/lancidie/p/9293827.html