更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

View File

@@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Linq;
using System.Net;
using UnityEngine.UIElements;
using System.IO;
namespace BITKit
{
public class ApplyJson : Provider
{
public TranslateSO translateSO;
public override void Set<T>(T obj)
{
switch (obj)
{
case string _string:
if (translateSO)
{
_string = translateSO.Get(_string, false);
}
DataParser.Set(_string);
Debug.Log("已加载Json配置...");
break;
case IDictionary<string, string> _dictionary:
if (_dictionary.Count is 1 && _dictionary.Keys.ElementAt(0) is "value" or "json")
{
DataParser.Set(_dictionary.Values.ElementAt(0));
}
foreach (var pair in _dictionary)
{
DataParser.Set(pair.Key, pair.Value);
}
break;
case HttpListenerRequest _request:
System.IO.Stream body = _request.InputStream;
System.Text.Encoding encoding = _request.ContentEncoding;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
if (_request.ContentType != null)
{
// Debug.Log("Client data content type {0}" + _request.ContentType);
}
//Debug.Log("Client data content length {0}" + _request.ContentLength64);
//Debug.Log("Start of client data:");
// Convert the data to a string and display it on the console.
string s = reader.ReadToEnd();
//Debug.Log(s);
//Debug.Log("End of client data:");
body.Close();
reader.Close();
if (translateSO)
{
s = translateSO.Get(s, false);
}
DataParser.Set(s);
break;
}
}
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(ApplyJson))]
public class ApplyJsonInspector : BITInspector<ApplyJson>
{
TextField textField;
public override VisualElement CreateInspectorGUI()
{
FillDefaultInspector(root, serializedObject, true);
textField = root.Create<TextField>();
var button = root.Create<Button>();
textField.isDelayed = true;
textField.multiline = true;
button.clicked += Excute;
button.text = "应用Json";
return root;
}
void Excute()
{
BITAppForUnity.ThrowIfNotPlaying();
agent.Set(textField.value);
}
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c0356767b94f764b8d8d3f14d01f016
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public class SetData : Provider<string>
{
[SerializeReference,SubclassSelector]public References key;
public override string Get()
{
throw new System.NotImplementedException();
}
public override void Set(string t)
{
Data.Set(key, t);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a622433d198bfe54fa1c7036f2bb22c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: