LWFObject.FitForHeight C# (CSharp) Method

FitForHeight() public method

public FitForHeight ( int stageHeight ) : void
stageHeight int
return void
    public virtual void FitForHeight(int stageHeight)
    {
        AddLoadCallback((o) => lwf.FitForHeight(stageHeight));
    }

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::FitForHeight