Skip to content

Commit

Permalink
Merge pull request #1 from TamakiRuri/master
Browse files Browse the repository at this point in the history
Added wall mode support for import tool
  • Loading branch information
TamakiRuri authored Sep 20, 2024
2 parents b5b5408 + 52029f2 commit f5ff85d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
29 changes: 20 additions & 9 deletions EditorOnly/ImportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ public static void ShowExample()
ImportSettings wnd = GetWindow<ImportSettings>();
wnd.titleContent = new GUIContent("Item Lock Settings");
}
// list to process
List<String> userLists=new List<String>();
List<ItemList> itemLists=new List<ItemList>();

// final lists
List<String> userListFinal=new List<String>();
List<GameObject> targetItemFinal = new List<GameObject>();
List<int> actionModeFinal = new List<int>();
List<bool> allowOwnerFinal = new List<bool>();
List<bool> wallModeFinal = new List<bool>();

GameObject controlCenter;

Expand Down Expand Up @@ -81,14 +84,17 @@ public void CreateGUI()
SetupButtonHandler();
}
[Serializable]private struct ItemList{
public ItemList(GameObject target=null, int action=0, bool allow=false){
targetObject = target;
actionMode = action;
allowInstanceOwner = allow;
public ItemList(GameObject l_target=null, int l_action=0, bool l_allow=false, bool l_wall = false){
targetObject = l_target;
actionMode = l_action;
allowInstanceOwner = l_allow;
wallMode = l_wall;
}
public GameObject targetObject;
public int actionMode;
public bool allowInstanceOwner;

public bool wallMode;
}
private void ReloadItemData(){
VisualElement root = rootVisualElement;
Expand All @@ -97,14 +103,15 @@ private void ReloadItemData(){
GameObject[] l_objects = controlCenter.GetComponent<ItemLockDatabase>().exportObjectData();
int[] l_modes = controlCenter.GetComponent<ItemLockDatabase>().exportModeData();
bool[] l_allowOwner = controlCenter.GetComponent<ItemLockDatabase>().exportAllowOwnerData();
bool[] l_wallMode = controlCenter.GetComponent<ItemLockDatabase>().exportWallData();
ItemList[] l_list = new ItemList[l_objects.Length];
for (int i = 0; i < l_objects.Length; i++){
l_list[i] = new ItemList(l_objects[i], l_modes[i], l_allowOwner[i]);
l_list[i] = new ItemList(l_objects[i], l_modes[i], l_allowOwner[i], l_wallMode[i]);
}
itemLists = l_list.ToList();
userLists = l_usernames.ToList();
foreach (ItemList ll_list in itemLists){
Debug.Log("Game Object " + ll_list.targetObject + " Mode " + ll_list.actionMode + " Allow Owner " + ll_list.allowInstanceOwner + " Loaded");
Debug.Log("Game Object " + ll_list.targetObject + " Mode " + ll_list.actionMode + " Allow Owner " + ll_list.allowInstanceOwner + "Wall Mode" + ll_list.wallMode+" Loaded");
}
//add users
var userList = root.Q<ListView>("username");
Expand All @@ -122,6 +129,7 @@ private void ReloadItemData(){
(e.ElementAt(0).ElementAt(0) as ObjectField).value = itemLists[i].targetObject;
(e.ElementAt(0).ElementAt(1) as IntegerField).value = itemLists[i].actionMode;
(e.ElementAt(0).ElementAt(2) as BaseBoolField).value = itemLists[i].allowInstanceOwner;
(e.ElementAt(0).ElementAt(3) as BaseBoolField).value = itemLists[i].wallMode;
};
root.Q<Label>("result").text = "Data Loaded from Local Database";
}
Expand All @@ -145,9 +153,9 @@ private void UsernameHandler(TextField text){
private void TargetObjectHandler(VisualElement obj){
targetItemFinal.Add((GameObject)obj.Q<ObjectField>().value);
actionModeFinal.Add(obj.Q<IntegerField>().value);
allowOwnerFinal.Add(obj.Q<BaseBoolField>().value);
allowOwnerFinal.Add(obj.Q<BaseBoolField>("allow-owner").value);
wallModeFinal.Add(obj.Q<BaseBoolField>("wall-mode").value);
}
//data related functions not implemented
private void GenerateLockData(ClickEvent _event){
VisualElement root = rootVisualElement;
root.Q<Label>("result").text = "Wait";
Expand All @@ -156,6 +164,7 @@ private void GenerateLockData(ClickEvent _event){
targetItemFinal.Clear();
actionModeFinal.Clear();
allowOwnerFinal.Clear();
wallModeFinal.Clear();

try {
root.Query<TextField>("user").ForEach(UsernameHandler);
Expand All @@ -182,7 +191,9 @@ private void generateDatatoCenter(){
controlCenterUdon.SendMessage("importModes", modes);
bool[] allowowners = allowOwnerFinal.ToArray();
controlCenterUdon.SendMessage("importAllowOwner", allowowners);
controlCenter.GetComponent<ItemLockDatabase>().importObjectData(gameobjs, modes, allowowners);
bool[] wallmodes = wallModeFinal.ToArray();
controlCenterUdon.SendMessage("importWallModes", wallmodes);
controlCenter.GetComponent<ItemLockDatabase>().importObjectData(gameobjs, modes, allowowners, wallmodes);
}
//data related functions not implemented
private void DeleteLockData(ClickEvent _event){
Expand Down
1 change: 1 addition & 0 deletions EditorOnly/ItemListTemplate.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<uie:ObjectField name="target-object" label="Target Object" type="UnityEngine.GameObject, UnityEngine.CoreModule" />
<ui:IntegerField name="action-mode" label="Action Mode" value="0" />
<ui:Toggle name="allow-owner" label="Allow Instance Owner" />
<ui:Toggle name="wall-mode" label="Wall Mode" />
</ui:VisualElement>
</ui:UXML>
4 changes: 2 additions & 2 deletions EditorOnly/ItemLockDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class ItemLockDatabase : MonoBehaviour
public void importUsernames(String[] l_usernames){
usernames = l_usernames;
}
public void importObjectData(GameObject[] l_objects, int[] l_modes, bool[] l_allowOwner){
public void importObjectData(GameObject[] l_objects, int[] l_modes, bool[] l_allowOwner, bool[] l_wallModes){
ItemLockList[] l_list = new ItemLockList[l_objects.Length];
for (int i = 0; i < l_allowOwner.Length; i++){
ItemLockList l_entry = new ItemLockList(l_objects[i], l_modes[i], l_allowOwner[i], false);
ItemLockList l_entry = new ItemLockList(l_objects[i], l_modes[i], l_allowOwner[i], l_wallModes[i]);
l_list[i] = l_entry;
}
targetObjects = l_list;
Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ It works with colliders, so items like teleporters will also work.

パフォーマンス影響小 / Low performance cost.

Wall Mode: 指定した人だけがぬける壁(コライダー)、使えるテレポーターなどを作れます。

Use wall mode to make whitelisted players to go through certain walls or use teleporters etc.

### 注意事項 / Limitations

ジョイン時に実行されるため、ターゲットオブジェクトをスイッチでオンにするとスクリプトが無効になります。

そのため、ワールドでユーザーを追加したり、削除したりすることができません。

導入ツールでは許可の時にオブジェクト・コライダーを有効にするため、特定の人しか抜けない壁を作ったりすることができません。(次のBetaで導入予定、他の導入方法では利用できます。)

This script will be run at join, thus enabling the targets object with switches will make this script useless.

Therefore, adding or deleting whitelisted users in VRChat is not supported.

Using the import tool will enable the object or collider only when the person is whitelisted, thus creating a wall that only whitelisted people can go through is not currently supported. (Available at next beta, other methods work in this version)

### 導入

3種類の導入方法があります。 / There are three ways to import this gimmick.
Expand All @@ -58,9 +58,9 @@ Open Studio Saphir/Item Lock Settings at tool bar.

Using the + mark at bottom right corner and input usernames for whitelisted users.

アイテムリストを作ります。Target Object は対象アイテムです。Action Mode 0では許可されないユーザーがオブジェクトを見えない(無効モード)、1では動かせないです。Allow Instance Ownerを有効にすれば、インスタンスを作った人が許可されます。
アイテムリストを作ります。Target Object は対象アイテムです。Action Mode 0では許可されないユーザーがオブジェクトを見えない(無効モード)、1では動かせないです。Allow Instance Ownerを有効にすれば、インスタンスを作った人が許可されます。WallModeでは、指定した人だけがぬける壁(コライダー)、使えるテレポーターなどを作れます。

Create the item list. At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object.
Create the item list. At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object. Use wall mode to make whitelisted players to go through certain walls or use teleporters etc.

**一番上のGenerate Dataを押す。この作業は毎回編集する時に必要になります。**

Expand All @@ -70,10 +70,6 @@ ItemLockCenter(Managed)がシーンの中で配置されます。(動かさな

ItemLockCenter(Managed) will be placed at the scene. (Do not move this object) You can edit this using the same ways as advanced prefabs.

> Wall Mode を無効にするため、Wall Mode をご利用の方は下のPrefabをご利用ください。
> This scripts removes wall mode settings for now. Please use the prefab method to edit wall mode enabled objects.
#### Prefabを利用する / Use the prefab

![Sample2](./Sample2.png)
Expand All @@ -86,9 +82,9 @@ There are two types of prefabs. Advanced prefab allow editing modes and the opti

Using the + mark at bottom right corner and input usernames for whitelisted users.

アイテムリストを作ります。Target Object は対象アイテムです。Action Mode 0では許可されないユーザーがオブジェクトを見えない(無効モード)、1では動かせないです。Allow Instance Ownerを有効にすれば、インスタンスを作った人が許可されます。Wall Modeを有効にすれば、特定の人しか通れない壁が作れます
アイテムリストを作ります。Target Object は対象アイテムです。Action Mode 0では許可されないユーザーがオブジェクトを見えない(無効モード)、1では動かせないです。Allow Instance Ownerを有効にすれば、インスタンスを作った人が許可されます。WallModeでは、指定した人だけがぬける壁(コライダー)、使えるテレポーターなどを作れます

Create the item list. At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object. Enabling Wall Mode can allow creation of whitelisted walls that only allow whitelisted people to go through.
Create the item list. At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object. Use wall mode to make whitelisted players to go through certain walls or use teleporters etc.

**Advanced PrefabではGenerate Dataを押す。この作業は毎回編集する時に必要になります。**

Expand All @@ -106,4 +102,4 @@ Using the + mark at bottom right corner and input usernames for whitelisted user

Action Mode 0では許可されないユーザーがオブジェクトを見えない(無効モード)、1では動かせないです。Allow Instance Ownerを有効にすれば、インスタンスを作った人が許可されます。Wall Modeを有効にすれば、特定の人しか通れない壁が作れます。

At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object.Enabling Wall Mode can allow creation of whitelisted walls that only allow whitelisted people to go through.
At action mode 0 only whitelisted users can see the object, and at 1 only they can move the object. Use wall mode to make whitelisted players to go through certain walls or use teleporters etc.
Binary file added SimpleItemLock-b2.unitypackage
Binary file not shown.

0 comments on commit f5ff85d

Please sign in to comment.