-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathSetTeleport.cs
37 lines (31 loc) · 1.07 KB
/
SetTeleport.cs
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
#if UNITY_EDITOR
using System;
using Unity.Netcode.Components;
using UnityEditor;
using UnityEngine;
public class SetTeleport : MonoBehaviour
{
public void Set(Vector3 pos)
{
// GetComponent<NetworkTransform>().Teleport(pos, transform.rotation, transform.localScale);
GetComponent<NetworkTransform>().SetState(pos, transform.rotation, transform.localScale, false);
}
[CustomEditor(typeof(SetTeleport))]
public class GameEventEditor : Editor
{
private string m_Pos = "position";
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var setterObject = (SetTeleport)target;
GUILayout.TextArea($"Current pos: {setterObject.transform.position}");
m_Pos = GUILayout.TextField(m_Pos);
if (GUILayout.Button("Set"))
{
var posParsed = m_Pos.Split(',');
setterObject.Set(new Vector3(Convert.ToUInt32(posParsed[0]), Convert.ToUInt32(posParsed[1]), Convert.ToUInt32(posParsed[2])));
}
}
}
}
#endif