Procedural Content Generation for Unity Game Development by Ryan Watkins

Procedural Content Generation for Unity Game Development by Ryan Watkins

Author:Ryan Watkins [Watkins, Ryan]
Language: eng
Format: epub, azw3, pdf
Publisher: Packt Publishing
Published: 2016-01-29T23:00:00+00:00


Before we return to the Unity Editor, we need to uncomment the commented code from our Chest.cs file. This will open up another field to edit in the Chest prefab. Once you uncomment the code, return to the Unity Editor and add the Item prefab to the Random Item field of the Chest prefab.

chest and item but no visible inventory

Now, we can play the game and see our item system in action. You can find a chest and open it to reveal a random item. However, you still can't pick it up. Even if you could pick up the item, you would really have no way of knowing what is in your inventory. We did write the code that would handle this though. We only need to add the UI elements that will display our inventory. Here is what we need to add:

In Hierarchy, right-click on the Canvas object.

Navigate to UI | Image.

Name image GloveImage.

Set both Width and Height to 50.

Set Pos X to -430 and Pos Y to -180.

Set Source Image to Items_Sprite_Sheet_2.

Create another image.

Name the image BootImage.

Set Pos X to -365 and Pos Y to -180.

Set Source Image to Items_Sprite_Sheet_3.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.