Пример #1
0
        private void SetScale(ChangeEvent <int> e)
        {
            UpdateScale(e.newValue);

            m_FitToScreenEnabled = false;
            m_FitToScreenToggle.SetValueWithoutNotify(m_FitToScreenEnabled);
        }
Пример #2
0
 void CreateTracingMenu()
 {
     m_EnableTracingButton         = this.MandatoryQ <ToolbarToggle>("enableTracingButton");
     m_EnableTracingButton.tooltip = "Toggle Tracing For Current Instance";
     m_EnableTracingButton.SetValueWithoutNotify(m_Store.GetState().EditorDataModel.TracingEnabled);
     m_EnableTracingButton.RegisterValueChangedCallback(e => OnToggleTracing?.Invoke(e));
 }
Пример #3
0
        private void InitPreviewToolbar()
        {
            #region Scale
            m_ScaleSlider           = m_RootElement.Q <SliderInt>("scale-slider");
            m_ScaleSlider.lowValue  = kScaleMin;
            m_ScaleSlider.highValue = kScaleMax;
            m_ScaleSlider.value     = m_Scale;
            m_ScaleSlider.RegisterCallback <ChangeEvent <int> >(SetScale);

            m_ScaleValueLabel      = m_RootElement.Q <Label>("scale-value-label");
            m_ScaleValueLabel.text = m_Scale.ToString();

            m_FitToScreenToggle = m_RootElement.Q <ToolbarToggle>("fit-to-screen");
            m_FitToScreenToggle.RegisterValueChangedCallback(FitToScreen);
            m_FitToScreenToggle.SetValueWithoutNotify(m_FitToScreenEnabled);
            #endregion

            #region Rotate
            var          namePostfix = EditorGUIUtility.isProSkin ? "_dark" : "_light";
            const string iconPath    = "packages/com.unity.device-simulator/Editor/icons";

            m_RootElement.Q <Image>("rotate-cw-image").image = AssetDatabase.LoadAssetAtPath <Texture2D>($"{iconPath}/rotate_cw{namePostfix}.png");
            m_RootElement.Q <VisualElement>("rotate-cw").AddManipulator(new Clickable(RotateDeviceCW));

            m_RootElement.Q <Image>("rotate-ccw-image").image = AssetDatabase.LoadAssetAtPath <Texture2D>($"{iconPath}/rotate_ccw{namePostfix}.png");
            m_RootElement.Q <VisualElement>("rotate-ccw").AddManipulator(new Clickable(RotateDeviceCCW));
            #endregion

            // Highlight safe area.
            var highlightSafeAreaToggle = m_RootElement.Q <Toggle>("highlight-safe-area");
            highlightSafeAreaToggle.RegisterValueChangedCallback((evt) => { m_HighlightSafeArea = evt.newValue; OnStateChanged(); });
            highlightSafeAreaToggle.SetValueWithoutNotify(m_HighlightSafeArea);
        }
        private void StopPicking()
        {
            m_PickElement = false;
            m_PickToggle.SetValueWithoutNotify(false);
            m_PickOverlay.ClearOverlay();

            panelDebug?.MarkDirtyRepaint();
            Focus();
        }
Пример #5
0
        void CreateTracingMenu()
        {
            m_EnableTracingButton         = this.MandatoryQ <ToolbarToggle>("enableTracingButton");
            m_EnableTracingButton.tooltip = "Toggle Tracing For Current Instance";
            m_EnableTracingButton.SetValueWithoutNotify(m_Store.GetState().EditorDataModel.TracingEnabled);
            m_EnableTracingButton.RegisterValueChangedCallback(e => OnToggleTracing?.Invoke(e));

            m_PickTargetButton         = this.Q <Button>("pickTargetButton");
            m_PickTargetButton.tooltip = "Pick a target";
            m_PickTargetButton.clickable.clickedWithEventInfo += OnPickTargetButton;
            m_PickTargetLabel         = m_PickTargetButton.Q <Label>("pickTargetLabel");
            m_PickTargetLabel.tooltip = "Choose an entity trace to display";
            m_PickTargetIcon          = m_PickTargetButton.Q(null, "icon");

            m_FirstFrameTracingButton                    = this.Q <Button>("firstFrameTracingButton");
            m_FirstFrameTracingButton.tooltip            = "Go To First Frame";
            m_FirstFrameTracingButton.clickable.clicked += OnFirstFrameTracingButton;

            m_PreviousFrameTracingButton                    = this.Q <Button>("previousFrameTracingButton");
            m_PreviousFrameTracingButton.tooltip            = "Go To Previous Frame";
            m_PreviousFrameTracingButton.clickable.clicked += OnPreviousFrameTracingButton;

            m_PreviousStepTracingButton                    = this.Q <Button>("previousStepTracingButton");
            m_PreviousStepTracingButton.tooltip            = "Go To Previous Step";
            m_PreviousStepTracingButton.clickable.clicked += OnPreviousStepTracingButton;

            m_NextStepTracingButton                    = this.Q <Button>("nextStepTracingButton");
            m_NextStepTracingButton.tooltip            = "Go To Next Step";
            m_NextStepTracingButton.clickable.clicked += OnNextStepTracingButton;

            m_NextFrameTracingButton                    = this.Q <Button>("nextFrameTracingButton");
            m_NextFrameTracingButton.tooltip            = "Go To Next Frame";
            m_NextFrameTracingButton.clickable.clicked += OnNextFrameTracingButton;

            m_LastFrameTracingButton                    = this.Q <Button>("lastFrameTracingButton");
            m_LastFrameTracingButton.tooltip            = "Go To Last Frame";
            m_LastFrameTracingButton.clickable.clicked += OnLastFrameTracingButton;

            m_CurrentFrameTextField = this.Q <IntegerField>("currentFrameTextField");
            m_CurrentFrameTextField.AddToClassList("frameCounterLabel");
            m_CurrentFrameTextField.RegisterCallback <KeyDownEvent>(OnFrameCounterKeyDown);
            m_TotalFrameLabel = this.Q <Label>("totalFrameLabel");
            m_TotalFrameLabel.AddToClassList("frameCounterLabel");
        }
Пример #6
0
        void OnContextChange()
        {
            // Sync the toolbar
            m_PickToggle.SetValueWithoutNotify(m_Context.pickElement);
            m_ShowLayoutToggle.SetValueWithoutNotify(m_Context.showLayoutBound);

            if (Unsupported.IsDeveloperBuild())
            {
                m_RepaintOverlayToggle.SetValueWithoutNotify(m_Context.showRepaintOverlay);
                m_ShowDrawStatsToggle.SetValueWithoutNotify(m_Context.showDrawStats);
                m_BreakBatchesToggle.SetValueWithoutNotify(m_Context.breakBatches);
                m_ShowWireframeToggle.SetValueWithoutNotify(m_Context.showWireframe);

                ApplyToPanel(m_Context);
            }

            panelDebug?.MarkDirtyRepaint();
            panelDebug?.MarkDebugContainerDirtyRepaint();
        }
Пример #7
0
        void OnContextChange()
        {
            // Sync the toolbar
            m_PickToggle.SetValueWithoutNotify(m_Context.pickElement);
            m_ShowLayoutToggle.SetValueWithoutNotify(m_Context.showLayoutBound);

            if (Unsupported.IsDeveloperBuild())
            {
                m_RepaintOverlayToggle.SetValueWithoutNotify(m_Context.showRepaintOverlay);
                m_ShowDrawStatsToggle.SetValueWithoutNotify(m_Context.showDrawStats);

                var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater;
                if (updater != null)
                {
                    updater.DebugGetRenderChain().drawStats = m_Context.showDrawStats;
                }
            }

            panelDebug?.MarkDirtyRepaint();
            panelDebug?.MarkDebugContainerDirtyRepaint();
        }
Пример #8
0
        public new void OnEnable()
        {
            base.OnEnable();

            DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this;

            m_DebuggerSelection = new DebuggerSelection();
            m_RepaintOverlay    = new RepaintOverlayPainter();
            m_PickOverlay       = new HighlightOverlayPainter();
            m_LayoutOverlay     = new LayoutOverlayPainter();

            var root  = this.rootVisualElement;
            var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet;

            root.styleSheets.Add(sheet);

            StyleSheet colorSheet;

            if (EditorGUIUtility.isProSkin)
            {
                colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet;
            }
            else
            {
                colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet;
            }

            root.styleSheets.Add(colorSheet);
            root.Add(m_Toolbar);

            m_PickToggle = new ToolbarToggle()
            {
                name = "pickToggle"
            };
            m_PickToggle.text = "Pick Element";
            m_PickToggle.RegisterValueChangedCallback((e) =>
            {
                m_PickElement = e.newValue;
                // On OSX, as focus-follow-mouse is not supported,
                // we explicitly focus the EditorWindow when enabling picking
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    Panel p = m_DebuggerSelection.panel as Panel;
                    if (p != null)
                    {
                        TryFocusCorrespondingWindow(p);
                    }
                }
            });

            m_Toolbar.Add(m_PickToggle);

            m_ShowLayoutToggle = new ToolbarToggle()
            {
                name = "layoutToggle"
            };
            m_ShowLayoutToggle.SetValueWithoutNotify(m_ShowLayoutBound);
            m_ShowLayoutToggle.text = "Show Layout";
            m_ShowLayoutToggle.RegisterValueChangedCallback((e) =>
            {
                m_ShowLayoutBound = e.newValue;
                panelDebug?.MarkDirtyRepaint();
                panelDebug?.MarkDebugContainerDirtyRepaint();
            });

            m_Toolbar.Add(m_ShowLayoutToggle);

            if (Unsupported.IsDeveloperBuild())
            {
                m_RepaintOverlayToggle = new ToolbarToggle()
                {
                    name = "repaintOverlayToggle"
                };
                m_RepaintOverlayToggle.text = "Repaint Overlay";
                m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_ShowRepaintOverlay = e.newValue);
                m_Toolbar.Add(m_RepaintOverlayToggle);

                m_UXMLLiveReloadToggle = new ToolbarToggle()
                {
                    name = "UXMLReloadToggle"
                };
                m_UXMLLiveReloadToggle.SetValueWithoutNotify(RetainedMode.UxmlLiveReloadIsEnabled);
                m_UXMLLiveReloadToggle.text = "UXML Live Reload";
                m_UXMLLiveReloadToggle.RegisterValueChangedCallback((e) => RetainedMode.UxmlLiveReloadIsEnabled = e.newValue);
                m_Toolbar.Add(m_UXMLLiveReloadToggle);

                m_ShowDrawStatsToggle = new ToolbarToggle()
                {
                    name = "drawStatsToggle"
                };
                m_ShowDrawStatsToggle.text = "Draw Stats";
                m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) =>
                {
                    var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater;
                    if (updater != null)
                    {
                        updater.DebugGetRenderChain().drawStats = e.newValue;
                    }
                    panelDebug?.MarkDirtyRepaint();
                });
                m_Toolbar.Add(m_ShowDrawStatsToggle);
            }

            var splitter = new DebuggerSplitter();

            root.Add(splitter);

            m_TreeViewContainer = new DebuggerTreeView(m_DebuggerSelection, SelectElement);
            m_TreeViewContainer.style.flexGrow = 1f;
            splitter.leftPane.Add(m_TreeViewContainer);

            m_StylesDebuggerContainer = new StylesDebugger(m_DebuggerSelection);
            splitter.rightPane.Add(m_StylesDebuggerContainer);
        }
Пример #9
0
        void LoadTemplate()
        {
            rootVisualElement.Clear();

            UIElementsUtils.ApplyStyleSheet(k_Stylesheet, rootVisualElement);
            UIElementsUtils.ApplyStyleSheet(Timeline.k_Stylesheet, rootVisualElement);
            UIElementsUtils.ApplyStyleSheet(k_ToolbarStyle, rootVisualElement);

            UIElementsUtils.CloneTemplateInto(k_MainLayout, rootVisualElement);

            VisualElement outerElement = rootVisualElement.Q <VisualElement>("kinematica");

            m_Toolbar = outerElement.Q <VisualElement>("toolbar");

            m_MainLayout = outerElement.Q <VisualElement>("windowContent");

            // Input for Build
            {
                m_MainInputLayout      = outerElement.Q <VisualElement>("inputLayout");
                m_ClipAndSettingsInput = m_MainLayout.Q <VisualElement>("inputArea");

                m_GutterToggleMenu = m_MainLayout.Q <VisualElement>("gutterToggleMenu");
                var selectorClick = new Clickable(OnGutterMenuClicked);
                m_GutterToggleMenu.AddManipulator(selectorClick);

                m_GutterLabels = m_MainLayout.Q <VisualElement>("gutterList");

                //Profile and Asset creation
                {
                    m_AssetCreateLayout = m_MainLayout.Q <VisualElement>(classes: "createLayout");

                    var createButton = m_AssetCreateLayout.Q <Button>("createButton");
                    createButton.clickable.clicked += CreateButtonClicked;
                    createButton.text = "Create";
                }

                m_EditAssetButton = rootVisualElement.Q <Button>("editAssetButton");
                m_EditAssetButton.clickable.clicked += EditAsset;

                m_AssetDirtyWarning = rootVisualElement.Q <VisualElement>("assetDirtyWarning");

                m_ProgressBar = rootVisualElement.Q <ProgressBar>("progressBar");
                HideProgressBar();

                m_BuildButton = rootVisualElement.Q <Button>("buildButton");
                m_BuildButton.clickable.clicked += BuildAsset;

                m_CancelBuildButton = rootVisualElement.Q <Button>("cancelBuildButton");
                m_CancelBuildButton.clickable.clicked += CancelBuildAsset;
                DisplayCancelBuildButton(false);

                var assetSelector = m_Toolbar.Q <ObjectField>("asset");
                assetSelector.objectType = typeof(Asset);
                assetSelector.RegisterValueChangedCallback(OnAssetSelectionChanged);

                m_AnimationLibraryListView               = m_ClipAndSettingsInput.Q <AnimationClipListView>("animationLibrary");
                m_AnimationLibraryListView.m_Window      = this;
                m_AnimationLibraryListView.selectionType = SelectionType.Multiple;
                m_AnimationLibraryListView.makeItem      = MakeAnimationItem;
                m_AnimationLibraryListView.bindItem      = BindAnimationItem;
                m_AnimationLibraryListView.itemHeight    = 18;
                UIElementsUtils.ApplyStyleSheet(k_AnimationLibraryStyle, m_ClipAndSettingsInput.Q <VisualElement>("clipsArea"));

                m_Timeline = rootVisualElement.Q <Timeline>("timeline");
                m_Timeline.PreviewTargetChanged    += OnTimelinePreviewTargetChanged;
                m_Timeline.GutterTrackAdded        += OnGutterTrackCreated;
                m_Timeline.ForceGutterTrackDisplay += ForceGutterTrackDisplay;
                m_Timeline.LoadTemplate(rootVisualElement);
                m_AnimationLibraryListView.onSelectionChanged += OnLibrarySelectionChanged;

                m_PreviewToggle = rootVisualElement.Q <ToolbarToggle>("previewToggle");
                m_PreviewToggle.SetValueWithoutNotify(m_Timeline.PreviewEnabled);
                m_PreviewToggle.RegisterValueChangedCallback(evt => m_Timeline.PreviewEnabled = evt.newValue);
                m_Timeline.PreviewEnabledChangeEvent += enabled => m_PreviewToggle.SetValueWithoutNotify(enabled);
            }

            SetToolbarEnable(false);
        }
 public void TogglePlayOffWithoutNotify()
 {
     m_PlayToggle.SetValueWithoutNotify(false);
 }