Ejemplo n.º 1
0
        private IEnumerator AutosaveStudio()
        {
            while (true)
            {
                yield return(new WaitForSeconds(AutosaveInterval.Value * 60));

                //Studio not loaded yet
                if (!Studio.Studio.IsInstance())
                {
                    continue;
                }

                if (AutosaveFileLimit.Value != 0 && AutosaveEnabled.Value)
                {
                    //Display a counter before saving so that the user has a chance to stop moving the camera around
                    if (AutosaveCountdown.Value > 0)
                    {
                        for (int countdown = AutosaveCountdown.Value; countdown > 0; countdown--)
                        {
                            SetText($"Autosaving in {countdown}");
                            yield return(new WaitForSeconds(1));
                        }
                    }

                    SetText("Saving...");
                    yield return(new WaitForSeconds(1));

                    //Don't save if the user is in the middle of clicking and dragging
                    while (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2))
                    {
                        yield return(new WaitForSeconds(1));
                    }

                    //Needed so the thumbnail is correct
                    yield return(new WaitForEndOfFrame());

                    Autosaving = true;

                    //Game runs similar code
                    foreach (KeyValuePair <int, ObjectCtrlInfo> item in Studio.Studio.Instance.dicObjectCtrl)
                    {
                        item.Value.OnSavePreprocessing();
                    }
                    Studio.CameraControl m_CameraCtrl = (Studio.CameraControl)Traverse.Create(Studio.Studio.Instance).Field("m_CameraCtrl").GetValue();
                    Studio.Studio.Instance.sceneInfo.cameraSaveData = m_CameraCtrl.Export();
                    DateTime now  = DateTime.Now;
                    string   str  = $"autosave_{now.Year}_{now.Month:00}{now.Day:00}_{now.Hour:00}{now.Minute:00}_{now.Second:00}_{now.Millisecond:000}.png";
                    string   path = $"{UserData.Create(AutosavePathStudio)}{str}";
                    Studio.Studio.Instance.sceneInfo.Save(path);

                    DeleteAutosaves(AutosavePathStudio);

                    SetText("Saved!");
                    Autosaving = false;
                    yield return(new WaitForSeconds(2));

                    SetText("");
                }
            }
        }
Ejemplo n.º 2
0
        private static void StartPOV()
        {
            var ctrlInfo = Studio.Studio.GetCtrlInfo(Singleton <Studio.Studio> .Instance.treeNodeCtrl.selectNode);

            if (!(ctrlInfo is OCIChar ocichar))
            {
                return;
            }

            var temp = GameObject.Find("StudioScene/Camera/CameraSet/CameraController");

            if (temp == null)
            {
                return;
            }

            cc = temp.GetComponent <Studio.CameraControl>();
            if (cc == null)
            {
                return;
            }

            chara = ocichar.charInfo;

            eyes = chara.eyeLookCtrl.eyeLookScript.eyeObjs;
            if (eyes == null)
            {
                return;
            }

            head = chara.objHeadBone;
            if (head == null)
            {
                return;
            }

            if (hideHead.Value)
            {
                head.SetActive(false);
            }

            var data = cc.Export();

            backupData = data;
            backupFov  = cc.fieldOfView;

            cc.Import(new Studio.CameraControl.CameraData(data)
            {
                distance = Vector3.zero
            });
            viewRotation = Vector3.zero;

            toggle = true;
        }