import a shapefile in unity scene
Hi everyone, I need to import a shapefile into my unity scene. Could you please tell me if there is a way to do it? Thank you
Hi there,
It's been almost a year you asked this question and I am currently in need of the same thing as you were and I don't find the way of doing it (been searching quite everywhere) !! Did you have what you were searching for ? If yes, please let me know :)
Thanks in advance.
Answer by asalaporte · Jul 05, 2019 at 01:45 PM
Here is the method we used :
First : a C# script was written by ESRI, which is the society which created the Shapefile format. This script basically reads polylines, lines... but if you want to use it for 3D (polygon Z, type 35), you need to modify this script to add the Z axis (which we’ve done).
Then : In a monobehavior script (that you'll create and bind to GameObject) you will call the method of ESRI's script. This new script will allow you to catch 3DVectors.
Then : You call Mesh's method by using a library called Triangle.Net which will make the mesh. BUT, this last library have to be sligthly modified if you want to use it with shapefile value (which we’ve done too, by removing a directory).
Here is our work (most of it from my colleague in fact, credits to her :) ) :
I’m giving you the link to a GitHub where the files are in the states in which we’ve been able to have something drawn into Unity. My collegue is still working on it and we’ll probably push the work for you to have it (with real 3D shapefiles, PNG, greyscale heightmap correctly drawn into Unity).
https://github.com/AsaLap/ShapeFileForUnity
Technically, it works if you use the shapefile given on the GitHub and if you correctly bind the script and the ChunkPrefab to an empty GambeObject AND if you don't forget to put the path of the shapefile into the correct field (click on the GameObject with the binded script, and you'll have a field named "path" waiting for you to fill it).
Link to ESRI script :
Link to Triangle.Net :
Really hope it can help you, sorry for the mess, we’ll try to make things clear once it’s all done :)
Answer by charlotte-andre · May 07, 2020 at 10:08 AM
Hi ! I'm the programmer of this code ! I've done a readMe of this project but forget to add it on my Git ! I'll try to find it and insert it as soon as possible !
Hey! it really works But all the Z values I get are equal to 1.... which still gives me a 2D design... what could it be? Also "departement.shp" attached is on 2D as well
Answer by ysklab · Jun 28, 2019 at 12:23 PM
Hi @asalaporte ; No I still looking for a solution. Do you have a solution since your last message?
Hello @ysklab , yes my collegue and I made it through ! I'll post our method here next week :)
Thank you @asalaporte . I am waiting to see it!
Answer by JakhonGame · May 07, 2020 at 09:37 AM
Can you add readme file to your github repository? We don't know how to use it.
I am referring to this project:
[https://github.com/CharlotteAndre/ShapeFileForUnity/tree/master/Assets][1]
Your answer
Follow this Question
Related Questions
How do I get list of nearby locations using Mapbox with Unity? 0 Answers
What is the best way to achieve local database for mobile? 0 Answers
Some help with Data Save/Load would be most appreciated 3 Answers
How to script TreeObject variables in runtime ? 0 Answers
Save multiple inputs for one item and print out all items 0 Answers