public Material Process(Material processable) { Recipe recipe = RecipeManager.Instance.FindRecipe(processable.Name, Name); if (recipe == null) { Debug.LogWarning($"Processor: cannot process {processable.Name} via {Name}."); return(null); } Material toMaterial = MaterialInfoHolder.Instance.GetMaterialPrefab(recipe.To); if (toMaterial == null) { Debug.LogWarning($"Processor: cannot find material info for {recipe.To}."); return(null); } Destroy(processable.gameObject); try { TimeUtils.Delay(recipe.ProcessingTime); } catch (Exception e) { Debug.LogWarning(e.Message); } var position = m_tileComponent.GetPosition(); position.y += Height; GameObject newInstance = Instantiate(toMaterial.gameObject, position, TileUtils.InitRotation); try { var obj = newInstance.GetComponent <MotionScript>(); if (obj != null) { m_currentMotion = obj; Move(obj); } } catch (NullReferenceException e) { Debug.LogError(e.Message); } return(newInstance.GetComponent <Material>()); }