Scriptable Object

  ScriptableObject 是一个可继承的Class,适用于存储大数据的情形。

   Consider for example that you have made a prefab with a script which has an array of a million integers. The array occupies 4MB of memory and is owned by the prefab. Each time you instantiate that prefab, you will get a copy of that array. If you created 10 game objects, then you would end up with 40MB of array data for the 10 instances.

  Unity serializes all primitive types, strings, arrays, lists, types specific to Unity such as Vector3 and your custom classes with the Serializable attribute as copies belonging to the object they were declared in.This means that if you created a ScriptableObject and stored the million integers in an array it declares then the array will be stored with that instance. The instances are thought to own their individual data.

  If you have a script with a reference to the ScriptableObject with the million integers, Unity will only store a reference to the ScriptableObject in the script data. The ScriptableObject in turn stores the array. 10 instances of a prefab that has a reference to a ScriptableObject, that holds 4MB data, would total to roughly 4MB and not 40MB as discussed in the other example.

CreateAssetMenuAttribute

  Mark a ScriptableObject-derived type to be automatically listed in the Assets/Create submenu, so that instances of the type can be easily created and stored in the project as ".asset" files.

  在 ScriptableObject 类定义的上一行加上 [CreateAssetMenu] ,即可通过 Asset/Create 菜单来创建此 ScriptableObject 类的asset。

  

参考:

1、http://docs.unity3d.com/Manual/class-ScriptableObject.html

2、http://docs.unity3d.com/ScriptReference/CreateAssetMenuAttribute.html

Scriptable Object的更多相关文章

  1. Unity 最佳实践

    转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...

  2. Rhino+envjs-1.2.js 在java运行网站js 工具类

    java爬虫遇到个页面加密的东西,找了些资料学习学习 做了个java运行js的工具类,希望对大家有用,其中用到client(获取js)可以自行换成自己的client.主要是用了 Rhino就是Java ...

  3. Unity中 动态加载 Resources.Load()和Asset Bundle 的区别

    版权声明:本文为博主原创文章,未经博主允许不得转载. 初学Unity的过程中,会发现打包发布程序后,unity会自动将场景需要引用到的资源打包到安装包里,没有到的不会跟进去.我们在编辑器里看到的Ass ...

  4. What is XMLHTTP? How to use security zones in Internet Explorer

    Types of Security Zones Internet Zone This zone contains Web sites that are not on your computer or ...

  5. 开发自定义ScriptableRenderPipeline,将DrawCall降低180倍

    0x00 前言 大家都知道,Unity在2018版本中正式推出了Scriptable Render Pipeline.我们既可以通过Package Manager下载使用Unity预先创建好的Ligh ...

  6. unity, asset operations

    //----create asset //ref: http://wiki.unity3d.com/index.php?title=CreateScriptableObjectAsset CmyScr ...

  7. Unity中资源动态加载的几种方式比较

    http://blog.csdn.net/leonwei/article/details/18406103 初学Unity的过程中,会发现打包发布程序后,unity会自动将场景需要引用到的资源打包到安 ...

  8. Error: CompareBaseObjectsInternal can only be called from the main thread

    Posted: 01:39 PM 06-17-2013 hi, we're working on a project where we need to do some calculations on ...

  9. java调用js函数

    问题:js函数可能有多个,之间有相互调用关系,有jquery jar包 org.mozilla.javascript-1.7.2 js   envjs-1.2.js java代码 import jav ...

随机推荐

  1. yii framework config 可以被配置的项目

    http://hi.baidu.com/lossless1009/item/990fdb33a52ffcf1e7bb7a4c <?php002 003 // 取消下行的注释,来定义一个路径别名0 ...

  2. Eclipse: the import java.util cannot be resolved

    the import java.util cannot be resolved 导入JRE System Library. 右键项目 Build Path Configure Build Path.. ...

  3. Java堆外内存之四:直接使用Unsafe类操作堆外内存

    在nio以前,是没有光明正大的做法的,有一个work around的办法是直接访问Unsafe类.如果你使用Eclipse,默认是不允许访问sun.misc下面的类的,你需要稍微修改一下,给Type ...

  4. linux修改文件系统挂载的目录

    比如想把已经挂载在home目录上的硬盘挂载到data目录上, 如下操作 #df -h(查看分区情况及数据盘名称) # mkdir /data(如果没有data目录就创建,否则此步跳过) # umoun ...

  5. override的实现原理

    转载 http://blog.csdn.net/fan2012huan/article/details/51007517 基于基类的调用和基于接口的调用,从性能上来讲,基于基类的调用性能更高 .因为i ...

  6. 部署DNS从服务器

    修改主服务器中区域信息文件: # vi /etc/named.rfc1912.zones 检查配置文件是否有错误 # named-checkconf 重启named服务程序,让配置文件生效 #syst ...

  7. 基于nginx和tengine的tcp反向代理,负载均衡 安装和配置

    先下载nginx_tcp_proxy_module模块. wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master ...

  8. PHP 弹出文件下载 原理 代码

    /** * @author      default7<default7@zbphp.com> * @description 演示PHP弹出下载的原理 * * @param $file_n ...

  9. OpenGL chapter2

    opengl: 图形硬件的一种软件接口:最大的优点:它的速度快于光线追踪器或软件渲染引擎. GLUT: AUX是OpenGL辅助函数库. 数据类型: GLboolean 位宽:1 GLbyte 8 G ...

  10. Java反射机制 —— 简单了解

    一.概述 JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为jav ...