-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* ✨ Add XNFT Wallet + xNFT WebGLTemplate - Add XNFTWallet to Runtime codebase and related xNFT js lib to Runtime plugins. - WebGLTemplates folder with xNFT template to be used when building for xNFT - Comments showing how to use it in LoginScreen.cs * Added WebGLTemplatesExporter + LoginXNFT Button Prefab * ♻️ Add copy/paste & refactor backpack code * ✨ Add XNFT Wallet + xNFT WebGLTemplate (magicblock-labs#31) * ✨ Add XNFT Wallet + xNFT WebGLTemplate - Add XNFTWallet to Runtime codebase and related xNFT js lib to Runtime plugins. - WebGLTemplates folder with xNFT template to be used when building for xNFT - Comments showing how to use it in LoginScreen.cs * Added WebGLTemplatesExporter + LoginXNFT Button Prefab * ➕ Add missing script * ✨ Update template * 🙈 Update n.pmignore * 📄 Update License * ♻️ Add license meta * 🎨 Improve link UI * 🎨 Improve scene Co-authored-by: Nicolas Francisquelo Tacca <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
/TextMesh Pro/ | ||
TextMesh Pro.meta | ||
LICENSE | ||
CONTRIBUTING.md | ||
README.md | ||
CODE_OF_CONDUCT.md |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace WebGLSupport.Detail | ||
{ | ||
public class RebuildChecker | ||
{ | ||
IInputField input; | ||
|
||
string beforeString; | ||
int beforeCaretPosition; | ||
int beforeSelectionFocusPosition; | ||
int beforeSelectionAnchorPosition; | ||
//Vector2 anchoredPosition; | ||
|
||
public RebuildChecker(IInputField input) | ||
{ | ||
this.input = input; | ||
} | ||
|
||
public bool NeedRebuild(bool debug = false) | ||
{ | ||
var res = false; | ||
|
||
// any not same | ||
if (beforeString != input.text) | ||
{ | ||
if(debug) Debug.Log(string.Format("beforeString : {0} != {1}", beforeString, input.text)); | ||
beforeString = input.text; | ||
res = true; | ||
} | ||
|
||
if (beforeCaretPosition != input.caretPosition) | ||
{ | ||
if (debug) Debug.Log(string.Format("beforeCaretPosition : {0} != {1}", beforeCaretPosition, input.caretPosition)); | ||
beforeCaretPosition = input.caretPosition; | ||
res = true; | ||
} | ||
|
||
if (beforeSelectionFocusPosition != input.selectionFocusPosition) | ||
{ | ||
if (debug) Debug.Log(string.Format("beforeSelectionFocusPosition : {0} != {1}", beforeSelectionFocusPosition, input.selectionFocusPosition)); | ||
beforeSelectionFocusPosition = input.selectionFocusPosition; | ||
res = true; | ||
} | ||
|
||
if (beforeSelectionAnchorPosition != input.selectionAnchorPosition) | ||
{ | ||
if (debug) Debug.Log(string.Format("beforeSelectionAnchorPosition : {0} != {1}", beforeSelectionAnchorPosition, input.selectionAnchorPosition)); | ||
beforeSelectionAnchorPosition = input.selectionAnchorPosition; | ||
res = true; | ||
} | ||
|
||
//if (anchoredPosition != input.TextComponentRectTransform().anchoredPosition) | ||
//{ | ||
// if (debug) Debug.Log(string.Format("anchoredPosition : {0} != {1}", anchoredPosition, input.TextComponentRectTransform().anchoredPosition)); | ||
// anchoredPosition = input.TextComponentRectTransform().anchoredPosition; | ||
// res = true; | ||
//} | ||
return res; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
using System.Runtime.InteropServices; // for DllImport | ||
using AOT; | ||
using System; | ||
|
||
namespace WebGLSupport | ||
{ | ||
class WebGLInputMobilePlugin | ||
{ | ||
#if UNITY_WEBGL && !UNITY_EDITOR | ||
[DllImport("__Internal")] | ||
public static extern int WebGLInputMobileRegister(Action<int> OnTouchEnd); | ||
|
||
[DllImport("__Internal")] | ||
public static extern void WebGLInputMobileOnFocusOut(int id, Action<int> OnFocusOut); | ||
#else | ||
/// <summary> | ||
/// ID を割り振り | ||
/// </summary> | ||
/// <returns></returns> | ||
public static int WebGLInputMobileRegister(Action<int> OnTouchEnd) { return 0; } | ||
|
||
public static void WebGLInputMobileOnFocusOut(int id, Action<int> OnFocusOut) {} | ||
#endif | ||
} | ||
|
||
public class WebGLInputMobile : MonoBehaviour, IPointerDownHandler | ||
{ | ||
static Dictionary<int, WebGLInputMobile> instances = new Dictionary<int, WebGLInputMobile>(); | ||
|
||
int id = -1; | ||
|
||
private void Awake() | ||
{ | ||
#if !(UNITY_WEBGL && !UNITY_EDITOR) | ||
// WebGL 以外、更新メソッドは動作しないようにします | ||
enabled = false; | ||
#endif | ||
} | ||
|
||
/// <summary> | ||
/// 押されたら、touchend イベントを登録する | ||
/// </summary> | ||
/// <param name="eventData"></param> | ||
public void OnPointerDown(PointerEventData eventData) | ||
{ | ||
if (id != -1) return; | ||
id = WebGLInputMobilePlugin.WebGLInputMobileRegister(OnTouchEnd); | ||
instances[id] = this; | ||
} | ||
|
||
[MonoPInvokeCallback(typeof(Action<int>))] | ||
static void OnTouchEnd(int id) | ||
{ | ||
var @this = instances[id]; | ||
@this.GetComponent<WebGLInput>().OnSelect(); | ||
@this.StartCoroutine(RegisterOnFocusOut(id)); | ||
} | ||
|
||
static IEnumerator RegisterOnFocusOut(int id) | ||
{ | ||
yield return null; // wait one frame. | ||
WebGLInputMobilePlugin.WebGLInputMobileOnFocusOut(id, OnFocusOut); | ||
} | ||
|
||
[MonoPInvokeCallback(typeof(Action<int>))] | ||
static void OnFocusOut(int id) | ||
{ | ||
var @this = instances[id]; | ||
@this.StartCoroutine(ExecFocusOut(id)); | ||
} | ||
|
||
static IEnumerator ExecFocusOut(int id) | ||
{ | ||
yield return null; // wait one frame. | ||
var @this = instances[id]; | ||
@this.GetComponent<WebGLInput>().DeactivateInputField(); | ||
// release | ||
@this.id = -1; | ||
instances.Remove(id); | ||
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var WebGLInputMobile = { | ||
$instances: [], | ||
|
||
WebGLInputMobileRegister: function (touchend) { | ||
var id = instances.push(null) - 1; | ||
|
||
document.body.addEventListener("touchend", function () { | ||
document.body.removeEventListener("touchend", arguments.callee); | ||
Runtime.dynCall("vi", touchend, [id]); | ||
}); | ||
|
||
return id; | ||
}, | ||
WebGLInputMobileOnFocusOut: function (id, focusout) { | ||
document.body.addEventListener("focusout", function () { | ||
document.body.removeEventListener("focusout", arguments.callee); | ||
Runtime.dynCall("vi", focusout, [id]); | ||
}); | ||
}, | ||
} | ||
|
||
autoAddDeps(WebGLInputMobile, '$instances'); | ||
mergeInto(LibraryManager.library, WebGLInputMobile); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.