public void CreateModSettingsTable() { DynData <OptionsPanel> d = new DynData <OptionsPanel>(optionsPanel); GameObject old = d.Get <AgeTransform>("controlBindingsTable").gameObject; GameObject table = (GameObject)GameObject.Instantiate(old); table.name = "ModSettingsTable"; table.transform.SetParent(modSettingsScroll.GetComponent <AgeControlScrollView>().Viewport.transform); AgeTransform oldTable = old.GetComponent <AgeTransform>(); AgeTransform newTable = table.GetComponent <AgeTransform>(); modSettingsScroll.GetComponent <AgeControlScrollView>().VirtualArea = newTable; newTable.Init(); newTable.Position = oldTable.Position; newTable.VerticalSpacing = oldTable.VerticalSpacing; modSettingsTable = newTable; }
public void CreateFrame() { DynData <OptionsPanel> d = new DynData <OptionsPanel>(optionsPanel); GameObject oldObj = d.Get <AgeControlToggle>("vSyncToggle").transform.parent.parent.parent.parent.gameObject; // oldObj in this case is the "Frame" object that we would like to duplicate. GameObject frame = (GameObject)GameObject.Instantiate(oldObj); // The frame is a child of the current display. frame.transform.SetParent(transform); frame.name = "ModSettingsFrame"; Rect te = optionsPanel.transform.FindChild("1-Frame").GetComponent <AgeTransform>().Position; frame.GetComponent <AgeTransform>().Position = te; frame.GetComponent <AgeTransform>().PixelOffsetLeft = optionsPanel.transform.FindChild("1-Frame").GetComponent <AgeTransform>().PixelOffsetLeft; frame.GetComponent <AgeTransform>().PixelOffsetTop = optionsPanel.transform.FindChild("1-Frame").GetComponent <AgeTransform>().PixelOffsetTop; // Delete the Frame from the GUI control, there can only be one frame (otherwise weird things happen) GameObject.DestroyImmediate(transform.FindChild("1-Frame").gameObject); GameObject bg = (GameObject)GameObject.Instantiate(optionsPanel.transform.FindChild("0-Bg").gameObject); bg.transform.SetParent(transform); //transform.SetParent(optionsPanel.AgeTransform.GetParent().transform); bg.name = "ModSettingsBackground"; // Destroys the useless RightSide // Instead, we will expand the leftSide to have everything! // We need to delete all of its children too, and its children's children, etc. frame.transform.FindChild("2-LeftPart").name = "CentralPart"; Util.DeleteChildrenExclusive(frame.transform.FindChild("CentralPart").gameObject); AgeTransform left = frame.transform.FindChild("CentralPart").GetComponent <AgeTransform>(); left.Init(); left.Position = optionsPanel.transform.FindChild("1-Frame").FindChild("2-LeftPart").GetComponent <AgeTransform>().Position; left.Width = frame.GetComponent <AgeTransform>().Width; left.PixelMarginTop = 20; left.Height = left.Height + (optionsPanel.transform.FindChild("1-Frame").FindChild("2-LeftPart").GetComponent <AgeTransform>().PixelMarginTop - left.PixelMarginTop); left.Height -= 10; Util.DeleteChildrenInclusive(frame.transform.FindChild("3-RightPart").gameObject); //GameObject.DestroyImmediate(frame.transform.FindChild("3-RightPart")); AgeControlButton cancel = frame.transform.FindChild("7-CancelButton").GetComponent <AgeControlButton>(); cancel.AgeTransform.Position = optionsPanel.transform.FindChild("1-Frame").FindChild("7-CancelButton").GetComponent <AgeControlButton>().AgeTransform.Position; // Fixes a strange bug AgeControlButton confirm = frame.transform.FindChild("9-ConfirmButton").GetComponent <AgeControlButton>(); confirm.AgeTransform.Position = optionsPanel.transform.FindChild("1-Frame").FindChild("9-ConfirmButton").GetComponent <AgeControlButton>().AgeTransform.Position; // Fixes a strange bug AgeControlButton reset = frame.transform.FindChild("8-ResetButton").GetComponent <AgeControlButton>(); reset.AgeTransform.Position = optionsPanel.transform.FindChild("1-Frame").FindChild("8-ResetButton").GetComponent <AgeControlButton>().AgeTransform.Position; // Fixes a strange bug // Sets the buttons to match the OptionsPanel buttons cancel.AgeTransform.PixelMarginBottom = 3; cancel.AgeTransform.PixelMarginLeft = 3; cancel.AgeTransform.PixelMarginRight = 4; confirm.AgeTransform.PixelMarginBottom = 3; confirm.AgeTransform.PixelMarginLeft = 4; confirm.AgeTransform.PixelMarginRight = 3; reset.AgeTransform.PixelMarginBottom = 3; reset.AgeTransform.PixelMarginLeft = 3; reset.AgeTransform.PixelMarginRight = 4; reset.AgeTransform.PixelOffsetLeft = 309; reset.transform.FindChild("2-Label").GetComponent <AgePrimitiveLabel>().Text = "Reset Settings"; cancel.OnActivateObject = gameObject; confirm.OnActivateObject = gameObject; reset.OnActivateObject = gameObject; this.frame = frame; }