Browse Source

添加命令代码,修改实例化命令代码,修改BlueObject

蓝色星空 1 year ago
parent
commit
43a915e901

+ 18 - 0
Assets/Scripts/Blue/Command/GetGameObjectCommand.cs

@@ -0,0 +1,18 @@
+using Blue;
+using UnityEngine;
+
+public class GetGameObjectCommand : ICommand
+{
+    private GameObject obj;
+    public GetGameObjectCommand(GameObject obj)
+    {
+        this.obj = obj;
+    }
+    public void OnExcute()
+    {
+        if(InstantiateSystem.Instance.objDic.ContainsKey(obj.name))
+            InstantiateSystem.Instance.objDic[obj.name] = obj;
+        else
+            InstantiateSystem.Instance.objDic.Add(obj.name,obj);
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/Command/GetGameObjectCommand.cs.meta

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

+ 4 - 2
Assets/Scripts/Blue/Command/InstantiateCommand.cs

@@ -4,12 +4,14 @@ using UnityEngine;
 public class InstantiateCommand : ICommand
 {
     private GameObject prefab;
-    public InstantiateCommand(GameObject prefab)
+    private string content;
+    public InstantiateCommand(GameObject prefab,string content="")
     {
         this.prefab = prefab;
+        this.content = content;
     }
     public void OnExcute()
     {
-        InstantiateSystem.Instance.InstantiatePrefab(prefab);
+        InstantiateSystem.Instance.InstantiatePrefab(prefab, content);
     }
 }

+ 1 - 0
Assets/Scripts/Blue/ScriptableObject/BlueObject.cs

@@ -5,4 +5,5 @@ public class BlueObject : ScriptableObject
 {
     //可以包含更多的数据,信息
     public GameObject WarningPopUp;
+    public string NetErrorText;
 }

+ 1 - 0
Assets/Scripts/Blue/ScriptableObject/PrefabsAsset.asset

@@ -14,3 +14,4 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   WarningPopUp: {fileID: 2160148988178575977, guid: 725f0ac354735774cbc2e7c450ccb350,
     type: 3}
+  NetErrorText: "\u4FDD\u5B58\u5931\u8D25\\n\u670D\u52A1\u5668\u5F02\u5E38,\u8BF7\u7A0D\u540E\u91CD\u8BD5"

+ 1 - 1
Assets/Scripts/Net/HttpTool.cs

@@ -142,8 +142,8 @@ public class HttpTool : MonoSingleton<HttpTool>
 
             if (webRequest.isHttpError || webRequest.isNetworkError)
             {
-                Debug.LogError(webRequest.error + "\n" + webRequest.downloadHandler.text + "\n" + methodName);
                 CallBack?.Invoke("UnityWebRequest Error");
+                Debug.LogError(webRequest.error + "\n" + webRequest.downloadHandler.text + "\n" + methodName);
                 //GameManager.Instance.text2.text = webRequest.error;
             }
             else