UIWidget.ParentHasChanged C# (CSharp) Method

ParentHasChanged() public method

Checks to ensure that the widget is still parented to the right panel.
public ParentHasChanged ( ) : void
return void
    public void ParentHasChanged()
    {
        if (mPanel != null)
        {
            // This code allows drag & dropping of widgets onto different panels in the editor.
            bool valid = true;
            Transform t = cachedTransform.parent;

            // Run through the parents and see if this widget is still parented to the transform
            while (t != null)
            {
                if (t == mPanel.cachedTransform) break;
                if (!mPanel.WatchesTransform(t)) { valid = false; break; }
                t = t.parent;
            }

            // This widget is no longer parented to the same panel. Remove it and re-add it to a new one.
            if (!valid)
            {
                if (!keepMaterial || Application.isPlaying) material = null;
                mPanel = null;
                CreatePanel();
            }
        }
    }

Usage Example

Beispiel #1
0
 static public int ParentHasChanged(IntPtr l)
 {
     try {
         UIWidget self = (UIWidget)checkSelf(l);
         self.ParentHasChanged();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
All Usage Examples Of UIWidget::ParentHasChanged