Changing attack from "fire1" to UIButton or bool + android issue

Poiu

New member
Hello again.
This time I got 2 questions, but I would like to post them together.

1. Im working on android game, so I would like to change controls to UI buttons. Interaction, and movement were pretty easy to swap, but Im struggling on changing melee attack trigger. Is there any easy way to achive this?

2. When I build my game to android platform, player can't interact with items on the ground and my inventory is empty. I don't have too much info on this one since I modified quite some stuff and scripts + Im getting rid of all "Demo" stuff, or rewritinig it. Any hints where I could look to fix it?
 
For question 1

The character input in the demo is controlled by the Character Input component which inherits the ICharacterInput interface:
1599116709523.png

The character input is bound to the ItemObject input through the "CharacterEquipper" component by using a ItemObjectHandler object.

If you are changing the input I would recommend making your own ItemObjectHandler by inheriting that class (in the demo we use CharacterEquipmentItemObjectHandler so you can inspire yourself from that). You can then replace "CharacterEquipper" with your own component that uses the ItemObjectHandler you created to use the itemObject actions.

If you need more explanation on this let me know.


For question 2. Make sure to make a development build for android and check that there aren't any errors. If there is nothing in the inventory, shop, storage and you can't pickup items it means that there is a bug somewhere that prevented the items from being loaded.
I would try building to a simulated device as it may make testing easier for you: https://docs.unity3d.com/Packages/com.unity.device-simulator@2.2/manual/index.html
 
1. I managed to solve this problem by adding option to use buttons at "KeyStringInput" struct, and changing "CharacterInput" to match new KeyStringInput syntax. I like UIS input system, so I wanted to keep its functionality in case I would like to release my game for PC at some point.

2. There are no errors or warnings. Everything works fine at Device Simulator , just as in Unity game window after hitting "play" button. Building with "Development Build" option didn't helped as well : (
 
I just made an android build and it seems to work for me. I was able to open the inventory and equip the sword (I haven't tested the rest as I didn't implement mobile controls, but I would assume everything else works).
If it works in the device simulator but not in a build, I'm not sure what the problem could be. My advice would be to try building the original demo to see if you have the same problem. You could also add some debug statements in strategic places to see if the items are being loaded correctly.
That would be in the InventorySystemManager and the Inventory components.
 
Sorry for such late reply.
I tried android build from demo scene some time ago and it was working, thats why I was 100% sure that I messed up something and I found what was wrong.

So what was actualy causing problem:
Edit -> Project Settings -> Player -> Other Settings -> Down at "Optimization" section -> Managed Stripping Level

For my project options "High" and "Medium" were causing problems with showing items at inventories, and interacting with some of UI buttons.
Options "Low" and "Disabled" are fixing this issue.

android_problem.png

If you encounter this problem, choose your Stripping level. Each is described at Unity Documentation.
 
Top