55
66namespace ParrelSync
77{
8- public class Project : System . ICloneable
9- {
10- public string name ;
11- public string projectPath ;
12- string rootPath ;
13- public string assetPath ;
14- public string projectSettingsPath ;
15- public string libraryPath ;
16- public string packagesPath ;
17- public string autoBuildPath ;
18- char [ ] separator = new char [ 1 ] { '/' } ;
19-
20-
21- /// <summary>
22- /// Default constructor
23- /// </summary>
24- public Project ( )
25- {
26-
27- }
28-
29-
30- /// <summary>
31- /// Initialize the project object by parsing its full path returned by Unity into a bunch of individual folder names and paths.
32- /// </summary>
33- /// <param name="path"></param>
34- public Project ( string path )
35- {
36- ParsePath ( path ) ;
37- }
38-
39-
40- /// <summary>
41- /// Create a new object with the same settings
42- /// </summary>
43- /// <returns></returns>
44- public object Clone ( )
45- {
46- Project newProject = new Project ( ) ;
47- newProject . rootPath = rootPath ;
48- newProject . projectPath = projectPath ;
49- newProject . assetPath = assetPath ;
50- newProject . projectSettingsPath = projectSettingsPath ;
51- newProject . libraryPath = libraryPath ;
52- newProject . name = name ;
53- newProject . separator = separator ;
54- newProject . packagesPath = packagesPath ;
55- newProject . autoBuildPath = autoBuildPath ;
56-
57- return newProject ;
58- }
59-
60-
61- /// <summary>
62- /// Update the project object by renaming and reparsing it. Pass in the new name of a project, and it'll update the other member variables to match.
63- /// </summary>
64- /// <param name="name"></param>
65- public void updateNewName ( string newName )
66- {
67- name = newName ;
68- ParsePath ( rootPath + "/" + name + "/Assets" ) ;
69- }
70-
71-
72- /// <summary>
73- /// Debug override so we can quickly print out the project info.
74- /// </summary>
75- /// <returns></returns>
76- public override string ToString ( )
77- {
78- string printString = name + "\n " +
79- rootPath + "\n " +
80- projectPath + "\n " +
81- assetPath + "\n " +
82- projectSettingsPath + "\n " +
83- packagesPath + "\n " +
84- autoBuildPath + "\n " +
85- libraryPath ;
86- return ( printString ) ;
87- }
88-
89- private void ParsePath ( string path )
90- {
91- //Unity's Application functions return the Assets path in the Editor.
92- projectPath = path ;
93-
94- //pop off the last part of the path for the project name, keep the rest for the root path
95- List < string > pathArray = projectPath . Split ( separator ) . ToList < string > ( ) ;
96- name = pathArray . Last ( ) ;
97-
98- pathArray . RemoveAt ( pathArray . Count ( ) - 1 ) ;
99- rootPath = string . Join ( separator [ 0 ] . ToString ( ) , pathArray ) ;
100-
101- assetPath = projectPath + "/Assets" ;
102- projectSettingsPath = projectPath + "/ProjectSettings" ;
103- libraryPath = projectPath + "/Library" ;
104- packagesPath = projectPath + "/Packages" ;
105- autoBuildPath = projectPath + "/AutoBuild" ;
106-
107- }
108- }
8+ public class Project : System . ICloneable
9+ {
10+ public string name ;
11+ public string projectPath ;
12+ string rootPath ;
13+ public string assetPath ;
14+ public string projectSettingsPath ;
15+ public string libraryPath ;
16+ public string packagesPath ;
17+ public string autoBuildPath ;
18+ public string localPackages ;
19+
20+ char [ ] separator = new char [ 1 ] { '/' } ;
21+
22+
23+ /// <summary>
24+ /// Default constructor
25+ /// </summary>
26+ public Project ( )
27+ {
28+
29+ }
30+
31+
32+ /// <summary>
33+ /// Initialize the project object by parsing its full path returned by Unity into a bunch of individual folder names and paths.
34+ /// </summary>
35+ /// <param name="path"></param>
36+ public Project ( string path )
37+ {
38+ ParsePath ( path ) ;
39+ }
40+
41+
42+ /// <summary>
43+ /// Create a new object with the same settings
44+ /// </summary>
45+ /// <returns></returns>
46+ public object Clone ( )
47+ {
48+ Project newProject = new Project ( ) ;
49+ newProject . rootPath = rootPath ;
50+ newProject . projectPath = projectPath ;
51+ newProject . assetPath = assetPath ;
52+ newProject . projectSettingsPath = projectSettingsPath ;
53+ newProject . libraryPath = libraryPath ;
54+ newProject . name = name ;
55+ newProject . separator = separator ;
56+ newProject . packagesPath = packagesPath ;
57+ newProject . autoBuildPath = autoBuildPath ;
58+ newProject . localPackages = localPackages ;
59+
60+
61+ return newProject ;
62+ }
63+
64+
65+ /// <summary>
66+ /// Update the project object by renaming and reparsing it. Pass in the new name of a project, and it'll update the other member variables to match.
67+ /// </summary>
68+ /// <param name="name"></param>
69+ public void updateNewName ( string newName )
70+ {
71+ name = newName ;
72+ ParsePath ( rootPath + "/" + name + "/Assets" ) ;
73+ }
74+
75+
76+ /// <summary>
77+ /// Debug override so we can quickly print out the project info.
78+ /// </summary>
79+ /// <returns></returns>
80+ public override string ToString ( )
81+ {
82+ string printString = name + "\n " +
83+ rootPath + "\n " +
84+ projectPath + "\n " +
85+ assetPath + "\n " +
86+ projectSettingsPath + "\n " +
87+ packagesPath + "\n " +
88+ autoBuildPath + "\n " +
89+ localPackages + "\n " +
90+ libraryPath ;
91+ return ( printString ) ;
92+ }
93+
94+ private void ParsePath ( string path )
95+ {
96+ //Unity's Application functions return the Assets path in the Editor.
97+ projectPath = path ;
98+
99+ //pop off the last part of the path for the project name, keep the rest for the root path
100+ List < string > pathArray = projectPath . Split ( separator ) . ToList < string > ( ) ;
101+ name = pathArray . Last ( ) ;
102+
103+ pathArray . RemoveAt ( pathArray . Count ( ) - 1 ) ;
104+ rootPath = string . Join ( separator [ 0 ] . ToString ( ) , pathArray ) ;
105+
106+ assetPath = projectPath + "/Assets" ;
107+ projectSettingsPath = projectPath + "/ProjectSettings" ;
108+ libraryPath = projectPath + "/Library" ;
109+ packagesPath = projectPath + "/Packages" ;
110+ autoBuildPath = projectPath + "/AutoBuild" ;
111+ localPackages = projectPath + "/LocalPackages" ;
112+ }
113+ }
109114}
0 commit comments