浮动小游戏已经基本搞好
新做了两个设置界面 一些bug修复和优化
This commit is contained in:
@@ -2,6 +2,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
@@ -9,6 +10,7 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
public Image card_icon_image;
|
||||
public Text card_name_text;
|
||||
public Text authorName_text;
|
||||
public Text versionCode_text;
|
||||
public Text description_text;
|
||||
public Text _isOfficial_text;
|
||||
public Text source_text;
|
||||
@@ -21,7 +23,7 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
private string indexFilePath;
|
||||
|
||||
// 给 loadLittleGamesPrefab 调用以填充文本和路径
|
||||
public void SetData(string indexPath, string cardName, string authorName, string description, string isOfficial, string source, string yyyyMmDd)
|
||||
public void SetData(string indexPath, string cardName, string authorName, string description, string isOfficial, string source, string yyyyMmDd, string version = null)
|
||||
{
|
||||
indexFilePath = indexPath;
|
||||
if (card_name_text != null) card_name_text.text = cardName ?? "";
|
||||
@@ -31,7 +33,11 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
if (source_text != null) source_text.text = source ?? "";
|
||||
if (yyyy_mm_dd != null) yyyy_mm_dd.text = yyyyMmDd ?? "";
|
||||
|
||||
UnityEngine.Debug.Log($"game_card_Prefab.SetData: indexPath='{indexFilePath}', card_name='{cardName}', author='{authorName}', isOfficial='{isOfficial}', source='{source}'");
|
||||
// version
|
||||
string ver = string.IsNullOrEmpty(version) ? "0.0.0" : version;
|
||||
if (versionCode_text != null) versionCode_text.text = ver;
|
||||
|
||||
UnityEngine.Debug.Log($"game_card_Prefab.SetData: indexPath='{indexFilePath}', card_name='{cardName}', author='{authorName}', isOfficial='{isOfficial}', source='{source}', version='{ver}'");
|
||||
}
|
||||
|
||||
void Awake()
|
||||
@@ -110,6 +116,21 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
UnityEngine.Debug.Log("Calling WebViewLauncher.OpenUrl with: " + indexFilePath);
|
||||
WebViewLauncher.Instance.OpenUrl(indexFilePath);
|
||||
|
||||
// After initiating navigation, set the input field display to localhost::parent/index.html
|
||||
try
|
||||
{
|
||||
if (WebViewLauncher.Instance != null && WebViewLauncher.Instance.urlInputField != null)
|
||||
{
|
||||
string parent = Path.GetFileName(Path.GetDirectoryName(indexFilePath));
|
||||
string display = $"localhost::{parent}/{Path.GetFileName(indexFilePath)}";
|
||||
WebViewLauncher.Instance.urlInputField.text = display;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("Failed to set url input display: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,6 +141,20 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
UnityEngine.Debug.Log("Found launcher in scene, calling OpenUrl: " + indexFilePath);
|
||||
launcherObj.OpenUrl(indexFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
if (launcherObj.urlInputField != null)
|
||||
{
|
||||
string parent = Path.GetFileName(Path.GetDirectoryName(indexFilePath));
|
||||
string display = $"localhost::{parent}/{Path.GetFileName(indexFilePath)}";
|
||||
launcherObj.urlInputField.text = display;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("Failed to set url input display: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,6 +164,20 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
var launcher = go.AddComponent<WebViewLauncher>();
|
||||
launcher.OpenUrl(indexFilePath);
|
||||
GameObject.DontDestroyOnLoad(go);
|
||||
|
||||
try
|
||||
{
|
||||
if (launcher.urlInputField != null)
|
||||
{
|
||||
string parent = Path.GetFileName(Path.GetDirectoryName(indexFilePath));
|
||||
string display = $"localhost::{parent}/{Path.GetFileName(indexFilePath)}";
|
||||
launcher.urlInputField.text = display;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("Failed to set url input display: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user