Ejemplo n.º 1
0
        public void HandleSceneAddButton(SceneData sceneData = null)
        {
            SideScenePanel panel = new SideScenePanel();

            panel.Click  += OnScenePanelClick;
            panel.Delete += OnScenePanelDelete;

            TimeSpan coursorTime = _timeLine.TimeLineEngine.Time;
            TimeSpan duration    = new TimeSpan(0, 0, 10);

            if (sceneData != null)
            {
                duration = sceneData.Duration;
            }
            foreach (SideScenePanel scenePanel in _scenePanels)
            {
                if (coursorTime >= scenePanel.Scene.Start && coursorTime < scenePanel.Scene.End)
                {
                    EditorUtility.DisplayDialog("Error!", "You cannot add scene on the occupied time.", "Ok");
                    return;
                }
                if (coursorTime < scenePanel.Scene.Start && coursorTime + duration > scenePanel.Scene.Start)
                {
                    TimeSpan gap = scenePanel.Scene.Start - coursorTime;
                    if (gap < duration)
                    {
                        duration = gap;
                    }
                }
            }
            if (coursorTime + duration > _timeLine.TimeLineEngine.Duration)
            {
                duration = _timeLine.TimeLineEngine.Duration - coursorTime;
            }
            if (sceneData == null)
            {
                panel.Scene.Color = ExtensionMethods.ChangeColorBrightness(Color.gray, 0.7f);
            }
            else
            {
                panel.Scene.AssignWithoutTime(sceneData);
            }

            panel.Scene.Start = coursorTime;
            panel.Scene.End   = coursorTime + duration;
            _scenePanels.Add(panel);
            _scenesLine.AddLabel(panel.Scene);
        }
Ejemplo n.º 2
0
        /// <summary> Load data from given asset data.</summary>
        /// <param name="data">Data to be loaded.</param>
        public void LoadData(CutsceneAsset data)
        {
            if (data == null)
            {
                return;
            }
            _enableSave = false;


            _baseData      = null;
            _selectedScene = null;
            _scenePanels.Clear();
            _scenesLine.ClearLabels();
            _timeLine.ClearLabels();
            _soundLine.AudioClip          = null;
            _soundLine.AudioClipStartTime = TimeSpan.Zero;


            _baseData = data;

            _timeLine.Zoom = _baseData.Zoom;

            _soundLine.AudioClip          = _baseData.AudioClip;
            _soundLine.AudioClipStartTime = new TimeSpan(_baseData.AudioClipStartTimeTicks);

            foreach (SceneData scene in _baseData.Scenes)
            {
                SideScenePanel panel = new SideScenePanel(scene);
                panel.Click  += OnScenePanelClick;
                panel.Delete += OnScenePanelDelete;
                _scenePanels.Add(panel);
                _scenesLine.AddLabel(panel.Scene);
            }
            _timeLine.SourceListToTimeLabels(_baseData.TimeLabelsData);

            _timelinePanelScrollPos = _baseData.ScrollPos;
            _enableSave             = true;
            initialized             = true;

            if (EditorApplication.isPlaying)
            {
                bool             cutsceneEngineFound = false;
                CutsceneEngine[] engines             = FindObjectsOfType <CutsceneEngine>();
                foreach (CutsceneEngine engine in engines)
                {
                    if (engine.Cutscene.GetInstanceID() == _baseData.GetInstanceID())
                    {
                        _timeLine.AssignExternalTimeFlowEngine(engine.TimeEngine);
                        cutsceneEngineFound = true;
                        break;
                    }
                }
                if (!cutsceneEngineFound)
                {
                    _timeLine.CreateNewEngine(new TimeSpan(_baseData.TimeTicks), new TimeSpan(_baseData.DurationTicks));
                }
            }
            else
            {
                _timeLine.TimeLineEngine.SetTime(new TimeSpan(_baseData.TimeTicks));
                _timeLine.TimeLineEngine.Duration = new TimeSpan(_baseData.DurationTicks);
            }
        }