embed:tutorial2
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
embed:tutorial2 [2023/01/16 21:46] – machiaworx | embed:tutorial2 [2023/01/21 13:15] (現在) – [実装] machiaworx | ||
---|---|---|---|
行 31: | 行 31: | ||
using Miniscript; | using Miniscript; | ||
using TMPro; | using TMPro; | ||
- | |||
public class ScriptMover : MonoBehaviour | public class ScriptMover : MonoBehaviour | ||
行 40: | 行 39: | ||
public Interpreter interpreter; | public Interpreter interpreter; | ||
- | public string globalVarName=""; | + | |
+ | | ||
private int frame=0; | private int frame=0; | ||
| | ||
行 53: | 行 53: | ||
interpreter.implicitOutput = (string s,bool t) => Debug.Log($" | interpreter.implicitOutput = (string s,bool t) => Debug.Log($" | ||
interpreter.errorOutput = (string s,bool t) => { | interpreter.errorOutput = (string s,bool t) => { | ||
- | |||
// | // | ||
Debug.LogError(s); | Debug.LogError(s); | ||
行 70: | 行 69: | ||
}; | }; | ||
+ | // | ||
RunScript(loadText); | RunScript(loadText); | ||
} | } | ||
行 76: | 行 76: | ||
// | // | ||
string extraSource = " | string extraSource = " | ||
+ | | ||
+ | // | ||
interpreter.Reset(extraSource+sourceCode); | interpreter.Reset(extraSource+sourceCode); | ||
| | ||
行 81: | 行 83: | ||
interpreter.Compile(); | interpreter.Compile(); | ||
- | // | + | // |
ValMap data = new ValMap(); | ValMap data = new ValMap(); | ||
data[" | data[" | ||
行 87: | 行 89: | ||
data[" | data[" | ||
data[" | data[" | ||
+ | | ||
+ | // | ||
interpreter.SetGlobalValue(globalVarName, | interpreter.SetGlobalValue(globalVarName, | ||
} | } | ||
行 101: | 行 105: | ||
#endif | #endif | ||
} | } | ||
+ | | ||
+ | // | ||
UpdateFromScript(); | UpdateFromScript(); | ||
} | } | ||
行 107: | 行 113: | ||
ValMap data = null; | ValMap data = null; | ||
try { | try { | ||
+ | // | ||
data = interpreter.GetGlobalValue(globalVarName) as ValMap; | data = interpreter.GetGlobalValue(globalVarName) as ValMap; | ||
} catch (UndefinedIdentifierException) { | } catch (UndefinedIdentifierException) { | ||
行 127: | 行 134: | ||
</ | </ | ||
- | 終わったら画面UIのテキストをCubeの枠にドラッグ&ドロップしておいてください。 | + | 終わったらCubeからテキスト部分を参照しておいてください。 |
==== Miniscript言語で書いたソースコード用意 ==== | ==== Miniscript言語で書いたソースコード用意 ==== | ||
- | 以下のテキストを用意して、ScriptMoverクラスのテキストに登録しておいてください。 | + | 以下の内容のテキストファイルを用意してください。 |
serif=[" | serif=[" | ||
行 138: | 行 145: | ||
ship.cnt+=1 | ship.cnt+=1 | ||
change(serif[(ship.cnt/ | change(serif[(ship.cnt/ | ||
+ | | ||
+ | 終わったらCubeから作ったソースコードを参照しておいてください。 | ||
==== 動かしてみましょう ==== | ==== 動かしてみましょう ==== |
embed/tutorial2.1673873201.txt.gz · 最終更新: 2023/01/16 21:46 by machiaworx