Advertisement
akram_0090

projeny project

Jul 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.46 KB | None | 0 0
  1. http://casualient.com/5Xo
  2.  
  3. The purpose of Projeny is to allow your Unity3D project to easily scale in size without heavily impacting development time.
  4.  
  5. Projeny allows you to:
  6.  
  7. Share any Unity assets (code, scenes, prefabs, etc.) across multiple different Unity projects without copy and pasting
  8. Instantly switch between platforms
  9. Easily upgrade or downgrade installed asset store packages
  10. Optimize compile time of your project by getting Unity to only recompile the code that changes most often
  11. Split up your project into discrete packages, so that you can manage the dependencies between each, instead of having one giant Unity project of inter-related files
  12. Declare dependencies between packages, so that you always get the packages that you need without needing to hunt down missing libraries or broken links
  13. Generate a more intelligent Visual Studio solution than the Unity default, using package dependencies to create csproj dependencies
  14. See below for details on how Projeny achieves all these features.
  15.  
  16. This project is open source. If you're interested in helping, great! There's still a number of features we'd like to support eventually (in particular we need help with supporting OSX).
  17.  
  18. NOTE: Projeny requires Unity3D 5.3.1 or higher, since it makes use of the -buildTarget command line switch is only fixed in 5.3.1
  19.  
  20. Table Of Contents
  21.  
  22. Installation
  23. Overview
  24. Advantages of Using Projeny
  25. Shared files between projects
  26. Package Organization and Asset Store integration
  27. Near instant platform switching
  28. Compile time optimization
  29. Platform specific package folders
  30. Dependency Management of Packages
  31. More intelligent Visual Studio Solution generation
  32. Usage Details
  33. Managing Asset Store Assets / Releases
  34. Using Multiple Package Folders
  35. Sharing Project Settings
  36. Gotchas With Directory Links
  37. Frequently Asked Questions
  38. How do I create a new package?
  39. How do I create a new project?
  40. How do I start an entirely new set of Projeny-based project from scratch?
  41. How do I import Unity's Standard Assets?
  42. Configuration Files
  43. Projeny.yaml reference
  44. ProjenyProject.yaml reference
  45. ProjenyPackage.yaml reference
  46. Custom Release Sources
  47. Command Line Reference
  48. Appendix
  49. A. "Gotchas" with using external assemblies:
  50. Release Notes
  51. License
  52. Installation
  53.  
  54. You can either run Projeny directly from source (requires python) or simply download the latest binary. Note that Projeny is currently only supported on Windows (with an OSX version planned for future releases).
  55.  
  56. From Binary
  57.  
  58. Go to the releases section and download the latest ProjenyInstaller.exe
  59. Note that after installation completes, you will need to add the [Install Directory]/Bin directory to your windows path.
  60. From Source
  61.  
  62. Clone this repo to a place on your hard drive
  63. Make sure python 3.x is installed and that you have also installed the following:
  64. pyyaml (to install run pip install pyyaml)
  65. python for windows extensions (download here for your version of python)
  66. Open UnityPlugin/Projeny.sln in Visual Studio
  67. Build in Release Mode
  68. Add the Projeny/Source/bin folder to your windows path
  69. Overview
  70.  
  71. Projeny works by composing your Unity3D projects entirely out of 'directory links' (aka windows junctions aka symbolic links).
  72.  
  73. This is best shown with an example. After installing Projeny, download the sample project from the releases page and extract it to a new folder on your hard drive. The folder structure should appear like this:
  74.  
  75. Projeny.yaml
  76. UnityPackages
  77. AllMovers
  78. CommonShapeMover
  79. CubeMover
  80. SphereMover
  81. UnityProjects
  82. ProjenyProject.yaml
  83. AllMovers
  84. ProjenyProject.yaml
  85. ProjectSettings
  86. CubeMover
  87. ProjenyProject.yaml
  88. ProjectSettings
  89. SphereMover
  90. ProjenyProject.yaml
  91. ProjectSettings
  92. Each folder in the UnityProjects directory represents an actual Unity3D project. Note that they each have the familiar ProjectSettings directory but they do not yet have an Assets directory. This is because these projects have not been initialized yet by Projeny. You'll also notice a file named Projeny.yaml at the root of the folder structure. This is a simple text file that is used to specify configuration settings for Projeny.
  93.  
  94. To initialize these Unity projects we must run Projeny from the command line. Open up command prompt or powershell and navigate to the root directory (the same directory where you will find Projeny.yaml). Then execute prj --init. If the prj command is not found, check that it has been added to your windows PATH variable, as mentioned in the install instructions. All this command does is initialize some of the the directory links for these projects.
  95.  
  96. If we look at our project folders again, we see that a bunch of new folders appear to have been added. Let's look at the CubeMover project in particular:
  97.  
  98. UnityProjects
  99. CubeMover
  100. ProjectSettings
  101. CubeMover-Windows
  102. Assets
  103. CubeMover
  104. Plugins
  105. CommonShapeMover
  106. Projeny
  107. ProjectSettings
  108. The CubeMover-Windows folder is new, and now has the familiar Assets directory. It also contains a bunch of folders within it such as CubeMover, CommonShapeMover, etc.
  109.  
  110. To actually run our project, open the CubeMover-Windows folder in Unity and then open the scene at CubeMover/CubeMain. After running it you should see the cube move around while changing colors.
  111.  
  112. So where did all these files come from? The answer is 'directory links' (aka windows junctions aka symbolic links). All of these new folders are not really folders in themselves but instead they are simply links to existing folders somewhere else.
  113.  
  114. In fact, if you're using source control, the entire CubeMover-Windows directory should be excluded from it (by using a .gitignore file, a .svnignore, .p4ignore, or whatever ignore method applies to the source control you're using). If you're using subversion or git, this will happen automatically when you initialize your project (otherwise, you will have to make sure to add the ignore files yourself).
  115.  
  116. We do this because the contents of the CubeMover-Windows folder does not itself contain any real content. It simply contains temporary files generated by Unity (such as the Library folder) and directory links to other directories that actually do contain content.
  117.  
  118. The directories containing the actual content can be found in the UnityPackages directory. This is where you will find the CubeMover and CommonShapeMover folders that we see linked to underneath the assets directory.
  119.  
  120. But how does Projeny know which packages to use for the CubeMover project? For this it reads from a configuration text file, which can be found at CubeMover/ProjenyProject.yaml. Details on this file are covered in another section below. This file can be changed by hand, but most of the time however you can use Projeny's built-in Unity plugin to manipulate this file instead. You can try this by opening the CubeMover project in Unity, then clicking the menu item Projeny -> Package Manager.... This window will be be explained in more detail in the following sections.
  121.  
  122. Advantages of Using Projeny
  123.  
  124. Ok so why are we doing this? Why go to the trouble of creating this seemingly complex directory structure of for every project? What's wrong with the standard way that Unity is designed?
  125.  
  126. We do this because it has many advantages over standard Unity development:
  127.  
  128. 1 - Shared files between projects
  129.  
  130. By using directory links, you can have multiple Unity projects all using the same package folders, without needing to copy and paste each package per project. You can change a file such as a prefab or a C# file, and that change will be applied to all other projects that are using it as well
  131.  
  132. Previously, the best way to share code between different Unity projects was to put the code into a DLL and then output that DLL to all the Unity Projects that you want to use it in. This works ok but has a number of gotchas that make this approach difficult to do correctly.
  133.  
  134. Want to re-use some common utility code/prefabs in several different games? Just have multiple Unity projects for each game all using the same utility packages directly.
  135.  
  136. Want to just test one part of your game without needing to fire up the entire project? Just create another Unity project and reference only the parts of the game you want to test.
  137.  
  138. To see this in action, do the following: (Note: this assumes you have already run prj --init as described above)
  139.  
  140. Open Unity then open the project at UnityProjects/SphereMover/SphereMover-Windows
  141. Open another copy of Unity then open the project at UnityProjects/CubeMover/CubeMover-Windows
  142. Open the scene named SphereMain in the first Unity and the scene CubeMain in the second Unity
  143. If you run them you should see the shapes move and change colors
  144. The script used here to move both the Sphere and the Cube is the same, and can be found in the shared package CommonShapeMover.
  145. As a further example, open up the Unity project at UnityProjects/AllMovers/AllMovers-Windows
  146. Run the scene AllMovers
  147. You should see both the cube and sphere in the same scene
  148. This works because these three projects all have some shared packages. Note that this allows sharing code as well prefabs (ie. the cube and the sphere prefabs), scenes, etc.
  149. 2 - Package Organization and Asset Store Integration
  150.  
  151. Projeny allows you to much more easily manage many different Unity packages that you've created yourself, but also those packages that you've installed through the asset store.
  152.  
  153. You can build up a big collection of packages that you've purchased through the asset store and added to your UnityPackages directory, and then easily include or exclude those by simply selecting or not selecting them for each project. Projeny can also be used to easily upgrade/downgrade installed asset store packages all through a simple interface within Unity. See this section for more details on managing asset store packages through Projeny.
  154.  
  155. 3 - Near instant platform switching
  156.  
  157. You might be wondering why the projects that you've been dealing with are all marked with the suffix '-Windows'. Or why there are multiple ProjectSettings folders that appear after you run the --init command as described above (One underneath CubeMover and another underneath CubeMover-Windows)
  158.  
  159. The reason for this is to allow Projeny to create entirely separate Unity project directories for each platform. This allows us to jump instantly from one platform to another without needing to wait for Unity to process all the assets.
  160.  
  161. In the examples above, we have only initialized the windows Unity project CubeMover-Windows but we can also create CubeMover-iOS, CubeMover-Android, etc. by opening these platforms for this project.
  162.  
  163. When that occurs, Projeny will create a directory link to the main ProjectSettings directory so that we can have all these different platform-specific projects use the same Unity project settings.
  164.  
  165. To see this in action, open up the CubeMover project in Unity then select the menu item Projeny -> Change Platform -> iOS. The first time you do this will take longer since Unity has to process the files but any subsequent times should be nearly instant, since it should be no different from simply opening another project.
  166.  
  167. 4 - Compile time optimization
  168.  
  169. Unity compiles your project in multiple passes. The first pass compiles all C# files that are in the Plugins/ directory and the second pass compiles all other C# files. If Unity does not detect any changes in the Plugins/ directory then Unity will skip this first pass and only execute the second pass. (Note: This is a bit of a simplification - see here for full details)
  170.  
  171. We can take advantage of this by always putting all stable packages (such as those obtained through asset store) into the Plugins folder and putting the packages that we change frequently directly underneath the Assets folder.
  172.  
  173. And because we are using directory links, and the entire CubeMover-Windows folder is ignored by source control, changing the location of these directory links is trivial. You can modify this directory structure multiple times per day based on what you're working on, by simply using changing a few things in the Projeny Package Manager window.
  174.  
  175. To see this in action, open up the AllMovers-Windows project.
  176.  
  177. By default, the assets folder should appear as follows:
  178.  
  179. AllMovers
  180. CommonShapeMover
  181. CubeMover
  182. Plugins
  183. Projeny
  184. SphereMover
  185. If we are only working within the AllMovers project, there is no reason we need to be recompiling CommonShapeMover, CubeMover, and SphereMover projects every time a script changes. So these projects can be moved to be underneath the Plugins folder.
  186.  
  187. To do this, open up the package manager by clicking on the menu item Projeny -> Package Manager.... You should see something like this:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement