Ejemplo n.º 1
0
 private void RegisterChild(SpatialControl child)
 {
     GD.Print("Registering: ", child.Name, "; ", child.GetIndex());
     if (child.GetIndex() == 0)
     {
         child.Translation = new Vector3(child.Translation.x, 0, child.Translation.z);
     }
     else
     {
         var previousSC = (SpatialControl)GetChild(child.GetIndex() - 1);
         SetBelow(previousSC, child);
     }
     child.Connect(nameof(SizeChanged), this, nameof(OnChildSizeChanged),
                   new Godot.Collections.Array {
         child
     });
     OnChildSizeChanged(Vector2.Zero, child);
 }
Ejemplo n.º 2
0
 public void OnChildSizeChanged(Vector2 oldSize, SpatialControl child)
 {
     if (Math.Abs(oldSize.y - child.Size.y) < 1e-7)
     {
         return; //we don't actually care about changes that don't affect vertical size.
     }
     GD.Print(child.Name, "; ", child.Translation, "; ", oldSize, " -> ", child.Size);
     for (int i = child.GetIndex() + 1; i < GetChildCount(); i++)
     {
         var nextChild = (SpatialControl)GetChild(i);
         SetBelow(child, nextChild);
         child = nextChild;
     }
     Size = new Vector2(Size.x, -child.Translation.y + child.Size.y);
     GD.Print(GetPath() + "size set to: ", Size);
 }