Пример #1
0
        void OnEnable()
        {
            int numTargets = targets.Length;

            m_assets = new FrameMarker[numTargets];
            for (int i = 0; i < numTargets; i++)
            {
                m_assets[i] = targets[i] as FrameMarker;
            }
        }
Пример #2
0
    static void ToggleFrameMarker(ShortcutArguments args) {
        foreach (Object obj in Selection.objects) {
            FrameMarker marker = obj as FrameMarker;
            if (null == marker) {
                continue;
            }
            FrameMarkerInspector.ToggleMarkerValueByContext(marker);

        }        
    }    
Пример #3
0
    static void LockAndEditFrame(ShortcutArguments args) {
        
        foreach (Object obj in Selection.objects) {
            FrameMarker frameMarker = obj as FrameMarker;
            if (null == frameMarker) {
                continue;
            }
            SISPlayableFrame playableFrame       = frameMarker.GetOwner();
            RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset<RenderCachePlayableAsset>();            
            if (null == playableAsset)
                return;
        
            FrameMarkerInspector.LockAndEditPlayableFrame(playableFrame, playableAsset);

        }        
                        
    }    
Пример #4
0
        public IEnumerator ResetFrameMarkers()
        {
            PlayableDirector director = EditorUtilityTest.NewSceneWithDirector();
            TimelineClip     clip     = EditorUtilityTest.CreateTestSISTimelineClip(director);
            StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset;

            Assert.IsNotNull(sisAsset);
            yield return(null);

            SISClipData clipData = sisAsset.GetBoundClipData();

            Assert.IsNotNull(clipData);
            clipData.RequestFrameMarkers(true);
            yield return(null);

            //Change image to false
            StreamingImageSequenceTrack track = clip.GetParentTrack() as StreamingImageSequenceTrack;

            Assert.IsNotNull(track);
            foreach (var m in track.GetMarkers())
            {
                FrameMarker marker = m as FrameMarker;
                Assert.IsNotNull(marker);
                marker.SetFrameUsed(false);

                UnityEngine.Assertions.Assert.IsFalse(marker.IsFrameUsed());
            }
            yield return(null);

            sisAsset.ResetPlayableFrames();
            yield return(null);

            //Check if all markers have been reset to used
            foreach (var m in track.GetMarkers())
            {
                FrameMarker marker = m as FrameMarker;
                Assert.IsNotNull(marker);
                UnityEngine.Assertions.Assert.IsTrue(marker.IsFrameUsed());
            }
            yield return(null);


            EditorUtilityTest.DestroyTestTimelineAssets(clip);
            yield return(null);
        }
//----------------------------------------------------------------------------------------------------------------------    
    public override void DrawOverlay(IMarker m, MarkerUIStates uiState, MarkerOverlayRegion region)
    {
        FrameMarker marker = m as FrameMarker;
        if (null == marker)
            return;

        SISPlayableFrame playableFrame = marker.GetOwner();
        
        //Check invalid PlayableFrame/ClipData. Perhaps because of unsupported Duplicate operation ?
        PlayableFrameClipData clipData = playableFrame?.GetOwner();
        if (clipData == null)
            return;
        
        PlayableFramePropertyID inspectedPropertyID = clipData.GetInspectedProperty();
        switch (inspectedPropertyID) {
            case PlayableFramePropertyID.USED: {
                
                if (playableFrame.IsLocked()) {
                    //At the moment, all locked frames are regarded as inactive 
                    if (playableFrame.IsUsed()) {
                        Graphics.DrawTexture(region.markerRegion, EditorTextures.GetInactiveCheckedTexture());
                    }
                    Rect lockRegion = region.markerRegion;
                    lockRegion.x -= 5;
                    lockRegion.y -= 8;
                    Graphics.DrawTexture(lockRegion, EditorTextures.GetLockTexture());                    
                } else {
                    if (playableFrame.IsUsed()) {
                        Graphics.DrawTexture(region.markerRegion, EditorTextures.GetCheckedTexture());
                    }
                    
                }
                break;
            }
            case PlayableFramePropertyID.LOCKED: {
                if (playableFrame.IsLocked()) {
                    Graphics.DrawTexture(region.markerRegion, EditorTextures.GetLockTexture());                    
                }
                break;
            }
            
        }
        
    }
Пример #6
0
        internal static void ToggleMarkerValueByContext(FrameMarker frameMarker)
        {
            SISPlayableFrame        playableFrame       = frameMarker.GetOwner();
            TimelineClipSISData     timelineClipSISData = playableFrame.GetOwner();
            PlayableFramePropertyID inspectedPropertyID = timelineClipSISData.GetInspectedProperty();

            switch (inspectedPropertyID)
            {
            case PlayableFramePropertyID.USED: {
                playableFrame.SetUsed(!playableFrame.IsUsed());
                break;
            }

            case PlayableFramePropertyID.LOCKED: {
                playableFrame.SetLocked(!playableFrame.IsLocked());
                break;
            }
            }
        }
Пример #7
0
//----------------------------------------------------------------------------------------------------------------------
        private static void SetMarkerValueByContext(FrameMarker frameMarker, bool value)
        {
            SISPlayableFrame        playableFrame       = frameMarker.GetOwner();
            TimelineClipSISData     timelineClipSISData = playableFrame.GetOwner();
            PlayableFramePropertyID inspectedPropertyID = timelineClipSISData.GetInspectedProperty();

            switch (inspectedPropertyID)
            {
            case PlayableFramePropertyID.USED: {
                playableFrame.SetUsed(value);
                break;
            }

            case PlayableFramePropertyID.LOCKED: {
                playableFrame.SetLocked(value);
                break;
            }
            }
        }
//----------------------------------------------------------------------------------------------------------------------
        ///<inheritdoc />
        public override ActionValidity Validate(IEnumerable <IMarker> markers)
        {
            foreach (IMarker marker in markers)
            {
                FrameMarker frameMarker = marker as FrameMarker;
                if (null == frameMarker)
                {
                    return(ActionValidity.NotApplicable);
                }


                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return(ActionValidity.NotApplicable);
                }
            }
            return(ActionValidity.Valid);
        }
//----------------------------------------------------------------------------------------------------------------------    
    public override void DrawOverlay(IMarker m, MarkerUIStates uiState, MarkerOverlayRegion region)
    {
        FrameMarker marker = m as FrameMarker;
        if (null == marker)
            return;


        SISPlayableFrame playableFrame = marker.GetOwner();
        TimelineClipSISData timelineClipSISData = playableFrame.GetOwner();
        PlayableFramePropertyID inspectedPropertyID = timelineClipSISData.GetInspectedProperty();
        switch (inspectedPropertyID) {
            case PlayableFramePropertyID.USED: {
                
                if (playableFrame.IsLocked()) {
                    //At the moment, all locked frames are regarded as inactive 
                    if (playableFrame.IsUsed()) {
                        Graphics.DrawTexture(region.markerRegion, EditorTextures.GetInactiveCheckedTexture());
                    }
                    Rect lockRegion = region.markerRegion;
                    lockRegion.x -= 5;
                    lockRegion.y -= 8;
                    Graphics.DrawTexture(lockRegion, EditorTextures.GetLockTexture());                    
                } else {
                    if (playableFrame.IsUsed()) {
                        Graphics.DrawTexture(region.markerRegion, EditorTextures.GetCheckedTexture());
                    }
                    
                }
                break;
            }
            case PlayableFramePropertyID.LOCKED: {
                if (playableFrame.IsLocked()) {
                    Graphics.DrawTexture(region.markerRegion, EditorTextures.GetLockTexture());                    
                }
                break;
            }
            
        }
        
    }
        ///<inheritdoc />
        public override bool Execute(IEnumerable <IMarker> markers)
        {
            foreach (IMarker marker in markers)
            {
                FrameMarker frameMarker = marker as FrameMarker;
                if (null == frameMarker)
                {
                    return(false);
                }

                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return(false);
                }

                FrameMarkerInspector.LockAndEditPlayableFrame(playableFrame, playableAsset);
            }

            return(true);
        }
        static void RenderCachePlayableAssetInspector_OnSelectionChanged()
        {
            if (!m_lockMode)
            {
                return;
            }

            //Abort lock mode if we are not selecting marker
            foreach (var selectedObj in Selection.objects)
            {
                FrameMarker marker = selectedObj as FrameMarker;
                if (null == marker)
                {
                    UnlockSISData();
                    return;
                }

                if (m_inspectedSISDataForLocking != marker.GetOwner().GetOwner())
                {
                    UnlockSISData();
                    return;
                }
            }
        }
        public IEnumerator UncheckFrameMarkers()
        {
            PlayableDirector director = EditorUtilityTest.NewSceneWithDirector();
            TimelineClip     clip     = EditorUtilityTest.CreateTestTimelineClip(director);
            StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset;

            Assert.IsNotNull(sisAsset);
            TimelineClipSISData timelineClipSISData = sisAsset.GetBoundTimelineClipSISData();

            timelineClipSISData.RequestFrameMarkers(true);
            yield return(null);

            double timePerFrame = TimelineUtility.CalculateTimePerFrame(clip);
            int    numImages    = sisAsset.GetImageFileNames().Count;

            clip.timeScale = 3.75f; //use scaling
            EditorUtilityTest.ResizeSISTimelineClip(clip, (timePerFrame * numImages));
            yield return(null);

            int numFrames = TimelineUtility.CalculateNumFrames(clip);

            Assert.AreEqual(numImages, numFrames);

            //Reset: make sure that the curve is a simple straight line from 0 to 1
            StreamingImageSequencePlayableAsset.ResetTimelineClipCurve(clip);
            yield return(null);

            sisAsset.ResetPlayableFrames();
            yield return(null);

            StreamingImageSequenceTrack track = clip.parentTrack as StreamingImageSequenceTrack;

            Assert.IsNotNull(track);
            List <FrameMarker> frameMarkers = new List <FrameMarker>();

            int i = 0;

            foreach (var m in track.GetMarkers())
            {
                FrameMarker marker = m as FrameMarker;
                Assert.IsNotNull(marker);
                frameMarkers.Add(marker);
                int imageIndex = sisAsset.GlobalTimeToImageIndex(clip, marker.time);
                Assert.AreEqual(i, imageIndex);
                ++i;
            }

            //Uncheck and see if the unchecked images became ignored
            frameMarkers[4].SetFrameUsed(false);
            frameMarkers[5].SetFrameUsed(false);
            Assert.AreEqual(3, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[4].time));
            Assert.AreEqual(3, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[5].time));


            frameMarkers[7].SetFrameUsed(false);
            frameMarkers[8].SetFrameUsed(false);
            Assert.AreEqual(6, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[7].time));
            Assert.AreEqual(6, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[8].time));

            EditorUtilityTest.DestroyTestTimelineAssets(clip);
            yield return(null);
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangeImage"/> class with the specified
        /// <see cref="EntityImage"/>.</summary>
        /// <param name="image">
        /// The <see cref="EntityImage"/> whose data to change.</param>
        /// <exception cref="PropertyValueException">
        /// The current <see cref="ImageSection"/> contains an empty <see
        /// cref="ImageSection.ImageFiles"/> collection.</exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="image"/> is a null reference.</exception>
        /// <remarks>
        /// The data of the specified <paramref name="image"/> may be changed in the dialog, as
        /// indicated by the value of the <see cref="DataChanged"/> property.</remarks>

        public ChangeImage(EntityImage image)
        {
            if (image == null)
            {
                ThrowHelper.ThrowArgumentNullException("image");
            }

            // require non-empty ImageFiles for simplicity
            if (MasterSection.Instance.Images.ImageFiles.Count == 0)
            {
                ThrowHelper.ThrowPropertyValueException(
                    "MasterSection.Instance.Images.ImageFiles", Tektosyne.Strings.PropertyEmpty);
            }

            this._image = image;
            InitializeComponent();
            Title += image.Id;

            // initialize frame control buttons
            AddFrameButton.ShowSymbol(Symbols.BoxEmpty);
            RemoveFrameButton.ShowSymbol(Symbols.BoxCrossed);
            MoveLeftButton.ShowSymbol(Symbols.ArrowLeft);
            MoveRightButton.ShowSymbol(Symbols.ArrowRight);

            // set maximum ranges for frame dimensions
            LeftUpDown.Maximum   = Int32.MaxValue;
            TopUpDown.Maximum    = Int32.MaxValue;
            WidthUpDown.Minimum  = 1;
            WidthUpDown.Maximum  = Int32.MaxValue;
            HeightUpDown.Minimum = 1;
            HeightUpDown.Maximum = Int32.MaxValue;

            // add image files to combo box
            foreach (string id in MasterSection.Instance.Images.ImageFiles.Keys)
            {
                FileCombo.Items.Add(id);
            }

            // add animation options to combo boxes
            AnimationCombo.ItemsSource = Enum.GetValues(typeof(AnimationMode));
            SequenceCombo.ItemsSource  = Enum.GetValues(typeof(AnimationSequence));

            // add scaling options to combo boxes
            var scalingValues = Enum.GetValues(typeof(ImageScaling));

            ScalingXCombo.ItemsSource = scalingValues;
            ScalingYCombo.ItemsSource = scalingValues;

            // set animation & scaling options
            AnimationCombo.SelectedItem = image.Animation;
            SequenceCombo.SelectedItem  = image.Sequence;
            ScalingXCombo.SelectedItem  = image.ScalingX;
            ScalingYCombo.SelectedItem  = image.ScalingY;

            // enable sequence control if animation enabled
            SequenceCombo.IsEnabled = (image.Animation != AnimationMode.None);

            // initialize list box parameters
            FrameList.Polygon  = MasterSection.Instance.Areas.MapGrid.Element;
            FrameList.ScalingX = image.ScalingX;
            FrameList.ScalingY = image.ScalingY;

            // add default rectangle if none defined
            if (image.Frames.Count == 0)
            {
                image.Frames.Add(CreateFrame());
            }

            // add frame bounds to list box
            foreach (ImageFrame frame in image.Frames)
            {
                RectI bounds = frame.Bounds;

                // correct any illegal location values
                int maxPoint = SimpleXml.MaxPointIValue;
                int left     = Math.Max(0, Math.Min(maxPoint, bounds.Left));
                int top      = Math.Max(0, Math.Min(maxPoint, bounds.Top));

                // correct any illegal size values
                int maxSize = SimpleXml.MaxSizeIValue;
                int width   = Math.Max(1, Math.Min(maxSize, bounds.Width));
                int height  = Math.Max(1, Math.Min(maxSize, bounds.Height));

                // add frame with corrected bounds to list box
                RectI      newBounds = new RectI(left, top, width, height);
                ImageFrame newFrame  = new ImageFrame(frame);
                newFrame.Bounds = newBounds;

                FrameList.Items.Add(new ImageListBoxItem(newFrame));

                // add invalid file identifier to combo box
                string fileId = newFrame.Source.Key;
                if (!String.IsNullOrEmpty(fileId) && !FileCombo.Items.Contains(fileId))
                {
                    FileCombo.Items.Add(fileId);
                }
            }

            // disable Remove if only one frame defined
            RemoveFrameButton.IsEnabled = (FrameList.Items.Count > 1);

            // animate dashed outline of frame marker
            DoubleAnimation animation = new DoubleAnimation(10, 0, Duration.Automatic);

            animation.RepeatBehavior = RepeatBehavior.Forever;
            FrameMarker.BeginAnimation(Shape.StrokeDashOffsetProperty, animation);

            // construction completed
            this._initialized = true;
        }
Пример #14
0
    // Set attributes of the Frame Marker with the given id.
    public bool SetFrameMarker(FrameMarker item, int id)
    {
        if (id < 0 || id >= frameMarkers.Length)
            return false;

        frameMarkers[id] = item;
        frameMarkersDefined[id] = true;
        return true;
    }
Пример #15
0
    // Clear data of the Frame Marker with the given id and set it to undefined.
    public bool InvalidateFrameMarker(int id)
    {
        if (id < 0 || id >= frameMarkers.Length)
            return false;

        frameMarkers[id] = new FrameMarker();
        frameMarkersDefined[id] = false;

        return true;
    }
Пример #16
0
    // Creates a new Frame Marker with the data of the Frame Marker with the
    // given id.
    // Returns false if Frame Marker does not exist.
    public bool GetFrameMarker(int id, out FrameMarker fm)
    {
        fm = new FrameMarker();
        bool defined = false;

        try
        {
            fm = frameMarkers[id];
            defined = frameMarkersDefined[id];
        }
        catch
        {
            throw;
        }

        return defined;
    }