-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from IwamotoKakeru/feat/clear-times
feat: クリア回数を取得・保存
- Loading branch information
Showing
8 changed files
with
218 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using Utility; | ||
|
||
/// <summary> | ||
/// タイトルでクリア回数を表示する | ||
/// </summary> | ||
public class ClearTimesText : MonoBehaviour | ||
{ | ||
private Text text; | ||
private int clearTimes = -1; | ||
|
||
void Awake() | ||
{ | ||
text = GetComponent<Text>(); | ||
#if UNITY_WEBGL && !UNITY_EDITOR | ||
clearTimes = WebGL.GetClearTimes(); | ||
#endif | ||
text.text = "クリア回数: " + clearTimes.ToString(); | ||
} | ||
|
||
void Start() | ||
{ | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters