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; }
public HideWidgetCommand(GrabWidget widget, BaseCommand parent = null) : base(parent) { m_Widget = widget; if (widget is StencilWidget) { m_WidgetTransform = TrTransform.FromLocalTransform(widget.transform); } else if (widget is MediaWidget) { m_WidgetTransform = TrTransform.FromLocalTransform(widget.transform); m_WidgetTransform.scale = widget.GetSignedWidgetSize(); } m_TiltMeterCost = m_Widget.GetTiltMeterCost(); TiltMeterScript.m_Instance.AdjustMeterWithWidget(m_TiltMeterCost, up: false); }