LWFObject.Load C# (CSharp) Method

Load() public method

public Load ( string path, string texturePrefix = "", string fontPrefix = "", float zOffset, float zRate = 1, int renderQueueOffset, Camera camera = null, bool autoUpdate = true, bool>.System.Func lwfDataCallback = null, System.Action lwfLoadCallback = null, System.Action lwfDestroyCallback = null, Func,System lwfDataLoader = null, UnityEngine.Texture2D>.System.Func textureLoader = null, System.Action textureUnloader = null, object luaState = null ) : bool
path string
texturePrefix string
fontPrefix string
zOffset float
zRate float
renderQueueOffset int
camera Camera
autoUpdate bool
lwfDataCallback bool>.System.Func
lwfLoadCallback System.Action
lwfDestroyCallback System.Action
lwfDataLoader Func,System
textureLoader UnityEngine.Texture2D>.System.Func
textureUnloader System.Action
luaState object
return bool
    public virtual bool Load(string path,
		string texturePrefix = "", string fontPrefix = "",
		float zOffset = 0, float zRate = 1, int renderQueueOffset = 0,
		Camera camera = null, bool autoUpdate = true,
		LWFDataCallback lwfDataCallback = null,
		LWFCallback lwfLoadCallback = null,
		LWFCallback lwfDestroyCallback = null,
		LWFDataLoader lwfDataLoader = null,
		TextureLoader textureLoader = null,
		TextureUnloader textureUnloader = null
#if LWF_USE_LUA
		, object luaState = null
#endif
		)
    {
        lwfName = path;
        callUpdate = autoUpdate;
        if (camera == null)
            camera = Camera.main;

        if (lwfLoadCallback != null)
            lwfLoadCallbacks.Add(lwfLoadCallback);
        if (lwfDestroyCallback != null)
            lwfDestroyCallbacks.Add(lwfDestroyCallback);

        LWF.Data data =
            ResourceCache.SharedInstance().LoadLWFData(lwfName, lwfDataLoader);
        if (data == null || !data.Check())
            return false;

        if (lwfDataCallback != null && !lwfDataCallback(data))
            return false;

        if (rendererFactoryConstructor != null) {
            RendererFactoryArguments arg = new RendererFactoryArguments(
                data, gameObject, zOffset, zRate, renderQueueOffset, camera,
                texturePrefix, fontPrefix, textureLoader, textureUnloader);
            factory = rendererFactoryConstructor(arg);
        } else if (useCombinedMeshRenderer && data.textures.Length == 1) {
            factory = new LWF.CombinedMeshRenderer.Factory(
                data, gameObject, zOffset, zRate, renderQueueOffset, camera,
                texturePrefix, fontPrefix, textureLoader, textureUnloader);
        } else {
            factory = new LWF.DrawMeshRenderer.Factory(
                data, gameObject, zOffset, zRate, renderQueueOffset, camera,
                texturePrefix, fontPrefix, textureLoader, textureUnloader);
        }

        #if LWF_USE_LUA
        lwf = new LWF.LWF(data, factory, luaState);
        #else
        lwf = new LWF.LWF(data, factory);
        #endif

        OnLoad();

        return true;
    }

Usage Example

Example #1
0
    void InitLWF()
    {
        DestroyLWF();

        if (string.IsNullOrEmpty(mPath))
        {
            Debug.LogWarning(
                "UILWFObject: path should be a correct lwf bytes path");
            return;
        }

        string texturePrefix = System.IO.Path.GetDirectoryName(mPath);

        if (texturePrefix.Length > 0)
        {
            texturePrefix += "/";
        }

        GameObject o = new GameObject(mPath);

        o.layer     = gameObject.layer;
        o.hideFlags = HideFlags.HideAndDontSave;

        Transform transform = o.transform;

        transform.parent        = gameObject.transform;
        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;
        transform.localScale    = Vector3.one;

        Camera camera = NGUITools.FindCameraForLayer(o.layer);

        mLWFObject = o.AddComponent <LWFObject>();
        mLWFObject.Load(mPath, texturePrefix, "",
                        mZOffset, mZRate, mRenderQueueOffset, camera, true);

        int height = (int)camera.orthographicSize * 2;
        int width  = (int)(camera.aspect * (float)height);

        switch (mScaleType)
        {
        case ScaleType.FIT_FOR_HEIGHT:
            mLWFObject.FitForHeight(height);
            break;

        case ScaleType.FIT_FOR_WIDTH:
            mLWFObject.FitForWidth(width);
            break;

        case ScaleType.SCALE_FOR_HEIGHT:
            mLWFObject.ScaleForHeight(height);
            break;

        case ScaleType.SCALE_FOR_WIDTH:
            mLWFObject.ScaleForWidth(width);
            break;
        }
    }
All Usage Examples Of LWFObject::Load