UIWidget.Update C# (CSharp) Method

Update() public method

Ensure that we have a panel to work with. The reason the panel isn't added in OnEnable() is because OnEnable() is called right after Awake(), which is a problem when the widget is brought in on a prefab object as it happens before it gets parented.
public Update ( ) : void
return void
    public void Update()
    {
        CheckLayer();

        // Ensure we have a panel to work with by now
        if (mPanel == null) CreatePanel();
        #if UNITY_EDITOR
        else if (!Application.isPlaying) ParentHasChanged();
        #endif

        // Automatically reset the Z scaling component back to 1 as it's not used
        Vector3 scale = cachedTransform.localScale;

        if (scale.z != 1f)
        {
            scale.z = 1f;
            mTrans.localScale = scale;
        }
    }

Usage Example

Ejemplo n.º 1
0
    private void AnchotObjectToTable(GameObject obj, int row)
    {
        obj.transform.localScale = Vector3.one;
        UIWidget widget = obj.GetComponent <UIWidget>();

        widget.leftAnchor.target     = table;
        widget.rightAnchor.target    = table;
        widget.bottomAnchor.target   = table;
        widget.topAnchor.target      = table;
        widget.leftAnchor.relative   = 0;
        widget.leftAnchor.absolute   = 0;
        widget.rightAnchor.relative  = 1;
        widget.rightAnchor.absolute  = 0;
        widget.bottomAnchor.relative = 1;
        widget.bottomAnchor.absolute = (row + 1) * -height;
        widget.topAnchor.relative    = 1;
        widget.topAnchor.absolute    = row * -height;
        widget.Update();
    }
All Usage Examples Of UIWidget::Update