diff --git a/Assets/Plugins/CookieManager.jslib b/Assets/Plugins/CookieManager.jslib
new file mode 100644
index 0000000..b0bc8e1
--- /dev/null
+++ b/Assets/Plugins/CookieManager.jslib
@@ -0,0 +1,23 @@
+function SetClearTimes(clearTimes) {
+ document.cookie = "clear_times=" + clearTimes + ";max-age=31536000";
+ console.log("Set clearTimes = %d ", clearTimes);
+}
+
+// TODO: 現在の実装だとclearTimes以外の保存したいデータに対応できないので修正
+function GetClearTimes() {
+ var clearTimes;
+ try {
+ clearTimes = parseInt(document.cookie.split("=")[1]);
+ console.log("clearTimes = %d ", clearTimes);
+ } catch {
+ console.log("Unable Get clearTimes", clearTimes);
+ }
+ return clearTimes;
+}
+
+const cookiePlugins = {};
+cookiePlugins[SetClearTimes.name] = SetClearTimes;
+cookiePlugins[GetClearTimes.name] = GetClearTimes;
+
+// Unity側へ反映
+mergeInto(LibraryManager.library, cookiePlugins);
diff --git a/Assets/Plugins/CookieManager.jslib.meta b/Assets/Plugins/CookieManager.jslib.meta
new file mode 100644
index 0000000..9c46f80
--- /dev/null
+++ b/Assets/Plugins/CookieManager.jslib.meta
@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: 9ebdc4c1eab7d4dc5bf6810c1a9cc7a1
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ WebGL: WebGL
+ second:
+ enabled: 1
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scenes/Title.unity b/Assets/Scenes/Title.unity
index 431d934..3f9b7f1 100644
--- a/Assets/Scenes/Title.unity
+++ b/Assets/Scenes/Title.unity
@@ -123,6 +123,98 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
+--- !u!1 &166402754
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 166402755}
+ - component: {fileID: 166402758}
+ - component: {fileID: 166402756}
+ - component: {fileID: 166402759}
+ m_Layer: 5
+ m_Name: ClearTimes
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &166402755
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 166402754}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 232318860}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0.5, y: 0.5}
+ m_AnchorMax: {x: 0.5, y: 0.5}
+ m_AnchoredPosition: {x: 310, y: 180}
+ m_SizeDelta: {x: 300, y: 30}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!114 &166402756
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 166402754}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
+ m_RaycastTarget: 1
+ m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+ m_Maskable: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_FontData:
+ m_Font: {fileID: 12800000, guid: bacbf1a90b8e34ca9a11eef6ce0e0aec, type: 3}
+ m_FontSize: 30
+ m_FontStyle: 0
+ m_BestFit: 0
+ m_MinSize: 0
+ m_MaxSize: 100
+ m_Alignment: 2
+ m_AlignByGeometry: 0
+ m_RichText: 1
+ m_HorizontalOverflow: 0
+ m_VerticalOverflow: 0
+ m_LineSpacing: 1
+ m_Text: "\u30AF\u30EA\u30A2\u56DE\u6570: --"
+--- !u!222 &166402758
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 166402754}
+ m_CullTransparentMesh: 1
+--- !u!114 &166402759
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 166402754}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: ddfcfaff71e0d4dd1afcb3460ff78739, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
--- !u!1 &232318856
GameObject:
m_ObjectHideFlags: 0
@@ -220,6 +312,7 @@ RectTransform:
- {fileID: 286217875}
- {fileID: 990477082}
- {fileID: 1867554084}
+ - {fileID: 166402755}
- {fileID: 374588864}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -3250,7 +3343,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
- m_Text: 'Device: PC'
+ m_Text: 'Device: --'
--- !u!114 &1867554086
MonoBehaviour:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/ClearTimesText.cs b/Assets/Scripts/ClearTimesText.cs
new file mode 100644
index 0000000..6495524
--- /dev/null
+++ b/Assets/Scripts/ClearTimesText.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using Utility;
+
+///
+/// タイトルでクリア回数を表示する
+///
+public class ClearTimesText : MonoBehaviour
+{
+ private Text text;
+ private int clearTimes = -1;
+
+ void Awake()
+ {
+ text = GetComponent();
+#if UNITY_WEBGL && !UNITY_EDITOR
+ clearTimes = WebGL.GetClearTimes();
+#endif
+ text.text = "クリア回数: " + clearTimes.ToString();
+ }
+
+ void Start()
+ {
+ }
+
+}
diff --git a/Assets/Scripts/ClearTimesText.cs.meta b/Assets/Scripts/ClearTimesText.cs.meta
new file mode 100644
index 0000000..3ccf06a
--- /dev/null
+++ b/Assets/Scripts/ClearTimesText.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ddfcfaff71e0d4dd1afcb3460ff78739
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/DeviceTypeText.cs b/Assets/Scripts/DeviceTypeText.cs
index 462939b..29fe984 100644
--- a/Assets/Scripts/DeviceTypeText.cs
+++ b/Assets/Scripts/DeviceTypeText.cs
@@ -4,6 +4,9 @@
using UnityEngine.UI;
using Utility;
+///
+/// タイトルでデバイス種別を表示するためのスクリプト
+///
public class DeviceTypeText : MonoBehaviour
{
private Text text;
diff --git a/Assets/Scripts/Endroll.cs b/Assets/Scripts/Endroll.cs
index 8f8f6a4..7919c83 100644
--- a/Assets/Scripts/Endroll.cs
+++ b/Assets/Scripts/Endroll.cs
@@ -29,26 +29,33 @@ public class Endroll : MonoBehaviour
};
private string company = "九州工業大学\nプログラミング研究会";
private string clearTimeText;
+ private int clearTimes = -1;
private Vector3 logoPos = new Vector3(0.0f, 1.6f, 0.0f);
- void Start()
+ void Awake()
{
tex = GetComponent();
-
stopWatch = GameObject.Find("StopWatch").GetComponent().stopWatch;
- float totalSec = (float)(stopWatch.Elapsed.TotalMilliseconds / 1000);
+#if UNITY_WEBGL && !UNITY_EDITOR
+ clearTimes = WebGL.GetClearTimes();
+#endif
+ }
+
+ void Start()
+ {
+ float totalSec = (float)(stopWatch.Elapsed.TotalMilliseconds / 1000);
clearTimeText = "クリアタイム\n" + stopWatch.Elapsed.ToString(@"mm\:ss\.ff") + "\nCongratulation!!!\n";
clearTimeText += totalSec.ToString() + "秒としてランキングに掲載しました";
-#if UNITY_EDITOR
- // 何もしない
- // エディター上で実行した際のタイムを登録しないようにするため
-#else
+#if UNITY_WEBGL && !UNITY_EDITOR
// unityroomのランキングへ登録
UnityroomApiClient.Instance.SendScore(1, totalSec, ScoreboardWriteMode.HighScoreDesc);
+
+ WebGL.SetClearTimes(clearTimes+1);
#endif
+ Debug.Log(clearTimes);
StartCoroutine(RunEndroll());
}
diff --git a/Assets/Scripts/Utility.cs b/Assets/Scripts/Utility.cs
index 3bcb8be..fcdcd17 100644
--- a/Assets/Scripts/Utility.cs
+++ b/Assets/Scripts/Utility.cs
@@ -23,7 +23,7 @@ public static class Tags
///
/// ホバーのために用いる
///
- [ObsoleteAttribute("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover";
+ [Obsolete("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover";
///
/// キャラクタが歩く地面や壁等に用いる
@@ -101,6 +101,18 @@ public static class WebGL
///
/// デバイス種別の文字列
[DllImport("__Internal")] public static extern string GetDeviceType();
+
+
+ ///
+ /// cookieにクリア回数を書き込みます
+ ///
+ [DllImport("__Internal")] public static extern void SetClearTimes(int clearTimes);
+
+ ///
+ /// cookieからクリア回数を読み込みます
+ ///
+ /// クリア回数
+ [DllImport("__Internal")] public static extern int GetClearTimes();
}
#endif
}