Scriptable Object
【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的更多相关文章
- Unity 最佳实践
转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...
- Rhino+envjs-1.2.js 在java运行网站js 工具类
java爬虫遇到个页面加密的东西,找了些资料学习学习 做了个java运行js的工具类,希望对大家有用,其中用到client(获取js)可以自行换成自己的client.主要是用了 Rhino就是Java ...
- Unity中 动态加载 Resources.Load()和Asset Bundle 的区别
版权声明:本文为博主原创文章,未经博主允许不得转载. 初学Unity的过程中,会发现打包发布程序后,unity会自动将场景需要引用到的资源打包到安装包里,没有到的不会跟进去.我们在编辑器里看到的Ass ...
- 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 ...
- 开发自定义ScriptableRenderPipeline,将DrawCall降低180倍
0x00 前言 大家都知道,Unity在2018版本中正式推出了Scriptable Render Pipeline.我们既可以通过Package Manager下载使用Unity预先创建好的Ligh ...
- unity, asset operations
//----create asset //ref: http://wiki.unity3d.com/index.php?title=CreateScriptableObjectAsset CmyScr ...
- Unity中资源动态加载的几种方式比较
http://blog.csdn.net/leonwei/article/details/18406103 初学Unity的过程中,会发现打包发布程序后,unity会自动将场景需要引用到的资源打包到安 ...
- 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 ...
- java调用js函数
问题:js函数可能有多个,之间有相互调用关系,有jquery jar包 org.mozilla.javascript-1.7.2 js envjs-1.2.js java代码 import jav ...
随机推荐
- HDFS高级开发培训课程之HDFS开发实例课件
前言: 刚刚完成的HDFS高级开发培训课程课件中的一个章节,不知道PPT,如何导出HTML格式,只好批量导出图片,贴图了. 连接管理:建立连接.断开连接.设置连接参数 文件操作:浏览文件.上传文件.下 ...
- VS编译时使用/去除NuGet管理库
原文链接:VS编译时自动下载NuGet管理的库 之前一直使用NuGet来管理一些第三方的库,但是每次check in代码时候为了保证编译通过,都需要把对应的packages check in. 比较耗 ...
- pyplot 绘图与可视化
1. 基本使用 #!/usr/bin/env python # coding=utf-8 import matplotlib.pyplot as plt from numpy.random impor ...
- 用cmd导入oracle的.dmp文件和修改oracle管理员密码
1,首先创建用户 语法[创建用户]: create user 用户名 identified by 口令[即密码]: 例子:create user zhengxin identified by zhen ...
- numpy的linspace函数
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False,dtype=None)[source] 文档:https://docs ...
- 【Python编程:从入门到实践】chapter9 类
chapter9 类 9.1 创建和使用类 9.1.1 创建Dog类 class Dog(): """一次模拟小狗的简单尝试""" def ...
- Design a high performance cache for multi-threaded environment
如何设计一个支持高并发的高性能缓存库 不 考虑并发情况下的缓存的设计大家应该都比较清楚,基本上就是用map/hashmap存储键值,然后用双向链表记录一个LRU来用于缓存的清理.这篇文章 应该是讲得很 ...
- T1330 最少步数(#Ⅱ- 8)(广度优先搜索)
[题目描述] 在各种棋中,棋子的走法总是一定的,如中国象棋中马走“日”.有一位小学生就想如果马能有两种走法将增加其趣味性,因此,他规定马既能按“日”走,也能如象一样走“田”字.他的同桌平时喜欢下围棋, ...
- web.py尝试性学习!
首先导入web.py模块! import web 没有的话就: pip install web web.py的URL结构: urls = ( '/', "index" ) 第一部分 ...
- .NET MVC ToList() 转Json
#region 方法一 #region ToList()转json /// <summary> /// 通过类别 Id 获相应产品 /// </summary> /// < ...