Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Possible to push walls with Probuilder on mobile at runtime?

Discussion in 'Editor & General Support' started by mcbauer, Aug 28, 2023.

  1. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    496
    Let me clarify, what I want to do is create a basic room floor plan, and then using my phone from a top down perspective, i 'd like to be able to push walls further apart, or closer together with my finger: as if I am designing a floor plan.

    I can do this with simple cubes and whatnot, but I'd really like to take advantage of Probuilder's UV tools so that I can also drag out the end of a wall and extend the total length of it and have the texture tile correctly.

    Anywho, thanks in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    You would need to first define and create the UX for what you contemplate: select, adjust, confirm, deselect.

    Warning: what you contemplate is not a trivial task. Go use your favorite CAD/CAM or 3D editing software (like Blender3D) and perform the steps (by mouse) that you envision doing within your UX.

    Now think of how those steps will work on mobile, where you do not have mouse hover and you can only tap and drag.

    That's what I mean by "define and create the UX," or the "user experience."

    And start simple: try making a simple vector line editor on touchscreen to start. If you understand the parts of that you might have a fighting chance of editing 3D geometry editing.

    You're welcome to start with my "finger polygons" code in my MakeGeo project. It already works on touch or mouse using the same code path:

    https://github.com/kurtdekker/makeg...d/makepolygoncollider2d/testfingerpolygons.cs

    Bring that up and instead of just making geometry and dropping it, record the positions in your own collection and begin to work on "select and adjust the dots I already created in step #1" type code.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
  3. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    496
    thanks @Kurt-Dekker I def get that this is not trivial, just curious if Probuilder has the ability to even do what I want. I'll give MakeGeo a shot!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Probuilder has code that only works within the editor for dealing with the UX flow: selecting, picking, etc.

    I have not used the modify-the-actual-mesh API so I don't know what utility it might provide.

    At the end of the day you will need to:

    - accept user input
    - from that input decide what vertex (vertices) the user is meaning
    - change those vertices due to further user input
    - update the actual Unity Mesh for presentation purposes.

    Making editors is tricky stuff. :)

    Keep in mind you may want to extract and restore (save / load) this data in the future as well.

    Load/Save steps:

    https://forum.unity.com/threads/save-system-questions.930366/#post-6087384

    An excellent discussion of loading/saving in Unity3D by Xarbrough:

    https://forum.unity.com/threads/save-system.1232301/#post-7872586

    Loading/Saving ScriptableObjects by a proxy identifier such as name:

    https://forum.unity.com/threads/use...lds-in-editor-and-build.1327059/#post-8394573

    When loading, you can never re-create a MonoBehaviour or ScriptableObject instance directly from JSON. The reason is they are hybrid C# and native engine objects, and when the JSON package calls
    new
    to make one, it cannot make the native engine portion of the object.

    Instead you must first create the MonoBehaviour using AddComponent<T>() on a GameObject instance, or use ScriptableObject.CreateInstance<T>() to make your SO, then use the appropriate JSON "populate object" call to fill in its public fields.

    If you want to use PlayerPrefs to save your game, it's always better to use a JSON-based wrapper such as this one I forked from a fellow named Brett M Johnson on github:

    https://gist.github.com/kurtdekker/7db0500da01c3eb2a7ac8040198ce7f6

    Do not use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.

    https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769