FairyGUI.GGraph.SetNativeObject C# (CSharp) Method

SetNativeObject() public method

设置内容为一个原生对象。这个图形对象相当于一个占位的用途。
public SetNativeObject ( DisplayObject obj ) : void
obj DisplayObject 原生对象
return void
        public void SetNativeObject(DisplayObject obj)
        {
            if (displayObject == obj)
                return;

            if (displayObject != null)
            {
                if (displayObject.parent != null)
                    displayObject.parent.RemoveChild(displayObject, true);
                else
                    displayObject.Dispose();
                _shape = null;
                displayObject.gOwner = null;
                displayObject = null;
            }

            displayObject = obj;

            if (displayObject != null)
            {
                displayObject.alpha = this.alpha;
                displayObject.rotation = this.rotation;
                displayObject.visible = this.visible;
                displayObject.touchable = this.touchable;
                displayObject.gOwner = this;
            }

            if (parent != null)
                parent.ChildStateChanged(this);
            HandlePositionChanged();
        }

Usage Example

示例#1
0
    public RenderImage(GGraph holder)
    {
        _width = (int)holder.width;
        _height = (int)holder.height;
        _cacheTexture = true;

        this._image = new Image();
        holder.SetNativeObject(this._image);

        if (_camera == null)
            CreateCamera();

        this._root = new GameObject("render_image" + _gid++).transform;
        Object.DontDestroyOnLoad(this._root.gameObject);
        this._root.SetParent(_camera.transform, false);
        SetLayer(this._root.gameObject, HIDDEN_LAYER);

        this.modelRoot = new GameObject("model_root").transform;
        Object.DontDestroyOnLoad(this.modelRoot.gameObject);
        this.modelRoot.SetParent(this._root, false);

        this._background = new GameObject("background").transform;
        Object.DontDestroyOnLoad(this._background.gameObject);
        this._background.SetParent(this._root, false);

        this._image.onAddedToStage.Add(OnAddedToStage);
        this._image.onRemovedFromStage.Add(OnRemoveFromStage);

        if (this._image.stage != null)
            OnAddedToStage();
    }
All Usage Examples Of FairyGUI.GGraph::SetNativeObject