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. ThinkJava-访问权限控制

    6.2.3 private: 你无法访问 关键字private的意思是,除了包含该成员的类之外,其他任何类都无法访问这个成员.由 于处于同一个包内的其他类是不可以访问private成员的,因此这等于说 ...

  2. 1077 Kuchiguse (20 分)

    1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  3. scrapy 抓取拉勾网数据

    其实很简单,却因为一些小问题,折腾不少时间,简要记录一下,以备后需. >> scrapy startproject lagou >> cd lagou >> scr ...

  4. linux中nmcli命令使用及网络配置

    nmcli命令与配置文件对应关系  主机名: 如果说你没有设置主机名的话,默认是localhost.localdomain 修改配置文件的主机名 # hostnamectl  set-hostname ...

  5. js如何获取数字占的位数~

    获取整数的长度可以用以下几种方法实现: 1.调用toString方法转为字符串后取长度 var num = 123; alert(num.toString().length); 2.隐式转字符串后取长 ...

  6. python 之路之函数01

    一   函数 1  那么要想学习函数,我们首先应该知道函数是什么? 我们这里所说的函数与数学中的函数是不同的概念,在这里我们可以把函数看成我们写代码过程中需要用到的工具. 2  那么这个‘工具’有什么 ...

  7. redis详解(一)-- 概述

    首先,分布式缓存框架 可以 看成是nosql的一种 (1)什么是redis? redis 是一个基于内存的高性能key-value数据库. (有空再补充,有理解错误或不足欢迎指正) (2)Reids的 ...

  8. 机器学习入门-DBSCAN聚类算法

    DBSCAN 聚类算法又称为密度聚类,是一种不断发张下线而不断扩张的算法,主要的参数是半径r和k值 DBSCAN的几个概念: 核心对象:某个点的密度达到算法设定的阈值则其为核心点,核心点的意思就是一个 ...

  9. 前端开发-4-HTML-table&form&表单控制 标签

    1.table标签 <!DOCTYPE html> <html lang="cn"> <head> <meta charset=" ...

  10. UI5-文档-4.1-Hello World!

    如你所知,SAPUI5是关于HTML5的.让我们开始构建第一个仅使用HTML的“Hello World”. Preview 浏览器显示文本“Hello World” Coding 你可以在此查看和下载 ...