public override void OnInspectorGUI() { var script = target as FlexibleUIData; if (GUILayout.Button("Update In Editor")) { FlexibleUI.RefreshAll(script); } GUILayout.Space(10); DrawDefaultInspector(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); FlexibleUI ui = target as FlexibleUI; if (GUILayout.Button("Apply")) { ui.Update(); } }
public override void OnInspectorGUI() { var script = target as FlexibleUI; DrawDefaultInspector(); GUILayout.BeginHorizontal(); if (GUI.changed) { FlexibleUI.UpdateSkin(script); } //if (GUILayout.Button("Update This")) //{ // FlexibleUI.UpdateSkin(script); //} if (GUILayout.Button("Update All")) { FlexibleUI.RefreshAll(script.skinData); } GUILayout.EndHorizontal(); }
public void OnValidate() { //Upon switching item list, move everything to new one int count = allUIObjects.Items.Count - 1; for (int i = count; i >= 0; i--) { //take out leftover empty items if (allUIObjects.Items[i] == null) { allUIObjects.Remove(allUIObjects.Items[i]); continue; } CollectionItemUI collectionItemUI = ((CollectionItemUI)allUIObjects.Items[i]); FlexibleUI flexibleUI = collectionItemUI.GetComponent <FlexibleUI>(); LayoutElement layoutElement = collectionItemUI.GetComponent <LayoutElement>(); if (layoutElement != null) { layoutElement.minWidth = layoutElement.preferredWidth = elementWidth; layoutElement.minHeight = layoutElement.preferredHeight = elementHeight; } flexibleUI.OnSkinUI(); } }
private void OnEnable() { flexibleUI = (FlexibleUI)target; }
public void Swap() { int activeThemesCount = allFlexibleUIData.Count; if (previousFlexibleUIData == null) { OnEnable(); } //Check if activeIndex is within the existing range if (activeIndex > activeThemesCount - 1) { activeIndex = 0; } //Adds unique themes to the new elements if (activeThemesCount > previousFlexibleUIData.Count) { //if there are no spare themes if (activeThemesCount > popRef.allThemes.Count) { allFlexibleUIData = previousFlexibleUIData.ToList(); Debug.LogError("Themes cannot be used twice due to unique collections, create new Theme first", popRef.allThemes[0]); } else { int indexLimit = activeThemesCount; allFlexibleUIData = previousFlexibleUIData.ToList(); foreach (var item in popRef.allThemes) { if (!allFlexibleUIData.Contains(item)) { allFlexibleUIData.Add(item); if (allFlexibleUIData.Count == indexLimit) { break; } } } OnEnable(); } } else if (allFlexibleUIData.Count < previousFlexibleUIData.Count) { OnEnable(); } //Check for repeating Theme usage, reset if not unique else { bool allUnique = allFlexibleUIData.GroupBy(x => x).All(g => g.Count() == 1); if (!allUnique) { allFlexibleUIData = previousFlexibleUIData.ToList(); Debug.LogError("Not allowed to use the same Theme twice. This will merge collections", this); } } activeThemesCount = allFlexibleUIData.Count; for (int i = 0; i < activeThemesCount; i++) { if (allFlexibleUIData[i] != previousFlexibleUIData[i]) { for (int j = 0; j < previousFlexibleUIData[i].allUIObjects.Items.Count; j++) { CollectionItemUI collectionItemUI = (CollectionItemUI)previousFlexibleUIData[i].allUIObjects.Items[j]; collectionItemUI.allUIObjects = allFlexibleUIData[i].allUIObjects; collectionItemUI.allUIObjects.Add(collectionItemUI); FlexibleUI flexibleUI = collectionItemUI.GetComponent <FlexibleUI>(); flexibleUI.flexibleUIData = allFlexibleUIData[i]; flexibleUI.OnSkinUI(); } previousFlexibleUIData[i].allUIObjects.Items.Clear(); } } for (int i = 0; i < activeThemesCount; i++) { ItemsCollectionUI allUIObjects = allFlexibleUIData[i].allUIObjects; int subCount = allUIObjects.Items.Count - 1; for (int j = subCount; j >= 0; j--) { //take out leftover empty items if (allUIObjects.Items[j] == null) { allUIObjects.Remove(allUIObjects.Items[j]); continue; } ((CollectionItemUI)allUIObjects.Items[j]).GetComponent <FlexibleUI>().flexibleUIData = allFlexibleUIData[i]; } } for (int i = 0; i < activeThemesCount; i++) { allFlexibleUIData[i].OnValidate(); previousFlexibleUIData[i] = allFlexibleUIData[i]; } }
public static void UpdateSkin(FlexibleUI script) { script.OnSkinUI(); }
public static void ChangeSkin(FlexibleUI script, FlexibleUIData skin) { script.skinData = skin; }