public virtual void Show(InventoryItemDatabase database)
 {
     if (database != null)
     {
         Show(database.items);
     }
     else
     {
         Debug.LogWarning("Given database is null...");
     }
 }
        public override void OnEnable()
        {
            base.OnEnable();

            tar = (InventoryPlayer)target;
            equipLocations = serializedObject.FindProperty("equipLocations");

            dynamicallyFindUIElements = serializedObject.FindProperty("dynamicallyFindUIElements");
            characterUIPath = serializedObject.FindProperty("characterUIPath");
            inventoryPaths = serializedObject.FindProperty("inventoryPaths");
            skillbarPath = serializedObject.FindProperty("skillbarPath");

            characterCollection = serializedObject.FindProperty("characterCollection");
            inventoryCollections = serializedObject.FindProperty("inventoryCollections");
            skillbarCollection = serializedObject.FindProperty("skillbarCollection");


            itemDatabase = InventoryEditorUtility.GetItemDatabase(true, false);
            if (itemDatabase == null)
                Debug.LogError("No item database found in scene, cannot edit item.");


            list = new UnityEditorInternal.ReorderableList(serializedObject, equipLocations, false, true, false, false);
            list.elementHeight = 66;
            list.drawHeaderCallback += rect =>
            {
                EditorGUI.LabelField(rect, "Equipment binding");
            };
            list.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y += 2;

                var r3 = rect;
                r3.width = 25;

                rect.x += 30;
                rect.width -= 30;
                var r = rect;
                var r2 = rect;
                r2.width -= EditorGUIUtility.labelWidth;
                r2.x += EditorGUIUtility.labelWidth;

                r3.x += 8;
                r3.y += 24;
                var t = equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform").objectReferenceValue as Transform;
                if (t != null && t.IsChildOf(((InventoryPlayer) target).transform))
                {
                    EditorGUI.Toggle(r3, GUIContent.none, true, "VisibilityToggle");
                }
                else
                {
                    EditorGUI.Toggle(r3, GUIContent.none, false, "VisibilityToggle");                    
                }
                


                GUI.enabled = false;
                EditorGUI.ObjectField(r, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("associatedField"), new GUIContent("Associated field"));
                GUI.enabled = true;

                rect.y += 18;
                EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform"));

                if (t != null && t.IsChildOf(((InventoryPlayer)target).transform) == false)
                {
                    rect.y += 18;
                    EditorGUI.HelpBox(rect, "Equip transform has to be a child of this character.", MessageType.Error);
                }

                rect.y += 18;
                EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipHandlerType"));
            };


            if (tar.characterCollection != null && tar.characterCollection.container != null)
            {
                if (IsOutOfSync())
                {
                    ReSync();
                }
            }
        }
Example #3
0
 void Start()
 {
     PrintItemInfo(InventoryItemDatabase.GetItem(0));
     PrintItemInfo(InventoryItemDatabase.GetItem(1));
 }
        public override void Show(IList <InventoryItemBase> objectsToPickFrom)
        {
            base.Show(objectsToPickFrom);

            sceneDatabase = InventoryEditorUtil.GetItemDatabase(true, false);
        }