From d871623d69b15602bde37ba9a480b391e97ffafc Mon Sep 17 00:00:00 2001 From: reng Date: Fri, 1 Aug 2025 16:13:18 +0800 Subject: [PATCH] update --- Assets/Scenes/SampleScene.unity | 24 +++++++++------ Assets/Scripts/SaveImage.cs | 53 +++++++++++++++++---------------- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index fe54b03..47d028d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -228,7 +228,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: "\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341" + m_text: "\u5728\u9019\u6BB5\u65C5\u7A0B\u4E2D\uFF0C\u6211\u6210\u9577\u3001\u5B78\u7FD2\uFF0C\u9762\u5C0D\u6311\u6230\uFF0C\u6536\u7A6B\u7121\u6578\u3002\u6211\u4E0D\u65B7\u63A2\u7D22\uFF0C\u8FFD\u6C42\u5922\u60F3\uFF0C\u73CD\u60DC\u6BCF\u500B\u77AC\u9593\u3002\u9019\u662F\u4E00\u751F\u96E3\u5FD8\u7684\u7D93\u6B77\u3002" m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 2f1ea7d7bb8b67740ae93a973eaf8fd9, type: 2} m_sharedMaterial: {fileID: -4264381060954844368, guid: 2f1ea7d7bb8b67740ae93a973eaf8fd9, type: 2} @@ -836,8 +836,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 113, y: 0} - m_SizeDelta: {x: 226, y: 0} + m_AnchoredPosition: {x: 83, y: 0} + m_SizeDelta: {x: 166, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &366298495 MonoBehaviour: @@ -944,7 +944,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 775.4286, y: -226} + m_AnchoredPosition: {x: 775.4286, y: -166} m_SizeDelta: {x: 255.14287, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &428712011 @@ -2574,7 +2574,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 159.4643, y: 0} - m_SizeDelta: {x: 226, y: 0} + m_SizeDelta: {x: 166, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &830016229 MonoBehaviour: @@ -2874,8 +2874,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 113, y: 0} - m_SizeDelta: {x: 226, y: 0} + m_AnchoredPosition: {x: 83, y: 0} + m_SizeDelta: {x: 166, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1060364296 MonoBehaviour: @@ -3347,7 +3347,7 @@ MonoBehaviour: m_Calls: - m_Target: {fileID: 1146279351} m_TargetAssemblyTypeName: SaveImage, Assembly-CSharp - m_MethodName: save + m_MethodName: Save m_Mode: 0 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -3372,6 +3372,9 @@ MonoBehaviour: uploader: {fileID: 1146279349} renderTexture: {fileID: 8400000, guid: 35e8ac38ef95d18419a5a58ab9299adf, type: 2} OutputFolder: output + FirebaseUrl: https://firestore.googleapis.com/v1/projects/uc-24070-thegreattipsy/databases/(default)/documents/ + TextNumber: {fileID: 1020432302} + TextSummary: {fileID: 225567322} --- !u!1 &1255800682 GameObject: m_ObjectHideFlags: 0 @@ -4024,7 +4027,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 483.39288, y: 0} - m_SizeDelta: {x: 254.25, y: 0} + m_SizeDelta: {x: 186.75, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1811530096 MonoBehaviour: @@ -4269,6 +4272,9 @@ MonoBehaviour: uploader: {fileID: 0} renderTexture: {fileID: 8400000, guid: 03a5ea2ccdc34a645ae9ebab8b7f7a8d, type: 2} OutputFolder: output + FirebaseUrl: https://firestore.googleapis.com/v1/projects/uc-24070-thegreattipsy/databases/(default)/documents/ + TextNumber: {fileID: 0} + TextSummary: {fileID: 0} --- !u!1 &1995476942 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/SaveImage.cs b/Assets/Scripts/SaveImage.cs index 0d2eea9..f440607 100644 --- a/Assets/Scripts/SaveImage.cs +++ b/Assets/Scripts/SaveImage.cs @@ -3,6 +3,7 @@ using Amazon.S3.Model; using UltraCombos.Upload; using OscJack; using System.Collections; +using TMPro; [System.Serializable] public class S3Tag @@ -22,6 +23,8 @@ public class SaveImage : MonoBehaviour public string FirebaseUrl = "https://firestore.googleapis.com/v1/projects/uc-24070-thegreattipsy/databases/(default)/documents/"; + public TextMeshProUGUI TextNumber; + public TextMeshProUGUI TextSummary; // Start is called before the first frame update void Start() @@ -38,8 +41,26 @@ public class SaveImage : MonoBehaviour - public void save(string filename) + public void Save(string input_text) { + + var parmas = input_text.Split('#'); + if (parmas.Length < 2) + { + Debug.LogError("Input text must contain at least two parts separated by '#'."); + return; + } + + string id = parmas[0].Trim(); + string summary = parmas[1].Trim(); + + TextNumber.text = id; + TextSummary.text = summary; + + + + string filename = $"{id}.png"; // Use the ID as the filename + if (string.IsNullOrEmpty(filename)) { Debug.LogError("Filename cannot be null or empty."); @@ -91,8 +112,9 @@ public class SaveImage : MonoBehaviour if (response.success) { Debug.Log("Upload successful: " + response.message); - - writeToFirebase(filename, response.message); + + writeToFirebase("prints", filename, response.message); + writeToFirebase("records", filename, response.message); } else { @@ -106,7 +128,7 @@ public class SaveImage : MonoBehaviour } } - public void writeToFirebase(string filename, string url) + public void writeToFirebase(string collection, string filename, string url) { Debug.Log("Writing to Firebase: " + filename); StartCoroutine(WriteToFirebaseCoroutine(filename, url)); @@ -116,7 +138,7 @@ public class SaveImage : MonoBehaviour string id=filename.Split('/')[2].Split('.')[0]; Debug.Log("Extracted ID: " + id); - string firebaseUrl = FirebaseUrl + "prints/" + id; + string firebaseUrl = FirebaseUrl + collection + "/" + id; string jsonData = "{ \"fields\": { " + "\"url\": { \"stringValue\": \"" + url + "\" }, " + "\"timestamp\": { \"timestampValue\": \"" + System.DateTime.UtcNow.ToString("o") + "\" } " + @@ -147,25 +169,6 @@ public class SaveImage : MonoBehaviour } } } - - public void sendOscMessage(string message) - { - // Implement your OSC message sending logic here - Debug.Log("Sending OSC message: " + message); - StartCoroutine(SendOscMessageCoroutine(message)); - } - public IEnumerator SendOscMessageCoroutine(string message){ - - using (var client = new OscClient("127.0.0.1", 9000)) - { - // Send two-component float values ten times. - for (var i = 0; i < 1; i++) - { - yield return new WaitForSeconds(0.5f); - client.Send("/uploaded", // OSC address - message); // Message content - } - } - } + } \ No newline at end of file