FromJsonOverwrite() private method

private FromJsonOverwrite ( string json, object objectToOverwrite ) : void
json string
objectToOverwrite object
return void
コード例 #1
0
ファイル: HostView.cs プロジェクト: yaoya/UnityDecompiled
        internal void Reload(object userData)
        {
            EditorWindow editorWindow = userData as EditorWindow;

            if (!(editorWindow == null))
            {
                Type     type     = editorWindow.GetType();
                string   json     = EditorJsonUtility.ToJson(editorWindow);
                DockArea dockArea = editorWindow.m_Parent as DockArea;
                if (dockArea != null)
                {
                    int idx = dockArea.m_Panes.IndexOf(editorWindow);
                    dockArea.RemoveTab(editorWindow, false);
                    UnityEngine.Object.DestroyImmediate(editorWindow, true);
                    editorWindow = (ScriptableObject.CreateInstance(type) as EditorWindow);
                    dockArea.AddTab(idx, editorWindow);
                }
                else
                {
                    editorWindow.Close();
                    editorWindow = (ScriptableObject.CreateInstance(type) as EditorWindow);
                    if (editorWindow != null)
                    {
                        editorWindow.Show();
                    }
                }
                EditorJsonUtility.FromJsonOverwrite(json, editorWindow);
            }
        }
コード例 #2
0
        public static void PasteRules(MenuCommand item)
        {
            RuleTilePlus tile = item.context as RuleTilePlus;

            if (tile == null)
            {
                return;
            }

            try {
                RuleTileRuleWrapper rulesWrapper = new RuleTileRuleWrapper();
                EditorJsonUtility.FromJsonOverwrite(EditorGUIUtility.systemCopyBuffer, rulesWrapper);
                tile.m_TilingRules.AddRange(rulesWrapper.rules);
            } catch (Exception) {
                Debug.LogError("Unable to paste rules from system copy buffer");
            }
        }
コード例 #3
0
ファイル: HostView.cs プロジェクト: Achay009/UnityCsReference
        internal void Reload(object userData)
        {
            EditorWindow window = userData as EditorWindow;

            if (window == null)
            {
                return;
            }

            // Get some info on the existing window.
            Type windowType = window.GetType();

            // Save what we can of the window.
            string windowJson = EditorJsonUtility.ToJson(window);

            DockArea dockArea = window.m_Parent as DockArea;

            if (dockArea != null)
            {
                int windowIndex = dockArea.m_Panes.IndexOf(window);

                // Destroy window.
                dockArea.RemoveTab(window, false); // Don't kill dock if empty.
                DestroyImmediate(window, true);

                // Create window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                dockArea.AddTab(windowIndex, window);
            }
            else
            {
                // Close the existing window.
                window.Close();

                // Recreate window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                if (window != null)
                {
                    window.Show();
                }
            }

            // Restore what we can of the window.
            EditorJsonUtility.FromJsonOverwrite(windowJson, window);
        }
コード例 #4
0
        private static void PasteRules(MenuCommand item)
        {
            RuleTile tile = item.context as RuleTile;

            if (tile == null)
            {
                return;
            }

            try
            {
                RuleTileRuleWrapper rulesWrapper = new RuleTileRuleWrapper();
                EditorJsonUtility.FromJsonOverwrite(EditorGUIUtility.systemCopyBuffer, rulesWrapper);
                tile.m_TilingRules.AddRange(rulesWrapper.rules);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
コード例 #5
0
ファイル: RuleTileEditor.cs プロジェクト: show50726/PF2D
        private static void PasteRules(MenuCommand item)
        {
            RuleTile tile = item.context as RuleTile;

            if (tile == null)
            {
                return;
            }

            try
            {
                RuleTileRuleWrapper rulesWrapper = new RuleTileRuleWrapper();
                EditorJsonUtility.FromJsonOverwrite(EditorGUIUtility.systemCopyBuffer, rulesWrapper);
                tile.m_TilingRules.AddRange(rulesWrapper.rules);
            }
#pragma warning disable CS0168 // 已宣告變數,但從未使用過它
            catch (Exception e)
#pragma warning restore CS0168 // 已宣告變數,但從未使用過它
            {
                Debug.LogError("Unable to paste rules from system copy buffer");
            }
        }
コード例 #6
0
        public static bool ParseCustom <T>(string text, out T res) where T : new()
        {
            res = new T();
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }
            var prefix = CustomPrefix <T>();

            if (!text.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            try
            {
                EditorJsonUtility.FromJsonOverwrite(text.Substring(prefix.Length), res);
            }
            catch (ArgumentException)
            {
                return(false);
            }
            return(true);
        }
コード例 #7
0
 protected override void DeserializeView(string serializedView)
 {
     EditorJsonUtility.FromJsonOverwrite(serializedView, this);
 }