Do you have Items can be arranged in Menus? checked in the Settings Manager? That would cause a NullReferenceException error in the code snippet on March 21.
If so, either uncheck that setting or try this:
List<InvInstance> items = KickStarter.runtimeInventory.PlayerInvCollection.InvInstances;
for (int i = 0; i < items.Count; i++)
{
if (!InvInstance.IsValid (items[i]))
{
items.RemoveAt (i);
i--;
}
}
items.Sort (delegate (InvInstance a, InvInstance b) { return a.GetProperty ("MyProperty").IntegerValue.CompareTo (b.GetProperty ("MyProperty").IntegerValue); });
PlayerMenus.ResetInventoryBoxes ();
Comments
Through script, you can access the items as a List and call its Sort function.
Items at runtime are stored in an InvInstance class, which has a GetProperty function that can be used to access an Integer property's value:
Hi Chris,
Thanks a lot, I have tried your code.
But I got the error:
NullReferenceException: Object reference not set to an instance of an object
So, can you help? Thanks a lot.
Try this:
Hi Chris,
Thanks a lot.
But I got this error:
error CS0019: Operator '&&' cannot be applied to operands of type 'bool' and 'int'
Would you please help me again, thanks a lot.
Do you have Items can be arranged in Menus? checked in the Settings Manager? That would cause a NullReferenceException error in the code snippet on March 21.
If so, either uncheck that setting or try this: