Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f committed May 16, 2020
2 parents 14ff810 + 4c72ef2 commit acd0835
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 16 deletions.
43 changes: 34 additions & 9 deletions Assets/Mochizuki/VRChat/InventorySystem/Editor/InventoryEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ namespace Mochizuki.VRChat.InventorySystem
{
public class InventoryEditor : EditorWindow
{
private GameObject _avatar;
private Collider _collider;
private const string DefaultOffPrefabGuid = "c60b79bdc1de7d247b272b70086e6580";
private const string DefaultOnPrefabGuid = "deff4827e5a63f740ababf687a316661";

private GameObject _collider;
private bool _isUseDefaultOnPrefab;
private GameObject _object;
private GameObject _parent;
private GameObject _prefab;
Expand All @@ -29,35 +32,51 @@ public static void ShowWindow()
public void OnGUI()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Prefab Information : ");

_isUseDefaultOnPrefab = EditorGUILayout.Toggle(new GUIContent("Use DefaultON Prefab"), _isUseDefaultOnPrefab);

EditorGUI.BeginDisabledGroup(true);

_prefab = ObjectPicker("Inventory Prefab", _prefab);
_prefab = ObjectPicker("Prefab", GetPrefab(_isUseDefaultOnPrefab));

EditorGUI.EndDisabledGroup();

EditorGUILayout.Space();
EditorGUILayout.LabelField("Your Inventory Information:");
EditorGUILayout.LabelField("Inventory Information : ");

_avatar = ObjectPicker("Avatar", _avatar);
_collider = ObjectPicker("Collider", _collider);
_object = ObjectPicker("Object", _object);
_parent = ObjectPicker("Inventory Parent", _parent);

EditorGUI.BeginDisabledGroup(_prefab == null || _avatar == null || _collider == null || _object == null || _parent == null);
EditorGUI.BeginDisabledGroup(_prefab == null || _collider == null || _object == null || _parent == null);

if (GUILayout.Button("Unpack and Configure Prefab (Breaking)")) ConfigurePrefab();

EditorGUI.EndDisabledGroup();
}

private static GameObject GetPrefab(bool useDefaultOnPrefab)
{
var guid = useDefaultOnPrefab ? DefaultOnPrefabGuid : DefaultOffPrefabGuid;
var path = AssetDatabase.GUIDToAssetPath(guid);

return AssetDatabase.LoadAssetAtPath<GameObject>(path);
}

private static T ObjectPicker<T>(string label, T obj) where T : Object
{
return EditorGUILayout.ObjectField(new GUIContent(label), obj, typeof(T), true) as T;
}

private void ConfigurePrefab()
{
PrefabUtility.UnpackPrefabInstance(_prefab, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
var prefab = (GameObject) PrefabUtility.InstantiatePrefab(_prefab);

PrefabUtility.UnpackPrefabInstance(prefab, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);

// configure
foreach (var transform in _prefab.GetComponentsInChildren<Transform>(true))
foreach (var transform in prefab.GetComponentsInChildren<Transform>(true))
switch (transform.name)
{
case "InventoryObject":
Expand Down Expand Up @@ -89,7 +108,13 @@ private void ConfigurePrefab()
}

// cleanup
DestroyImmediate(_prefab);
DestroyImmediate(prefab);

_isUseDefaultOnPrefab = false;
_collider = null;
_object = null;
_parent = null;
_prefab = null;
}
}
}
21 changes: 21 additions & 0 deletions Assets/Mochizuki/VRChat/InventorySystem/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Fuyuno Mikazuki / Natsuneko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions Assets/Mochizuki/VRChat/InventorySystem/LICENSE.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5313,7 +5313,7 @@ ParticleSystem:
startLifetime:
serializedVersion: 2
minMaxState: 0
scalar: 0.25
scalar: 0.15
minScalar: 5
maxCurve:
serializedVersion: 2
Expand Down Expand Up @@ -10077,7 +10077,7 @@ ParticleSystem:
lengthInSec: 0.1
simulationSpeed: 1
stopAction: 0
cullingMode: 0
cullingMode: 3
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
looping: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ ParticleSystem:
startLifetime:
serializedVersion: 2
minMaxState: 0
scalar: 0.25
scalar: 0.15
minScalar: 5
maxCurve:
serializedVersion: 2
Expand Down Expand Up @@ -5064,7 +5064,7 @@ ParticleSystem:
lengthInSec: 0.1
simulationSpeed: 1
stopAction: 0
cullingMode: 0
cullingMode: 3
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
looping: 0
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ Experimental Unity Project that provides Inventory System in VRChat.
- This system used new features in Unity 2018.3.
- VRChat 2020.1 or higher

## How to use
## How to use (Japanese)

https://docs.mochizuki.moe/VRChat/InventorySystem

## How to use (English)

### Preparation

1. Download UnityPackage from [Releases](https://github.com/mika-f/VRChat-InventorySystem/releases).
1. Download UnityPackage from [BOOTH](https://natsuneko.booth.pm/items/2041145) or build by yourself.
1. Import UnityPackage to your avatar project.
1. Drag and Drop `InventorySystem_DefaultXXX.prefab` to your hierarchy tree.

### Automatically Setup (Recommend)

1. Open `Inventory Editor` from `Mochizuki/VRChat/Inventory Editor` in menubar.
1. Drag and Drop `InventorySystem_DefaultXXX` into the `Inventory Prefab` field.
1. Drag and Drop avatar GameObject into the `Avatar` field.
1. Drag and Drop collider GameObject into the `Collider` field.
1. Drag and Drop object that you want to in and out into the `Object` field.
Expand Down

0 comments on commit acd0835

Please sign in to comment.