void BeginTextEditingOnExistingActor() { if (cooldownRoutine != null) { StopCoroutine(cooldownRoutine); } audioSource.Play(); actorWasJustCreated = false; actorBeingEdited = hoverActor; actorTextBeforeEditing = actorBeingEdited.GetCommentText(); inputField.text = actorBeingEdited.GetCommentText(); inputFieldObject.SetActive(true); EventSystem.current.SetSelectedGameObject(inputField.gameObject); }
void EndTextEditing() { if (IsEditing()) { // Erm, do this first, cuz deactivating stuff could cause this to be // called again recursively. Like deactivating the inputFieldObject! lastActorEdited = actorBeingEdited; actorBeingEdited = null; inputFieldObject.SetActive(false); cooldownRoutine = StartCoroutine(CooldownRoutine()); if (inputField.text == EMPTY_TEXT) { engine.DestroyActor(lastActorEdited); } else { editMain.SetTargetActor(lastActorEdited); // editMain.SetFocusedTargetActor(lastActorEdited); string undoText = actorTextBeforeEditing; if (actorWasJustCreated) { var engine = lastActorEdited.GetEngine(); var actorData = engine.SaveActor(lastActorEdited); undoStack.PushUndoForCreatingActor(lastActorEdited, $"Create text panel"); } else { string currText = lastActorEdited.GetCommentText(); if (ActorUndoUtil.GetUnableToEditActorReason(lastActorEdited.GetEngine(), lastActorEdited.GetName()) == null) { undoStack.PushUndoForActor( lastActorEdited, $"Edit text panel", redoActor => { redoActor.SetCommentText(currText); redoActor.ApplyPropertiesToClones(); }, undoActor => { undoActor.SetCommentText(undoText); undoActor.ApplyPropertiesToClones(); }); } } } } }