- Home /
Missing Method Exception when trying to access EditorJsonUtility class methods
Hi, I want to convert unity game object to json object , So I used the EditorJsonUtility class for this purpose, but it seems that editor isn't able to find the methods of that class . I reinstalled unity(5.3.2f1) but, the problem still persists.
I have attached this script to a simple 2D game object which i want to convert to json object:
using UnityEngine;
using UnityEditor;
public class MyObjectManager : MonoBehaviour {
public string jsonObject;
void Start()
{
jsonObject = EditorJsonUtility.ToJson(gameObject);
Debug.Log(jsonObject);
}
}
Here's a snippet of the error :
Any help will be appreciated!!
@charmi212121 I've approved your post. I've contacted an agent in support, as I'm unclear about the EditorJasonUtility.
Are you aware that this is an EDITOR utility and is not meant to be used at Runtime, as far as I know? What was your intended use for this Class?
In either case, I'm not sure it should be throwing an error at run-time, so I'll have someone look into it.
Yes @$$anonymous$$I'm aware about it being used in editor scripts. Originally I've used the EditorJsonUtility class methods in a custom inspector script extending the editor class, the same error followed there.
$$anonymous$$y intended use was to serialize the game object into a file, but the unity game object couldn't be serialized by using serializable so i found that EditorJsonUtility class had just the right functions that served my purpose.
Can confirm the existence of this problem. Have attempted to generate a JSON representation of multiple types of objects deriving from UnityEngine.Object to no avail. Yes, I am aware that this is an editor utility.
Also, it doesn't help that, apparently, this functionality was removed from JsonUtility in 5.3.0, at least judging from the beta release notes.
PList document support also seems to have been removed in 5.3. $$anonymous$$y work-around was to include the source myself.
How about using the regular version?
http://docs.unity3d.com/ScriptReference/JsonUtility.html
Then adding the ExecuteInEdit$$anonymous$$ode attribute?
I see what you mean but you can't make it work like that. To be clear it is perfectly possible to use JsonUtility, even in the editor, the problem is that somewhere within the C++ side of things Unity decided to prevent serializing "non-user-defined UnityEngine.Object types".
Presumably there must have been a good reason for that (I hope), anyway the problem is that EditorJsonUtility is broken because...well...it's missing from 5.3.2, even though it is listed in the docs as having been added to the API in 5.3.2!
Answer by RichardFine · Feb 22, 2016 at 02:57 PM
This is a bug in Unity 5.3. I've just fixed it (and written tests to ensure it does not happen again) and will get the fix into a patch release ASAP.
Answer by Neodrop · Mar 17, 2016 at 05:57 AM
@RichardFine Still no fixes in 5.3.4. But mentioned in beta 5.4.b9 What's wrong with current stable releases?
Answer by unity_Tt-zftHUdh007w · Aug 19, 2020 at 11:32 AM
@RichardFine If you patched it, then why is it still happening in the 2020 version? Here is the error: "MissingMethodException: Attempted to access a missing method. UnityEditor.MenuUtils.ExtractMenuItemWithPath (System.String menuString, UnityEditor.GenericMenu menu, System.String replacementMenuString, UnityEngine.Object[] temporaryContext, System.Int32 userData, System.Action`3[T1,T2,T3] onBeforeExecuteCallback, System.Action`3[T1,T2,T3] onAfterExecuteCallback) (at :0) UnityEditor.SceneHierarchy.AddCreateGameObjectItemsToMenu (UnityEditor.GenericMenu menu, UnityEngine.Object[] context, System.Boolean includeCreateEmptyChild, System.Boolean includeGameObjectInPath, System.Int32 targetSceneHandle) (at :0) UnityEditor.SceneHierarchy.CreateGameObjectContextClick (UnityEditor.GenericMenu menu, System.Int32 contextClickedItemID) (at :0) UnityEditor.SceneHierarchy.ContextClickOutsideItems () (at :0) UnityEditor.IMGUI.Controls.TreeViewController.HandleUnusedEvents () (at :0) UnityEditor.IMGUI.Controls.TreeViewController.OnGUI (UnityEngine.Rect rect, System.Int32 keyboardControlID) (at :0) UnityEditor.SceneHierarchy.DoTreeView (System.Single searchPathHeight) (at :0) UnityEditor.SceneHierarchy.OnGUI (UnityEngine.Rect rect) (at :0) UnityEditor.SceneHierarchyWindow.DoSceneHierarchy () (at :0) UnityEditor.SceneHierarchyWindow.OnGUI () (at :0) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at :0) UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at :0) UnityEditor.DockArea.OldOnGUI () (at :0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToRegularTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0) UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0) UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel iPanel) (at :0) UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at :0) UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at :0) UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at :0) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at :0) "
did you find a solution to the 2020 version?