[MenuItem("Assets/Create/C# System Script",false,70)]publicstaticvoidCreateSystemCS(){//参数为传递给CreateEventCSScriptAsset类action方法的参数ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<CreateSystemCSScriptAsset>(), GetSelectPathOrFallback() +"/New Script.cs"...
GetDirectoryName(path); break; } } return path; } /// <summary> /// 创建脚本文件的委托类 /// </summary> class CreateNewCShapScriptAsset : EndNameEditAction { public override void Action(int instanceId, string pathName, string resourceFile) { UnityEngine.Object obj = CreateScriptAssetFrom...
The first script of the example implements a class derived from ScriptableObject. using UnityEngine; [CreateAssetMenu] public class VehicleTypeInfo :ScriptableObject{ // Class that represents a specific type of vehicle [Range(0.1f, 100f)] public float m_MaxSpeed = 0.1f; ...
using UnityEditor; public class CreateLua { [MenuItem("Assets/Create/Lua Script",false,80)] public static void CreateNewLua() { ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<CreateScriptAssetAction>(), GetSelectedPathOrFallback() + "/New Lua.lua", null...
Unity ScriptObject创建Asset文件 创建ScriptObject可以创建带序列化的资源,只保存数据不用绑定在游戏对象上。创建出来的本子资源可以通过资源加载到游戏里使用。这里介绍一下使用Resources加载。 创建好的asset文件也可以在Inspector中进行编辑。 1usingSystem.Collections.Generic;2usingUnityEngine;34[CreateAssetMenu]5public...
创建ScriptObject可以创建带序列化的资源,只保存数据不⽤绑定在游戏对象上。创建出来的本⼦资源可以通过资源加载到游戏⾥使⽤。这⾥介绍⼀下使⽤Resources加载。创建好的asset⽂件也可以在Inspector中进⾏编辑。1using System.Collections.Generic;2using UnityEngine;3 4 [CreateAssetMenu]5public class ...
lAssetBundle.CreateFrom和WWW.AssetBundle 创建一个AssetBundle内存镜像 lAssetBundle.Load和Resources.Load 从AssetBundle读取一个指定名称的Asset并生成Asset内存对象。如果多次Load同名对象,除第一次外都只会返回已经生成的Asset对象,也就是说多次Load一个Asset并不会生成多个副本。
lAssetBundle.CreateFrom和WWW.AssetBundle 创建一个AssetBundle内存镜像 lAssetBundle.Load和Resources.Load 从AssetBundle读取一个指定名称的Asset并生成Asset内存对象。如果多次Load同名对象,除第一次外都只会返回已经生成的Asset对象,也就是说多次Load一个Asset并不会生成多个副本。
AssetBundle AssetBundle1 = AssetBundle.CreateFromFile("1.unity3d"); 从AssetBundle1里读取并创建一个Texture Asset,把obj1的主贴图指向它 obj1.renderer.material.mainTexture = AssetBundle1.Load("wall") as Texture; 把obj2的主贴图也指向同一个Texture Asset ...
public class ScriptsInfoEditor : UnityEditor.AssetModificationProcessor { public const string authorName = "tackor(修改为你自己的名称即可)"; private static void OnWillCreateAsset(string path) { path = path.Replace(".meta", ""); if (path.EndsWith(".cs")) ...