Esempio n. 1
0
        public override VisualElement CreateInspectorGUI()
        {
            m_Root = new VisualElement();

            UIElementsUtils.CloneTemplateInto($"Inspectors/AnimationLibraryEditor.uxml", m_Root);
            UIElementsUtils.ApplyStyleSheet(k_AnimationLibraryEditorStyle, m_Root);
            UIElementsUtils.ApplyStyleSheet(BuilderWindow.k_Stylesheet, m_Root);

            var label = m_Root.Q <TextField>("clipNames");

            label.SetEnabled(false);

#if !UNITY_2020_1_OR_NEWER
            var retargetingInput = m_Root.Q <VisualElement>("retargeting");
            retargetingInput.style.display = DisplayStyle.None;
#endif

            m_RetargetSourceAvatarField = m_Root.Q <ObjectField>("retargetSourceAvatar");
            m_RetargetSourceAvatarField.allowSceneObjects = false;
            m_RetargetSourceAvatarField.objectType        = typeof(Avatar);
            m_RetargetSourceAvatarField.RegisterValueChangedCallback(OnRetargetSourceAvatarChanged);

            var library = target as TaggedAnimationClipSelectionContainer;
            InitializeRetargetingSourceSelector();

            m_Root.RegisterCallback <AttachToPanelEvent>(evt => Refresh());
            library.SelectionChanged += Refresh;

            return(m_Root);
        }
Esempio n. 2
0
        public MetricsEditor(Asset asset)
        {
            m_Asset = asset;

            UIElementsUtils.CloneTemplateInto("Drawers/MetricsDrawer.uxml", this);
            UIElementsUtils.ApplyStyleSheet("Drawers/MetricsDrawer.uss", this);

            AddToClassList("drawerRoot");

            m_MetricEditorContainer = this.Q <VisualElement>("metricsContainer");

            BuildMetricFields();

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
        }
Esempio n. 3
0
        void LoadTemplate()
        {
            UIElementsUtils.ApplyStyleSheet($"{nameof(BoundaryClipWindow)}.uss", rootVisualElement);
            UIElementsUtils.CloneTemplateInto($"{nameof(BoundaryClipWindow)}.uxml", rootVisualElement);
            rootVisualElement.AddToClassList("boundaryClipWindow");

            m_PreSelector  = rootVisualElement.Q <BoundarySelector>("preBoundarySelector");
            m_PostSelector = rootVisualElement.Q <BoundarySelector>("postBoundarySelector");

            var okButton = rootVisualElement.Q <Button>("confirmButton");

            okButton.clickable.clicked += OKClicked;

            var cancelButton = rootVisualElement.Q <Button>("cancelButton");

            cancelButton.clickable.clicked += Close;
        }
        public override VisualElement CreateInspectorGUI()
        {
            m_Root = new VisualElement();
            UIElementsUtils.CloneTemplateInto($"Inspectors/TaggedAnimationClipEditor.uxml", m_Root);
            UIElementsUtils.ApplyStyleSheet(k_AnnotationsEditorStyle, m_Root);
            UIElementsUtils.ApplyStyleSheet(BuilderWindow.k_Stylesheet, m_Root);

#if !UNITY_2020_1_OR_NEWER
            var retargetingInput = m_Root.Q <VisualElement>("retargeting");
            retargetingInput.style.display = DisplayStyle.None;
#endif
            m_ClipField = m_Root.Q <TextField>("clipName");
            m_ClipField.SetEnabled(false);

            m_RetargetSourceAvatarField = m_Root.Q <ObjectField>("retargetSourceAvatar");
            m_RetargetSourceAvatarField.allowSceneObjects = false;
            m_RetargetSourceAvatarField.objectType        = typeof(Avatar);
            m_RetargetSourceAvatarField.RegisterValueChangedCallback(OnRetargetSourceAvatarChanged);

            Refresh();

            var annotationsList = target as TimelineSelectionContainer;
            annotationsList.AnnotationsChanged += Refresh;

            TaggedAnimationClip clip = annotationsList.Clip;
            Asset asset = null;
            if (clip != null)
            {
                asset = clip.Asset;
                if (asset != null)
                {
                    asset.BuildStarted += BuildStarted;
                    asset.BuildStopped += BuildStopped;
                }
            }

            if (EditorApplication.isPlaying || asset != null && asset.BuildInProgress)
            {
                SetInputEnabled(false);
            }

            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            return(m_Root);
        }
        public override VisualElement CreateInspectorGUI()
        {
            m_Root = new VisualElement();

            m_Warning = new VisualElement();
            UIElementsUtils.CloneTemplateInto("AssetDirtyWarning.uxml", m_Warning);
            UIElementsUtils.ApplyStyleSheet(BuilderWindow.k_Stylesheet, m_Warning);

            ShowOrHideAssetDirtyWarning(EditorApplication.isPlaying);

            m_Root.Add(m_Warning);

            m_Root.Add(new IMGUIContainer(OnInspectorGUI));

            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            return(m_Root);
        }
        void LoadTemplate()
        {
            UIElementsUtils.ApplyStyleSheet(styleSheet, rootVisualElement);
            UIElementsUtils.ApplyStyleSheet(toolbarStyleSheet, rootVisualElement);

            UIElementsUtils.CloneTemplateInto("NodeGraphWindow.uxml", rootVisualElement);

            var breadcrumb = rootVisualElement.Q <Breadcrumb>("breadcrumb");

            breadcrumb.Clear();
            breadcrumb.PushItem("Root");

            var content       = rootVisualElement.Q <VisualElement>("content");
            var graphNodeView = new GraphNodeView(this);

            graphNodeView.name = "graphNodeView";
            content.Add(graphNodeView);

            DisplayMessages();
        }
        void LoadTemplate()
        {
            UIElementsUtils.CloneTemplateInto("PlayControls.uxml", this);
            UIElementsUtils.ApplyStyleSheet("PlayControl.uss", this);
            AddToClassList("playControl");

            var gotoBeginButton = this.Q <Button>("firstFrame");

            gotoBeginButton.clickable.clicked += OnFirstFrameClicked;
            var previousFrameButton = this.Q <Button>("previousFrame");

            previousFrameButton.clickable.clicked += OnStepBackClicked;
            m_PlayToggle = this.Q <ToolbarToggle>("play");
            m_PlayToggle.RegisterValueChangedCallback(evt => OnPlayClicked(evt.newValue));
            var nextFrameButton = this.Q <Button>("nextFrame");

            nextFrameButton.clickable.clicked += OnStepForwardClicked;
            var gotoEndButton = this.Q <Button>("lastFrame");

            gotoEndButton.clickable.clicked += OnLastFrameClicked;
        }
Esempio n. 8
0
        public override VisualElement CreateInspectorGUI()
        {
            m_Root = new VisualElement();
            UIElementsUtils.ApplyStyleSheet(BuilderWindow.k_Stylesheet, m_Root);
            UIElementsUtils.CloneTemplateInto(k_TemplatePath, m_Root);
            m_Root.AddToClassList("mainContainer");

            m_Asset = target as Asset;
            m_Asset.BuildStarted += BuildStarted;
            m_Asset.BuildStopped += BuildStopped;

            m_AssetSettingsInput = m_Root.Q <VisualElement>("assetSettings");
            //set restrictions on asset settings
            var sampleRateInput = m_AssetSettingsInput.Q <FloatField>("sampleRate");

            sampleRateInput.isDelayed = true;
            var   sampleRateSlider = m_AssetSettingsInput.Q <Slider>("sampleRateSlider");
            float sampleRate       = Mathf.Clamp(m_Asset.SampleRate, 1f, m_Asset.SampleRate);

            sampleRateInput.value  = sampleRate;
            sampleRateSlider.value = sampleRate;
            sampleRateInput.RegisterValueChangedCallback(evt =>
            {
                float newSampleRate = Mathf.Clamp(evt.newValue, k_MinSampleRate, k_MaxSampleRate);
                m_Asset.SampleRate  = newSampleRate;
                sampleRateSlider.SetValueWithoutNotify(newSampleRate);
                ClampTimeHorizonInput(1f / newSampleRate);
            });
            sampleRateSlider.RegisterValueChangedCallback(evt =>
            {
                float newSampleRate = Mathf.Clamp(evt.newValue, k_MinSampleRate, k_MaxSampleRate);
                m_Asset.SampleRate  = newSampleRate;
                sampleRateInput.SetValueWithoutNotify(newSampleRate);
                ClampTimeHorizonInput(1f / newSampleRate);
            });
            sampleRateInput.SetFloatFieldRange(sampleRateSlider.lowValue, sampleRateSlider.highValue);

            m_TimeHorizonInput           = m_AssetSettingsInput.Q <FloatField>("timeHorizon");
            m_TimeHorizonInput.isDelayed = true;
            m_TimeHorizonSlider          = m_AssetSettingsInput.Q <Slider>("timeHorizonSlider");
            m_TimeHorizonSlider.value    = m_Asset.TimeHorizon;
            m_TimeHorizonInput.value     = m_Asset.TimeHorizon;
            m_TimeHorizonInput.RegisterValueChangedCallback(evt =>
            {
                float newTimeHorizon = Mathf.Clamp(evt.newValue, k_MinTimeHorizon, k_MaxTimeHorizon);
                m_Asset.TimeHorizon  = newTimeHorizon;
                m_TimeHorizonSlider.SetValueWithoutNotify(newTimeHorizon);
            });
            m_TimeHorizonSlider.RegisterValueChangedCallback(evt =>
            {
                float newTimeHorizon = Mathf.Clamp(evt.newValue, k_MinTimeHorizon, k_MaxTimeHorizon);
                m_Asset.TimeHorizon  = newTimeHorizon;
                m_TimeHorizonInput.SetValueWithoutNotify(newTimeHorizon);
            });

            m_TimeHorizonSlider.lowValue = 1f / sampleRateSlider.lowValue;
            m_TimeHorizonInput.SetFloatFieldRange(m_TimeHorizonSlider.lowValue, m_TimeHorizonSlider.highValue);

            var avatarSelector = m_Root.Q <ObjectField>("destinationAvatar");

            avatarSelector.objectType = typeof(Avatar);

            avatarSelector.value = m_Asset.DestinationAvatar;
            avatarSelector.RegisterValueChangedCallback(OnAvatarSelectionChanged);

            UIElementsUtils.ApplyStyleSheet(k_Stylesheet, m_Root);

            m_MetricsEditor = new MetricsEditor(m_Asset);
            m_Root.Q <VisualElement>("metrics").Add(m_MetricsEditor);

            var buildButton = m_Root.Q <Button>("buildButton");

            buildButton.clickable.clicked += BuildButtonClicked;

            if (EditorApplication.isPlaying || m_Asset.BuildInProgress)
            {
                SetInputEnabled(false);
            }

            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            return(m_Root);
        }
Esempio n. 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);
        }
Esempio n. 10
0
        internal TagEditor(TagAnnotation tag, TaggedAnimationClip clip)
        {
            m_Tag  = tag;
            m_Clip = clip;

            UIElementsUtils.CloneTemplateInto("Inspectors/TagEditor.uxml", this);
            UIElementsUtils.ApplyStyleSheet(AnnotationsEditor.k_AnnotationsEditorStyle, this);
            AddToClassList(AnnotationsEditor.k_AnnotationsContainer);
            AddToClassList("drawerElement");

            var deleteButton = this.Q <Button>("deleteButton");

            deleteButton.clickable.clicked += () => { RemoveTag(m_Tag); };

            if (!tag.payload.ValidPayloadType)
            {
                Clear();
                var unknownLabel = new Label {
                    text = TagAttribute.k_UnknownTagType
                };
                unknownLabel.AddToClassList(AnnotationsEditor.k_UnknownAnnotationType);
                Add(unknownLabel);
                return;
            }

            TextField tagType = this.Q <TextField>("tagType");

            tagType.value = TagAttribute.GetDescription(m_Tag.Type);
            tagType.SetEnabled(false);

            Asset asset = m_Clip.Asset;

            TextField tagName = this.Q <TextField>("name");

            tagName.value = m_Tag.name;
            tagName.RegisterValueChangedCallback(evt =>
            {
                if (!evt.newValue.Equals(m_Tag.name, StringComparison.Ordinal))
                {
                    Undo.RecordObject(asset, "Change tag name");
                    m_Tag.name = evt.newValue;
                    m_Tag.NotifyChanged();
                    asset.MarkDirty();
                }
            });

            TextField metricLabel = this.Q <TextField>("metricLabel");
            var       metric      = asset.GetMetricForTagType(m_Tag.Type);

            if (metric != null)
            {
                metricLabel.value = metric.name;
                metricLabel.SetEnabled(false);
            }
            else
            {
                metricLabel.style.display = DisplayStyle.None;
            }

            TimeField stf = this.Q <TimeField>("startTime");

            stf.Init(m_Clip, m_Tag.startTime);
            stf.TimeChanged += (newTime) =>
            {
                if (!EqualityComparer <float> .Default.Equals(m_Tag.startTime, newTime))
                {
                    Undo.RecordObject(asset, "Change tag start time");
                    m_Tag.startTime = newTime;
                    m_Tag.NotifyChanged();
                    asset.MarkDirty();
                }
            };


            TimeField dtf = this.Q <TimeField>("durationTime");

            dtf.Init(m_Clip, m_Tag.duration);
            dtf.TimeChanged += (newTime) =>
            {
                if (!EqualityComparer <float> .Default.Equals(m_Tag.duration, newTime))
                {
                    Undo.RecordObject(asset, "Change tag duration");
                    m_Tag.duration = newTime;
                    m_Tag.NotifyChanged();
                    asset.MarkDirty();
                }
            };

            var so = m_Tag.payload.ScriptableObject;

            if (so != null)
            {
                m_PayloadInspector = UnityEditor.Editor.CreateEditor(so) as GenericStructInspector;
                m_PayloadInspector.StructModified += () =>
                {
                    m_Tag.payload.Serialize();
                    m_Tag.NotifyChanged();
                    m_Clip.Asset.MarkDirty();
                };

                VisualElement inspectorElement   = m_PayloadInspector.CreateInspectorGUI() ?? new IMGUIContainer(m_PayloadInspector.OnInspectorGUI);
                var           inspectorContainer = this.Q <VisualElement>("payloadInspector");
                inspectorContainer.Add(inspectorElement);
            }

            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);

            m_Tag.Changed += Refresh;
            asset.AssetWasDeserialized += Refresh;
        }
Esempio n. 11
0
        public MarkerEditor(MarkerAnnotation marker, TaggedAnimationClip clip)
        {
            m_Clip   = clip;
            m_Marker = marker;
            UIElementsUtils.ApplyStyleSheet(BuilderWindow.k_Stylesheet, this);
            UIElementsUtils.CloneTemplateInto("Inspectors/MarkerEditor.uxml", this);
            AddToClassList("drawerElement");

            var deleteButton = this.Q <Button>("deleteButton");

            deleteButton.clickable.clicked += () => { RemoveMarker(m_Marker); };

            if (!marker.payload.ValidPayloadType)
            {
                var contents = this.Q <VisualElement>(classes: "arrayEntryContents");
                contents.Clear();
                var unknownLabel = new Label {
                    text = MarkerAttribute.k_UnknownMarkerType
                };
                unknownLabel.AddToClassList(AnnotationsEditor.k_UnknownAnnotationType);
                contents.Add(unknownLabel);
                return;
            }

            TextField typeLabel = this.Q <TextField>();

            typeLabel.value = MarkerAttribute.GetDescription(m_Marker.payload.Type);
            typeLabel.SetEnabled(false);

            var timeField = this.Q <TimeField>("timeInSeconds");

            timeField.Init(m_Clip, marker.timeInSeconds);
            timeField.TimeChanged += newTime =>
            {
                if (!EqualityComparer <float> .Default.Equals(m_Marker.timeInSeconds, newTime))
                {
                    Undo.RecordObject(m_Clip.Asset, "Change marker time");
                    m_Marker.timeInSeconds = newTime;
                    m_Marker.NotifyChanged();
                    clip.Asset.MarkDirty();
                }
            };

            m_Marker.Changed += UpdateTime;

            m_PayloadInspector = UnityEditor.Editor.CreateEditor(m_Marker.payload.ScriptableObject) as GenericStructInspector;

            m_PayloadInspector.StructModified += () =>
            {
                m_Marker.payload.Serialize();
                m_Clip.Asset.MarkDirty();
            };

            VisualElement inspectorElement   = m_PayloadInspector.CreateInspectorGUI() ?? new IMGUIContainer(m_PayloadInspector.OnInspectorGUI);
            var           inspectorContainer = this.Q <VisualElement>("payloadInspector");

            inspectorContainer.Add(inspectorElement);

            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
            m_Clip.Asset.AssetWasDeserialized += UpdateTime;
        }