public void OnClickRun() { if (m_code == null || m_program.HasValue) { return; } m_files["program.kj"] = Encoding.UTF8.GetBytes(m_code.text); var assembly = Compiler.CompileBin("program.kj", "descriptor.kjo", m_files, error => Debug.LogError(error)); if (assembly == null) { return; } m_program = VM.Start(assembly, "main", 256, 256, error => Debug.LogError(error)); m_action = Action.None; if (m_runButton != null) { m_runButton.interactable = false; } if (m_stopButton != null) { m_stopButton.interactable = true; } }
private void Update() { if (!m_program.HasValue) { return; } if (m_action == Action.None) { if (!VM.Resume(m_program.Value, OnProcessOp, error => Debug.LogError(error))) { m_program = null; m_action = Action.None; if (m_runButton != null) { m_runButton.interactable = true; } if (m_stopButton != null) { m_stopButton.interactable = false; } transform.position = m_originPos; transform.rotation = Quaternion.identity; } } }
private void OnProcessOp(string op, UIntPtr[] paramsPtrs, UIntPtr[] targetsPtrs) { if (op == "movx") { m_action = Action.MovX; var value = VM.StateLoad <int>(paramsPtrs[0]); m_coroutine = StartCoroutine(Move(Mathf.Sign((float)value), 0, Mathf.Abs((float)value))); } else if (op == "movy") { m_action = Action.MovY; var value = VM.StateLoad <int>(paramsPtrs[0]); m_coroutine = StartCoroutine(Move(0, Mathf.Sign((float)-value), Mathf.Abs((float)value))); } }
public void OnClickStop() { if (m_program.HasValue) { VM.Cancel(m_program.Value); m_program = null; m_action = Action.None; if (m_runButton != null) { m_runButton.interactable = true; } if (m_stopButton != null) { m_stopButton.interactable = false; } transform.position = m_originPos; transform.rotation = Quaternion.identity; if (m_coroutine != null) { StopCoroutine(m_coroutine); } } }