MaterialVariant 类型
继承于 Material
材质变体是材质资源的一个延伸。 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。
索引
属性(properties)
loadedBoolean该资源是否已经成功加载urlString资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。nativeUrlString返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。_nativeStringSerializable url for native asset._nativeAssetObjectThe underlying native asset of this asset if one is available...._uuidString_nameString_objFlagsNumbernameString该对象的名称。isValidBoolean表示该对象是否可用(被 destroy 后将不可用)。
方法
createWithBuiltincreatesetProperty是指材质的属性getProperty获取材质的属性。define设置材质的宏定义。getDefine获取材质的宏定义。setCullMode设置材质的裁减模式。setDepth设置材质的深度渲染状态。setBlend设置材质的混合渲染状态。setStencilEnabled设置是否开启模板测试。setStencil设置材质的模板测试渲染参数。toStringReturns the asset's url....serialize应 AssetDB 要求提供这个方法createNode使用该资源在场景中创建一个新节点。_setRawAssetSet native file name for this asset.destroy销毁该对象,并释放所有它对其它对象的引用。_destructClear all references in the instance...._onPreDestroyCalled before the object being destroyed._serializeThe customized serialization for this object. (Editor Only)_deserializeInit this object from the custom serialized data.
Details
属性(properties)
loaded
该资源是否已经成功加载
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/assets/CCAsset.js:57 |
url
资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。 nativeUrl 与 url 的区别在于,url 是资源最终路径,所以 url 不需要再经过 md5 以及子包的路径转换, 另外某些带缓存机制的小游戏平台(微信等)上url可能会指向临时文件路径或者缓存路径,如果你需要在这些平台上使用资源的原生文件,请使用url,避免使用nativeUrl
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/assets/CCAsset.js:68 |
nativeUrl
返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/assets/CCAsset.js:85 |
_native
Serializable url for native asset.
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/assets/CCAsset.js:123 |
_nativeAsset
The underlying native asset of this asset if one is available. This property can be used to access additional details or functionality releated to the asset. This property will be initialized by the loader if
_nativeis available.
| meta | description |
|---|---|
| 类型 | Object |
| 定义于 | cocos2d/core/assets/CCAsset.js:131 |
_uuid
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/assets/CCRawAsset.js:46 |
_name
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/platform/CCObject.js:76 |
_objFlags
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/platform/CCObject.js:83 |
name
该对象的名称。
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/platform/CCObject.js:240 |
示例
obj.name = "New Obj";
isValid
表示该对象是否可用(被 destroy 后将不可用)。
当一个对象的destroy调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始isValid就会返回 false,而当前帧内isValid仍然会是 true。如果希望判断当前帧是否调用过destroy,请使用cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/platform/CCObject.js:258 |
示例
var node = new cc.Node();
cc.log(node.isValid); // true
node.destroy();
cc.log(node.isValid); // true, still valid in this frame
// after a frame...
cc.log(node.isValid); // false, destroyed in the end of last frame
方法
createWithBuiltin
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/material-variant.ts:29 |
参数列表
materialNameMaterial.BUILTIN_NAMEownerRenderComponent
create
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/material-variant.ts:40 |
参数列表
materialMaterialownerRenderComponent
setProperty
是指材质的属性
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:190 |
参数列表
getProperty
获取材质的属性。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:228 |
参数列表
define
设置材质的宏定义。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:242 |
参数列表
getDefine
获取材质的宏定义。
| meta | description |
|---|---|
| 返回 | boolean | number |
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:260 |
参数列表
setCullMode
设置材质的裁减模式。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:275 |
参数列表
setDepth
设置材质的深度渲染状态。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:286 |
参数列表
setBlend
设置材质的混合渲染状态。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:304 |
参数列表
enablednumberblendEqnumberblendSrcnumberblendDstnumberblendAlphaEqnumberblendSrcAlphanumberblendDstAlphanumberblendColornumberpassIdxnumber
setStencilEnabled
设置是否开启模板测试。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:332 |
参数列表
setStencil
设置材质的模板测试渲染参数。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/material/CCMaterial.js:343 |
参数列表
stencilTestnumberstencilFuncnumberstencilRefnumberstencilMasknumberstencilFailOpnumberstencilZFailOpnumberstencilZPassOpnumberstencilWriteMasknumberpassIdxnumber
toString
Returns the asset's url.
The Asset object overrides the toString() method of the Object object.
For Asset objects, the toString() method returns a string representation of the object.
JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
| meta | description |
|---|---|
| 返回 | String |
| 定义于 | cocos2d/core/assets/CCAsset.js:184 |
serialize
应 AssetDB 要求提供这个方法
| meta | description |
|---|---|
| 返回 | String |
| 定义于 | cocos2d/core/assets/CCAsset.js:198 |
createNode
使用该资源在场景中创建一个新节点。
如果这类资源没有相应的节点类型,该方法应该是空的。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/CCAsset.js:209 |
参数列表
_setRawAsset
Set native file name for this asset.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/assets/CCAsset.js:224 |
参数列表
destroy
销毁该对象,并释放所有它对其它对象的引用。
实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。
您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/platform/CCObject.js:293 |
示例
obj.destroy();
_destruct
Clear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:427 |
_onPreDestroy
Called before the object being destroyed.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:460 |
_serialize
The customized serialization for this object. (Editor Only)
| meta | description |
|---|---|
| 返回 | object |
| 定义于 | cocos2d/core/platform/CCObject.js:485 |
参数列表
exportingBoolean
_deserialize
Init this object from the custom serialized data.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:495 |
参数列表
dataObject the serialized json datactx_Deserializer