Processor on Crafter gets reset

Zaddo

Active member
I haven't debugged this. But I thought it was worth mentioning.

Twice now the Processor on the Crafter has reset from my custom processor to SimpleCraftingProcessor. The first was when I added a category to the crafter. The second time was when I added a new component to the game object.

Seems to happen on play.


On version 1.2.10
 
Last edited:
That would mean the value isn't being serialized or dirtied correctly.
Can you confrim that your custom crafting processor is indeed [Serializable]?

I've tested in the latest version on UIS and it seems to work fine when switching between processors and pressing play
 
My custom processor is derived from UIS SimpleCraftingProcessor. Could this issue be caused because I am using a derived class? Perhaps the editor is checking the selected processor using "is", eg: if (ServerCraftingProcessor is SimpleCraftingProcessor) would be true?

Here is my processor class:
C#:
/// ---------------------------------------------
/// Ultimate Inventory System.
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------

namespace Opsive.UltimateInventorySystem.Crafting.Processors
{
    using Opsive.Shared.Utility;
    using Opsive.UltimateInventorySystem.Core;
    using Opsive.UltimateInventorySystem.Core.DataStructures;
    using Opsive.UltimateInventorySystem.Core.InventoryCollections;
    using Opsive.UltimateInventorySystem.DeadFear;
    using System;
    using System.Collections.Generic;
    using TinyIoC;
    using UnityEngine;
    using EventHandler = Opsive.Shared.Events.EventHandler;

    public class ServerCraftingProcessor : SimpleCraftingProcessor
    {

        private IoCRef<IClientInventoryBridge> refInventoryBridge = new IoCRef<IClientInventoryBridge>();
        internal IClientInventoryBridge iBridge => refInventoryBridge.Ref;

        /// <summary>
        /// Check if the parameters are valid to craft an item.
        /// </summary>
        /// <param name="recipe">The recipe.</param>
        /// <param name="inventory">The inventory containing the items.</param>
        /// <param name="quantity">The quantity to craft.</param>
        /// <param name="selectedIngredients">The item infos selected.</param>
        /// <returns>True if you can craft.</returns>
        protected override bool CanCraftInternal(CraftingRecipe recipe, IInventory inventory,
            ListSlice<ItemInfo> selectedIngredients, int quantity)
        {
                   return base.CanCraftInternal(recipe, inventory, selectedIngredients, quantity);
        }

        /// <summary>
        /// Craft the items.
        /// </summary>
        /// <param name="recipe">The recipe.</param>
        /// <param name="inventory">The inventory containing the items.</param>
        /// <param name="selectedIngredients">The item infos selected.</param>
        /// <param name="quantity">The quantity to craft.</param>
        /// <returns>True if you can craft.</returns>
        protected override CraftingResult CraftInternal(CraftingRecipe recipe, IInventory inventory,
            ListSlice<ItemInfo> selectedIngredients, int quantity)
        {
            if (CanCraftInternal(recipe, inventory, selectedIngredients, quantity) == false)
            {
                return new CraftingResult(null, false);
            }

            // Send message to server to craft recipe
            iBridge.CraftRecipe(recipe.ID, quantity);

            return new CraftingResult(null, false);

        }
    }
}
 
I tested your code in my project (removed the parts that were causing compiler errors).
And it works fine. Even after pressing play the processor is kept

I am using Unity 2021.3 and UIS 1.2.12 what versions are you using?
 
I tested your code in my project (removed the parts that were causing compiler errors).
And it works fine. Even after pressing play the processor is kept

I am using Unity 2021.3 and UIS 1.2.12 what versions are you using?

I am on unity 2020.3.38f1 and 1.2.10. It must be related to the versions or some other environmental factor.

I can avoid this happening by ensuring the editor isn't open on my character when I hit play. So I am not too bothered. Thanks for looking into it, I am happy to leave it at that.
 
Top