├── .gitignore
├── Documentation
├── inventory1.gif
├── renderer.png
└── shape-property.png
├── LICENSE
├── README.md
└── Unity Project
├── .idea
└── .idea.Unity Project
│ ├── .idea
│ ├── contentModel.xml
│ ├── encodings.xml
│ ├── indexLayout.xml
│ ├── modules.xml
│ ├── projectSettingsUpdater.xml
│ └── vcs.xml
│ └── riderModule.iml
├── .vscode
└── settings.json
├── Assets
├── Example.meta
└── Example
│ ├── Inventories.prefab
│ ├── Inventories.prefab.meta
│ ├── Inventory Camera.unity
│ ├── Inventory Camera.unity.meta
│ ├── Inventory Overlay.unity
│ ├── Inventory Overlay.unity.meta
│ ├── Inventory World Space.unity
│ ├── Inventory World Space.unity.meta
│ ├── InventoryProvider.cs
│ ├── InventoryProvider.cs.meta
│ ├── InventorySelection.cs
│ ├── InventorySelection.cs.meta
│ ├── ItemDefinition.cs
│ ├── ItemDefinition.cs.meta
│ ├── ItemTypes.cs
│ ├── ItemTypes.cs.meta
│ ├── Items.meta
│ ├── Items
│ ├── Dagger.asset
│ ├── Dagger.asset.meta
│ ├── Gadget.asset
│ ├── Gadget.asset.meta
│ ├── Green Vial.asset
│ ├── Green Vial.asset.meta
│ ├── Ray Gun.asset
│ ├── Ray Gun.asset.meta
│ ├── Red Vial.asset
│ ├── Red Vial.asset.meta
│ ├── Stun Baton.asset
│ └── Stun Baton.asset.meta
│ ├── SizeInventoryExample.cs
│ ├── SizeInventoryExample.cs.meta
│ ├── inventory.png
│ └── inventory.png.meta
├── Logs
└── Packages-Update.log
├── Packages
├── FarrokGames.Inventory
│ ├── Editor.meta
│ ├── Editor
│ │ ├── Farrokhgames.Inventory.Editor.asmdef
│ │ ├── Farrokhgames.Inventory.Editor.asmdef.meta
│ │ ├── InventoryShapePropertyDrawer.cs
│ │ └── InventoryShapePropertyDrawer.cs.meta
│ ├── LICENSE.md
│ ├── LICENSE.md.meta
│ ├── README.md
│ ├── README.md.meta
│ ├── Runtime.meta
│ ├── Runtime
│ │ ├── Farrokhgames.Inventory.asmdef
│ │ ├── Farrokhgames.Inventory.asmdef.meta
│ │ ├── IInventoryItem.cs
│ │ ├── IInventoryItem.cs.meta
│ │ ├── IInventoryManager.cs
│ │ ├── IInventoryManager.cs.meta
│ │ ├── IInventoryProvider.cs
│ │ ├── IInventoryProvider.cs.meta
│ │ ├── InventoryController.cs
│ │ ├── InventoryController.cs.meta
│ │ ├── InventoryDraggedItem.cs
│ │ ├── InventoryDraggedItem.cs.meta
│ │ ├── InventoryManager.cs
│ │ ├── InventoryManager.cs.meta
│ │ ├── InventoryRenderMode.cs
│ │ ├── InventoryRenderMode.cs.meta
│ │ ├── InventoryRenderer.cs
│ │ ├── InventoryRenderer.cs.meta
│ │ ├── InventoryShape.cs
│ │ ├── InventoryShape.cs.meta
│ │ ├── Pool.cs
│ │ └── Pool.cs.meta
│ ├── Tests.meta
│ ├── Tests
│ │ ├── Farrokhgames.Inventory.Tests.asmdef
│ │ ├── Farrokhgames.Inventory.Tests.asmdef.meta
│ │ ├── InventoryManagerTests.cs
│ │ ├── InventoryManagerTests.cs.meta
│ │ ├── InventoryShapeTests.cs
│ │ ├── InventoryShapeTests.cs.meta
│ │ ├── PoolTests.cs
│ │ ├── PoolTests.cs.meta
│ │ ├── TestItem.cs
│ │ ├── TestItem.cs.meta
│ │ ├── TestProvider.cs
│ │ └── TestProvider.cs.meta
│ ├── package.json
│ └── package.json.meta
└── manifest.json
└── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── NetworkManager.asset
├── Physics2DSettings.asset
├── PresetManager.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── TagManager.asset
├── TimeManager.asset
├── UnityConnectSettings.asset
├── VFXManager.asset
├── XRSettings.asset
└── editorsettings.asset
/.gitignore:
--------------------------------------------------------------------------------
1 | # =============== #
2 | # Unity generated #
3 | # =============== #
4 | Temp/
5 | Obj/
6 | UnityGenerated/
7 | Library/
8 | Unity Project/Temp/
9 | Unity Project/Obj/
10 | Unity Project/UnityGenerated/
11 | Unity Project/Library/
12 |
13 | # ===================================== #
14 | # Visual Studio / MonoDevelop generated #
15 | # ===================================== #
16 | ExportedObj/
17 | *.svd
18 | *.userprefs
19 | *.csproj
20 | *.pidb
21 | *.suo
22 | *.sln
23 | *.user
24 | *.unityproj
25 | *.booproj
26 |
27 | # ============ #
28 | # OS generated #
29 | # ============ #
30 | .DS_Store
31 | .DS_Store?
32 | ._*
33 | .Spotlight-V100
34 | .Trashes
35 | Icon?
36 | ehthumbs.db
37 | Thumbs.db
--------------------------------------------------------------------------------
/Documentation/inventory1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FarrokhGames/Inventory/174f55d1d03cc9742c367020c491fd03508834a9/Documentation/inventory1.gif
--------------------------------------------------------------------------------
/Documentation/renderer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FarrokhGames/Inventory/174f55d1d03cc9742c367020c491fd03508834a9/Documentation/renderer.png
--------------------------------------------------------------------------------
/Documentation/shape-property.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FarrokhGames/Inventory/174f55d1d03cc9742c367020c491fd03508834a9/Documentation/shape-property.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Farrokh Games
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## A Diablo 2-style inventory system for Unity3D
2 |
3 |
4 |
5 | ## Table of Contents
6 | - Features
7 | - Installation
8 | - Example
9 | - Documentation
10 | - Getting Started
11 | - The Inventory
12 | - Items
13 | - Rendering the Inventory
14 | - Interacting with the Inventory
15 | - Other files included
16 | - License
17 |
18 | ---
19 |
20 | ## Features
21 | - ```Resize``` at runtime, dropping what no longer fits.
22 | - ```Add/Remove``` and check if an item fits from code.
23 | - ```Equipment slots``` for all your RPG needs.
24 | - ```Custom shapes``` for each item.
25 | - Rearrange items by ```draggin and dropping```, with visual feedback.
26 | - ```Move items between inventories```.
27 | - Remove items by ```dropping``` them outside the inventory.
28 | - Easily add ```custom graphics``` and change the size of your inventory.
29 | - Supports ```scaled canvases```.
30 | - Tested thoroughly with over ```75 Unit Tests```, and profiled using the Unity Profiler.
31 | - Tested using all types of ```Canvas render modes``` (Screen Space Overlay, Screen Space Camera and World Space)
32 |
33 | ---
34 |
35 | ## Installation
36 | Simply copy the folder "```Packages/FarrokGames.Inventory```" into your own projects packages folder and you're good to go. Optionally, you can add the folder "```Assets/Example```" to get started right away.
37 |
38 | ---
39 |
40 | ## Example
41 | A fully functional example is included with this reposetory and can be found in the folder "```Assets/Example```".
42 |
43 | - ```Inventory Overlay.scene``` - the Unity Scene that contains an example using the Canvas render mode of Screen Space Overlay.
44 | - ```Inventory Camera.scene``` - the Unity Scene that contains an example using the Canvas render mode of Screen Space Camera.
45 | - ```Inventory World Space.scene``` - the Unity Scene that contains an example using the Canvas render mode of World Space.
46 | - ```Inventory.png``` - includes all artwork used in the example.
47 | - ```ItemDefinition.cs``` - a ```ScriptableObject``` implemetation of ```IInventoryItem```.
48 | - ```SizeInventoryExample.cs``` - a ```MonoBehaviour``` that creates and connects an Inventory with a Renderer, and fills it with items.
49 | - ```Items-folder``` - Contains the ```ItemDefinitions``` used in the example.
50 |
51 | ---
52 |
53 | ## Documentation
54 | Below you can find documentation of various parts of the system. You are encouraged to look through the code, where more in-depth code docs can be found.
55 |
56 | ---
57 |
58 | ### Getting Started
59 | Creating a new inventory is simple. Remember that the inventory system rests within its own namespace, so don't forget to add ```using FarrokhGames.Inventory```.
60 | ```cs
61 | var inventory = new InventoryManager(8, 4); // Creates an inventory with a width of 8 and height of 4
62 | ```
63 |
64 | ---
65 |
66 | ### The Inventory
67 | Below is a list of actions methods and getters within ```InventoryManager.cs```.
68 | ```cs
69 | ///
70 | /// Invoked when an item is added to the inventory
71 | ///
72 | Action onItemAdded { get; set; }
73 |
74 | ///
75 | /// Invoked when an item was not able to be added to the inventory
76 | ///
77 | Action onItemAddedFailed { get; set; }
78 |
79 | ///
80 | /// Invoked when an item is removed to the inventory
81 | ///
82 | Action onItemRemoved { get; set; }
83 |
84 | ///
85 | /// Invoked when an item is removed from the inventory and should be placed on the ground.
86 | ///
87 | Action onItemDropped { get; set; }
88 |
89 | ///
90 | /// Invoked when an item was unable to be placed on the ground (most likely to its canDrop being set to false)
91 | ///
92 | Action onItemDroppedFailed { get; set; }
93 |
94 | ///
95 | /// Invoked when the inventory is rebuilt from scratch
96 | ///
97 | Action onRebuilt { get; set; }
98 |
99 | ///
100 | /// Invoked when the inventory changes its size
101 | ///
102 | Action onResized { get; set; }
103 |
104 | ///
105 | /// The width of the inventory
106 | ///
107 | int width { get; }
108 |
109 | ///
110 | /// The height of the inventory
111 | ///
112 | int height { get; }
113 |
114 | ///
115 | /// Sets a new width and height of the inventory
116 | ///
117 | void Resize(int width, int height);
118 |
119 | ///
120 | /// Returns all items inside this inventory
121 | ///
122 | IInventoryItem[] allItems { get; }
123 |
124 | ///
125 | /// Returns true if given item is present in this inventory
126 | ///
127 | bool Contains(IInventoryItem item);
128 |
129 | ///
130 | /// Returns true if this inventory is full
131 | ///
132 | bool isFull { get; }
133 |
134 | ///
135 | /// Returns true if its possible to add given item
136 | ///
137 | bool CanAdd(IInventoryItem item);
138 |
139 | ///
140 | /// Add given item to the inventory. Returns true
141 | /// if successful
142 | ///
143 | bool TryAdd(IInventoryItem item);
144 |
145 | ///
146 | /// Returns true if its possible to add item at location
147 | ///
148 | bool CanAddAt(IInventoryItem item, Vector2Int point);
149 |
150 | ///
151 | /// Tries to add item att location and returns true if successful
152 | ///
153 | bool TryAddAt(IInventoryItem item, Vector2Int point);
154 |
155 | ///
156 | /// Returns true if its possible to remove this item
157 | ///
158 | bool CanRemove(IInventoryItem item);
159 |
160 | ///
161 | /// Returns true ifits possible to swap this item
162 | ///
163 | bool CanSwap(IInventoryItem item);
164 |
165 | ///
166 | /// Removes given item from this inventory. Returns
167 | /// true if successful.
168 | ///
169 | bool TryRemove(IInventoryItem item);
170 |
171 | ///
172 | /// Returns true if its possible to drop this item
173 | ///
174 | bool CanDrop(IInventoryItem item);
175 |
176 | ///
177 | /// Removes an item from this inventory. Returns true
178 | /// if successful.
179 | ///
180 | bool TryDrop(IInventoryItem item);
181 |
182 | ///
183 | /// Drops all items from this inventory
184 | ///
185 | void DropAll();
186 |
187 | ///
188 | /// Clears (destroys) all items in this inventory
189 | ///
190 | void Clear();
191 |
192 | ///
193 | /// Rebuilds the inventory
194 | ///
195 | void Rebuild();
196 |
197 | ///
198 | /// Get an item at given point within this inventory
199 | ///
200 | IInventoryItem GetAtPoint(Vector2Int point);
201 |
202 | ///
203 | /// Returns all items under given rectangle
204 | ///
205 | IInventoryItem[] GetAtPoint(Vector2Int point, Vector2Int size);
206 | ```
207 | ---
208 |
209 | ### Items
210 | Items inside the inventory are represented by the IInventoryItem interface. In the included example, this interface is attached to a ```ScritableObject``` making it possible to create, store and change item details in the asset folder.
211 | ```cs
212 | using UnityEngine;
213 | using FarrokhGames.Inventory;
214 |
215 | ///
216 | /// ScriptableObject representing an Inventory Item
217 | ///
218 | [CreateAssetMenu(fileName = "Item", menuName = "Inventory/Item", order = 1)]
219 | public class ItemDefinition : ScriptableObject, IInventoryItem
220 | {
221 | [SerializeField] private Sprite _sprite;
222 | [SerializeField] private InventoryShape _shape;
223 | [SerializeField] private bool _canDrop;
224 |
225 | public string Name => return this.name;
226 | public Sprite Sprite => return _sprite;
227 | public InventoryShape Shape => _shape;
228 | public bool canDrop => _canDrop;
229 |
230 | ///
231 | /// Creates a copy if this scriptable object
232 | ///
233 | public IInventoryItem CreateInstance()
234 | {
235 | return ScriptableObject.Instantiate(this);
236 | }
237 | }
238 | ```
239 | The shape of an item is defined by the serializable ```ItemShape.cs``` class which has a useful property drawer.
240 |
241 |
242 |
243 | ---
244 |
245 | ### Rendering the Inventory
246 | The inventory system comes with a renderer in a MonoBehaviour called ```InventoryRenderer.cs```.
247 |
248 |
249 |
250 | Simply add this to a ```GameObject``` within your ```Canvas```, and connect it to an inventory using the following code.
251 |
252 | ```cs
253 | ///
254 | /// Set what inventory to use when rendering
255 | ///
256 | /// Inventory to use
257 | public void SetInventory(InventoryManager inventory);
258 | ```
259 |
260 | *Please see the image at the top of this document as an example of how the rendering looks*
261 |
262 | ---
263 |
264 | ### Interacting with the Inventory
265 | To enable interactions (drag and drop), add ```InventoryController.cs``` to the same ```GameObject``` as your renderer.
266 |
267 | ---
268 |
269 | ### Other files included
270 | Besides the actual inventory, there are sipport-classes included in the reposetory.
271 |
272 | - ```Pool.cs``` - A generic pool of objects that can be retrieved and recycled without invoking additional allocations. Used by the ```Renderer``` to pool sprites.
273 |
274 | **You are free to use these** support-classes under the same license, and their ```Unit Tests``` are included.
275 |
276 | ---
277 |
278 | ## License
279 | MIT License
280 |
281 | Copyright (c) 2020 Farrokh Games
282 |
283 | Permission is hereby granted, free of charge, to any person obtaining a copy
284 | of this software and associated documentation files (the "Software"), to deal
285 | in the Software without restriction, including without limitation the rights
286 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
287 | copies of the Software, and to permit persons to whom the Software is
288 | furnished to do so, subject to the following conditions:
289 |
290 | The above copyright notice and this permission notice shall be included in all
291 | copies or substantial portions of the Software.
292 |
293 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
294 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
295 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
296 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
297 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
298 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
299 | SOFTWARE.
300 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/contentModel.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Library/PackageCache/com.unity.collab-proxy@1.2.16
7 | Library/PackageCache/com.unity.ext.nunit@1.0.0
8 | Library/PackageCache/com.unity.ide.vscode@1.1.4
9 | Library/PackageCache/com.unity.test-framework@1.1.9
10 | Library/PackageCache/com.unity.textmeshpro@2.0.1
11 | Library/PackageCache/com.unity.xr.legacyinputhelpers@2.0.2
12 | Packages
13 | ProjectSettings
14 |
15 |
16 | .idea
17 | .vscode
18 | Library
19 | Logs
20 | Temp
21 | obj
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/projectSettingsUpdater.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Unity Project/.idea/.idea.Unity Project/riderModule.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Unity Project/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude":
3 | {
4 | "**/.DS_Store":true,
5 | "**/.git":true,
6 | "**/.gitignore":true,
7 | "**/.gitmodules":true,
8 | "**/*.booproj":true,
9 | "**/*.pidb":true,
10 | "**/*.suo":true,
11 | "**/*.user":true,
12 | "**/*.userprefs":true,
13 | "**/*.unityproj":true,
14 | "**/*.dll":true,
15 | "**/*.exe":true,
16 | "**/*.pdf":true,
17 | "**/*.mid":true,
18 | "**/*.midi":true,
19 | "**/*.wav":true,
20 | "**/*.gif":true,
21 | "**/*.ico":true,
22 | "**/*.jpg":true,
23 | "**/*.jpeg":true,
24 | "**/*.png":true,
25 | "**/*.psd":true,
26 | "**/*.tga":true,
27 | "**/*.tif":true,
28 | "**/*.tiff":true,
29 | "**/*.3ds":true,
30 | "**/*.3DS":true,
31 | "**/*.fbx":true,
32 | "**/*.FBX":true,
33 | "**/*.lxo":true,
34 | "**/*.LXO":true,
35 | "**/*.ma":true,
36 | "**/*.MA":true,
37 | "**/*.obj":true,
38 | "**/*.OBJ":true,
39 | "**/*.asset":true,
40 | "**/*.cubemap":true,
41 | "**/*.flare":true,
42 | "**/*.mat":true,
43 | "**/*.meta":true,
44 | "**/*.prefab":true,
45 | "**/*.unity":true,
46 | "build/":true,
47 | "Build/":true,
48 | "Library/":true,
49 | "library/":true,
50 | "obj/":true,
51 | "Obj/":true,
52 | "ProjectSettings/":true,
53 | "temp/":true,
54 | "Temp/":true
55 | }
56 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2a2185600db2a46f4a377abc9e5f097e
3 | folderAsset: yes
4 | timeCreated: 1509490923
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Inventories.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 48a3257b2fa87467d8f95a41140cd3ce
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 100100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Inventory Camera.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f73292cb172884e46a8ec1fde0f4ac75
3 | timeCreated: 1481784028
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Inventory Overlay.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 3
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 0}
41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 11
47 | m_GIWorkflowMode: 1
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_EnvironmentLightingMode: 0
54 | m_EnableBakedLightmaps: 0
55 | m_EnableRealtimeLightmaps: 0
56 | m_LightmapEditorSettings:
57 | serializedVersion: 12
58 | m_Resolution: 2
59 | m_BakeResolution: 40
60 | m_AtlasSize: 1024
61 | m_AO: 0
62 | m_AOMaxDistance: 1
63 | m_CompAOExponent: 1
64 | m_CompAOExponentDirect: 0
65 | m_ExtractAmbientOcclusion: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 1
75 | m_BakeBackend: 0
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 500
79 | m_PVRBounces: 2
80 | m_PVREnvironmentSampleCount: 500
81 | m_PVREnvironmentReferencePointCount: 2048
82 | m_PVRFilteringMode: 0
83 | m_PVRDenoiserTypeDirect: 0
84 | m_PVRDenoiserTypeIndirect: 0
85 | m_PVRDenoiserTypeAO: 0
86 | m_PVRFilterTypeDirect: 0
87 | m_PVRFilterTypeIndirect: 0
88 | m_PVRFilterTypeAO: 0
89 | m_PVREnvironmentMIS: 0
90 | m_PVRCulling: 1
91 | m_PVRFilteringGaussRadiusDirect: 1
92 | m_PVRFilteringGaussRadiusIndirect: 5
93 | m_PVRFilteringGaussRadiusAO: 2
94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
96 | m_PVRFilteringAtrousPositionSigmaAO: 1
97 | m_ExportTrainingData: 0
98 | m_TrainingDataDestination: TrainingData
99 | m_LightProbeSampleCountMultiplier: 4
100 | m_LightingDataAsset: {fileID: 0}
101 | m_UseShadowmask: 0
102 | --- !u!196 &4
103 | NavMeshSettings:
104 | serializedVersion: 2
105 | m_ObjectHideFlags: 0
106 | m_BuildSettings:
107 | serializedVersion: 2
108 | agentTypeID: 0
109 | agentRadius: 0.5
110 | agentHeight: 2
111 | agentSlope: 45
112 | agentClimb: 0.4
113 | ledgeDropHeight: 0
114 | maxJumpAcrossDistance: 0
115 | minRegionArea: 2
116 | manualCellSize: 0
117 | cellSize: 0.16666667
118 | manualTileSize: 0
119 | tileSize: 256
120 | accuratePlacement: 0
121 | debug:
122 | m_Flags: 0
123 | m_NavMeshData: {fileID: 0}
124 | --- !u!1 &466132161
125 | GameObject:
126 | m_ObjectHideFlags: 0
127 | m_CorrespondingSourceObject: {fileID: 0}
128 | m_PrefabInstance: {fileID: 0}
129 | m_PrefabAsset: {fileID: 0}
130 | serializedVersion: 6
131 | m_Component:
132 | - component: {fileID: 466132164}
133 | - component: {fileID: 466132163}
134 | - component: {fileID: 466132162}
135 | m_Layer: 0
136 | m_Name: EventSystem
137 | m_TagString: Untagged
138 | m_Icon: {fileID: 0}
139 | m_NavMeshLayer: 0
140 | m_StaticEditorFlags: 0
141 | m_IsActive: 1
142 | --- !u!114 &466132162
143 | MonoBehaviour:
144 | m_ObjectHideFlags: 0
145 | m_CorrespondingSourceObject: {fileID: 0}
146 | m_PrefabInstance: {fileID: 0}
147 | m_PrefabAsset: {fileID: 0}
148 | m_GameObject: {fileID: 466132161}
149 | m_Enabled: 1
150 | m_EditorHideFlags: 0
151 | m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
152 | m_Name:
153 | m_EditorClassIdentifier:
154 | m_HorizontalAxis: Horizontal
155 | m_VerticalAxis: Vertical
156 | m_SubmitButton: Submit
157 | m_CancelButton: Cancel
158 | m_InputActionsPerSecond: 10
159 | m_RepeatDelay: 0.5
160 | m_ForceModuleActive: 0
161 | --- !u!114 &466132163
162 | MonoBehaviour:
163 | m_ObjectHideFlags: 0
164 | m_CorrespondingSourceObject: {fileID: 0}
165 | m_PrefabInstance: {fileID: 0}
166 | m_PrefabAsset: {fileID: 0}
167 | m_GameObject: {fileID: 466132161}
168 | m_Enabled: 1
169 | m_EditorHideFlags: 0
170 | m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
171 | m_Name:
172 | m_EditorClassIdentifier:
173 | m_FirstSelected: {fileID: 0}
174 | m_sendNavigationEvents: 1
175 | m_DragThreshold: 5
176 | --- !u!4 &466132164
177 | Transform:
178 | m_ObjectHideFlags: 0
179 | m_CorrespondingSourceObject: {fileID: 0}
180 | m_PrefabInstance: {fileID: 0}
181 | m_PrefabAsset: {fileID: 0}
182 | m_GameObject: {fileID: 466132161}
183 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
184 | m_LocalPosition: {x: 0, y: 0, z: 0}
185 | m_LocalScale: {x: 1, y: 1, z: 1}
186 | m_Children: []
187 | m_Father: {fileID: 0}
188 | m_RootOrder: 2
189 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
190 | --- !u!1 &876042626
191 | GameObject:
192 | m_ObjectHideFlags: 0
193 | m_CorrespondingSourceObject: {fileID: 0}
194 | m_PrefabInstance: {fileID: 0}
195 | m_PrefabAsset: {fileID: 0}
196 | serializedVersion: 6
197 | m_Component:
198 | - component: {fileID: 876042631}
199 | - component: {fileID: 876042630}
200 | m_Layer: 0
201 | m_Name: Main Camera
202 | m_TagString: MainCamera
203 | m_Icon: {fileID: 0}
204 | m_NavMeshLayer: 0
205 | m_StaticEditorFlags: 0
206 | m_IsActive: 1
207 | --- !u!20 &876042630
208 | Camera:
209 | m_ObjectHideFlags: 0
210 | m_CorrespondingSourceObject: {fileID: 0}
211 | m_PrefabInstance: {fileID: 0}
212 | m_PrefabAsset: {fileID: 0}
213 | m_GameObject: {fileID: 876042626}
214 | m_Enabled: 1
215 | serializedVersion: 2
216 | m_ClearFlags: 2
217 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
218 | m_projectionMatrixMode: 1
219 | m_GateFitMode: 2
220 | m_FOVAxisMode: 0
221 | m_SensorSize: {x: 36, y: 24}
222 | m_LensShift: {x: 0, y: 0}
223 | m_FocalLength: 50
224 | m_NormalizedViewPortRect:
225 | serializedVersion: 2
226 | x: 0
227 | y: 0
228 | width: 1
229 | height: 1
230 | near clip plane: -10
231 | far clip plane: 10
232 | field of view: 60
233 | orthographic: 1
234 | orthographic size: 5
235 | m_Depth: -1
236 | m_CullingMask:
237 | serializedVersion: 2
238 | m_Bits: 4294967295
239 | m_RenderingPath: -1
240 | m_TargetTexture: {fileID: 0}
241 | m_TargetDisplay: 0
242 | m_TargetEye: 3
243 | m_HDR: 0
244 | m_AllowMSAA: 1
245 | m_AllowDynamicResolution: 0
246 | m_ForceIntoRT: 0
247 | m_OcclusionCulling: 1
248 | m_StereoConvergence: 10
249 | m_StereoSeparation: 0.022
250 | --- !u!4 &876042631
251 | Transform:
252 | m_ObjectHideFlags: 0
253 | m_CorrespondingSourceObject: {fileID: 0}
254 | m_PrefabInstance: {fileID: 0}
255 | m_PrefabAsset: {fileID: 0}
256 | m_GameObject: {fileID: 876042626}
257 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
258 | m_LocalPosition: {x: 0, y: 0, z: -10}
259 | m_LocalScale: {x: 1, y: 1, z: 1}
260 | m_Children: []
261 | m_Father: {fileID: 0}
262 | m_RootOrder: 0
263 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
264 | --- !u!1001 &1367319694
265 | PrefabInstance:
266 | m_ObjectHideFlags: 0
267 | serializedVersion: 2
268 | m_Modification:
269 | m_TransformParent: {fileID: 1980279642}
270 | m_Modifications:
271 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
272 | type: 3}
273 | propertyPath: m_LocalPosition.x
274 | value: 0
275 | objectReference: {fileID: 0}
276 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
277 | type: 3}
278 | propertyPath: m_LocalPosition.y
279 | value: 0
280 | objectReference: {fileID: 0}
281 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
282 | type: 3}
283 | propertyPath: m_LocalPosition.z
284 | value: 0
285 | objectReference: {fileID: 0}
286 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
287 | type: 3}
288 | propertyPath: m_LocalRotation.x
289 | value: 0
290 | objectReference: {fileID: 0}
291 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
292 | type: 3}
293 | propertyPath: m_LocalRotation.y
294 | value: 0
295 | objectReference: {fileID: 0}
296 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
297 | type: 3}
298 | propertyPath: m_LocalRotation.z
299 | value: 0
300 | objectReference: {fileID: 0}
301 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
302 | type: 3}
303 | propertyPath: m_LocalRotation.w
304 | value: 1
305 | objectReference: {fileID: 0}
306 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
307 | type: 3}
308 | propertyPath: m_RootOrder
309 | value: 0
310 | objectReference: {fileID: 0}
311 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
312 | type: 3}
313 | propertyPath: m_AnchoredPosition.x
314 | value: 0
315 | objectReference: {fileID: 0}
316 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
317 | type: 3}
318 | propertyPath: m_AnchoredPosition.y
319 | value: 12
320 | objectReference: {fileID: 0}
321 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
322 | type: 3}
323 | propertyPath: m_SizeDelta.x
324 | value: 0
325 | objectReference: {fileID: 0}
326 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
327 | type: 3}
328 | propertyPath: m_SizeDelta.y
329 | value: 0
330 | objectReference: {fileID: 0}
331 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
332 | type: 3}
333 | propertyPath: m_AnchorMin.x
334 | value: 0
335 | objectReference: {fileID: 0}
336 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
337 | type: 3}
338 | propertyPath: m_AnchorMin.y
339 | value: 0
340 | objectReference: {fileID: 0}
341 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
342 | type: 3}
343 | propertyPath: m_AnchorMax.x
344 | value: 1
345 | objectReference: {fileID: 0}
346 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
347 | type: 3}
348 | propertyPath: m_AnchorMax.y
349 | value: 1
350 | objectReference: {fileID: 0}
351 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
352 | type: 3}
353 | propertyPath: m_Pivot.x
354 | value: 0.5
355 | objectReference: {fileID: 0}
356 | - target: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
357 | type: 3}
358 | propertyPath: m_Pivot.y
359 | value: 0.5
360 | objectReference: {fileID: 0}
361 | - target: {fileID: 224525799100627122, guid: 48a3257b2fa87467d8f95a41140cd3ce,
362 | type: 3}
363 | propertyPath: m_AnchorMin.y
364 | value: 0
365 | objectReference: {fileID: 0}
366 | - target: {fileID: 224525799100627122, guid: 48a3257b2fa87467d8f95a41140cd3ce,
367 | type: 3}
368 | propertyPath: m_AnchorMax.y
369 | value: 0
370 | objectReference: {fileID: 0}
371 | - target: {fileID: 224525799100627122, guid: 48a3257b2fa87467d8f95a41140cd3ce,
372 | type: 3}
373 | propertyPath: m_AnchoredPosition.x
374 | value: 0
375 | objectReference: {fileID: 0}
376 | - target: {fileID: 224525799100627122, guid: 48a3257b2fa87467d8f95a41140cd3ce,
377 | type: 3}
378 | propertyPath: m_AnchoredPosition.y
379 | value: 0
380 | objectReference: {fileID: 0}
381 | - target: {fileID: 224528672208050248, guid: 48a3257b2fa87467d8f95a41140cd3ce,
382 | type: 3}
383 | propertyPath: m_AnchorMin.y
384 | value: 0
385 | objectReference: {fileID: 0}
386 | - target: {fileID: 224528672208050248, guid: 48a3257b2fa87467d8f95a41140cd3ce,
387 | type: 3}
388 | propertyPath: m_AnchorMax.y
389 | value: 0
390 | objectReference: {fileID: 0}
391 | - target: {fileID: 224528672208050248, guid: 48a3257b2fa87467d8f95a41140cd3ce,
392 | type: 3}
393 | propertyPath: m_AnchoredPosition.x
394 | value: 0
395 | objectReference: {fileID: 0}
396 | - target: {fileID: 224528672208050248, guid: 48a3257b2fa87467d8f95a41140cd3ce,
397 | type: 3}
398 | propertyPath: m_AnchoredPosition.y
399 | value: 0
400 | objectReference: {fileID: 0}
401 | - target: {fileID: 1919124042662507149, guid: 48a3257b2fa87467d8f95a41140cd3ce,
402 | type: 3}
403 | propertyPath: m_AnchorMin.y
404 | value: 0
405 | objectReference: {fileID: 0}
406 | - target: {fileID: 1919124042662507149, guid: 48a3257b2fa87467d8f95a41140cd3ce,
407 | type: 3}
408 | propertyPath: m_AnchorMax.y
409 | value: 0
410 | objectReference: {fileID: 0}
411 | - target: {fileID: 1919124042662507149, guid: 48a3257b2fa87467d8f95a41140cd3ce,
412 | type: 3}
413 | propertyPath: m_AnchoredPosition.x
414 | value: 0
415 | objectReference: {fileID: 0}
416 | - target: {fileID: 1919124042662507149, guid: 48a3257b2fa87467d8f95a41140cd3ce,
417 | type: 3}
418 | propertyPath: m_AnchoredPosition.y
419 | value: 0
420 | objectReference: {fileID: 0}
421 | - target: {fileID: 2106048171253168516, guid: 48a3257b2fa87467d8f95a41140cd3ce,
422 | type: 3}
423 | propertyPath: m_AnchorMin.y
424 | value: 0
425 | objectReference: {fileID: 0}
426 | - target: {fileID: 2106048171253168516, guid: 48a3257b2fa87467d8f95a41140cd3ce,
427 | type: 3}
428 | propertyPath: m_AnchorMax.y
429 | value: 0
430 | objectReference: {fileID: 0}
431 | - target: {fileID: 2106048171253168516, guid: 48a3257b2fa87467d8f95a41140cd3ce,
432 | type: 3}
433 | propertyPath: m_AnchoredPosition.x
434 | value: 0
435 | objectReference: {fileID: 0}
436 | - target: {fileID: 2106048171253168516, guid: 48a3257b2fa87467d8f95a41140cd3ce,
437 | type: 3}
438 | propertyPath: m_AnchoredPosition.y
439 | value: 0
440 | objectReference: {fileID: 0}
441 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
442 | type: 3}
443 | propertyPath: m_AnchoredPosition.x
444 | value: 512
445 | objectReference: {fileID: 0}
446 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
447 | type: 3}
448 | propertyPath: m_AnchorMin.y
449 | value: 0
450 | objectReference: {fileID: 0}
451 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
452 | type: 3}
453 | propertyPath: m_AnchorMax.y
454 | value: 0
455 | objectReference: {fileID: 0}
456 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
457 | type: 3}
458 | propertyPath: m_AnchoredPosition.y
459 | value: 0
460 | objectReference: {fileID: 0}
461 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
462 | type: 3}
463 | propertyPath: m_SizeDelta.x
464 | value: 0
465 | objectReference: {fileID: 0}
466 | - target: {fileID: 3822296998695286236, guid: 48a3257b2fa87467d8f95a41140cd3ce,
467 | type: 3}
468 | propertyPath: m_SizeDelta.y
469 | value: 0
470 | objectReference: {fileID: 0}
471 | - target: {fileID: 6087068503683214428, guid: 48a3257b2fa87467d8f95a41140cd3ce,
472 | type: 3}
473 | propertyPath: m_AnchorMin.y
474 | value: 0
475 | objectReference: {fileID: 0}
476 | - target: {fileID: 6087068503683214428, guid: 48a3257b2fa87467d8f95a41140cd3ce,
477 | type: 3}
478 | propertyPath: m_AnchorMax.y
479 | value: 0
480 | objectReference: {fileID: 0}
481 | - target: {fileID: 6087068503683214428, guid: 48a3257b2fa87467d8f95a41140cd3ce,
482 | type: 3}
483 | propertyPath: m_AnchoredPosition.x
484 | value: 0
485 | objectReference: {fileID: 0}
486 | - target: {fileID: 6087068503683214428, guid: 48a3257b2fa87467d8f95a41140cd3ce,
487 | type: 3}
488 | propertyPath: m_AnchoredPosition.y
489 | value: 0
490 | objectReference: {fileID: 0}
491 | - target: {fileID: 7636310937544795877, guid: 48a3257b2fa87467d8f95a41140cd3ce,
492 | type: 3}
493 | propertyPath: m_AnchorMin.y
494 | value: 0
495 | objectReference: {fileID: 0}
496 | - target: {fileID: 7636310937544795877, guid: 48a3257b2fa87467d8f95a41140cd3ce,
497 | type: 3}
498 | propertyPath: m_AnchorMax.y
499 | value: 0
500 | objectReference: {fileID: 0}
501 | - target: {fileID: 7636310937544795877, guid: 48a3257b2fa87467d8f95a41140cd3ce,
502 | type: 3}
503 | propertyPath: m_AnchoredPosition.x
504 | value: 0
505 | objectReference: {fileID: 0}
506 | - target: {fileID: 7636310937544795877, guid: 48a3257b2fa87467d8f95a41140cd3ce,
507 | type: 3}
508 | propertyPath: m_AnchoredPosition.y
509 | value: 0
510 | objectReference: {fileID: 0}
511 | m_RemovedComponents: []
512 | m_SourcePrefab: {fileID: 100100000, guid: 48a3257b2fa87467d8f95a41140cd3ce, type: 3}
513 | --- !u!224 &1693025268 stripped
514 | RectTransform:
515 | m_CorrespondingSourceObject: {fileID: 224204867781484398, guid: 48a3257b2fa87467d8f95a41140cd3ce,
516 | type: 3}
517 | m_PrefabInstance: {fileID: 1367319694}
518 | m_PrefabAsset: {fileID: 0}
519 | --- !u!1 &1980279638
520 | GameObject:
521 | m_ObjectHideFlags: 0
522 | m_CorrespondingSourceObject: {fileID: 0}
523 | m_PrefabInstance: {fileID: 0}
524 | m_PrefabAsset: {fileID: 0}
525 | serializedVersion: 6
526 | m_Component:
527 | - component: {fileID: 1980279642}
528 | - component: {fileID: 1980279641}
529 | - component: {fileID: 1980279640}
530 | - component: {fileID: 1980279639}
531 | m_Layer: 5
532 | m_Name: Canvas
533 | m_TagString: Untagged
534 | m_Icon: {fileID: 0}
535 | m_NavMeshLayer: 0
536 | m_StaticEditorFlags: 0
537 | m_IsActive: 1
538 | --- !u!114 &1980279639
539 | MonoBehaviour:
540 | m_ObjectHideFlags: 0
541 | m_CorrespondingSourceObject: {fileID: 0}
542 | m_PrefabInstance: {fileID: 0}
543 | m_PrefabAsset: {fileID: 0}
544 | m_GameObject: {fileID: 1980279638}
545 | m_Enabled: 1
546 | m_EditorHideFlags: 0
547 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
548 | m_Name:
549 | m_EditorClassIdentifier:
550 | m_IgnoreReversedGraphics: 1
551 | m_BlockingObjects: 0
552 | m_BlockingMask:
553 | serializedVersion: 2
554 | m_Bits: 4294967295
555 | --- !u!114 &1980279640
556 | MonoBehaviour:
557 | m_ObjectHideFlags: 0
558 | m_CorrespondingSourceObject: {fileID: 0}
559 | m_PrefabInstance: {fileID: 0}
560 | m_PrefabAsset: {fileID: 0}
561 | m_GameObject: {fileID: 1980279638}
562 | m_Enabled: 1
563 | m_EditorHideFlags: 0
564 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
565 | m_Name:
566 | m_EditorClassIdentifier:
567 | m_UiScaleMode: 0
568 | m_ReferencePixelsPerUnit: 100
569 | m_ScaleFactor: 2
570 | m_ReferenceResolution: {x: 800, y: 600}
571 | m_ScreenMatchMode: 0
572 | m_MatchWidthOrHeight: 0
573 | m_PhysicalUnit: 3
574 | m_FallbackScreenDPI: 96
575 | m_DefaultSpriteDPI: 96
576 | m_DynamicPixelsPerUnit: 1
577 | --- !u!223 &1980279641
578 | Canvas:
579 | m_ObjectHideFlags: 0
580 | m_CorrespondingSourceObject: {fileID: 0}
581 | m_PrefabInstance: {fileID: 0}
582 | m_PrefabAsset: {fileID: 0}
583 | m_GameObject: {fileID: 1980279638}
584 | m_Enabled: 1
585 | serializedVersion: 3
586 | m_RenderMode: 0
587 | m_Camera: {fileID: 876042630}
588 | m_PlaneDistance: 5
589 | m_PixelPerfect: 1
590 | m_ReceivesEvents: 1
591 | m_OverrideSorting: 0
592 | m_OverridePixelPerfect: 0
593 | m_SortingBucketNormalizedSize: 0
594 | m_AdditionalShaderChannelsFlag: 25
595 | m_SortingLayerID: 0
596 | m_SortingOrder: 0
597 | m_TargetDisplay: 0
598 | --- !u!224 &1980279642
599 | RectTransform:
600 | m_ObjectHideFlags: 0
601 | m_CorrespondingSourceObject: {fileID: 0}
602 | m_PrefabInstance: {fileID: 0}
603 | m_PrefabAsset: {fileID: 0}
604 | m_GameObject: {fileID: 1980279638}
605 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
606 | m_LocalPosition: {x: 0, y: 0, z: 0}
607 | m_LocalScale: {x: 0, y: 0, z: 0}
608 | m_Children:
609 | - {fileID: 1693025268}
610 | m_Father: {fileID: 0}
611 | m_RootOrder: 1
612 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
613 | m_AnchorMin: {x: 0, y: 0}
614 | m_AnchorMax: {x: 0, y: 0}
615 | m_AnchoredPosition: {x: 0, y: 0}
616 | m_SizeDelta: {x: 0, y: 0}
617 | m_Pivot: {x: 0, y: 0}
618 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Inventory Overlay.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c60b45d6939fb4b7cbc4619eb492024c
3 | timeCreated: 1481784028
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Inventory World Space.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 98c6d58fcc520439bba8bad4763f9e43
3 | timeCreated: 1481784028
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/InventoryProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace FarrokhGames.Inventory.Examples
5 | {
6 | public class InventoryProvider : IInventoryProvider
7 | {
8 | private List _items = new List();
9 | private int _maximumAlowedItemCount;
10 | ItemType _allowedItem;
11 |
12 | ///
13 | /// CTOR
14 | ///
15 | public InventoryProvider(InventoryRenderMode renderMode, int maximumAlowedItemCount = -1, ItemType allowedItem = ItemType.Any)
16 | {
17 | inventoryRenderMode = renderMode;
18 | _maximumAlowedItemCount = maximumAlowedItemCount;
19 | _allowedItem = allowedItem;
20 | }
21 |
22 | public int inventoryItemCount => _items.Count;
23 |
24 | public InventoryRenderMode inventoryRenderMode { get; private set; }
25 |
26 | public bool isInventoryFull
27 | {
28 | get
29 | {
30 | if (_maximumAlowedItemCount < 0)return false;
31 | return inventoryItemCount >= _maximumAlowedItemCount;
32 | }
33 | }
34 |
35 | public bool AddInventoryItem(IInventoryItem item)
36 | {
37 | if (!_items.Contains(item))
38 | {
39 | _items.Add(item);
40 | return true;
41 | }
42 | return false;
43 | }
44 |
45 | public bool DropInventoryItem(IInventoryItem item)
46 | {
47 | return RemoveInventoryItem(item);
48 | }
49 |
50 | public IInventoryItem GetInventoryItem(int index)
51 | {
52 | return _items[index];
53 | }
54 |
55 | public bool CanAddInventoryItem(IInventoryItem item)
56 | {
57 | if (_allowedItem == ItemType.Any)return true;
58 | return (item as ItemDefinition).Type == _allowedItem;
59 | }
60 |
61 | public bool CanRemoveInventoryItem(IInventoryItem item)
62 | {
63 | return true;
64 | }
65 |
66 | public bool CanDropInventoryItem(IInventoryItem item)
67 | {
68 | return true;
69 | }
70 |
71 | public bool RemoveInventoryItem(IInventoryItem item)
72 | {
73 | return _items.Remove(item);
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/InventoryProvider.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ab14f5f43932a4e51b5139145e6a75d2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/InventorySelection.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | namespace FarrokhGames.Inventory.Examples
5 | {
6 | public class InventorySelection : MonoBehaviour
7 | {
8 | Text _text;
9 |
10 | void Start()
11 | {
12 | _text = GetComponentInChildren();
13 | _text.text = string.Empty;
14 |
15 | var allControllers = GameObject.FindObjectsOfType();
16 |
17 | foreach (var controller in allControllers)
18 | {
19 | controller.onItemHovered += HandleItemHover;
20 | }
21 | }
22 |
23 | private void HandleItemHover(IInventoryItem item)
24 | {
25 | if (item != null)
26 | {
27 | _text.text = (item as ItemDefinition).Name;
28 | }
29 | else
30 | {
31 | _text.text = string.Empty;
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/InventorySelection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cd50d1063f39b42d8a9f2a20aa610fa3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/ItemDefinition.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace FarrokhGames.Inventory.Examples
4 | {
5 | ///
6 | /// Scriptable Object representing an Inventory Item
7 | ///
8 | [CreateAssetMenu(fileName = "Item", menuName = "Inventory/Item", order = 1)]
9 | public class ItemDefinition : ScriptableObject, IInventoryItem
10 | {
11 | [SerializeField] private Sprite _sprite = null;
12 | [SerializeField] private InventoryShape _shape = null;
13 | [SerializeField] private ItemType _type = ItemType.Utility;
14 | [SerializeField] private bool _canDrop = true;
15 | [SerializeField, HideInInspector] private Vector2Int _position = Vector2Int.zero;
16 |
17 | ///
18 | /// The name of the item
19 | ///
20 | public string Name => this.name;
21 |
22 | ///
23 | /// The type of the item
24 | ///
25 | public ItemType Type => _type;
26 |
27 | ///
28 | public Sprite sprite => _sprite;
29 |
30 | ///
31 | public int width => _shape.width;
32 |
33 | ///
34 | public int height => _shape.height;
35 |
36 | ///
37 | public Vector2Int position
38 | {
39 | get => _position;
40 | set => _position = value;
41 | }
42 |
43 | ///
44 | public bool IsPartOfShape(Vector2Int localPosition)
45 | {
46 | return _shape.IsPartOfShape(localPosition);
47 | }
48 |
49 | ///
50 | public bool canDrop => _canDrop;
51 |
52 | ///
53 | /// Creates a copy if this scriptable object
54 | ///
55 | public IInventoryItem CreateInstance()
56 | {
57 | var clone = ScriptableObject.Instantiate(this);
58 | clone.name = clone.name.Substring(0, clone.name.Length - 7); // Remove (Clone) from name
59 | return clone;
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/ItemDefinition.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 92e9099dba1c24dcda700fa19b64a47b
3 | timeCreated: 1509648015
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/ItemTypes.cs:
--------------------------------------------------------------------------------
1 | namespace FarrokhGames.Inventory.Examples
2 | {
3 | public enum ItemType
4 | {
5 | Any,
6 | Weapons,
7 | Utility,
8 | }
9 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/ItemTypes.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f2fb5a542a2a442c0851167a1577acf7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 317cfa3cf9a8645d78d28a356fc889dc
3 | folderAsset: yes
4 | timeCreated: 1481841553
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Dagger.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
13 | m_Name: Dagger
14 | m_EditorClassIdentifier:
15 | _sprite: {fileID: 21300002, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
16 | _shape:
17 | _width: 2
18 | _height: 1
19 | _shape: 0101
20 | _type: 1
21 | _position: {x: 0, y: 0}
22 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Dagger.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 53fac397599b9450cb6ffc84b6990844
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Gadget.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_GameObject: {fileID: 0}
9 | m_Enabled: 1
10 | m_EditorHideFlags: 0
11 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
12 | m_Name: Gadget
13 | m_EditorClassIdentifier:
14 | _sprite: {fileID: 21300008, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
15 | _shape:
16 | _width: 1
17 | _height: 2
18 | _shape: 0101
19 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Gadget.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a790d8ff8de79447eba65a1c9f328eb1
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Green Vial.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_GameObject: {fileID: 0}
9 | m_Enabled: 1
10 | m_EditorHideFlags: 0
11 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
12 | m_Name: Green Vial
13 | m_EditorClassIdentifier:
14 | _sprite: {fileID: 21300018, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
15 | _shape:
16 | _width: 1
17 | _height: 1
18 | _shape: 01
19 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Green Vial.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1e71a40542e224abcb0957010541b8c8
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Ray Gun.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
13 | m_Name: Ray Gun
14 | m_EditorClassIdentifier:
15 | _sprite: {fileID: 21300000, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
16 | _shape:
17 | _width: 2
18 | _height: 2
19 | _shape: 01010001
20 | _type: 1
21 | _canDrop: 0
22 | _position: {x: 0, y: 0}
23 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Ray Gun.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2103fea2b7f614248bd4e2271871cbf9
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Red Vial.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_GameObject: {fileID: 0}
9 | m_Enabled: 1
10 | m_EditorHideFlags: 0
11 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
12 | m_Name: Red Vial
13 | m_EditorClassIdentifier:
14 | _sprite: {fileID: 21300006, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
15 | _shape:
16 | _width: 1
17 | _height: 1
18 | _shape: 01
19 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Red Vial.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 640085f25f2394070afe43c1edd4b92e
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Stun Baton.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 92e9099dba1c24dcda700fa19b64a47b, type: 3}
13 | m_Name: Stun Baton
14 | m_EditorClassIdentifier:
15 | _sprite: {fileID: 21300004, guid: 4f666dd4618814d2f8c5a2599cd224c7, type: 3}
16 | _shape:
17 | _width: 1
18 | _height: 4
19 | _shape: 01010101
20 | _type: 1
21 | _position: {x: 0, y: 0}
22 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/Items/Stun Baton.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 57a0e4d113f3d48eeb460a17da5183e4
3 | timeCreated: 1509649710
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 11400000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/SizeInventoryExample.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace FarrokhGames.Inventory.Examples
4 | {
5 | ///
6 | /// Example Lobby class
7 | ///
8 | [RequireComponent(typeof(InventoryRenderer))]
9 | public class SizeInventoryExample : MonoBehaviour
10 | {
11 | [SerializeField] private InventoryRenderMode _renderMode = InventoryRenderMode.Grid;
12 | [SerializeField] private int _maximumAlowedItemCount = -1;
13 | [SerializeField] private ItemType _allowedItem = ItemType.Any;
14 | [SerializeField] private int _width = 8;
15 | [SerializeField] private int _height = 4;
16 | [SerializeField] private ItemDefinition[] _definitions = null;
17 | [SerializeField] private bool _fillRandomly = true; // Should the inventory get filled with random items?
18 | [SerializeField] private bool _fillEmpty = false; // Should the inventory get completely filled?
19 |
20 | void Start()
21 | {
22 | var provider = new InventoryProvider(_renderMode, _maximumAlowedItemCount, _allowedItem);
23 |
24 | // Create inventory
25 | var inventory = new InventoryManager(provider, _width, _height);
26 |
27 | // Fill inventory with random items
28 | if (_fillRandomly)
29 | {
30 | var tries = (_width * _height) / 3;
31 | for (var i = 0; i < tries; i++)
32 | {
33 | inventory.TryAdd(_definitions[Random.Range(0, _definitions.Length)].CreateInstance());
34 | }
35 | }
36 |
37 | // Fill empty slots with first (1x1) item
38 | if (_fillEmpty)
39 | {
40 | for (var i = 0; i < _width * _height; i++)
41 | {
42 | inventory.TryAdd(_definitions[0].CreateInstance());
43 | }
44 | }
45 |
46 | // Sets the renderers's inventory to trigger drawing
47 | GetComponent().SetInventory(inventory, provider.inventoryRenderMode);
48 |
49 | // Log items being dropped on the ground
50 | inventory.onItemDropped += (item) =>
51 | {
52 | Debug.Log((item as ItemDefinition).Name + " was dropped on the ground");
53 | };
54 |
55 | // Log when an item was unable to be placed on the ground (due to its canDrop being set to false)
56 | inventory.onItemDroppedFailed += (item) =>
57 | {
58 | Debug.Log($"You're not allowed to drop {(item as ItemDefinition).Name} on the ground");
59 | };
60 |
61 | // Log when an item was unable to be placed on the ground (due to its canDrop being set to false)
62 | inventory.onItemAddedFailed += (item) =>
63 | {
64 | Debug.Log($"You can't put {(item as ItemDefinition).Name} there!");
65 | };
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/SizeInventoryExample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6cf862b43efc1409fa7d9796bfdd0f84
3 | timeCreated: 1481785221
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/inventory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FarrokhGames/Inventory/174f55d1d03cc9742c367020c491fd03508834a9/Unity Project/Assets/Example/inventory.png
--------------------------------------------------------------------------------
/Unity Project/Assets/Example/inventory.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4f666dd4618814d2f8c5a2599cd224c7
3 | TextureImporter:
4 | internalIDToNameTable:
5 | - first:
6 | 213: 21300000
7 | second: raygun
8 | - first:
9 | 213: 21300002
10 | second: dagger
11 | - first:
12 | 213: 21300004
13 | second: stunbaton
14 | - first:
15 | 213: 21300006
16 | second: vial_red
17 | - first:
18 | 213: 21300008
19 | second: gadget
20 | - first:
21 | 213: 21300010
22 | second: inventory_border
23 | - first:
24 | 213: 21300012
25 | second: inventory_cell_empty
26 | - first:
27 | 213: 21300014
28 | second: inventory_cell_selected
29 | - first:
30 | 213: 21300016
31 | second: inventory_cell_blocked
32 | - first:
33 | 213: 21300018
34 | second: vial_green
35 | externalObjects: {}
36 | serializedVersion: 10
37 | mipmaps:
38 | mipMapMode: 0
39 | enableMipMap: 0
40 | sRGBTexture: 0
41 | linearTexture: 0
42 | fadeOut: 0
43 | borderMipMap: 0
44 | mipMapsPreserveCoverage: 0
45 | alphaTestReferenceValue: 0.5
46 | mipMapFadeDistanceStart: 1
47 | mipMapFadeDistanceEnd: 3
48 | bumpmap:
49 | convertToNormalMap: 0
50 | externalNormalMap: 0
51 | heightScale: 0.25
52 | normalMapFilter: 0
53 | isReadable: 0
54 | streamingMipmaps: 0
55 | streamingMipmapsPriority: 0
56 | grayScaleToAlpha: 0
57 | generateCubemap: 6
58 | cubemapConvolution: 0
59 | seamlessCubemap: 0
60 | textureFormat: 1
61 | maxTextureSize: 2048
62 | textureSettings:
63 | serializedVersion: 2
64 | filterMode: 0
65 | aniso: -1
66 | mipBias: -100
67 | wrapU: 1
68 | wrapV: 1
69 | wrapW: 1
70 | nPOTScale: 0
71 | lightmap: 0
72 | compressionQuality: 50
73 | spriteMode: 2
74 | spriteExtrude: 1
75 | spriteMeshType: 1
76 | alignment: 0
77 | spritePivot: {x: 0.5, y: 0.5}
78 | spritePixelsToUnits: 100
79 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
80 | spriteGenerateFallbackPhysicsShape: 1
81 | alphaUsage: 1
82 | alphaIsTransparency: 1
83 | spriteTessellationDetail: -1
84 | textureType: 8
85 | textureShape: 1
86 | singleChannelComponent: 0
87 | maxTextureSizeSet: 0
88 | compressionQualitySet: 0
89 | textureFormatSet: 0
90 | platformSettings:
91 | - serializedVersion: 3
92 | buildTarget: DefaultTexturePlatform
93 | maxTextureSize: 2048
94 | resizeAlgorithm: 0
95 | textureFormat: -1
96 | textureCompression: 0
97 | compressionQuality: 50
98 | crunchedCompression: 0
99 | allowsAlphaSplitting: 0
100 | overridden: 0
101 | androidETC2FallbackOverride: 0
102 | forceMaximumCompressionQuality_BC6H_BC7: 1
103 | - serializedVersion: 3
104 | buildTarget: Standalone
105 | maxTextureSize: 2048
106 | resizeAlgorithm: 0
107 | textureFormat: -1
108 | textureCompression: 0
109 | compressionQuality: 50
110 | crunchedCompression: 0
111 | allowsAlphaSplitting: 0
112 | overridden: 0
113 | androidETC2FallbackOverride: 0
114 | forceMaximumCompressionQuality_BC6H_BC7: 1
115 | - serializedVersion: 3
116 | buildTarget: iPhone
117 | maxTextureSize: 2048
118 | resizeAlgorithm: 0
119 | textureFormat: -1
120 | textureCompression: 0
121 | compressionQuality: 50
122 | crunchedCompression: 0
123 | allowsAlphaSplitting: 0
124 | overridden: 0
125 | androidETC2FallbackOverride: 0
126 | forceMaximumCompressionQuality_BC6H_BC7: 1
127 | - serializedVersion: 3
128 | buildTarget: Android
129 | maxTextureSize: 2048
130 | resizeAlgorithm: 0
131 | textureFormat: -1
132 | textureCompression: 0
133 | compressionQuality: 50
134 | crunchedCompression: 0
135 | allowsAlphaSplitting: 0
136 | overridden: 0
137 | androidETC2FallbackOverride: 0
138 | forceMaximumCompressionQuality_BC6H_BC7: 1
139 | - serializedVersion: 3
140 | buildTarget: WebGL
141 | maxTextureSize: 2048
142 | resizeAlgorithm: 0
143 | textureFormat: -1
144 | textureCompression: 0
145 | compressionQuality: 50
146 | crunchedCompression: 0
147 | allowsAlphaSplitting: 0
148 | overridden: 0
149 | androidETC2FallbackOverride: 0
150 | forceMaximumCompressionQuality_BC6H_BC7: 1
151 | spriteSheet:
152 | serializedVersion: 2
153 | sprites:
154 | - serializedVersion: 2
155 | name: raygun
156 | rect:
157 | serializedVersion: 2
158 | x: 0
159 | y: 64
160 | width: 64
161 | height: 64
162 | alignment: 0
163 | pivot: {x: 0.5, y: 0.5}
164 | border: {x: 0, y: 0, z: 0, w: 0}
165 | outline: []
166 | physicsShape: []
167 | tessellationDetail: 0
168 | bones: []
169 | spriteID: 02305410000000000800000000000000
170 | internalID: 21300000
171 | vertices: []
172 | indices:
173 | edges: []
174 | weights: []
175 | - serializedVersion: 2
176 | name: dagger
177 | rect:
178 | serializedVersion: 2
179 | x: 0
180 | y: 32
181 | width: 64
182 | height: 32
183 | alignment: 0
184 | pivot: {x: 0.5, y: 0.5}
185 | border: {x: 0, y: 0, z: 0, w: 0}
186 | outline: []
187 | physicsShape: []
188 | tessellationDetail: 0
189 | bones: []
190 | spriteID: 22305410000000000800000000000000
191 | internalID: 21300002
192 | vertices: []
193 | indices:
194 | edges: []
195 | weights: []
196 | - serializedVersion: 2
197 | name: stunbaton
198 | rect:
199 | serializedVersion: 2
200 | x: 64
201 | y: 0
202 | width: 32
203 | height: 128
204 | alignment: 0
205 | pivot: {x: 0.5, y: 0.5}
206 | border: {x: 0, y: 0, z: 0, w: 0}
207 | outline: []
208 | physicsShape: []
209 | tessellationDetail: 0
210 | bones: []
211 | spriteID: 42305410000000000800000000000000
212 | internalID: 21300004
213 | vertices: []
214 | indices:
215 | edges: []
216 | weights: []
217 | - serializedVersion: 2
218 | name: vial_red
219 | rect:
220 | serializedVersion: 2
221 | x: 96
222 | y: 96
223 | width: 32
224 | height: 32
225 | alignment: 0
226 | pivot: {x: 0.5, y: 0.5}
227 | border: {x: 0, y: 0, z: 0, w: 0}
228 | outline: []
229 | physicsShape: []
230 | tessellationDetail: 0
231 | bones: []
232 | spriteID: 62305410000000000800000000000000
233 | internalID: 21300006
234 | vertices: []
235 | indices:
236 | edges: []
237 | weights: []
238 | - serializedVersion: 2
239 | name: gadget
240 | rect:
241 | serializedVersion: 2
242 | x: 96
243 | y: 0
244 | width: 32
245 | height: 64
246 | alignment: 0
247 | pivot: {x: 0.5, y: 0.5}
248 | border: {x: 0, y: 0, z: 0, w: 0}
249 | outline: []
250 | physicsShape: []
251 | tessellationDetail: 0
252 | bones: []
253 | spriteID: 82305410000000000800000000000000
254 | internalID: 21300008
255 | vertices: []
256 | indices:
257 | edges: []
258 | weights: []
259 | - serializedVersion: 2
260 | name: inventory_border
261 | rect:
262 | serializedVersion: 2
263 | x: 96
264 | y: 64
265 | width: 32
266 | height: 32
267 | alignment: 0
268 | pivot: {x: 0.5, y: 0.5}
269 | border: {x: 14, y: 14, z: 14, w: 14}
270 | outline: []
271 | physicsShape: []
272 | tessellationDetail: 0
273 | bones: []
274 | spriteID: a2305410000000000800000000000000
275 | internalID: 21300010
276 | vertices: []
277 | indices:
278 | edges: []
279 | weights: []
280 | - serializedVersion: 2
281 | name: inventory_cell_empty
282 | rect:
283 | serializedVersion: 2
284 | x: 0
285 | y: 16
286 | width: 16
287 | height: 16
288 | alignment: 0
289 | pivot: {x: 0.5, y: 0.5}
290 | border: {x: 8, y: 8, z: 8, w: 8}
291 | outline: []
292 | physicsShape: []
293 | tessellationDetail: 0
294 | bones: []
295 | spriteID: c2305410000000000800000000000000
296 | internalID: 21300012
297 | vertices: []
298 | indices:
299 | edges: []
300 | weights: []
301 | - serializedVersion: 2
302 | name: inventory_cell_selected
303 | rect:
304 | serializedVersion: 2
305 | x: 16
306 | y: 16
307 | width: 16
308 | height: 16
309 | alignment: 0
310 | pivot: {x: 0.5, y: 0.5}
311 | border: {x: 8, y: 8, z: 8, w: 8}
312 | outline: []
313 | physicsShape: []
314 | tessellationDetail: 0
315 | bones: []
316 | spriteID: e2305410000000000800000000000000
317 | internalID: 21300014
318 | vertices: []
319 | indices:
320 | edges: []
321 | weights: []
322 | - serializedVersion: 2
323 | name: inventory_cell_blocked
324 | rect:
325 | serializedVersion: 2
326 | x: 16
327 | y: 0
328 | width: 16
329 | height: 16
330 | alignment: 0
331 | pivot: {x: 0.5, y: 0.5}
332 | border: {x: 8, y: 8, z: 8, w: 8}
333 | outline: []
334 | physicsShape: []
335 | tessellationDetail: 0
336 | bones: []
337 | spriteID: 03305410000000000800000000000000
338 | internalID: 21300016
339 | vertices: []
340 | indices:
341 | edges: []
342 | weights: []
343 | - serializedVersion: 2
344 | name: vial_green
345 | rect:
346 | serializedVersion: 2
347 | x: 32
348 | y: 0
349 | width: 32
350 | height: 32
351 | alignment: 0
352 | pivot: {x: 0, y: 0}
353 | border: {x: 0, y: 0, z: 0, w: 0}
354 | outline: []
355 | physicsShape: []
356 | tessellationDetail: 0
357 | bones: []
358 | spriteID: 23305410000000000800000000000000
359 | internalID: 21300018
360 | vertices: []
361 | indices:
362 | edges: []
363 | weights: []
364 | outline: []
365 | physicsShape: []
366 | bones: []
367 | spriteID:
368 | internalID: 0
369 | vertices: []
370 | indices:
371 | edges: []
372 | weights: []
373 | secondaryTextures: []
374 | spritePackingTag:
375 | pSDRemoveMatte: 0
376 | pSDShowRemoveMatteOption: 0
377 | userData:
378 | assetBundleName:
379 | assetBundleVariant:
380 |
--------------------------------------------------------------------------------
/Unity Project/Logs/Packages-Update.log:
--------------------------------------------------------------------------------
1 |
2 | === Mon Jun 24 19:31:05 2019
3 |
4 | Packages were changed.
5 | Update Mode: updateDependencies
6 |
7 | The following packages were added:
8 | com.unity.collab-proxy@1.2.16
9 | com.unity.timeline@1.0.0
10 | com.unity.multiplayer-hlapi@1.0.2
11 | com.unity.xr.legacyinputhelpers@2.0.2
12 | The following packages were updated:
13 | com.unity.analytics from version 2.0.16 to 3.3.2
14 | com.unity.package-manager-ui from version 1.9.11 to 2.1.2
15 | com.unity.purchasing from version 2.0.3 to 2.0.6
16 | com.unity.textmeshpro from version 1.2.4 to 2.0.1
17 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cc7e678b03e1d4cf9b3b1e214ddf4d3a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Editor/Farrokhgames.Inventory.Editor.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Farrokhgames.Inventory.Editor",
3 | "references": [
4 | "Farrokhgames.Inventory"
5 | ],
6 | "includePlatforms": [
7 | "Editor"
8 | ],
9 | "excludePlatforms": [],
10 | "allowUnsafeCode": false,
11 | "overrideReferences": false,
12 | "precompiledReferences": [],
13 | "autoReferenced": true,
14 | "defineConstraints": [],
15 | "versionDefines": [],
16 | "noEngineReferences": false
17 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Editor/Farrokhgames.Inventory.Editor.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 739aa9972c5754b509c67021e4189c24
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Editor/InventoryShapePropertyDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace FarrokhGames.Inventory
5 | {
6 | ///
7 | /// Custom Property Drawer for InventoryShape
8 | ///
9 | [CustomPropertyDrawer(typeof(InventoryShape))]
10 | public class InventoryShapePropertyDrawer : PropertyDrawer
11 | {
12 | const int GridSize = 16; // The size between the boold-fields that make up the shape matrix
13 |
14 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
15 | {
16 | // Find properties
17 | var pWidth = property.FindPropertyRelative("_width");
18 | var pHeight = property.FindPropertyRelative("_height");
19 | var pShape = property.FindPropertyRelative("_shape");
20 |
21 | // Clamp height & width
22 | if (pWidth.intValue <= 0) { pWidth.intValue = 1; }
23 | if (pHeight.intValue <= 0) { pHeight.intValue = 1; }
24 |
25 | // Begin property
26 | EditorGUI.BeginProperty(position, label, property);
27 |
28 | // Draw label
29 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
30 |
31 | // Fix intent
32 | var indent = EditorGUI.indentLevel;
33 | EditorGUI.indentLevel = 0;
34 |
35 | // Calculate rects
36 | var halfWidth = position.width / 2;
37 | var widthRect = new Rect(position.x, position.y, halfWidth, GridSize);
38 | var heightRect = new Rect(position.x + halfWidth, position.y, halfWidth, GridSize);
39 |
40 | // Width & Height
41 | EditorGUIUtility.labelWidth = 40;
42 | EditorGUI.PropertyField(widthRect, pWidth, new GUIContent("width"));
43 | EditorGUI.PropertyField(heightRect, pHeight, new GUIContent("height"));
44 |
45 | // Draw grid
46 | var width = pWidth.intValue;
47 | var height = pHeight.intValue;
48 | pShape.arraySize = width * height;
49 | for (var x = 0; x < width; x++)
50 | {
51 | for (var y = 0; y < height; y++)
52 | {
53 | var index = x + width * y;
54 | var rect = new Rect(position.x + (x * GridSize), position.y + GridSize + (y * GridSize), GridSize, GridSize);
55 | EditorGUI.PropertyField(rect, pShape.GetArrayElementAtIndex(index), GUIContent.none);
56 | }
57 | }
58 |
59 | // Set indent back to what it was
60 | EditorGUI.indentLevel = indent;
61 |
62 | // End property
63 | EditorGUI.EndProperty();
64 | }
65 |
66 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
67 | {
68 | float height = EditorGUI.GetPropertyHeight(property, label);
69 | height += property.FindPropertyRelative("_height").intValue * GridSize;
70 | return height;
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Editor/InventoryShapePropertyDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1cc8a45534a2e4d0db5952d314a3cd9a
3 | timeCreated: 1509226575
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Farrokh Games
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/LICENSE.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b93854d56d65e422da88282c2026171e
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/README.md:
--------------------------------------------------------------------------------
1 | ## A Diablo 2-style inventory system for Unity3D
2 |
3 | ## Features
4 | - ```Resize``` at runtime, dropping what no longer fits.
5 | - ```Add/Remove``` and check if an item fits from code.
6 | - ```Equipment slots``` for all your RPG needs.
7 | - ```Custom shapes``` for each item.
8 | - Rearrange items by ```draggin and dropping```, with visual feedback.
9 | - ```Move items between inventories```.
10 | - Remove items by ```dropping``` them outside the inventory.
11 | - Easily add ```custom graphics``` and change the size of your inventory.
12 | - Supports ```scaled canvases```.
13 | - Tested thoroughly with over ```75 Unit Tests```, and profiled using the Unity Profiler.
14 | - Tested using all types of ```Canvas render modes``` (Screen Space Overlay, Screen Space Camera and World Space)
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b4e237ead57654fa5aa10dfc041c0b9c
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e3b75cb73528143949b4e8cf6eee2019
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/Farrokhgames.Inventory.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Farrokhgames.Inventory",
3 | "references": [],
4 | "includePlatforms": [],
5 | "excludePlatforms": [],
6 | "allowUnsafeCode": false,
7 | "overrideReferences": false,
8 | "precompiledReferences": [],
9 | "autoReferenced": true,
10 | "defineConstraints": [],
11 | "versionDefines": [],
12 | "noEngineReferences": false
13 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/Farrokhgames.Inventory.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad7ca1fe27ed848b1b66decacb1f3a63
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryItem.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace FarrokhGames.Inventory
4 | {
5 | public interface IInventoryItem
6 | {
7 | ///
8 | /// The sprite of this item
9 | ///
10 | Sprite sprite { get; }
11 |
12 | ///
13 | /// Returns this items position within an inventory
14 | ///
15 | Vector2Int position { get; set; }
16 |
17 | ///
18 | /// The width of this item
19 | ///
20 | int width { get; }
21 |
22 | ///
23 | /// The height of this item
24 | ///
25 | int height { get; }
26 |
27 | ///
28 | /// Returns true if given local position is part
29 | /// of this items shape
30 | ///
31 | bool IsPartOfShape(Vector2Int localPosition);
32 |
33 | ///
34 | /// Returns true if this item can be dropped on the ground
35 | ///
36 | bool canDrop { get; }
37 | }
38 |
39 | internal static class InventoryItemExtensions
40 | {
41 | ///
42 | /// Returns the lower left corner position of an item
43 | /// within its inventory
44 | ///
45 | internal static Vector2Int GetMinPoint(this IInventoryItem item)
46 | {
47 | return item.position;
48 | }
49 |
50 | ///
51 | /// Returns the top right corner position of an item
52 | /// within its inventory
53 | ///
54 | internal static Vector2Int GetMaxPoint(this IInventoryItem item)
55 | {
56 | return item.position + new Vector2Int(item.width, item.height);
57 | }
58 |
59 | ///
60 | /// Returns true if this item overlaps the given point within an inventory
61 | ///
62 | internal static bool Contains(this IInventoryItem item, Vector2Int inventoryPoint)
63 | {
64 | for (var iX = 0; iX < item.width; iX++)
65 | {
66 | for (var iY = 0; iY < item.height; iY++)
67 | {
68 | var iPoint = item.position + new Vector2Int(iX, iY);
69 | if (iPoint == inventoryPoint) { return true; }
70 | }
71 | }
72 | return false;
73 | }
74 |
75 | ///
76 | /// Returns true of this item overlaps a given item
77 | ///
78 | internal static bool Overlaps(this IInventoryItem item, IInventoryItem otherItem)
79 | {
80 | for (var iX = 0; iX < item.width; iX++)
81 | {
82 | for (var iY = 0; iY < item.height; iY++)
83 | {
84 | if (item.IsPartOfShape(new Vector2Int(iX, iY)))
85 | {
86 | var iPoint = item.position + new Vector2Int(iX, iY);
87 | for (var oX = 0; oX < otherItem.width; oX++)
88 | {
89 | for (var oY = 0; oY < otherItem.height; oY++)
90 | {
91 | if (otherItem.IsPartOfShape(new Vector2Int(oX, oY)))
92 | {
93 | var oPoint = otherItem.position + new Vector2Int(oX, oY);
94 | if (oPoint == iPoint) { return true; } // Hit! Items overlap
95 | }
96 | }
97 | }
98 | }
99 | }
100 | }
101 | return false; // Items does not overlap
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryItem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce535f68aff9e47a6b877edaeeb72947
3 | timeCreated: 1509652316
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace FarrokhGames.Inventory
5 | {
6 | public interface IInventoryManager : IDisposable
7 | {
8 | ///
9 | /// Invoked when an item is added to the inventory
10 | ///
11 | Action onItemAdded { get; set; }
12 |
13 | ///
14 | /// Invoked when an item was not able to be added to the inventory
15 | ///
16 | Action onItemAddedFailed { get; set; }
17 |
18 | ///
19 | /// Invoked when an item is removed to the inventory
20 | ///
21 | Action onItemRemoved { get; set; }
22 |
23 | ///
24 | /// Invoked when an item is removed from the inventory and should be placed on the ground.
25 | ///
26 | Action onItemDropped { get; set; }
27 |
28 | ///
29 | /// Invoked when an item was unable to be placed on the ground (most likely to its canDrop being set to false)
30 | ///
31 | Action onItemDroppedFailed { get; set; }
32 |
33 | ///
34 | /// Invoked when the inventory is rebuilt from scratch
35 | ///
36 | Action onRebuilt { get; set; }
37 |
38 | ///
39 | /// Invoked when the inventory changes its size
40 | ///
41 | Action onResized { get; set; }
42 |
43 | ///
44 | /// The width of the inventory
45 | ///
46 | int width { get; }
47 |
48 | ///
49 | /// The height of the inventory
50 | ///
51 | int height { get; }
52 |
53 | ///
54 | /// Sets a new width and height of the inventory
55 | ///
56 | void Resize(int width, int height);
57 |
58 | ///
59 | /// Returns all items inside this inventory
60 | ///
61 | IInventoryItem[] allItems { get; }
62 |
63 | ///
64 | /// Returns true if given item is present in this inventory
65 | ///
66 | bool Contains(IInventoryItem item);
67 |
68 | ///
69 | /// Returns true if this inventory is full
70 | ///
71 | bool isFull { get; }
72 |
73 | ///
74 | /// Returns true if its possible to add given item
75 | ///
76 | bool CanAdd(IInventoryItem item);
77 |
78 | ///
79 | /// Add given item to the inventory. Returns true
80 | /// if successful
81 | ///
82 | bool TryAdd(IInventoryItem item);
83 |
84 | ///
85 | /// Returns true if its possible to add item at location
86 | ///
87 | bool CanAddAt(IInventoryItem item, Vector2Int point);
88 |
89 | ///
90 | /// Tries to add item att location and returns true if successful
91 | ///
92 | bool TryAddAt(IInventoryItem item, Vector2Int point);
93 |
94 | ///
95 | /// Returns true if its possible to remove this item
96 | ///
97 | bool CanRemove(IInventoryItem item);
98 |
99 | ///
100 | /// Returns true ifits possible to swap this item
101 | ///
102 | bool CanSwap(IInventoryItem item);
103 |
104 | ///
105 | /// Removes given item from this inventory. Returns
106 | /// true if successful.
107 | ///
108 | bool TryRemove(IInventoryItem item);
109 |
110 | ///
111 | /// Returns true if its possible to drop this item
112 | ///
113 | bool CanDrop(IInventoryItem item);
114 |
115 | ///
116 | /// Removes an item from this inventory. Returns true
117 | /// if successful.
118 | ///
119 | bool TryDrop(IInventoryItem item);
120 |
121 | ///
122 | /// Drops all items from this inventory
123 | ///
124 | void DropAll();
125 |
126 | ///
127 | /// Clears (destroys) all items in this inventory
128 | ///
129 | void Clear();
130 |
131 | ///
132 | /// Rebuilds the inventory
133 | ///
134 | void Rebuild();
135 |
136 | ///
137 | /// Get an item at given point within this inventory
138 | ///
139 | IInventoryItem GetAtPoint(Vector2Int point);
140 |
141 | ///
142 | /// Returns all items under given rectangle
143 | ///
144 | IInventoryItem[] GetAtPoint(Vector2Int point, Vector2Int size);
145 | }
146 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f6fc0ef1e49924f89b245335706f132e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryProvider.cs:
--------------------------------------------------------------------------------
1 | namespace FarrokhGames.Inventory
2 | {
3 | ///
4 | /// A provider for a single inventory
5 | ///
6 | public interface IInventoryProvider
7 | {
8 | ///
9 | /// Returns the render mode of this inventory
10 | ///
11 | InventoryRenderMode inventoryRenderMode { get; }
12 |
13 | ///
14 | /// Returns the total amount of inventory items in
15 | /// this inventory
16 | ///
17 | int inventoryItemCount { get; }
18 |
19 | ///
20 | /// Returns true if the inventory is full
21 | ///
22 | bool isInventoryFull { get; }
23 |
24 | ///
25 | /// Returns the inventory item at given index
26 | ///
27 | IInventoryItem GetInventoryItem(int index);
28 |
29 | ///
30 | /// Returns true if given inventory item is allowed inside
31 | /// this inventory
32 | ///
33 | bool CanAddInventoryItem(IInventoryItem item);
34 |
35 | ///
36 | /// Returns true if given inventory item is allowed to
37 | /// be removed from this inventory
38 | ///
39 | bool CanRemoveInventoryItem(IInventoryItem item);
40 |
41 | ///
42 | /// Returns true if given inventory item is allowed to
43 | /// be dropped on the ground
44 | ///
45 | bool CanDropInventoryItem(IInventoryItem item);
46 |
47 | ///
48 | /// Invoked when an inventory item is added to the
49 | /// inventory. Returns true if successful.
50 | ///
51 | bool AddInventoryItem(IInventoryItem item);
52 |
53 | ///
54 | /// Invoked when an inventory item is removed to the
55 | /// inventory. Returns true if successful.
56 | ///
57 | bool RemoveInventoryItem(IInventoryItem item);
58 |
59 | ///
60 | /// Invoked when an inventory item is removed from the
61 | /// inventory and should be placed on the ground.
62 | /// Returns true if successful.
63 | ///
64 | bool DropInventoryItem(IInventoryItem item);
65 | }
66 | }
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/IInventoryProvider.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 375396e56963d47b99bb5885a1d12553
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Unity Project/Packages/FarrokGames.Inventory/Runtime/InventoryController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace FarrokhGames.Inventory
6 | {
7 | public interface IInventoryController
8 | {
9 | Action onItemHovered { get; set; }
10 | Action onItemPickedUp { get; set; }
11 | Action onItemAdded { get; set; }
12 | Action onItemSwapped { get; set; }
13 | Action onItemReturned { get; set; }
14 | Action onItemDropped { get; set; }
15 | }
16 |
17 | ///
18 | /// Enables human interaction with an inventory renderer using Unity's event systems
19 | ///
20 | [RequireComponent(typeof(InventoryRenderer))]
21 | public class InventoryController : MonoBehaviour,
22 | IPointerDownHandler, IBeginDragHandler, IDragHandler,
23 | IEndDragHandler, IPointerExitHandler, IPointerEnterHandler,
24 | IInventoryController
25 | {
26 | // The dragged item is static and shared by all controllers
27 | // This way items can be moved between controllers easily
28 | private static InventoryDraggedItem _draggedItem;
29 |
30 | ///
31 | public Action onItemHovered { get; set; }
32 |
33 | ///
34 | public Action onItemPickedUp { get; set; }
35 |
36 | ///
37 | public Action onItemAdded { get; set; }
38 |
39 | ///
40 | public Action onItemSwapped { get; set; }
41 |
42 | ///
43 | public Action onItemReturned { get; set; }
44 |
45 | ///
46 | public Action onItemDropped { get; set; }
47 |
48 | private Canvas _canvas;
49 | internal InventoryRenderer inventoryRenderer;
50 | internal InventoryManager inventory => (InventoryManager) inventoryRenderer.inventory;
51 |
52 | private IInventoryItem _itemToDrag;
53 | private PointerEventData _currentEventData;
54 | private IInventoryItem _lastHoveredItem;
55 |
56 | /*
57 | * Setup
58 | */
59 | void Awake()
60 | {
61 | inventoryRenderer = GetComponent();
62 | if (inventoryRenderer == null) { throw new NullReferenceException("Could not find a renderer. This is not allowed!"); }
63 |
64 | // Find the canvas
65 | var canvases = GetComponentsInParent