private static void AdaptCompute(IBTReadGetSet cb, string pre, int computeCount, SerializedObject serializedObject) { if (computeCount == 0) { return; } var computeType = GetIComputeType(cb.GetType(), $"{pre}A"); if (computeType == null) { Debug.LogError($"Err:No {pre}A Property"); return; } var computes = ((MonoBehaviour)cb).GetComponents(computeType); var allIds = new List <string>(); for (var index = 0; index < computes.Length; index++) { if (ReferenceEquals(computes[index], cb)) { continue; } var compute = (IBTID)computes[index]; if (string.IsNullOrEmpty(compute.ID) || allIds.Contains(compute.ID)) { compute.ID = index.ToString(); } allIds.Add(compute.ID); } var allChooseIndex = new List <int>(); for (var i = 0; i < computeCount; i++) { var id = serializedObject.FindProperty($"{pre}Id" + GetName(i)); allChooseIndex.Add(allIds.IndexOf(id.stringValue)); } for (var i = 0; i < computeCount; i++) { var id = serializedObject.FindProperty($"{pre}Id" + GetName(i)); var chooseIndex = allChooseIndex[i]; var valid = chooseIndex >= 0 && allChooseIndex.Count(s => s == chooseIndex) == 1; ShowPopup($"{pre} {GetName(i)} ID:", valid, ref chooseIndex, id, allIds, serializedObject); } }
public static void FitGetSet(IBTReadGetSet target, SerializedObject serializedObject) { AdaptCompute(target, "Get", target.ReadGetCount, serializedObject); }