protected override void OnRedo() { if (m_Widget != null) { // If we're re-doing this command and the widget exists, it's because we had previously // undone a creation. The widget will be hidden at this point, so we want to restore it, // much in the opposite way HideWidgetCommand works. // TODO: This function name is used more generally and should be renamed. m_Widget.gameObject.SetActive(true); m_Widget.RestoreFromToss(); } else { m_Widget = Object.Instantiate(m_Prefab); m_Widget.transform.position = m_SpawnXf.translation; // Widget type specific initialization. if (m_Widget is StencilWidget) { m_Widget.transform.parent = m_Canvas.transform; m_Widget.Show(true); } else if (m_Widget is ModelWidget) { // ModelWidget.Show(true) is not called here because the model must be assigned // before it can be turned on. } else if (m_Widget is ImageWidget) { m_Widget.transform.parent = m_Canvas.transform; m_Widget.Show(true); } else if (m_Widget is VideoWidget) { m_Widget.transform.parent = m_Canvas.transform; m_Widget.Show(true); } else if (m_Widget is CameraPathWidget) { m_Widget.transform.parent = m_Canvas.transform; m_Widget.transform.localPosition = Vector3.zero; m_Widget.transform.localRotation = Quaternion.identity; m_Widget.Show(true); App.Switchboard.TriggerCameraPathCreated(); WidgetManager.m_Instance.CameraPathsVisible = true; } m_Widget.InitIntroAnim(m_SpawnXf, m_EndXf, false, m_DesiredEndForward); m_TiltMeterCost = m_Widget.GetTiltMeterCost(); } WidgetManager.m_Instance.RefreshPinAndUnpinLists(); TiltMeterScript.m_Instance.AdjustMeterWithWidget(m_TiltMeterCost, up: true); m_TiltMeterCostUndone = false; }
protected override void OnUndo() { if (m_Widget != null) { m_Widget.gameObject.SetActive(true); m_Widget.RestoreFromToss(); m_Widget.transform.localPosition = m_WidgetTransform.translation; m_Widget.transform.localRotation = m_WidgetTransform.rotation; m_Widget.SetSignedWidgetSize(m_WidgetTransform.scale); WidgetManager.m_Instance.RefreshPinAndUnpinLists(); TiltMeterScript.m_Instance.AdjustMeterWithWidget(m_TiltMeterCost, up: true); if (m_Widget is CameraPathWidget) { App.Switchboard.TriggerCameraPathCreated(); } } else { Debug.LogError("Widget in undo stack was destroyed."); } }