Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextAsset

文本资源。

Hierarchy

Implements

Index

Constructors

constructor

  • newTextAsset(...args: ConstructorParameters<RawAsset>): TextAsset

Properties

_callbackTable

_callbackTable: any = createMap(true)

IEventTarget 实现,它们将被 applyMixins 在 EventTarget 中用相同的实现覆盖

Protected _name

_name: string

_native

_native: string = ""

用于本机资产的可序列化URL。供内部使用。

default

""

_objFlags

_objFlags: number

_uuid

_uuid: string

内部使用。

loaded

loaded: boolean = true

该资源是否已经成功加载。

text

text: string = ""

此资源包含的文本。

Static preventDeferredLoadDependents

preventDeferredLoadDependents: boolean = false

当场景或 Prefab 被标记为 asyncLoadAssets,禁止延迟加载该资源所依赖的其它 RawAsset。

property

{Boolean} preventDeferredLoadDependents

default

false

static

Static preventPreloadNativeObject

preventPreloadNativeObject: boolean = false

禁止预加载原生对象。

property

{Boolean} preventPreloadNativeObject

default

false

static

Accessors

Private nativeAsset

  • get nativeAsset(): any
  • set nativeAsset(obj: any): void

isValid

  • get isValid(): boolean
  • 表示该对象是否可用(被 destroy 后将不可用)。
    当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。
    因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。
    如果希望判断当前帧是否调用过 destroy,请使用 cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。

    property

    {Boolean} isValid

    default

    true

    readonly
    example
    import * as cc from 'cc';
    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

    Returns boolean

name

  • get name(): string
  • set name(value: string): void

nativeUrl

  • get nativeUrl(): string
  • 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。

    property

    nativeUrl

    type

    {String}

    readonly

    Returns string

Methods

destroyImmediate

  • _destroyImmediate(): void

destruct

  • _destruct(): void
  • 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; } } }

    Returns void

Private setRawAsset

  • setRawAsset(filename: string, inLibrary?: boolean): void

Optional createNode

destroy

  • destroy(): boolean
  • 销毁该对象,并释放所有它对其它对象的引用。
    实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。

    example
    obj.destroy();

    Returns boolean

    whether it is the first time the destroy being called

dispatchEvent

  • dispatchEvent(event: Event): void

emit

  • emit(key: string, ...args: any[]): void

hasEventListener

  • hasEventListener(key: string, callback?: Function | undefined, target?: Object | undefined): boolean

off

  • off(type: string, callback?: Function | undefined, target?: Object | undefined): void

on

  • on(type: string, callback: Function, target?: Object | undefined): Function | undefined

once

  • once(type: string, callback: Function, target?: Object | undefined): Function | undefined

removeAll

  • removeAll(keyOrTarget?: string | Object | undefined): void

targetOff

  • targetOff(keyOrTarget?: string | Object | undefined): void

toString

  • toString(): string

Static deferredDestroy

  • _deferredDestroy(): void

Static deserialize

  • deserialize(data: any): any

Static isRawAssetType

  • isRawAssetType(ctor: Function): boolean

Generated using TypeDoc