Search Unity

Error exporting into asset and fix

Discussion in 'World Building' started by OndrejP, Dec 11, 2019.

  1. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    304
    For some reason Application.dataPath returns c:/... but SaveFileInProject returns C:/...
    This causes issue when trying to get relative path in ExportAsset.AssetPathFromFullPath

    I've fixed it in ExportAsset.cs by replacing line 120 with:

    Code (CSharp):
    1. string relativeDirectory = string.Format("Assets{0}", directory.ToLower().Replace(Application.dataPath.ToLower(), ""));
    This is not ideal solution since it might not work well on Linux.

    Call stack:
    Code (CSharp):
    1. UnityException: Creating asset at path AssetsC:/Data/Projects/Assets/sss.asset failed.
    2. UnityEditor.ProBuilder.Actions.ExportAsset.CreateOrReplaceAsset[T] (T asset, System.String path) (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/ExportAsset.cs:307)
    3. UnityEditor.ProBuilder.Actions.ExportAsset.ExportMesh (System.String path, UnityEngine.ProBuilder.ProBuilderMesh mesh, System.Boolean replaceOriginal, System.Boolean batchExport) (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/ExportAsset.cs:287)
    4. UnityEditor.ProBuilder.Actions.ExportAsset.ExportMesh (UnityEngine.ProBuilder.ProBuilderMesh mesh, System.Boolean replaceOriginal) (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/ExportAsset.cs:169)
    5. UnityEditor.ProBuilder.Actions.ExportAsset.ExportWithFileDialog (System.Collections.Generic.IList`1[T] meshes, UnityEditor.ProBuilder.Actions.ExportAssetOptions options) (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/ExportAsset.cs:75)
    6. UnityEditor.ProBuilder.Actions.Export.DoAction () (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/Export.cs:211)
    7. UnityEditor.ProBuilder.Actions.Export.OnSettingsGUI () (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/MenuActions/Export/Export.cs:124)
    8. UnityEditor.ProBuilder.MenuOption.OnGUI () (at C:/Data/Projects/Volcanoids/Library/PackageCache/com.unity.probuilder@4.1.2/Editor/EditorCore/MenuOption.cs:78)
    9. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    10. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    11. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    12. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
    13. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <3b74787e58694cdda2c241162159b3b7>:0)
    14. UnityEditor.HostView.Invoke (System.String methodName) (at <3b74787e58694cdda2c241162159b3b7>:0)
    15. UnityEditor.HostView.OldOnGUI () (at <3b74787e58694cdda2c241162159b3b7>:0)
    16. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    17. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    18. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    19. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    20. UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <3b395df51d304a2aba4944c11905c08f>:0)
    21. UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <3b395df51d304a2aba4944c11905c08f>:0)
    22. UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    23. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    24. UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <3b395df51d304a2aba4944c11905c08f>:0)
    25. UnityEngine.UIElements.EventDispatcher.OpenGate () (at <3b395df51d304a2aba4944c11905c08f>:0)
    26. UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <3b395df51d304a2aba4944c11905c08f>:0)
    27. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    28. UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3b395df51d304a2aba4944c11905c08f>:0)
    29. UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3b395df51d304a2aba4944c11905c08f>:0)
    30. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    31. UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <3b395df51d304a2aba4944c11905c08f>:0)
    32. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <59837000ebf54955a9cb1d31caa86097>:0)
    33.  
     
  2. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    304
    Hello? The problem is still there!