Пример #1
0
        public object OnSerializePreferences()
        {
            if (!Core.EditorXR.preserveLayout)
            {
                return(null);
            }

            var preferences      = new Preferences();
            var workspaceLayouts = preferences.workspaceLayouts;

            foreach (var workspace in workspaces)
            {
                var layout = new WorkspaceLayout();
                layout.name          = workspace.GetType().FullName;
                layout.localPosition = workspace.transform.localPosition;
                layout.localRotation = workspace.transform.localRotation;
                layout.contentBounds = workspace.contentBounds;

                var serializeWorkspace = workspace as ISerializeWorkspace;
                if (serializeWorkspace != null)
                {
                    var payload = serializeWorkspace.OnSerializeWorkspace();
                    layout.payloadType = payload.GetType().FullName;
                    layout.payload     = JsonUtility.ToJson(payload);
                }

                workspaceLayouts.Add(layout);
            }

            return(preferences);
        }
Пример #2
0
        private WorkspaceLayout createNewWorkspaceLayoutWithOpenPresenters()
        {
            var workspaceLayout = new WorkspaceLayout();

            foreach (var presenter in _applicationController.OpenedPresenters())
            {
                var withId = presenter.Subject.DowncastTo <IWithId>();
                if (withId == null)
                {
                    continue;
                }
                var workspaceLayoutItem = new WorkspaceLayoutItem {
                    WasOpenOnSave = true, SubjectId = withId.Id, PresentationSettings = presenter.GetSettings()
                };
                workspaceLayout.AddLayoutItem(workspaceLayoutItem);
            }
            return(workspaceLayout);
        }