// Deep clones an item private static PageItem DeepCloneItem(PageItem item) { PageItem newItem = CreateInstance <PageItem>(); newItem.name = item.name; newItem.Icon = item.Icon; newItem.hideFlags = item.hideFlags; newItem.InitialState = item.InitialState; newItem.ObjectReference = item.ObjectReference; newItem.PageReference = item.PageReference; newItem.Saved = item.Saved; newItem.Sync = item.Sync; newItem.Type = item.Type; newItem.UseAnimations = item.UseAnimations; newItem.TransitionType = item.TransitionType; newItem.TransitionDuration = item.TransitionDuration; newItem.TransitionOffset = item.TransitionOffset; newItem.Control = item.Control; newItem.EnableClip = item.EnableClip; newItem.DisableClip = item.DisableClip; List <GroupItem> tempItems = new List <GroupItem>(); foreach (GroupItem groupItem in item.ButtonGroup) { GroupItem newGroupItem = DeepCloneGroupItem(groupItem); tempItems.Add(newGroupItem); } newItem.ButtonGroup = tempItems.ToArray(); tempItems.Clear(); foreach (GroupItem groupItem in item.EnableGroup) { GroupItem newGroupItem = DeepCloneGroupItem(groupItem); tempItems.Add(newGroupItem); } newItem.EnableGroup = tempItems.ToArray(); tempItems.Clear(); foreach (GroupItem groupItem in item.DisableGroup) { GroupItem newGroupItem = DeepCloneGroupItem(groupItem); tempItems.Add(newGroupItem); } newItem.DisableGroup = tempItems.ToArray(); tempItems.Clear(); return(newItem); }
// Converts a menu into a page private Page ConvertMenu(VRCExpressionsMenu menu) { // Create Page Page page = CreateInstance <Page>(); page.name = menu.name; // Convert Controls to Items foreach (VRCExpressionsMenu.Control control in menu.controls) { PageItem item = CreateInstance <PageItem>(); item.name = control.name; item.Type = PageItem.ItemType.Control; item.Control = control; page.Items.Add(item); } // Return Conversion return(page); }