// void DrawMultipleGroups() // { // // Group Template Description // EditorGUILayout.LabelField("Group Template Description"); // for(int i = 0; i < m_AddressableAssetGroupTargets.Length - 1; i++) // { // if (m_AddressableAssetGroupTargets[i].Description != m_AddressableAssetGroupTarget.Description) // { // EditorGUI.showMixedValue = true; // break; // } // } // EditorGUI.BeginChangeCheck(); // m_AddressableAssetGroupTarget.Description = EditorGUILayout.TextArea(m_AddressableAssetGroupTarget.Description); // EditorGUI.showMixedValue = false; // if (EditorGUI.EndChangeCheck()) // { // for (int i = 0; i < m_AddressableAssetGroupTargets.Length - 1; i++) // { // m_AddressableAssetGroupTargets[i].Description = m_AddressableAssetGroupTarget.Description; // } // } // // // Schemas // int objectCount = m_AddressableAssetGroupTarget.SchemaObjects.Count; // if (m_FoldoutState == null || m_FoldoutState.Length != objectCount) // m_FoldoutState = new bool[objectCount]; // // for (int i = 0; i < objectCount; i++) // { // if (!m_SchemaState[i]) continue; // // var schema = m_AddressableAssetGroupTarget.SchemaObjects[i]; // int currentIndex = i; // // DrawDivider(); // EditorGUILayout.BeginHorizontal(); // m_FoldoutState[i] = EditorGUILayout.Foldout(m_FoldoutState[i], m_AddressableAssetGroupTarget.SchemaObjects[i].DisplayName()); // // GUILayout.FlexibleSpace(); // GUIStyle gearIconStyle = UnityEngine.GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton"); // // if (EditorGUILayout.DropdownButton(EditorGUIUtility.IconContent("_Popup"), FocusType.Keyboard, gearIconStyle)) // { // var menu = new GenericMenu(); // menu.AddItem(AddressableAssetGroup.RemoveSchemaContent, false, () => // { // var schemaName = m_AddressableAssetGroupTarget.SchemaObjects[currentIndex].DisplayName(); // if (EditorUtility.DisplayDialog("Remove selected schema?", "Are you sure you want to remove " + schemaName + " schema?\n\nYou cannot undo this action.", "Yes", "No")) // { // Type schemaType = m_AddressableAssetGroupTarget.SchemaObjects[currentIndex].GetType(); // m_AddressableAssetGroupTarget.RemoveSchema(currentIndex); // for (int j = 0; j < m_AddressableAssetGroupTargets.Length - 1; j++) // { // int removeIndex = m_AddressableAssetGroupTargets[j].FindSchema(schemaType); // m_AddressableAssetGroupTargets[j].RemoveSchema(removeIndex); // } // // InitializeMultiSelectGroupSchemas(); // // var newFoldoutstate = new bool[objectCount - 1]; // for (int j = 0; j < newFoldoutstate.Length; j++) // { // if (j < i) // newFoldoutstate[j] = m_FoldoutState[j]; // else // newFoldoutstate[j] = m_FoldoutState[currentIndex + 1]; // } // // m_FoldoutState = newFoldoutstate; // return; // } // }); // menu.AddItem(AddressableAssetGroup.MoveSchemaUpContent, false, () => // { // foreach (var group in m_AddressableAssetGroupTargets) // { // int index = group.FindSchema(schema.GetType()); // if (index > 0) // { // var temp = group.SchemaObjects[index]; // group.SchemaObjects[index] = group.SchemaObjects[index - 1]; // group.SchemaObjects[index - 1] = temp; // } // } // InitializeMultiSelectGroupSchemas(); // return; // }); // menu.AddItem(AddressableAssetGroup.MoveSchemaDownContent, false, () => // { // foreach (var group in m_AddressableAssetGroupTargets) // { // int index = group.FindSchema(schema.GetType()); // if (index >= 0 && index < group.SchemaObjects.Count - 1) // { // var temp = group.SchemaObjects[index]; // group.SchemaObjects[index] = group.SchemaObjects[index + 1]; // group.SchemaObjects[index + 1] = temp; // } // } // InitializeMultiSelectGroupSchemas(); // return; // }); // menu.AddSeparator(""); // menu.AddItem(AddressableAssetGroup.ExpandSchemaContent, false, () => // { // m_FoldoutState[currentIndex] = true; // foreach (var group in m_AddressableAssetGroupTargets) // { // int index = group.FindSchema(schema.GetType()); // if (index != -1) // { // group.SchemaObjects[index].ShowAllProperties(); // } // } // }); // menu.ShowAsContext(); // } // // EditorGUILayout.EndHorizontal(); // // if (m_FoldoutState[i]) // { // try // { // EditorGUI.indentLevel++; // m_AddressableAssetGroupTarget.SchemaObjects[i].OnGUIMultiple(m_GroupSchemas[i]); // EditorGUI.indentLevel--; // } // catch (Exception se) // { // Debug.LogException(se); // } // } // } // // if (m_HiddenSchemas) // { // DrawDivider(); // EditorGUILayout.HelpBox(new GUIContent("Only schemas that are on all selected groups can be multi-edited.")); // } // // DrawDivider(); // EditorGUILayout.BeginHorizontal(); // GUILayout.FlexibleSpace(); // GUIStyle addSchemaButton = new GUIStyle(UnityEngine.GUI.skin.button); // addSchemaButton.fontSize = 12; // addSchemaButton.fixedWidth = 225; // addSchemaButton.fixedHeight = 22; // // if (EditorGUILayout.DropdownButton(new GUIContent("Add Schema", "Add new schema to this group."), FocusType.Keyboard, addSchemaButton)) // { // var menu = new GenericMenu(); // for (int i = 0; i < m_SchemaTypes.Count; i++) // { // var type = m_SchemaTypes[i]; // var schema = (AddressableAssetGroupSchema)CreateInstance(type); // // bool allGroupsDoNotHave = true; // foreach (var group in m_AddressableAssetGroupTargets) // { // if (group.HasSchema(type)) // allGroupsDoNotHave = false; // } // // if (allGroupsDoNotHave) // { // menu.AddItem(new GUIContent(schema.DisplayName(), ""), false, () => // { // OnAddSchema(type, true); // return; // }); // } // else // { // menu.AddDisabledItem(new GUIContent(schema.DisplayName(), ""), true); // } // } // // menu.ShowAsContext(); // } // // GUILayout.FlexibleSpace(); // EditorGUILayout.EndHorizontal(); // } void OnAddSchema(Type schemaType, bool multiSelect = false) { if (!m_AddressableAssetGroupTarget.AddSchema(schemaType)) { return; } // if (multiSelect) // { // for (int i = 0; i < m_AddressableAssetGroupTargets.Length - 1; i++) // { // if(!m_AddressableAssetGroupTargets[i].AddSchema(schemaType)) // return; // } // InitializeMultiSelectGroupSchemas(); // } var newFoldoutState = new bool[m_AddressableAssetGroupTarget.SchemaObjects.Count]; for (int i = 0; i < m_FoldoutState.Length; i++) { newFoldoutState[i] = m_FoldoutState[i]; } m_FoldoutState = newFoldoutState; m_FoldoutState[m_FoldoutState.Length - 1] = true; }
void OnAddSchema(object context) { if (!m_AddressableAssetGroupTarget.AddSchema(context as Type)) { return; } var newFoldoutState = new bool[m_AddressableAssetGroupTarget.SchemaObjects.Count]; for (int i = 0; i < m_FoldoutState.Length; i++) { newFoldoutState[i] = m_FoldoutState[i]; } m_FoldoutState = newFoldoutState; m_FoldoutState[m_FoldoutState.Length - 1] = true; }