public void ResetSelectedObject() { if (selectedObject == -1) { DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst")); return; } Debug.Log("Resetting object " + selectedObjectName + "."); ResetObject(selectedObject); }
public void PrepareSelectedObjectToReceiveBehavior() { if (selectedObject == -1) { DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst")); PanelLoadBg.AbortLoadStatic(); return; } Debug.Log("Preparing object " + selectedObjectName + " to receive behavior."); PanelLoadBg.SetProgrammableObjectStatic(GetIthObjectInSceneTransform(selectedObject).GetComponent <ProgrammableObject>()); }
void OnEnable() { if (avoidNextTextUpdate) { avoidNextTextUpdate = false; } // Update Source Blocks! if (cmdCubes != null) { foreach (Transform cmdCube in cmdCubes) { GameObject.Destroy(cmdCube.gameObject); } cmdCubes.Clear(); } if (linkCubes != null) { foreach (Transform linkCube in linkCubes) { GameObject.Destroy(linkCube.gameObject); } linkCubes.Clear(); } cmdCount = 0; if (inputFieldComponent == null) { inputFieldComponent = sourceCode.gameObject.GetComponent <InputField>(); } List <string> commands = new List <string>(inputFieldComponent.text.Split(';')); foreach (string splittedCommand in commands) { string cmd = splittedCommand.Trim(); if (cmd.Length > 0) { if (cmdMaterials.ContainsKey(cmd)) { AddCommandBlock(cmd); } else { DebugMessage.ErrorMessage("'" + cmd + "' " + TranslationManager.GetMessage("NotRecognizedCommand")); } } } SetSelectedBlock(-1); }
public void LoadCode(Dropdown sourceCode) { int result = -1; result = PanelLoadBg.TryToLoadCodeToProgrammableObjectStatic(sourceCode); if (result != 0 && sourceCodeComponent != null) { result = sourceCodeComponent.LoadCode(sourceCode); } if (result == 0) { DebugMessage.SuccessMessage(TranslationManager.GetMessage("LoadedSuccessfully")); } else { DebugMessage.ErrorMessage(TranslationManager.GetMessage("ErrorLoading")); } PanelLoadBg.ExitAnimation(); }
public void SaveCode(Text nameTextComponent) { int result = -1; string text = ""; if (nameTextComponent != null) { text = nameTextComponent.text; } if (sourceCodeComponent != null) { result = sourceCodeComponent.SaveCode(text); } if (result == 0) { DebugMessage.SuccessMessage(TranslationManager.GetMessage("SavedSuccessfully")); PanelSaveBg.ExitAnimation(); } else { DebugMessage.ErrorMessage(TranslationManager.GetMessage("ErrorSaving")); } }
public void DeleteSelectedBlock() { Transform cmdCubeToDelete = null; Transform linkCubeToDelete = null; int index; if (selectedBlock == -1) { DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst")); return; } index = 0; foreach (Transform cmdCubeTransform in cmdCubes) { if (selectedBlock == index) { cmdCubeToDelete = cmdCubeTransform; } else if (selectedBlock < index) { cmdCubeTransform.localPosition = new Vector3(0, cmdCubeTransform.localPosition.y + 1.5f, 0); cmdCubeTransform.gameObject.GetComponent <EvoLangCmdCube>().SetIndex(index - 1); } index++; } cmdCubes.Remove(cmdCubeToDelete); GameObject.Destroy(cmdCubeToDelete.gameObject); cmdCount--; if (cmdCount == selectedBlock) { if (selectedBlock > 0) { index = 1; foreach (Transform linkCubeTransform in linkCubes) { if (selectedBlock == index) { linkCubeToDelete = linkCubeTransform; } index++; } linkCubes.Remove(linkCubeToDelete); GameObject.Destroy(linkCubeToDelete.gameObject); } } else { index = 0; foreach (Transform linkCubeTransform in linkCubes) { if (selectedBlock == index) { linkCubeToDelete = linkCubeTransform; } else if (selectedBlock < index) { linkCubeTransform.localPosition = new Vector3(0, linkCubeTransform.localPosition.y + 1.5f, 0); } index++; } linkCubes.Remove(linkCubeToDelete); GameObject.Destroy(linkCubeToDelete.gameObject); } SetSelectedBlock(-1); }