-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPostionReset.cs
More file actions
63 lines (49 loc) · 1.46 KB
/
PostionReset.cs
File metadata and controls
63 lines (49 loc) · 1.46 KB
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
59
60
61
using System;
using System.Collections;
using UdonSharp;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using VRC.SDKBase;
using VRC.Udon;
public class PostionReset : UdonSharpBehaviour
{
public GameObject ParentObject;
public GameObject ResetLocation;
private GameObject[] objs;
void Start()
{
objs = new GameObject[ParentObject.transform.childCount];
for (int i = 0; i < ParentObject.transform.childCount; i++)
{
var child = ParentObject.transform.GetChild(i);
objs[i] = child.gameObject;
}
}
public override void Interact()
{
ResetItemsPosition();
}
public void ResetItemsPosition()
{
Networking.SetOwner(Networking.LocalPlayer, ParentObject);
for (int i = 0; i < ParentObject.transform.childCount; i++)
{
var child = ParentObject.transform.GetChild(i);
var pos = ResetLocation.transform.position;
Networking.SetOwner(Networking.LocalPlayer, child.gameObject);
child.transform.position = pos;
child.transform.localRotation = Quaternion.Euler(180, 0, 0);
}
}
private void SyncDrop()
{
for (int i = 0; i < objs.Length; i++)
{
if (Networking.IsOwner(objs[i].gameObject))
{
Networking.SetOwner(Networking.LocalPlayer, objs[i].gameObject);
}
}
}
}