Figure 8.
More complexities revealed, when trying to store the same ObjectType object but with different parameters. See  4.2 Checking if there is the same object in the backpack
for more details.

4.2 Checking if there is the same object in the backpack

If object did exist in the dictionary, it was required to know if it is similar or exactly the same object. Therefore, new function CheckIfObjectIsTheSame(gameObject), that checks if given object is the same as already stored in the backpack was created. This function, was set to be bool type, to simply retrieve the answer, if object is the same or not. If answer is true, function finds which Key in the dictionary has the same object, and amount of that object is incremented by one in backPackObjectAmount dictionary (second dictionary that keeps the amount of objects). Otherwise, if answer is false, meaning that object is not the same, but such type exists, Key of the same object type is incremented by one (two types of apples plus one equals to Apple_3) and added to two dictionaries.
The use of ObjectType gave possibility to recognize what type of object it is, therefore, CheckIfObjectIsTheSame does not need to compare all objects, but only of that type. For example if the new object is of type “Apple”, it only checks among different apples of Apple_Type_1, Apple_Type_2 etc. Function CheckIfObjectIsTheSame, finds if object is the same or not by checking its size, tag, ObjectType, mesh and weight, therefore individuality of object is not lost. Function does not need to check whether majority of set property requiring components exists at all (for example mass of Rigidbody component), since if object is in the backpack already, it means that it did had these properties. However, some exceptions needed to be made, for example some objects stored in the backpack can use animations, therefore mesh type is different than a normal skinned mesh type. Therefore checking if mesh component exists was a requirement. The function could be easily advanced in precision, by also checking material, texture, what sounds it has, etc. If one of the predefined checks is not true, object is categorized as a similar and not the same. Picture below shows part of this function, that returns answer true or false.