Search Unity

[DEPRECATED] Terrain Pressure Paint - Paint terrain with your pressure sensitive stylus inside Unity

Discussion in 'Assets and Asset Store' started by steego, Feb 26, 2015.

  1. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    FieldInfo treeSizeField =
    m_TreePainterType.GetField("brushSize", treeFlags);
     
  2. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    I'm guessing the m_TreePainterType is the one that's null, it should get its value from m_TreePainterType = m_EditorAssembly.GetType("UnityEditor.TreePainter");

    So probably they've done something with the tree painter in 2019.1, you can try to look for it if it's just been moved, or you can just remove everything related to painting trees if that's not something you use.
     
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Thanks, yes I'm using it a lot for trees.
    And yes I think they have done something with trees in the alpha, just I don't know what they did.
    Any tips on how I can look for what has changed?
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I think its because some of the api is named experimental in the alpha,
    I'm not to worried about it now
     
  5. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Yeah I'd advise you to wait until it leaves alpha before you start mucking about with it, by then the source code should be available here: https://github.com/Unity-Technologies/UnityCsReference

    You basically need to reverse engineer what they've done to the UnityEditor.TreePainter type, if it's just a rename you just have to rename it in the code, if it's more substantial, you have to figure out how the tree painting works now, and adjust accordingly, sorry I can't be more specific than that.
     
    Lars-Steenhoff likes this.
  6. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Yes I know what you mean, I was looking a the source code and saw it's only for 2018, so I decided to wait it out.
    I even managed to find the the list of functions for the alpha, and then I saw it said experimental in front of the new terrain functions.

    probably just a name change.
    I will get back to it when the 2019 gets into beta.
     
    steego likes this.
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
  8. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Not at the moment I'm afraid, what problems are you having?
     
  9. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    The menu of terrain pressure paint shows up normal, but when I create a terrain I get this error

    NullReferenceException: Object reference not set to an instance of an object
    FreakLibEditor.TerrainPressurePaint.TerrainPressurePaint.OnSceneGUI (UnityEditor.SceneView sv) (at Assets/Plugins/FreakshowStudio/TerrainPressurePaint/Editor/TerrainPressurePaint.cs:393)
    UnityEditor.SceneView.CallOnSceneGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:3293)
    UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2522)
    UnityEditor.SceneView.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2383)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:345)
    UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:339)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:315)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
    UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:340)
    UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:295)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:481)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:455)
    UnityEngine.UIElements.UIR.ImmediateRenderer.Draw (UnityEngine.UIElements.UIR.DrawChainState dcs) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderers.cs:447)
    UnityEngine.UIElements.UIR.UIRenderDevice.ContinueChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.UIElements.UIR.DrawChainState dcs, System.Boolean outerChainsWithMeshRenderer) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:841)
    UnityEngine.UIElements.UIR.UIRenderDevice.DrawChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.Rect viewport, UnityEngine.Matrix4x4 projection, UnityEngine.Texture atlas) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:824)
    UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:218)
    UnityEngine.UIElements.UIRRepaintUpdater.Update () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:190)
    UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:70)
    UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:589)
    UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
    UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
    UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
     
  10. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Sorry @Lars-Steenhoff this is more than 5 minutes work to look at, so I don't have the time right now I'm afraid. If you ping me in the first week of May I might be able to take a quick look, but I suspect the changes to the terrain system are too big for this to be a quick fix.
     
  11. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Sure thing!
     
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    @steego Do you have time to have a look now? Im ready to help were I can
     
  13. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    I've had a look, unfortunately they've changed a lot of the terrain painting tools, so it would need a complete rewrite to update at this point, and I don't have time for that right now, I'm sorry.

    I don't understand why they don't support it themselves though, at least on Mac it's more or less as simple as multiplying the strength with Event.current.pressure.

    Maybe try to get a hold of the terrain devs at UT and ask? Seems like they're not aware that painting with a stylus is something people would want (judging by my sales though, it doesn't really seem like something people want hehe).
     
    Lars-Steenhoff likes this.
  14. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Thanks for looking!

    Yea I was wondering why its not already build into unity.
    I did ask them last year at unity 2018

    You can see the question I asked about pressure sensitivity in the editor in this video at 39.47


    The answer was that it is planned, and that its related to the new unity input system.
    I'm not sure what the planned timeframe it for release.

    I will in the meantime stay on unity 2018.4 LTS for my terrain painting and then import the painted terrains into unity 2019.

    I do miss this tool, because tree painting with pressure is very nice, and I have been enjoying using your tool a lot.
    Thanks for making it!

     
  15. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Happy to hear it's been useful. They have a new tool system for terrain painting now, so it should be relatively easy to create new tools with pressure support I think, but it's not something I have the time for now.
     
    Lars-Steenhoff likes this.
  16. yaprakcierailesi

    yaprakcierailesi

    Joined:
    Mar 27, 2020
    Posts:
    1
    pls help me. Ek Açıklama 2020-04-08 083404.jpg
     
    Lars-Steenhoff likes this.
  17. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
  18. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Looks like unity 2019 was used in that screenshot
     
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I hope this will make terrain pressure paint come back to live :)
     
  20. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    I'm afraid the biggest changes are how the terrain system works, not so much just getting the pressure information (which is already present on MacOS).
     
  21. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Yes that is true, well I hope you or unity will make the terrain painting work again in 2019 with pressure. I don't want to get stuck in 2018.