public override bool isItemSelected(ItemData item, IEnumerable behaviourPairs, bool IsInverted = false) { foreach (string behaviourString in behaviourPairs) { ItemFilterSystem.BehaviourPair pair = JsonConvert.DeserializeObject <ItemFilterSystem.BehaviourPair>(behaviourString); if (item.classID == pair.classID) { foreach (BehaviourDefinition itemBehaviour in item.behaviours) { if (itemBehaviour.ID == pair.behaviourID) { if (!IsInverted) { return(true); } else { return(false); } } } } } if (!IsInverted) { return(false); } else { return(true); } }
void DrawBehaviourID(Rect displaySize) { var currentY = displaySize.y; for (int i = 0; i < behaviours.arraySize; i++) { Rect RemoveButtonRect = new Rect(displaySize.x + displaySize.width - 30, currentY, 30, 16); Rect behaviourIDRect = new Rect(RemoveButtonRect.x - 60, currentY, 60, 16); Rect behaviourLabelRect = new Rect(behaviourIDRect.x - 65, currentY, 65, 16); Rect ClassIDRect = new Rect(behaviourLabelRect.x - 60, currentY, 60, 16); Rect ClassLabelRect = new Rect(ClassIDRect.x - 35, currentY, 35, 16); string behaviourPrefromat = behaviours.GetArrayElementAtIndex(i).stringValue; ItemFilterSystem.BehaviourPair pair = JsonConvert.DeserializeObject <ItemFilterSystem.BehaviourPair>(behaviourPrefromat); if (pair == null) { pair = new ItemFilterSystem.BehaviourPair(); } int behaviourClass = EditorGUI.IntField(ClassIDRect, pair.classID); GUI.Label(behaviourLabelRect, "Behaviour"); int behaviourID = EditorGUI.IntField(behaviourIDRect, pair.behaviourID); GUI.Label(ClassLabelRect, "Class"); if (GUI.Button(RemoveButtonRect, "-")) { behaviours.DeleteArrayElementAtIndex(i); return; } if (behaviourClass >= 0) { pair.classID = behaviourClass; } if (behaviourID >= 0) { pair.behaviourID = behaviourID; } behaviours.GetArrayElementAtIndex(i).stringValue = JsonConvert.SerializeObject(pair); currentY += 16; } Rect AddButtonRect = new Rect(displaySize.x, currentY, displaySize.width, 16); if (GUI.Button(AddButtonRect, "+ Add New Behaviour")) { behaviours.InsertArrayElementAtIndex(behaviours.arraySize); } }
void DrawBehaviourID(Rect displaySize) { var currentY = displaySize.y; for (int i = 0; i < behaviours.arraySize; i++) { Rect RemoveButtonRect = new Rect(displaySize.x + displaySize.width - 30, currentY, 30, 16); Rect behaviourIDRect = new Rect(RemoveButtonRect.x - 60, currentY, 60, 16); Rect behaviourLabelRect = new Rect(behaviourIDRect.x - 65, currentY, 65, 16); Rect ClassIDRect = new Rect(behaviourLabelRect.x - 60, currentY, 60, 16); Rect ClassLabelRect = new Rect(ClassIDRect.x - 35, currentY, 35, 16); string behaviourPrefromat = behaviours.GetArrayElementAtIndex(i).stringValue; ItemFilterSystem.BehaviourPair pair = JsonConvert.DeserializeObject<ItemFilterSystem.BehaviourPair>(behaviourPrefromat); if (pair == null) { pair = new ItemFilterSystem.BehaviourPair(); } int behaviourClass = EditorGUI.IntField(ClassIDRect, pair.classID); GUI.Label(behaviourLabelRect, "Behaviour"); int behaviourID = EditorGUI.IntField(behaviourIDRect, pair.behaviourID); GUI.Label(ClassLabelRect, "Class"); if (GUI.Button(RemoveButtonRect, "-")) { behaviours.DeleteArrayElementAtIndex(i); return; } if (behaviourClass >= 0) { pair.classID = behaviourClass; } if (behaviourID >= 0) { pair.behaviourID = behaviourID; } behaviours.GetArrayElementAtIndex(i).stringValue = JsonConvert.SerializeObject(pair); currentY += 16; } Rect AddButtonRect = new Rect(displaySize.x, currentY, displaySize.width, 16); if (GUI.Button(AddButtonRect, "+ Add New Behaviour")) { behaviours.InsertArrayElementAtIndex(behaviours.arraySize); } }