46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using Newtonsoft.Json;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AddPoint : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string pointString;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public GameObject prefab;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
[ContextMenu("Add")]
|
|
public void Add()
|
|
{
|
|
Debug.Log("AAA");
|
|
List<RobotMapPoint> point = JsonConvert.DeserializeObject<List<RobotMapPoint>>(pointString);
|
|
for(int i=0;i< point.Count; i++)
|
|
{
|
|
double x = point[i].display_x;
|
|
double y = point[i].display_y;
|
|
GameObject obj = GameObject.Instantiate(prefab, transform);
|
|
//obj.t.position = new Vector3((float)y, (float)x, 0);
|
|
obj.GetComponent<RectTransform>().localPosition= new Vector3((float)y, (float)x, 0);
|
|
obj.transform.name = "point" + (i + 1).ToString();
|
|
obj.SetActive(true);
|
|
}
|
|
}
|
|
}
|