67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
#if UNITY_EDITOR
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using Unity.Plastic.Newtonsoft.Json.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using Debug = UnityEngine.Debug;
|
|
|
|
namespace Blocks4u.Editor
|
|
{
|
|
public static class RPC
|
|
{
|
|
public static JToken Test(JArray @params)
|
|
{
|
|
var jObject = new JObject();
|
|
jObject.Add("KEK", new JValue("KEK"));
|
|
return jObject;
|
|
}
|
|
|
|
public static JToken GetCurrentScene(JArray @params)
|
|
{
|
|
return new JValue(SceneManager.GetActiveScene().name);
|
|
}
|
|
|
|
private static List<Transform> GetChildren(Transform parent)
|
|
{
|
|
return parent.Cast<Transform>().ToList();
|
|
}
|
|
|
|
private static JObject BuildHierarchy(Transform parent)
|
|
{
|
|
var tree = new JObject();
|
|
foreach (var child in GetChildren(parent))
|
|
{
|
|
tree[child.name] = BuildHierarchy(child);
|
|
}
|
|
|
|
return tree;
|
|
}
|
|
|
|
|
|
public static JToken GetSceneHierarchy(JArray @params)
|
|
{
|
|
var scene = SceneManager.GetSceneByName(@params[0].ToString());
|
|
|
|
var hierarchy = new JObject();
|
|
|
|
foreach (var root in scene.GetRootGameObjects())
|
|
{
|
|
hierarchy[root.name] = BuildHierarchy(root.transform);
|
|
}
|
|
|
|
return hierarchy;
|
|
}
|
|
|
|
public static JToken TestSession(JArray @params)
|
|
{
|
|
return new JValue(true);
|
|
}
|
|
}
|
|
}
|
|
#endif |