Example #1
0
        public static bool OpenFile(int instanceID, int line)
        {
            CutsceneAsset data = EditorUtility.InstanceIDToObject(instanceID) as CutsceneAsset;

            if (data != null)
            {
                ShowWindow(data);
            }
            return(false);
        }
Example #2
0
        /// <summary> Shows cutscene planner windows.</summary>
        /// <param name="data"></param>
        public static void ShowWindow(CutsceneAsset data)
        {
            CutscenePlannerWindow window = EditorWindow.GetWindow <CutscenePlannerWindow>();

            if (data != null)
            {
                window.LoadData(data);
            }
            window.Focus();
        }
Example #3
0
        public static void AddCutscene()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (path == "")
            {
                path = "Assets";
            }
            else if (System.IO.Path.GetExtension(path) != "")
            {
                path = path.Replace(System.IO.Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            }

            CutsceneAsset newFile = ScriptableObject.CreateInstance <CutsceneAsset>();

            newFile.DefaultInit();

            newFile.CreateAsset(path, "New Cutscene");
        }
        /// <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);
            }
        }