Skip to content

Commit

Permalink
Changed Descriptions. Added some workarounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
TamakiRuri committed Dec 13, 2024
1 parent 791e21e commit 5045d94
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 294 deletions.
26 changes: 15 additions & 11 deletions EditorOnly/ItemLockDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ public class ItemLockDatabase : MonoBehaviour
{
[SerializeField] private String[] usernames;
[Header("必ずプレハブをUnpackしてからお使いください")]

[Header("Please UNPACK this prefab before using.")]

[Header(" ")]
[Header("Mode[0]アイテムが消える、[1]アイテムが触れなくなる")]
[Header("予め[0]オブジェクト[1]コライダーを無効にするとよりセキュアになります")]
[Header("全ての操作がJoin時に終わるため")]
[Header("スイッチでオブジェクト(コライダー)を有効にするとロックが解除されます")]
[Header("Wall Modeでは、動作が逆になります(壁などを一部の人だけがぬけるようにするなど)")]
[Header("導入したあと、下のスクリプトにデータが表示されます")]

[Header("Modeに関する詳しい説明は、Githubおよび商品ページにあります。")]

[Header("Specific Inforamtion is on the github and booth page")]

[Header("Github: https://github.com/TamakiRuri/SimpleItemLock")]

[Header("Booth: https://saphir.booth.pm/items/6375850")]

[Header(" ")]
[Header("Mode 0 will make the item disappear, 1 will make the item not touchable")]
[Header("Deactivating[0]objects[1]colliders before uploading is recommanded for better security")]
[Header("However, the item will be unlocked if a switch enables the object(collider) directly")]
[Header("In Wall Mode the function of the script become reversed.")]
[Header("(for creating walls that can only be go through by whitelisted users)")]

[Header("導入したあと、下のスクリプトにデータが表示されます")]

[Header("If the data is correctly imported, The script below will show the imported data")]

[Header(" ")]

[SerializeField] private ItemLockList[] targetObjects;
Expand Down
43 changes: 14 additions & 29 deletions ItemLockBasic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,25 @@ public class ItemLockBasic : UdonSharpBehaviour
[SerializeField] private GameObject targetObject;
[SerializeField] private String[] usernames;

[Header("Mode[0]アイテムが消える、[1]アイテムが触れなくなる")]
[Header("[1]予めコライダーを無効にするとよりセキュアになります")]
[Header("[0]このスクリプトがオブジェクトにアタッチしたまま無効にしないでください")]
[Header("スイッチでオブジェクト(コライダー)を有効にするとロックが解除されます。")]
[Header("Modeに関する詳しい説明は、Githubおよび商品ページにあります。")]

[Header("Specific Inforamtion is on the github and booth page")]

[Header("Mode 0 will make the item disappear, 1 will make the item not touchable")]
[Header("[1]Deactivating colliders before uploading is recommanded for better security")]
[Header("[0]Don't deactivate the game object if this script is attacted to it.")]
[Header("The item will be unlocked if a switch enables the object(collider) directly")]
[Header("Github: https://github.com/TamakiRuri/SimpleItemLock")]

[Header(" ")]
[Header("Booth: https://saphir.booth.pm/items/6375850")]

[Header(" ")]

[SerializeField] private int actionMode = 0;

[SerializeField] private bool allowInstanceOwner = false;

[Header("Wall Modeでは、動作が逆になります(壁などを一部の人だけがぬけるようにするなど)")]
[Header("In Wall Mode the function of the script become reversed (for creating walls that can only be go through by whitelisted users).")]
[Header(" ")]

[SerializeField] private bool wallMode = false;

private bool shouldOn = false;
private Collider targetCollider;

void Start()
{
if (targetObject == null) targetObject = gameObject;
shouldOn = UserCheck();
if (actionMode == 1)
{
targetCollider = targetObject.GetComponent<Collider>();
if (targetCollider == null)
{
Debug.LogError("Item Lock: This object is in Action Mode 1 but the Collider can't be detected");
Debug.LogError("Item Lock: このオブジェクトの動作モードがAction Mode 1ですがコライダーを取得できません");
return;
}
}
// (shouldOn && !wallMode) || (!shouldOn && wallMode)
// in non wall mode, output == shouldOn
// in wall mode, output == !shouldOn
Expand Down Expand Up @@ -88,7 +66,14 @@ private void ScriptAction(int mode, bool targetState)
targetObject.SetActive(targetState);
break;
case 1:
targetObject.GetComponent<Collider>().enabled = targetState;
Collider targetCollider = targetObject.GetComponent<Collider>();
if (targetCollider == null)
{
Debug.LogError("Item Lock: This object is in Action Mode 1 but the Collider can't be detected");
Debug.LogError("Item Lock: このオブジェクトの動作モードがAction Mode 1ですがコライダーを取得できません");
}
else
targetCollider.enabled = targetState;
break;
case 2:
ColliderRecursive(targetState);
Expand Down Expand Up @@ -192,7 +177,7 @@ private void ColliderRecursive(bool targetState)
public void ImportUsernames(String[] importedUsernames)
{
usernames = importedUsernames;
Debug.Log("Username Imported");
Debug.Log("Item Lock Basic: Username Imported");
}


Expand Down
44 changes: 22 additions & 22 deletions ItemLockCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,18 @@ public class ItemLockCenter : UdonSharpBehaviour
[SerializeField] private GameObject[] targetObjects;


[Header("Mode[0]アイテムが消える、[1]アイテムが触れなくなる")]
[Header("予め[0]オブジェクト[1]コライダーを無効にするとよりセキュアになります")]
[Header("全ての操作がJoin時に終わるため")]
[Header("スイッチでオブジェクト(コライダー)を有効にするとロックが解除されます。")]
[Header("Modeに関する詳しい説明は、Githubおよび商品ページにあります。")]

[Header("Specific Inforamtion is on the github and booth page")]

[Header("Mode 0 will make the item disappear, 1 will make the item not touchable")]
[Header("Deactivating[0]objects[1]colliders before uploading is recommanded for better security")]
[Header("However, the item will be unlocked if a switch enables the object(collider) directly")]
[Header("Github: https://github.com/TamakiRuri/SimpleItemLock")]

[Header(" ")]
[Header("Booth: https://saphir.booth.pm/items/6375850")]

[Header(" ")]

[SerializeField] private int actionMode = 0;
[SerializeField] private bool allowInstanceOwner = false;

[Header("Wall Modeでは、動作が逆になります(壁などを一部の人だけがぬけるようにするなど)")]
[Header("In Wall Mode the function of the script become reversed (for creating walls that can only be go through by whitelisted users).")]
[Header(" ")]
[SerializeField] private bool wallMode = false;
private bool shouldOn = false;
void Start()
Expand All @@ -38,9 +31,9 @@ void Start()
// (shouldOn && !wallMode) || (!shouldOn && wallMode)
// in non wall mode, output == shouldOn
// in wall mode, output == !shouldOn
foreach (GameObject _gameObject in targetObjects)
foreach (GameObject targetObject in targetObjects)
{
ScriptAction(_gameObject, actionMode, (shouldOn && !wallMode) || (!shouldOn && wallMode));
ScriptAction(targetObject, actionMode, (shouldOn && !wallMode) || (!shouldOn && wallMode));
}

}
Expand All @@ -63,23 +56,30 @@ private bool UserCheck()
}
return false;
}
private void ScriptAction(GameObject _gameObject, int mode, bool targetState)
private void ScriptAction(GameObject targetObject, int mode, bool targetState)
{
switch (mode)
{
case 0:
_gameObject.SetActive(targetState);
targetObject.SetActive(targetState);
break;
case 1:
_gameObject.GetComponent<Collider>().enabled = targetState;
Collider targetCollider = targetObject.GetComponent<Collider>();
if (targetCollider == null)
{
Debug.LogError("Item Lock: This object is in Action Mode 1 but the Collider can't be detected");
Debug.LogError("Item Lock: このオブジェクトの動作モードがAction Mode 1ですがコライダーを取得できません");
}
else
targetCollider.enabled = targetState;
break;
case 2:
ColliderRecursive(_gameObject, targetState);
ColliderRecursive(targetObject, targetState);
break;
case 3:
ColliderRecursive(_gameObject, targetState);
MeshRendererRecursive(_gameObject, targetState);
SkinnedMeshRendererRecursive(_gameObject, targetState);
ColliderRecursive(targetObject, targetState);
MeshRendererRecursive(targetObject, targetState);
SkinnedMeshRendererRecursive(targetObject, targetState);
break;
default:
Debug.LogError("Item Lock: Action Mode Index Out Of Bound.");
Expand Down Expand Up @@ -137,7 +137,7 @@ private void ColliderRecursive(GameObject targetObject, bool targetState)
public void ImportUsernames(String[] importedUsernames)
{
usernames = importedUsernames;
Debug.Log("Username Imported");
Debug.Log("Item Lock Center: Username Imported");
}
public String[] ExportUsernames()
{
Expand Down
18 changes: 13 additions & 5 deletions ItemLockCenterAdvanced.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ private void ScriptAction(GameObject targetObject, int mode, bool targetState)
targetObject.SetActive(targetState);
break;
case 1:
targetObject.GetComponent<Collider>().enabled = targetState;
Collider targetCollider = targetObject.GetComponent<Collider>();
if (targetCollider == null)
{
Debug.LogError("Item Lock: This object is in Action Mode 1 but the Collider can't be detected");
Debug.LogError("Item Lock: このオブジェクトの動作モードがAction Mode 1ですがコライダーを取得できません");
}
else
targetCollider.enabled = targetState;
break;
case 2:
ColliderRecursive(targetObject, targetState);
Expand Down Expand Up @@ -135,26 +142,27 @@ public void ImportLockData(GameObject[] l_gameObject, int[] l_modes, bool[] l_al
actionMode = l_modes;
allowInstanceOwner = l_allowOwner;
wallModes = l_wallModes;
Debug.Log("Item Lock Advanced: Data Imported");
}
public void ImportTargets(GameObject[] importedGameObjects)
{
targetObjects = importedGameObjects;
Debug.Log("Target GameObjects Imported");
Debug.Log("Item Lock Advanced: Target GameObjects Imported");
}
public void ImportModes(int[] importedModes)
{
actionMode = importedModes;
Debug.Log("Action Modes Imported");
Debug.Log("Item Lock Advanced: Action Modes Imported");
}
public void ImportAllowOwner(bool[] importedAllowOwner)
{
allowInstanceOwner = importedAllowOwner;
Debug.Log("Allow Instance Owner Settings Imported");
Debug.Log("Item Lock Advanced: Allow Instance Owner Settings Imported");
}
public void ImportWallModes(bool[] importedWallModes)
{
wallModes = importedWallModes;
Debug.Log("Wall Mode Settings Imported");
Debug.Log("Item Lock Advanced: Wall Mode Settings Imported");
}
// Export Functions (not in use)
public String[] ExportUsernames()
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,33 @@ Only whitelisted users will be able to interact or grab the item. The Collision

Target: target object itself. Child objects won't be affected. The target object should have collider directly attached.

#### Alpha - Mode 2 - コライダー一括モード/Collider Inclusive Mode
#### Mode 2 - コライダー一括モード/Collider Inclusive Mode

> コライダーを利用するギミックに干渉する可能性があります。アンロックしない想定のモードです
> コライダーコンポーネントのオンオフを制御するため、コライダーを利用するギミックに干渉する可能性があります。
許可されていないプレイヤーには、このオブジェクトおよび子オブジェクトのすべてのコライダーが無効になります。それ以外のスクリプトは正常に同期されます。

範囲: オブジェクトおよびすべての子オブジェクト

使用例: いくつかのオブジェクトのコライダーを一括管理する場合や、ギミックのコライダー構成が複雑な場合。

> This could potentially break other gimmicks that rely on colliders. This isn't designed to be unlocked.
> This could potentially break other gimmicks that rely on colliders.
Works the same as Mode 1 but all colliders on child objects will also going to be switched off.
Works the same as Mode 1 but all colliders on child objects will also be switched off.

#### Alpha - Mode 3 - コライダー一括&消失モード(仮)/Collider & Invisible Inclusive Mode
#### Mode 3 - コライダー一括&不可視モード/Collider & Invisible Inclusive Mode

> コライダー/Rendererを利用するギミックに干渉する可能性があります。アンロックしない想定のモードです
> コライダー/Rendererコンポーネントのオンオフを制御するため、それらを利用するギミックに干渉する可能性があります
許可されていないプレイヤーには、このオブジェクトおよび子オブジェクトのすべてのコライダー、MeshとSkinned Mesh Rendererが無効になります。そのため、アイテムが見られないままスクリプトの実行ができます。それ以外のスクリプトは正常に同期されます。

子オブジェクトにあるもののMesh RendererとSkinned Mesh Rendererがすべて無効になります。(ただし、パーティクル、UI、Spriteなどは正常に動作します)もし子オブジェクトに表示させたいものがありましたら、別のオブジェクトに移動してください。

範囲: オブジェクトおよびすべての子オブジェクト

使用例: ギミックの本体を隠したままギミック機能を利用する場合。

> This could potentially break other gimmicks that rely on colliders, mesh and skinned mesh renderers. This isn't designed to be unlocked.
> This could potentially break other gimmicks that rely on colliders, mesh and skinned mesh renderers.
Mode 2 with disabling all mesh and skinned mesh renderers to make the target object invisible.

Expand All @@ -88,7 +90,6 @@ Allow the player who create this instance to use the item.

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


### 注意事項 / Limitations

いたずら防止のためのギミックです。すべての状況に対応するものではありません。
Expand Down Expand Up @@ -131,6 +132,12 @@ From Beta-b4, due to the Stack Overflow issue, the import tool is removed.

From RC-b7, some variable names are changed. So in case of an update, please make sure you have a backup.

### 問題と回避策 / Limitations and workaround

1. インタラプトでテレポートするドアなどに対応するモードがない / No modes applicatable to doors that rely on interaction to teleport.

A: ドア(またはコライダーが入っている部分)をMode 1に設定して、その後ろに別のオブジェクトでコライダーを設定してください。

### 導入

2種類の導入方法があります。 / There are 2 ways to import this gimmick.
Expand Down
Binary file added SimpleItemLock-b11.unitypackage
Binary file not shown.
Binary file removed SimpleItemLock-b9.unitypackage
Binary file not shown.
Loading

0 comments on commit 5045d94

Please sign in to comment.