private static void AddNewSelectiveRule() { newRule.SelectiveProperties.Add(AssetAuditor.GetPropertyNames(GetSerializedObject(newRule.assetType))[0]); }
//done private static void DoNewRuleGUI() { newRule.RuleName = EditorGUILayout.TextField("Rule Name: ", newRule.RuleName); EditorGUI.BeginChangeCheck(); newRule.WildCardMatchType = (AssetAuditor.WildCardMatchType)EditorGUILayout.EnumPopup("Wild Card Matching Type: ", newRule.WildCardMatchType); if (EditorGUI.EndChangeCheck()) { newRule.WildCard = ""; } EditorGUI.BeginChangeCheck(); newRule.WildCard = EditorGUILayout.TextField("Wild Card: ", newRule.WildCard); if (EditorGUI.EndChangeCheck()) { AssetAuditor.queueComplete += AffectedAssetSearchComplete; AssetAuditor.UpdateAffectedAssets(newRule); } newRule.SelectiveMode = EditorGUILayout.Toggle("Selective Mode", newRule.SelectiveMode); if (newRule.SelectiveMode) { if (newRule.SelectiveProperties == null) { newRule.SelectiveProperties = new List <string>(); } SerializedObject so = GetSerializedObject(newRule.assetType); var propertyNames = AssetAuditor.GetPropertyNames(so); // TODO need to cache this // loop through all the selective properties for (int i = 0; i < newRule.SelectiveProperties.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); newRule.SelectiveProperties[i] = propertyNames[EditorGUILayout.Popup(SelectedFromList(propertyNames, newRule.SelectiveProperties[i]), propertyNames)]; if (EditorGUI.EndChangeCheck()) { AssetAuditor.queueComplete += AffectedAssetSearchComplete; AssetAuditor.UpdateAffectedAssets(newRule); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+", GUILayout.MaxWidth(20))) { AddNewSelectiveRule(); } if (GUILayout.Button("-", GUILayout.MaxWidth(20))) { RemoveLastSelectiveRule(); } EditorGUILayout.LabelField("Add and remove selective property overiding"); EditorGUILayout.EndHorizontal(); } // drop down for type EditorGUI.BeginChangeCheck(); newRule.assetType = (AssetAuditor.AssetType)EditorGUILayout.IntPopup("Rule Type: ", (int)newRule.assetType, new[] { "Texture", "Model", "Audio" }, new[] { 0, 1, 2 }); if (EditorGUI.EndChangeCheck()) { newRule.SelectiveProperties = new List <string>(); AssetAuditor.queueComplete += AffectedAssetSearchComplete; AssetAuditor.UpdateAffectedAssets(newRule); } if (!AssetAuditor.RuleExists(newRule)) { if (GUILayout.Button("Create New " + newRule.assetType + " Rule")) { switch (newRule.assetType) { case AssetAuditor.AssetType.Texture: AssetAuditor.CreateProxyTexture(newRule, ref currentAsset); break; case AssetAuditor.AssetType.Audio: AssetAuditor.CreateProxyAudio(newRule, ref currentAsset); break; case AssetAuditor.AssetType.Model: AssetAuditor.CreateProxyModel(newRule, ref currentAsset); break; default: throw new ArgumentOutOfRangeException(); } UpdateExistingRules(); AssetAuditor.queueComplete += AffectedAssetSearchComplete; AssetAuditor.UpdateAffectedAssets(assetRules[selected]); } } else { GUILayout.Label("Rule already exists in the project cannot create duplicates"); } GUILayout.Space(20); GUILayout.Label("Affect Assets Preview"); GUILayout.Space(5); Rect rt = GUILayoutUtility.GetRect(5, window ? window.position.width - 10 : 100f, 18, 18); EditorGUI.ProgressBar(rt, AssetAuditor.GetProgress(), "Affected Asset Search Progress " + (AssetAuditor.GetProgress() * 100f).ToString("0.00%")); scrollPosition = GUILayout.BeginScrollView(scrollPosition); if (affectedAssets != null) { foreach (string affectedAsset in affectedAssets) { EditorGUILayout.ObjectField( AssetDatabase.LoadAssetAtPath(affectedAsset, AssetAuditor.TypeFromAssetType(newRule.assetType)), AssetAuditor.TypeFromAssetType(newRule.assetType), false); } } GUILayout.EndScrollView(); if (GUILayout.Button("Open Audit View")) { AssetAuditorWindow.GetWindow(); } }