├── .gitattributes
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── proj.cs
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── UnityIO.csproj
└── UnityIO.sln
└── proj.unity
├── Assets
├── UnityIO.meta
└── UnityIO
│ ├── AssetDatabase.cs
│ ├── AssetDatabase.cs.meta
│ ├── Directory.cs
│ ├── Directory.cs.meta
│ ├── Editor.meta
│ ├── Editor
│ ├── ContextMenus.cs
│ ├── ContextMenus.cs.meta
│ ├── Unit Tests.meta
│ └── Unit Tests
│ │ ├── ConditionalProgressTests.cs
│ │ ├── ConditionalProgressTests.cs.meta
│ │ ├── ConvertPathTests.cs
│ │ ├── ConvertPathTests.cs.meta
│ │ ├── CreatingDirectoryTests.cs
│ │ ├── CreatingDirectoryTests.cs.meta
│ │ ├── DirectoryChangesTests.cs
│ │ ├── DirectoryChangesTests.cs.meta
│ │ ├── Documention.cs
│ │ ├── Documention.cs.meta
│ │ ├── EnumerationTests.cs
│ │ ├── EnumerationTests.cs.meta
│ │ ├── FileChangesTests.cs
│ │ ├── FileChangesTests.cs.meta
│ │ ├── GetFilesTests.cs
│ │ ├── GetFilesTests.cs.meta
│ │ ├── Loading Assets.meta
│ │ ├── Loading Assets
│ │ ├── Animations.meta
│ │ ├── Animations
│ │ │ ├── Died.anim
│ │ │ ├── Died.anim.meta
│ │ │ ├── Hit.anim
│ │ │ ├── Hit.anim.meta
│ │ │ ├── Player Attack.anim
│ │ │ └── Player Attack.anim.meta
│ │ ├── GUISkins.meta
│ │ ├── GUISkins
│ │ │ ├── Dark Skin.guiskin
│ │ │ ├── Dark Skin.guiskin.meta
│ │ │ ├── Light Skin.guiskin
│ │ │ └── Light Skin.guiskin.meta
│ │ ├── Misc Animation.anim
│ │ ├── Misc Animation.anim.meta
│ │ ├── Misc Prefab.prefab
│ │ ├── Misc Prefab.prefab.meta
│ │ ├── Misc Skin.guiskin
│ │ ├── Misc Skin.guiskin.meta
│ │ ├── Prefabs.meta
│ │ └── Prefabs
│ │ │ ├── Player Character.prefab
│ │ │ ├── Player Character.prefab.meta
│ │ │ ├── Weapon.prefab
│ │ │ └── Weapon.prefab.meta
│ │ ├── PathValidationTests.cs
│ │ ├── PathValidationTests.cs.meta
│ │ ├── UnityIOTestBase.cs
│ │ └── UnityIOTestBase.cs.meta
│ ├── Exceptions.cs
│ ├── Exceptions.cs.meta
│ ├── File.cs
│ ├── File.cs.meta
│ ├── Files.cs
│ ├── Files.cs.meta
│ ├── Interfaces.meta
│ ├── Interfaces
│ ├── IDirectory.cs
│ ├── IDirectory.cs.meta
│ ├── IFile.cs
│ ├── IFile.cs.meta
│ ├── IFiles.cs
│ └── IFiles.cs.meta
│ ├── NullFile.cs
│ ├── NullFile.cs.meta
│ ├── UnityIO.cs
│ └── UnityIO.cs.meta
└── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── NetworkManager.asset
├── Physics2DSettings.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── TagManager.asset
├── TimeManager.asset
├── UnityAdsSettings.asset
└── UnityConnectSettings.asset
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /[Ll]ibrary/
2 | /[Tt]emp/
3 | /[Oo]bj/
4 | /[Bb]uild/
5 | /[Bb]uilds/
6 | /Assets/AssetStoreTools*
7 |
8 | # Autogenerated VS/MD solution and project files
9 | ExportedObj/
10 | proj.unity/**/*.csproj
11 | *.unityproj
12 | proj.unity/**/*.sln
13 | *.suo
14 | *.tmp
15 | *.user
16 | *.userprefs
17 | *.pidb
18 | *.booproj
19 | *.svd
20 |
21 | # Unity3D generated meta files
22 | *.pidb.meta
23 |
24 | # Unity3D Generated File On Crash Reports
25 | sysinfo.txt
26 |
27 | # Builds
28 | *.apk
29 | *.unitypackage
30 | proj.cs/bin/
31 | proj.cs/obj/
32 | proj.unity/Temp/
33 | proj.unity/Library/
34 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at ByronMayne+UnityIO@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Byron Mayne
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://gitter.im/UnityIO/Lobby)
2 | [](https://github.com/ByronMayne/UnityIO/blob/master/LICENSE)
3 |
4 |
5 |
6 |
7 | # Unity IO
8 |
9 | ### Description
10 | Unity IO is made to try to remove the pain of working with Unity's file system. For anyone who has done extended work has figured out Unity makes this a huge pain. All the functionality you need is spread across multiple classes including [FileUtil](https://docs.unity3d.com/ScriptReference/FileUtil.html), [AssetDatabase](https://docs.unity3d.com/ScriptReference/AssetDatabase.html), [Resources](https://docs.unity3d.com/ScriptReference/Resources.html), [File](https://msdn.microsoft.com/en-us/library/system.io.file(v=vs.110).aspx), [FileInfo](https://msdn.microsoft.com/en-us/library/system.io.fileinfo(v=vs.110).aspx), [Path](https://msdn.microsoft.com/en-us/library/system.io.path(v=vs.110).aspx), [Directory](https://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.110).aspx), [Directory Info](https://msdn.microsoft.com/en-us/library/system.io.directoryinfo(v=vs.110).aspx), ect.
11 |
12 | ### Goals
13 |
14 | * Simple to use API.
15 | * Support Unity's meta files.
16 | * Allow for complex chaining with conditional execution.
17 | * Allow of loading, creating, destroying of Unity Assets.
18 |
19 |
20 |
21 | ## Directory Basics
22 | UnityIO works with the Unity asset path so all paths start from the ```Assets/``` folder. To start using UnityIO in your classes you must include the namespace ```UnityIO```
23 |
24 | ### Creating a Directory
25 | ``` csharp
26 | ///
27 | /// Creates a directory the root of our project
28 | ///
29 | public void CreatingRootDirectory()
30 | {
31 | IO.Root.CreateDirectory("Favorite Animals");
32 | }
33 | ```
34 | ```IO.Root``` is the ```/Assets``` folder at the root of your Unity project. In the example above we are asking UnityIO to create a new folder called Favorite Animals at ```Assets/Favorite Animals```.
35 | ``` csharp
36 | ///
37 | /// A few more ways to create folders
38 | ///
39 | public void CreateNestedCatFolder()
40 | {
41 | // Create in a chain.
42 | var catsFolder1 = IO.Root.CreateDirectory("Favorite Animals").CreateDirectory("Cats");
43 |
44 | // Break it down into two parts.
45 | var animals = IO.Root.CreateDirectory("Favorite Animals");
46 | var catsFolder2 = animals.CreateDirectory("Cats");
47 |
48 | // Do it in one step.
49 | var catsFolder3 = IO.Root.CreateDirectory("Favorite Animals/Cats");
50 |
51 | // Do it in one step with the helper.
52 | var catsFolder4 = IO.Root.CreateDirectory("Favorite Animals" + IO.PATH_SPLITTER + "Cats");
53 | }
54 | ```
55 | This code is doing the same above but it will also create a subdirectory called Cats. When you want to create subdirectories you have a few ways to do it. It all really depends how you want to do it but they all have the same result. If the code were to run above only two folders would be created and all of the variables would point to the same one.
56 |
57 | #### Notes
58 | * The paths do not end with a leading slash ```/```. Unity has a habit of switching this up but UnityIO will throw a planned exception letting you know.
59 | * All directories are split using the ```/``` character. You can use the constant ```IO.PATH_SPLITTER```.
60 |
61 |
62 | ### Destroying a Directory
63 | Well it turns out all our hard work we did was for nothing! Turns out you hate cats, don't worry I get it you are a monster. I will not judge lets destroy that directory.
64 | ```csharp
65 | ///
66 | /// Let's blow some things up
67 | ///
68 | public void Destroy()
69 | {
70 | // Get our directory and nuke it
71 | IO.Root["Favorite Animals"].GetDirectory("Cats").Delete();
72 |
73 | // Delete our cats folder.
74 | IO.Root.DeleteSubDirectory("Favorite Animals/Cats");
75 | }
76 | ```
77 | As with creating folder there are more than way to do things. The first example we are just finding our cats directory and tell it to kill itself with the ```Delete()``` function. The second way we are starting from the root and it will look for the subdirectory at the path we sent in. The ```DeleteSubDirectory(string name)``` just calls ```Delete()``` on the folder behind the scenes.
78 |
79 | Take that cats!
80 |
81 | You might be asking what happens if you tell it to delete a directory that does not exist.
82 |
83 | ```scharp
84 | ///
85 | /// This should do nothing.
86 | ///
87 | public void DeleteSomethingNotReal()
88 | {
89 | IO.Root["Favorite Animals"].GetDirectory("Dogs").Delete(); // Does not exist
90 | }
91 | ```
92 | In this case you well get an ```System.IO.DirectoryNotFoundException``` since you are trying to delete something that is not there. This can be super helpful but what if you only want to delete it if it does exist?
93 | ```csharp
94 | ///
95 | /// We should play it safe.
96 | ///
97 | public void ValidateBeforeDelete()
98 | {
99 | var favoriteAnimals = IO.Root["Favorite Animals"];
100 |
101 | if(favoriteAnimals.SubDirectoryExists("Dogs"))
102 | {
103 | favoriteAnimals.DeleteSubDirectory("Dogs");
104 | }
105 | }
106 | ```
107 | Above you can see we are checking to see if it exists before deleting it. This way we will not get an exception which is awesome. However this can become annoying to check every element has to be checked along the way. The other more usable way to do this would be to use a conditional.
108 | ```scharp
109 | ///
110 | /// We should play it safe and make it easy
111 | ///
112 | public void EasyValidateBeforeDelete()
113 | {
114 | IO.Root["Favorite Animals"].IfDirectoryExists("Dogs").Delete();
115 | }
116 | ```
117 | "Wait what does ```IfDirectoryExists()``` do?" Well I am glad you asked. One of the really cool features of UnityIO is conditionals. In this case if the directory exists the function ```Delete()``` will be called on the Dogs directory. If it does not exist the function will take no effect.
118 | ```csharp
119 | ///
120 | /// Look at the length of that things!
121 | ///
122 | public void ILikeChains()
123 | {
124 | IO.Root["Favorite Animals"].IfDirectoryExists("Dogs").IfDirectoryExists("With Four Legs").IfDirectoryExists("Who stink").Delete();
125 | }
126 | ```
127 | In this case only the first folder exists so the first conditional will return a NullFile class which has all the same functions but none of them have any effect. So that way your code will execute only as far as it can get. You don't have to worry about null checking since the code can't break if a file is missing. You have the power to chain as many of these as you want.
128 | ``` csharp
129 | ///
130 | /// Find, Create, and Destroy
131 | ///
132 | public void CreateAndDestroy()
133 | {
134 | IO.Root["Favorite Animals"].IfDirectoryExists("Dogs").CreateDirectory("Delete Me").Delete();
135 | }
136 | ```
137 |
138 | #### Notes
139 | * You can delete your whole project with ```IO.Root.Delete()```. I don't suggest you do that.
140 |
141 | ### Renaming a Directory
142 | Sometimes there are cases where you want to rename you directory. To do this is pretty simple.
143 | ```csharp
144 | ///
145 | /// Pick any name that is valid
146 | ///
147 | public void RenameDirectory()
148 | {
149 | IO.Root["My Dir"].Rename("Super Dir");
150 | }
151 | ```
152 | This is all you have to do just make sure you don't include any ```/``` in your name as they are already preserved. If a directory already exists with that name this function will throw an ```DirectoryAlreadyExistsException()```, so make sure you check before you try to create one.
153 |
154 | ### Duplicate a Directory
155 | As with moving duplicate is just as easy.
156 | ```CSHARP
157 | public void DuplicateADirectory()
158 | {
159 | var cheeseDrive = IO.Root["Types of Cheese"];
160 | // Creates a copy
161 | cheeseDrive.Duplicate();
162 | // Creates a copy with a set name
163 | cheeseDrive.Duplicate("Other Types of Cheese");
164 | }
165 | ```
166 | The ```cheeseDrive.Duplicate()``` function will create a new copy of the cheeseDrive and all it's contents. It will then rename that drive with a number on the end to make it unique. If you want more control you can just use the overloaded function to pick a valid name. If the name is already taken you well get an exception.
167 | ## File Basics
168 |
169 | As with working with directories working with files is just as easy. UnityIO does it's best to try to make things as painless as possible.
170 |
171 | ### Anatomy a File
172 | UnityIO has two interfaces that are used when dealing with files. The first one is ```IFile``` and ```IFiles```. Ifiles is simple an extension of ```IList``` with some extended functionality that I will cover later. IFile is the one you will be dealing with the most. IFile is implemented by ```File.cs``` and ```NullFile.cs```.
173 | ### Getting a File
174 | To get a file does not require to much work. In the example below we go to the directory we want and ask for all the files in there.
175 | ``` csharp
176 | // Normally we just use var for the return types but these examples we are using
177 | // the interface types to make it more clear so we have to include the following.
178 | using UnityIO.Interfaces;
179 |
180 | ///
181 | /// A simple example of getting all files from a folder called resources
182 | /// at 'Assets/Resources'
183 | ///
184 | public void GetResourceFiles()
185 | {
186 | // Get our directory
187 | IDirectory resourcesDirectory = IO.Root["Resources"];
188 | // Get all files.
189 | IFiles files = resourcesDirectory.GetFiles();
190 | }
191 | ```
192 | The code above looks for the directory ```Assets/Resources``` and returns all files that are in there. This code returns us back an ```IFiles``` which we can then just loop over to grab each file one by one.
193 | ```csharp
194 | // Get our directory
195 | IDirectory resourcesDirectory = IO.Root["Resources"];
196 | // Get all files.
197 | IFiles files = resourcesDirectory.GetFiles();
198 | // iterate over our files and print their names
199 | for(int i = 0; i < files.Count; i++)
200 | {
201 | Debug.Log(files[i].Name);
202 | }
203 | ```
204 | Above we are using our IFiles and printing the names to the UnityEngine.Debug console. Lets say we wanted
205 | to also get all files recursively we can do that too.
206 | ```csharp
207 | public void GetFilesRecursively()
208 | {
209 | // Get our directory
210 | IDirectory resourcesDirectory = IO.Root["Resources"];
211 | // Get all files recursively
212 | IFiles files = resourcesDirectory.GetFiles(recursive:true);
213 | }
214 | ```
215 |
216 | #### Searching for files
217 | Sometimes we also might want to only select files if they match a name. UnityIO under the hood uses System.IO to find files
218 | so it has the ability to use two unique wild cards. ```*```(asterisk) means Zero or more characters in that position. ```?``` (question mark) means Zero or one character in that position.
219 | This search can not use Unity's tags like ```t:```, ```l:```, or ```ref:```.
220 |
221 | Below are a few examples of some search functions.
222 | ```csharp
223 | // Returns every asset with 'Player' in it's name.
224 | var playerFiles = IO.Root.GetFiles("*Player*");
225 | ```
226 | ``` csharp
227 | // Get everything named with 'Player' and '.anim' extension
228 | var playerAnimations = IO.Root.GetFiles("*Player*.anim");
229 | ```
230 | ```csharp
231 | // get everything named 'Player' with one extra char maybe an 's'
232 | var playerChar = IO.Root.GetFiles("Player?");
233 | ```
234 |
235 | ```GetFiles()``` has a few different overrides that lets you combine both the search filter and the recursive bool.
236 |
237 | Notes:
238 | * At one point I might add Regex searches to this feature but I am not sure if that is overkill. Let me know with feedback if you would like that feature.
239 | * You might notice that you don't have the open to filter by Unity types. This was done so the code does not have to be rigid. I just did not want to have to write a huge case statement for all valid Unity types an extensions that match.
240 | * When you call ```GetFiles``` the assets themselves have not been loaded into memory we are only working with the paths.
241 |
242 | ### Deleting a File
243 | Once you have your file you might just want to be able to delete it.
244 | ```csharp
245 | ///
246 | /// Grabs all the files in the root directory and deletes them.
247 | ///
248 | public void DeleteAFile()
249 | {
250 | // Get all our files.
251 | var files = IO.Root.GetFiles();
252 | // Loop over them all and delete them
253 | for (int i = 0; i < files.Count; i++)
254 | {
255 | // Delete the file.
256 | files[i].Delete();
257 | }
258 | }
259 | ```
260 | This is great but lets say you want to delete a file only if it exists. Well just like the IDirectory class IFile has the option to only do tasks if a condition is met.
261 | ```csharp
262 | /// Only delete our file if it exists.
263 | IO.Root.IfFileExists("DeleteMe.txt").Delete();
264 | ```
265 | As expected this will only delete the file if it happens to exist on disk and otherwise have no effect.
266 |
267 | Notes:
268 | * All deletion uses AssetDatabase so the meta files are cleaned up too.
269 | * The files get deleted synchronously so if you check if it exists in the next line of code it will be cleared.
270 | *
271 | ### Renaming a File
272 | Sometimes you just want to change the file you are working with to do that try the following code.
273 |
274 | ``` csharp
275 | // Get the file we want to use.
276 | IFile fileToRename = IO.Root.GetFiles("DeleteMe.txt").FirstOrDefault();
277 | // Rename it
278 | fileToRename.Rename("DontDeleteMe.txt");
279 | ```
280 | You might also notice that we used the function ```FirstOrDefault``` this is a function on ```IFiles``` the returns the first file in the list or our null file (which just takes no actions. Read about it below). One thing you should take note of is ```Rename()``` is for renaming and not moving files, use ```Move()``` for that or an exception will be thrown.
281 | ### Moving a File
282 | Moving a file is the same as renaming but you can move the file outside it's current directory.
283 | ```csharp
284 | // Get the file we want to use.
285 | IFile fileToMove = IO.Root.GetFiles("DeleteMe.txt").FirstOrDefault();
286 | // Move it
287 | fileToRename.Move(IO.Root["Resources"].Path);
288 | ```
289 | This will take the ```Assets/DeleteMe.txt``` and move it too ```Assets/Resources/DeleteMe.txt```. If a file already exists in that directory it will be given a unique name by append incrementing numbers to the end.
290 |
291 | ### Utility
292 | There are a few helper functions that come bundled with UnityIO that can be quite useful.
293 |
294 | #### Root
295 | ```csharp
296 | IO.Root
297 | ```
298 | Used in many of the example above this is a shorthand to allow you to grab the root of the current Unity project you are working in.
299 |
300 | #### Convert Paths
301 | UnityIO uses all local Unity asset paths under the hood ie. ```Assets/blah/blah.png``` but if you are going to be interacting with any of C#'s System.IO libraries you will need the full system path. You can get this in a few ways.
302 | ``` csharp
303 | // Gets the full system path of a file instance
304 | string fileSystemPath = IFile.systemPath;
305 |
306 | // Gets the full system path of a directory instance
307 | string directorySystemPath = IDirectory.systemPath;
308 | ```
309 | This is very useful if you already have created instances for ```IFiles``` and ```IDirectories``` but if you just have a raw path to convert this is not useful. To convert raw paths you can use the following.
310 | ```csharp
311 | public void GetSystemPath(string assetPath)
312 | {
313 | // Convert our asset path to a system path
314 | return IO.AssetPathToSystemPath(assetPath);
315 | }
316 | ```
317 | or the reverse
318 |
319 | ```csharp
320 | public void GetAssetPath(string systemPath)
321 | {
322 | // Convert our system path to our asset path.
323 | return IO.SystemToAssetPath(systemPath);
324 | }
325 | ```
326 | Both of these can be used without creating any new classes. Each of these functions checks it's input to verify if it's valid before trying to convert them. If the input is not valid an exception will be thrown so it's best to make sure you are not sending in null or empty strings.
327 |
328 | ## Meta
329 |
330 | Handcrafted by Byron Mayne [[twitter](https://twitter.com/byMayne) • [github](https://github.com/ByronMayne)]
331 |
332 | Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
333 |
334 | If you have any feedback or suggestions for UnityIO feel free to contact me.
335 |
336 |
337 |
338 |
339 |
340 |
341 |
--------------------------------------------------------------------------------
/proj.cs/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/proj.cs/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UnityIO")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UnityIO")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("baabed0f-99c5-43c4-b6e7-e551a2d5c430")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/proj.cs/UnityIO.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BAABED0F-99C5-43C4-B6E7-E551A2D5C430}
8 | Exe
9 | Properties
10 | UnityIO
11 | UnityIO
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\proj.unity\Library\UnityAssemblies\nunit.framework.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | ..\proj.unity\Library\UnityAssemblies\UnityEditor.dll
49 |
50 |
51 | ..\proj.unity\Library\UnityAssemblies\UnityEngine.dll
52 |
53 |
54 |
55 |
56 | Documentation\Documention.cs
57 |
58 |
59 |
60 | UnityIO\Editor\
61 |
62 |
63 | UnityIO\Editor\
64 |
65 |
66 | UnityIO\Editor\
67 |
68 |
69 | UnityIO\Editor\
70 |
71 |
72 | UnityIO\Editor\
73 |
74 |
75 | UnityIO\Editor\Interfaces\
76 |
77 |
78 | UnityIO\Editor\Interfaces\
79 |
80 |
81 | UnityIO\Editor\Interfaces\
82 |
83 |
84 | UnityIO\Editor\
85 |
86 |
87 | UnityIO\Editor\Unit Tests\
88 |
89 |
90 | UnityIO\Editor\Unit Tests\
91 |
92 |
93 | UnityIO\Editor\Unit Tests\
94 |
95 |
96 | UnityIO\Editor\Unit Tests\
97 |
98 |
99 | UnityIO\Editor\Unit Tests\
100 |
101 |
102 | UnityIO\Editor\Unit Tests\
103 |
104 |
105 | UnityIO\Editor\Unit Tests\
106 |
107 |
108 | UnityIO\Editor\Unit Tests\
109 |
110 |
111 | UnityIO\Editor\
112 |
113 |
114 |
115 |
116 | Documentation\README.md
117 |
118 |
119 |
120 |
121 |
128 |
--------------------------------------------------------------------------------
/proj.cs/UnityIO.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityIO", "UnityIO.csproj", "{BAABED0F-99C5-43C4-B6E7-E551A2D5C430}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {BAABED0F-99C5-43C4-B6E7-E551A2D5C430}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {BAABED0F-99C5-43C4-B6E7-E551A2D5C430}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {BAABED0F-99C5-43C4-B6E7-E551A2D5C430}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {BAABED0F-99C5-43C4-B6E7-E551A2D5C430}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3d1ae5d31de10c4db76cea50f39e728
3 | folderAsset: yes
4 | timeCreated: 1477153792
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/AssetDatabase.cs:
--------------------------------------------------------------------------------
1 | #if !UNITY_EDITOR
2 | #define RELEASE_BUILD
3 | #else
4 | using UnityEditor;
5 | using UnityEditorInternal;
6 | using uAssetDatabase = UnityEditor.AssetDatabase;
7 | #endif
8 |
9 | using System;
10 | using Object = UnityEngine.Object;
11 | using UnityEngine;
12 | using System.IO;
13 |
14 | namespace UnityIO.AssetDatabaseWrapper
15 | {
16 | internal static class AssetDatabase
17 | {
18 | ///
19 | /// Returns the root directory of our application . In the editor
20 | /// this is the path to the root of the Unity project and on device
21 | /// this is the .
22 | ///
23 | public static string rootDirectory
24 | {
25 | get
26 | {
27 | #if !RELEASE_BUILD
28 | return Application.dataPath;
29 | #else
30 | return Application.persistentDataPath;
31 | #endif
32 | }
33 | }
34 |
35 | ///
36 | /// Returns true if this path is relative to the current project
37 | /// and false if it's not.
38 | ///
39 | public static bool IsRelativePath(string path)
40 | {
41 | return path.StartsWith(rootDirectory);
42 | }
43 |
44 | ///
45 | /// Returns the first asset object of type at given path assetPath.
46 | ///
47 | /// The type you want to load
48 | /// The path of the asset
49 | /// The loaded object
50 | public static T LoadAssetAtPath(string assetPath) where T : Object
51 | {
52 |
53 | if(IsRelativePath(assetPath))
54 | {
55 | #if !RELEASE_BUILD
56 | return uAssetDatabase.LoadAssetAtPath(assetPath);
57 | #endif
58 | }
59 | return null;
60 | }
61 |
62 | ///
63 | /// Returns the first asset object of type at given path assetPath.
64 | ///
65 | /// The path of the asset
66 | /// The type you want to load
67 | /// The loaded object
68 | public static Object LoadAssetAtPath(string assetPath, Type type)
69 | {
70 | #if !RELEASE_BUILD
71 | return uAssetDatabase.LoadAssetAtPath(assetPath, type);
72 | #else
73 | return null;
74 | #endif
75 | }
76 |
77 | ///
78 | /// Deletes the asset file at path.
79 | // Returns true if the asset has been successfully deleted, false if it doesn't exit or couldn't be removed.
80 | ///
81 | public static bool DeleteAsset(string assetPath)
82 | {
83 | #if !RELEASE_BUILD
84 | return uAssetDatabase.DeleteAsset(assetPath);
85 | #else
86 | // Convert to system path
87 | string systemPath = IO.AssetPathToSystemPath(assetPath);
88 | // Check if it exists
89 | if(File.Exists(systemPath))
90 | {
91 | // Delete it
92 | File.Delete(systemPath);
93 | // Return true
94 | return true;
95 | }
96 | else
97 | {
98 | return false;
99 | }
100 | #endif
101 |
102 | }
103 |
104 | ///
105 | /// Creates a new unique path for an asset.
106 | ///
107 | public static string GenerateUniqueAssetPath(string assetPath)
108 | {
109 | // Get our system path since we need the full one.
110 | string systemPath = IO.AssetPathToSystemPath(assetPath);
111 | // Create a holder for a unique one.
112 | string uniquePath = systemPath;
113 |
114 | // Loop till max int (We should never have that many folder but we don't want to loop forever).
115 | for (int i = 0; i < int.MaxValue; i++)
116 | {
117 | // If the file does not exist we can break.
118 | if(!File.Exists(uniquePath))
119 | {
120 | break;
121 | }
122 | // One with that name already exists so we append our number to the file name.
123 | uniquePath = IO.AppendName(systemPath, " " + i.ToString());
124 | }
125 | return uniquePath;
126 | }
127 |
128 | ///
129 | /// Duplicates the asset at path and stores it at newPath.
130 | ///
131 | /// Returns true if the copy was successful.
132 | public static bool CopyAsset(string path, string newPath)
133 | {
134 | #if !RELEASE_BUILD
135 | return uAssetDatabase.CopyAsset(path, newPath);
136 | #else
137 | // Convert our path to a system path
138 | string sourceFilePath = IO.AssetPathToSystemPath(path);
139 | // Get a unique one for our detestation path.
140 | string destSystemPath = GenerateUniqueAssetPath(newPath);
141 | // Copy the file.
142 | File.Copy(sourceFilePath, destSystemPath, false);
143 | // Return our result
144 | return true.
145 | #endif
146 | }
147 |
148 | ///
149 | /// Returns true if the fileName is valid on the supported platform.
150 | ///
151 | /// The name of the file you want to check.
152 | /// True if it's valid and false if it's not.
153 | public static bool IsValidFileName(string fileName)
154 | {
155 | char[] invalidChars = Path.GetInvalidFileNameChars();
156 |
157 | for(int i = 0; i < invalidChars.Length; i++)
158 | {
159 | if(fileName.IndexOf(invalidChars[i]) > -1)
160 | {
161 | return false;
162 | }
163 | }
164 |
165 | return true;
166 | }
167 |
168 | ///
169 | /// returns true if it exists, false otherwise false.
170 | ///
171 | public static bool IsValidFolder(string assetPath)
172 | {
173 | #if !RELEASE_BUILD
174 | return uAssetDatabase.IsValidFolder(assetPath);
175 | #else
176 | // Convert our path to a system path
177 | string sourceFilePath = IO.AssetPathToSystemPath(assetPath);
178 | // Return if it exists or not.
179 | return Directory.Exists(sourceFilePath);
180 | #endif
181 | }
182 |
183 | ///
184 | /// Checks if an asset file can be moved from one folder to another. (Without actually moving the file).
185 | ///
186 | /// The path where the asset currently resides.
187 | /// The path which the asset should be moved to.
188 | /// An empty string if the asset can be moved, otherwise an error message.
189 | public static string ValidateMoveAsset(string oldPath, string newPath)
190 | {
191 | #if !RELEASE_BUILD
192 | return uAssetDatabase.ValidateMoveAsset(oldPath, newPath);
193 |
194 |
195 | #else
196 | oldPath = IO.AssetPathToSystemPath(oldPath);
197 | newPath = IO.AssetPathToSystemPath(newPath);
198 |
199 | if(File.Exists(newPath))
200 | {
201 | return "File Already Exists";
202 | }
203 |
204 | if(AssetDatabase.IsValidFileName(newPath))
205 | {
206 | return "Not valid file name";
207 | }
208 |
209 | return string.Empty;
210 | #endif
211 | }
212 |
213 | ///
214 | /// Move an asset file from one folder to another.
215 | ///
216 | /// The path where the asset currently resides.
217 | /// The path which the asset should be moved to.
218 | ///
219 | public static string MoveAsset(string oldPath, string newPath)
220 | {
221 | #if !RELEASE_BUILD
222 | return uAssetDatabase.MoveAsset(oldPath, newPath);
223 | #else
224 | oldPath = IO.AssetPathToSystemPath(oldPath);
225 | newPath = IO.AssetPathToSystemPath(newPath);
226 | File.Move(oldPath, newPath);
227 | #endif
228 | }
229 |
230 | ///
231 | /// Rename an asset file.
232 | ///
233 | /// The path where the asset currently resides.
234 | /// The new name which should be given to the asset.
235 | ///
236 | public static string RenameAsset(string pathName, string newName)
237 | {
238 | #if !RELEASE_BUILD
239 | return uAssetDatabase.RenameAsset(pathName, newName);
240 | #endif
241 |
242 | }
243 |
244 | ///
245 | /// Create a new folder.
246 | ///
247 | /// The name of the parent folder.
248 | /// The name of the new folder.
249 | /// The GUID of the newly created folder.
250 | public static string CreateFolder(string parentFolder, string newFolderName)
251 | {
252 | #if !RELEASE_BUILD
253 | return uAssetDatabase.CreateFolder(parentFolder, newFolderName);
254 | #endif
255 | }
256 |
257 | ///
258 | /// Search the asset database using the search filter string.
259 | ///
260 | /// The filter string can contain search data. See below for details about this string.
261 | /// The folders where the search will start.
262 | /// Array of matching asset. Note that GUIDs will be returned.
263 | public static string[] FindAssets(string filter, string[] searchInFolders)
264 | {
265 | #if !RELEASE_BUILD
266 | return uAssetDatabase.FindAssets(filter, searchInFolders);
267 | #endif
268 | }
269 |
270 | ///
271 | /// Given an absolute path to a directory, this method will return an array of all it's subdirectories.
272 | ///
273 | public static string[] GetSubFolders(string path)
274 | {
275 | #if !RELEASE_BUILD
276 | return uAssetDatabase.GetSubFolders(path);
277 | #endif
278 | }
279 |
280 | ///
281 | /// Converts a system path to a project local one.
282 | ///
283 | public static string GetProjectRelativePath(string path)
284 | {
285 | #if !RELEASE_BUILD
286 | return FileUtil.GetProjectRelativePath(path);
287 | #endif
288 | }
289 |
290 | ///
291 | /// Creates a new asset at path.
292 | /// You must ensure that the path uses a supported extension ('.mat' for materials, '.cubemap' for cubemaps, '.GUISkin'
293 | /// for skins, '.anim' for animations and '.asset' for arbitrary other assets.)
294 | /// Note: Most of the uses of this function don't work on a build.
295 | ///
296 | public static void CreateAsset(T asset, string path) where T : Object
297 | {
298 | #if !RELEASE_BUILD
299 | uAssetDatabase.CreateAsset(asset, path);
300 | #endif
301 | }
302 | }
303 | }
304 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/AssetDatabase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4a46f6b80c96e3747af916c6c024bc14
3 | timeCreated: 1492634243
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Directory.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a3f045f8267318d499a53948a92ec9f1
3 | timeCreated: 1477156703
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8dfb71f6fee5eb340a9a2f336f59248d
3 | folderAsset: yes
4 | timeCreated: 1477155978
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/ContextMenus.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace UnityIO
5 | {
6 | ///
7 | /// This class contains some useful content menus for Unity.
8 | ///
9 | public static class ContextMenus
10 | {
11 | [MenuItem("Assets/UnityIO/Copy System Path")]
12 | public static void CopySystemPath()
13 | {
14 | // Get our object.
15 | Object selectedObject = Selection.activeObject;
16 | // Get the system path
17 | string systemPath = Application.dataPath;
18 | // Get asset path
19 | string asssetPath = UnityEditor.AssetDatabase.GetAssetPath(selectedObject);
20 | // Make sure we have a path
21 | if(string.IsNullOrEmpty(asssetPath))
22 | {
23 | return;
24 | }
25 | // Remove the 'Assets' part.
26 | asssetPath = asssetPath.Substring(6, asssetPath.Length - 6);
27 | // full path
28 | string fullPath = systemPath + asssetPath;
29 | // print
30 | EditorGUIUtility.systemCopyBuffer = fullPath;
31 |
32 | }
33 |
34 | [MenuItem("Assets/UnityIO/Copy Unity Path")]
35 | public static void CopyAssetPath()
36 | {
37 | // Get our object.
38 | Object selectedObject = Selection.activeObject;
39 | // return it's path
40 | string unityPath = UnityEditor.AssetDatabase.GetAssetPath(selectedObject);
41 | // COpy to buffer
42 | EditorGUIUtility.systemCopyBuffer = unityPath;
43 | }
44 |
45 | [MenuItem("Assets/UnityIO/Copy Unity Path", true)]
46 | [MenuItem("Assets/UnityIO/Copy System Path", true)]
47 | public static bool CopyPathValidation()
48 | {
49 | Object selected = Selection.activeObject;
50 |
51 | if(selected == null)
52 | {
53 | return false;
54 | }
55 |
56 | // Things that exist in the scene don't have an asset path.
57 | return !string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(selected));
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/ContextMenus.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4aabcc5fb9613ce4e885d36696b4bc7f
3 | timeCreated: 1477768184
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c01adb5324e6f3b459696ecaa3859191
3 | folderAsset: yes
4 | timeCreated: 1477155984
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/ConditionalProgressTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 | using UnityEngine;
34 | using UnityEditor;
35 | using UnityIO;
36 | using Object = UnityEngine.Object;
37 |
38 | public class ConditionalProgressTests : UnityIOTestBase
39 | {
40 | [Test]
41 | public void ConditionFolderRoot()
42 | {
43 | // Only create Sub Directory if Conditional Progress exists.
44 | IO.Root.IfSubDirectoryExists("Conditional Progress").CreateDirectory("Sub Directory");
45 | // It should not exists
46 | Assert.False(IO.Root.SubDirectoryExists("Conditional Progress/Sub Directory"));
47 | // Then really create it
48 | IO.Root.CreateDirectory("Conditional Progress");
49 | // Then try conditional again
50 | IO.Root.IfSubDirectoryExists("Conditional Progress").CreateDirectory("Sub Directory");
51 | // It should not exists since we created the parent directory
52 | Assert.True(IO.Root.SubDirectoryExists("Conditional Progress/Sub Directory"));
53 | // Cleanup
54 | IO.Root.IfSubDirectoryExists("Conditional Progress").Delete();
55 | }
56 |
57 | [Test]
58 | public void EmptyCheck()
59 | {
60 | // Create a new directory
61 | IO.Root.CreateDirectory("If Empty");
62 | // Check if it's empty
63 | Assert.True(IO.Root["If Empty"].IsEmpty(assetsOnly: false), "This should empty");
64 | // Add a sub folder
65 | IO.Root["If Empty"].CreateDirectory("Sub Directory");
66 | // This should be false since we say we want to include sub folders.
67 | Assert.False(IO.Root["If Empty"].IsEmpty(assetsOnly: false), "This should have passed because we have one folder.");
68 | // This should be false because we only care about Assets.
69 | Assert.False(IO.Root["If Empty"].IsEmpty(assetsOnly: true), "This should empty");
70 | // Cleanup
71 | IO.Root["If Empty"].Delete();
72 | }
73 |
74 | [Test]
75 | public void ConditionEmptyTest()
76 | {
77 | // Create a new directory
78 | IO.Root.CreateDirectory("Conditional Empty").CreateDirectory("Sub Directory");
79 | // Destroy it if it's empty (it's not).
80 | IO.Root["Conditional Empty"].IfEmpty(assetsOnly: false).Delete();
81 | // Check if it was deleted (it should not have been).
82 | Assert.True(IO.Root.SubDirectoryExists("Conditional Empty"), "The folder should not have been deleted");
83 | // Delete the next level instead this should work.
84 | IO.Root["Conditional Empty/Sub Directory"].IfEmpty(assetsOnly: false).Delete();
85 | // Check if it was deleted (it should have been).
86 | bool directroyStillExists = IO.Root.SubDirectoryExists("Conditional Empty/Sub Directory");
87 | // Clean up if the test failed
88 | IO.Root["Conditional Empty"].Delete();
89 | // Finish Test
90 | Assert.False(directroyStillExists);
91 | }
92 |
93 | [Test]
94 | [Description("Tests to see if we can cancel execution if a file does not exist. Tests both loading a valid fail and an invalid one.")]
95 | public void IfFileExists()
96 | {
97 | // Get our testingDir
98 | var testingDir = SetupAssetLoadingTest();
99 | // Load our asset only if it exists.
100 | GameObject loadedAsset = testingDir.IfFileExists("Misc Prefab").LoadAsset();
101 | // Our Asset should exist
102 | Assert.IsNotNull(loadedAsset, "We should have been able to load this asset");
103 | // Log output
104 | TestLog("Loaded " + loadedAsset.name + " successfully");
105 | // Load an invalid object.
106 | GameObject invalidObject = testingDir.IfFileExists("Fake Prefab").LoadAsset();
107 | // It should be null
108 | Assert.IsNull(invalidObject, "We should not have been able to load the asset named.");
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/ConditionalProgressTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bfea9f91637d1854e97c98e51eb7c893
3 | timeCreated: 1477160846
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/ConvertPathTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 |
33 | using NUnit.Framework;
34 | using UnityEngine;
35 | using UnityEditor;
36 | using UnityIO;
37 | using Object = UnityEngine.Object;
38 |
39 | public class ConvertPathTests : UnityIOTestBase
40 | {
41 | [Test]
42 | public void AssetPathTOSystemPathConvert()
43 | {
44 | string systemPath = Application.dataPath + "/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab";
45 | string assetPath = "Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab";
46 | string result = IO.AssetPathToSystemPath(assetPath);
47 | Assert.AreEqual(systemPath, result, "The path did not convert correctly");
48 | }
49 |
50 | [Test]
51 | public void SystemToAssetPathConvert()
52 | {
53 | string systemPath = Application.dataPath + "/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab";
54 | string assetPath = "Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab";
55 | string result = IO.SystemToAssetPath(systemPath);
56 | Assert.AreEqual(assetPath, result, "The path did not convert correctly");
57 | }
58 | }
59 |
60 |
61 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/ConvertPathTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1050a70e79992f743868c3eb574b1e00
3 | timeCreated: 1483123943
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/CreatingDirectoryTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 | using UnityIO;
34 |
35 | public class CreatingDirectory
36 | {
37 |
38 | [Test]
39 | public void CreateRootLevelDirectory()
40 | {
41 | IO.Root.CreateDirectory("CreateRootLevelDirectory");
42 | Assert.True(IO.Root.SubDirectoryExists("CreateRootLevelDirectory"));
43 | IO.Root.DeleteSubDirectory("CreateRootLevelDirectory");
44 | }
45 |
46 | [Test]
47 | public void CreateNestedDirectoryOneStep()
48 | {
49 | IO.Root.CreateDirectory("CreateNestedDirectoryOneStep/Folder One");
50 | Assert.True(IO.Root.SubDirectoryExists("CreateNestedDirectoryOneStep/Folder One"));
51 | IO.Root.DeleteSubDirectory("CreateNestedDirectoryOneStep");
52 | }
53 |
54 | [Test]
55 | public void CreateNestedDirectoryMultiStep()
56 | {
57 | IO.Root.CreateDirectory("CreateNestedDirectoryMultiStep").CreateDirectory("Folder One").CreateDirectory("Folder Two");
58 | Assert.True(IO.Root.SubDirectoryExists("CreateNestedDirectoryMultiStep/Folder One"));
59 | Assert.True(IO.Root.SubDirectoryExists("CreateNestedDirectoryMultiStep/Folder One/Folder Two"));
60 | IO.Root.DeleteSubDirectory("CreateNestedDirectoryMultiStep");
61 | }
62 |
63 | [Test]
64 | public void CreateNestedPreExistingRoot()
65 | {
66 | // Create the root by itself.
67 | IO.Root.CreateDirectory("CreateNestedDirectoryMultiStep");
68 | // Create it again with a child
69 | IO.Root.CreateDirectory("CreateNestedDirectoryMultiStep").CreateDirectory("MultiFolder_Temp");
70 | // Check if the child exists at the root
71 | bool directroyExistsInRoot = IO.Root.SubDirectoryExists("MultiFolder_Temp");
72 | // Clean up the root folder
73 | IO.Root["CreateNestedDirectoryMultiStep"].Delete();
74 | // If the test failed this folder will exist so we want to cleanup
75 | IO.Root.IfSubDirectoryExists("CreateNestedDirectoryMultiStep").Delete();
76 | // Fail or pass the test.
77 | Assert.False(directroyExistsInRoot);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/CreatingDirectoryTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 680190ca25d716d428f3abddb8532224
3 | timeCreated: 1477156006
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/DirectoryChangesTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 | using UnityIO;
34 | using UnityIO.Exceptions;
35 |
36 | public class DirectoryChangesTests
37 | {
38 | [Test]
39 | [Description("Tests to see if a a directory with one sub directory can be copied and get auto renamed")]
40 | public void DuplicateDirectory()
41 | {
42 | // Create our first folder
43 | var newFolder = IO.Root.CreateDirectory("DD");
44 | // Add a sub folder
45 | newFolder.CreateDirectory("Sub Directory");
46 | // duplicate our first one
47 | newFolder.Duplicate();
48 | // Make sure the original and it's sub directory are still in tack.
49 | Assert.True(IO.Root.SubDirectoryExists("DD"), "The original folder should be in the same place");
50 | // And it's sub folder
51 | Assert.True(IO.Root.SubDirectoryExists("DD/Sub Directory"), "The sub folder should be in the same place");
52 | // Make sure the original and it's sub directory are still in tack.
53 | Assert.True(IO.Root.SubDirectoryExists("DD 1"), "The original folder should be in the same place");
54 | // And it's sub folder
55 | Assert.True(IO.Root.SubDirectoryExists("DD 1/Sub Directory"), "The sub folder should be in the same place");
56 | }
57 |
58 | [Test]
59 | [Description("Tests to see if a a directory with one sub directory can be copied and get a new named assigned by the user")]
60 | public void DuplicateDirectoryWithName()
61 | {
62 | // Create our first folder
63 | var newFolder = IO.Root.CreateDirectory("DDWN");
64 | // Add a sub folder
65 | newFolder.CreateDirectory("Sub");
66 | // duplicate our first one
67 | newFolder.Duplicate(IO.Root.path + "/New DDWN");
68 | // Make sure the original and it's sub directory are still in tack.
69 | Assert.True(IO.Root.SubDirectoryExists("DDWN"), "The original folder should be in the same place");
70 | // And it's sub folder
71 | Assert.True(IO.Root.SubDirectoryExists("DDWN/Sub"), "The sub folder should be in the same place");
72 | // Make sure the original and it's sub directory are still in tack.
73 | Assert.True(IO.Root.SubDirectoryExists("New DDWN"), "The original folder should be in the same place");
74 | // And it's sub folder
75 | Assert.True(IO.Root.SubDirectoryExists("New DDWN/Sub"), "The sub folder should be in the same place");
76 | }
77 |
78 | [Test]
79 | [Description("Checks to see if a directory can be renamed")]
80 | public void Rename()
81 | {
82 | // Create a folder
83 | var newFolder = IO.Root.CreateDirectory("RNT");
84 | // Create a sub
85 | newFolder.CreateDirectory("Sub");
86 | // Rename it
87 | newFolder.Rename("RNT Renamed");
88 | // Old one should not exist
89 | Assert.False(IO.Root.SubDirectoryExists("RNT"), "The original folder should not exist anymore");
90 | // Check if the rename is there
91 | Assert.True(IO.Root.SubDirectoryExists("RNT Renamed"), "The original folder should not exist anymore");
92 | }
93 |
94 | [Test]
95 | [ExpectedException(ExpectedException = typeof(DirectroyAlreadyExistsException))]
96 | [Description("Checks to see if an exception is thrown when we try to rename a directory and one already exists with that name")]
97 | public void RenameWithConflict()
98 | {
99 | // Create a folder
100 | var rwc = IO.Root.CreateDirectory("RWC");
101 | // Create a second one
102 | var rwc2 = IO.Root.CreateDirectory("RWC2");
103 | // Rename the second one to cause an exception since that directory already exists.
104 | rwc2.Rename("RWC");
105 | }
106 |
107 | [Test]
108 | [Sequential]
109 | [Description("Checks to see if an exception is thrown when we try to rename a directory and the name has invalid characters.")]
110 | public void RenameWithInvalidName([Values("/", "\\", "<", ">", ":", "|", "\"")] string charactersToTest)
111 | {
112 | // The exception that was thrown.
113 | System.Exception thorwnException = null;
114 | // Create a working directory
115 | var rwc = IO.Root.CreateDirectory("RWIN");
116 | // Create a file to rename
117 | var newDir = rwc.CreateDirectory("Awesome");
118 | // Rename it with invalid characters.
119 | try
120 | {
121 | newDir.Rename(charactersToTest);
122 | }
123 | catch (System.Exception e)
124 | {
125 | thorwnException = e;
126 | }
127 |
128 | if (thorwnException is InvalidNameException)
129 | {
130 | Assert.Pass("The correct exception was thrown for the invalid character '" + charactersToTest + "'.");
131 | }
132 | else
133 | {
134 | if(thorwnException != null)
135 | {
136 | Assert.Fail("The expected exception was not captured for the invalid character '" + charactersToTest + "'. The Exception thrown was " + thorwnException.ToString());
137 | }
138 | else
139 | {
140 | Assert.Fail("No exception was thrown for invalid character '" + charactersToTest + "'");
141 | }
142 | }
143 | }
144 |
145 | [Test]
146 | [Sequential]
147 | [Description("Checks to see if an exception is thrown when we try to rename a directory and the name has invalid characters.")]
148 | public void MoveWithInvalidName([Values("/", "\\", "<", ">", ":", "|", "\"")] string charactersToTest)
149 | {
150 | // The exception that was thrown.
151 | System.Exception thorwnException = null;
152 | // Create a working directory
153 | var rwc = IO.Root.CreateDirectory("RWIN");
154 | // Create a file to rename
155 | var newDir = rwc.CreateDirectory("Awesome");
156 | // Rename it with invalid characters.
157 | try
158 | {
159 | newDir.Move(rwc.path + "/" + charactersToTest);
160 | }
161 | catch (System.Exception e)
162 | {
163 | thorwnException = e;
164 | }
165 |
166 | if (thorwnException is InvalidNameException)
167 | {
168 | Assert.Pass("The correct exception was thrown for the invalid character '" + charactersToTest + "'.");
169 | }
170 | else
171 | {
172 | if (thorwnException != null)
173 | {
174 | Assert.Fail("The expected exception was not captured for the invalid character '" + charactersToTest + "'. The Exception thrown was " + thorwnException.ToString());
175 | }
176 | else
177 | {
178 | Assert.Fail("No exception was thrown for invalid character '" + charactersToTest + "'");
179 | }
180 | }
181 | }
182 |
183 |
184 |
185 | [TearDown]
186 | public void TearDown()
187 | {
188 | IO.Root.IfSubDirectoryExists("DD").Delete();
189 | IO.Root.IfSubDirectoryExists("DD 1").Delete();
190 | IO.Root.IfSubDirectoryExists("DDWN").Delete();
191 | IO.Root.IfSubDirectoryExists("New DDWN").Delete();
192 | IO.Root.IfSubDirectoryExists("RNT").Delete();
193 | IO.Root.IfSubDirectoryExists("RNT Renamed").Delete();
194 | IO.Root.IfSubDirectoryExists("RWC").Delete();
195 | IO.Root.IfSubDirectoryExists("RWC2").Delete();
196 | IO.Root.IfSubDirectoryExists("RWIN").Delete();
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/DirectoryChangesTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 30aa69c7d566afb459cd14682375b60c
3 | timeCreated: 1477191940
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Documention.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using UnityEngine;
33 | using UnityIO;
34 | using UnityIO.Interfaces;
35 |
36 | public class Documention
37 | {
38 | #pragma warning disable 0219
39 | ///
40 | /// Creates a directory the root of our project
41 | ///
42 | public void CreatingRootDirectory()
43 | {
44 | IO.Root.CreateDirectory("Favorite Animals");
45 | }
46 |
47 | ///
48 | /// Creates a nested directory in our project
49 | ///
50 | public void CreateNestedDirectory()
51 | {
52 | IO.Root.CreateDirectory("Favorite Animals/Cats");
53 | }
54 |
55 | ///
56 | /// A few more ways to create folders
57 | ///
58 | public void CreateNestedCatFolder()
59 | {
60 | // Create in a chain
61 | var catsFolder1 = IO.Root.CreateDirectory("Favorite Animals").CreateDirectory("Cats");
62 |
63 | // Break it down into two parts.
64 | var animals = IO.Root.CreateDirectory("Favorite Animals");
65 | var catsFolder2 = animals.CreateDirectory("Cats");
66 |
67 | // Do it in one step.
68 | var catsFolder3 = IO.Root.CreateDirectory("Favorite Animals/Cats");
69 |
70 | // Do it in one step with the helper
71 | var catsFolder4 = IO.Root.CreateDirectory("Favorite Animals" + IO.PATH_SPLITTER + "Cats");
72 | }
73 |
74 | ///
75 | /// Lets blow some things up
76 | ///
77 | public void Destroy()
78 | {
79 | // Get our directory and nuke it
80 | IO.Root["Favorite Animals"]["Cats"].Delete();
81 |
82 | // Delete our cats folder.
83 | IO.Root.DeleteSubDirectory("Favorite Animals/Cats");
84 | }
85 |
86 | ///
87 | /// Lets see some explosions
88 | ///
89 | public void DeleteSomethingNotReal()
90 | {
91 | IO.Root["Favorite Animals"]["Dogs"].Delete(); // Does not exist
92 | }
93 |
94 | ///
95 | /// We should play it safe.
96 | ///
97 | public void ValidateBeforeDelete()
98 | {
99 | var favoriteAnimals = IO.Root["Favorite Animals"];
100 |
101 | if (favoriteAnimals.SubDirectoryExists("Dogs"))
102 | {
103 | favoriteAnimals.DeleteSubDirectory("Dogs");
104 | }
105 | }
106 |
107 | ///
108 | /// We should play it safe and make it easy
109 | ///
110 | public void EasyValidateBeforeDelete()
111 | {
112 | IO.Root["Favorite Animals"].IfSubDirectoryExists("Dogs").Delete();
113 | }
114 |
115 | ///
116 | /// Look at the length of that things!
117 | ///
118 | public void ILikeChains()
119 | {
120 | IO.Root["Favorite Animals"].IfSubDirectoryExists("Dogs").IfSubDirectoryExists("With Four Legs").IfSubDirectoryExists("Who stink").Delete();
121 | }
122 |
123 | ///
124 | /// Find, Create, and Destroy
125 | ///
126 | public void CreateAndDestroy()
127 | {
128 | IO.Root["Favorite Animals"].IfSubDirectoryExists("Dogs").CreateDirectory("Delete Me").Delete();
129 | }
130 |
131 | ///
132 | /// A simple example of getting all files from a folder called resources at Assets/Resources.
133 | ///
134 | public void GetResourceFiles()
135 | {
136 | // Get our directory
137 | IDirectory resourcesDirectory = IO.Root["Resources"];
138 | // Get all files.
139 | IFiles files = resourcesDirectory.GetFiles();
140 |
141 | // iterate over our files and print their names
142 | for (int i = 0; i < files.Count; i++)
143 | {
144 | Debug.Log(files[i].name);
145 | }
146 | }
147 |
148 | ///
149 | /// A simple example of getting all files from a folder called resources at Assets/Resources.
150 | ///
151 | public void GetFilesRecursively()
152 | {
153 | // Get our directory
154 | IDirectory resourcesDirectory = IO.Root["Resources"];
155 | // Get all files recursively
156 | IFiles files = resourcesDirectory.GetFiles(recursive: true);
157 | }
158 |
159 | public void SearchExamples()
160 | {
161 | // Returns every asset with 'Player' in it's name.
162 | var playerFiles = IO.Root.GetFiles("*Player*");
163 | // Get everything named with 'Player' and '.anim' extension
164 | var playerAnimations = IO.Root.GetFiles("*Player*.anim");
165 | // get everything named 'Player' with one extra char maybe an 's'
166 | var playerChar = IO.Root.GetFiles("Player?");
167 | }
168 |
169 | ///
170 | /// Grabs all the files in the root directory and deletes them.
171 | ///
172 | public void DeleteAFile()
173 | {
174 | // Get all our files.
175 | var files = IO.Root.GetFiles();
176 | // Loop over them all and delete them
177 | for (int i = 0; i < files.Count; i++)
178 | {
179 | // Delete the file.
180 | files[i].Delete();
181 | }
182 |
183 | var file = IO.Root.GetFiles("DELETEME.txt").FirstOrDefault();
184 |
185 | /// Only delete our file if it exists.
186 | IO.Root.IfFileExists("DeleteMe.txt").Delete();
187 |
188 | // Get the file we want to use.
189 | IFile fileToRename = IO.Root.GetFiles("DeleteMe.txt").FirstOrDefault();
190 | // Rename it
191 | fileToRename.Rename("DontDeleteMe.txt");
192 |
193 | IO.Root.GetFiles("DeleteMe.txt").FirstOrDefault().Rename("Delete All Of The Things.txt");
194 |
195 | // Get the file we want to use.
196 | IFile fileToMove = IO.Root.GetFiles("DeleteMe.txt").FirstOrDefault();
197 | // Move it
198 | fileToRename.Move(IO.Root["Resources"].path);
199 |
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Documention.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ca858dea963d04b44a5e0be3dd636fec
3 | timeCreated: 1477170977
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/EnumerationTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 |
34 | public class EnumerationTests : UnityIOTestBase
35 | {
36 |
37 | [Test]
38 | [Description("This test looks inside the " + GetFilesTests.UNIT_TEST_LOADING_TEST_ASSETS + " directory and counts the total files. It should be constant")]
39 | public void EnumerationCount()
40 | {
41 | var dir = GetFilesTests.SetupAssetLoadingTest();
42 |
43 | int count = 0;
44 | foreach(var directory in dir)
45 | {
46 | count++;
47 | }
48 | // Test if our count is correct.
49 | Assert.AreEqual(count, 4, "There should be four files in the testing directory at " + GetFilesTests.UNIT_TEST_LOADING_TEST_ASSETS);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/EnumerationTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b2d5aaf12fd95a44e8f69b50f5c5ce68
3 | timeCreated: 1477172634
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/FileChangesTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 | using UnityEditor;
34 | using UnityEngine;
35 | using UnityIO;
36 | using UnityIO.Classes;
37 | using UnityIO.Interfaces;
38 | using AssetDatabase = UnityEditor.AssetDatabase;
39 |
40 | public class FileChangesTests
41 | {
42 | private IDirectory m_WorkingDirectroy;
43 |
44 | [SetUp]
45 | public void Init()
46 | {
47 | // Creating our working Directory
48 | m_WorkingDirectroy = IO.Root.CreateDirectory(GetType().Name);
49 | // Create a prefab to work with.
50 | PrefabUtility.CreatePrefab(m_WorkingDirectroy.path + "/Cube.prefab", GameObject.CreatePrimitive(PrimitiveType.Cube));
51 | PrefabUtility.CreatePrefab(m_WorkingDirectroy.path + "/Cylinder.prefab", GameObject.CreatePrimitive(PrimitiveType.Cylinder));
52 | PrefabUtility.CreatePrefab(m_WorkingDirectroy.path + "/Plane.prefab", GameObject.CreatePrimitive(PrimitiveType.Plane));
53 | }
54 |
55 | [Test]
56 | [Description("Tests to see if we can duplicate a file")]
57 | public void DuplicateFile()
58 | {
59 | // Get our file
60 | IFile cube = m_WorkingDirectroy.GetFiles("*Cube*").FirstOrDefault();
61 | // Should not be null;
62 | Assert.IsNotInstanceOf(cube);
63 | // Duplicate our prefab
64 | var secondCube = cube.Duplicate();
65 | // Check if our first one still exists
66 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(cube.path));
67 | // And our second one is alive.
68 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(secondCube.path));
69 | }
70 |
71 | [Test]
72 | [Description("Tests to see if we can duplicate a file and give it a new name")]
73 | public void DuplicateFileWithNewName()
74 | {
75 | // Get our file
76 | IFile cube = m_WorkingDirectroy.GetFiles("*Cube*").FirstOrDefault();
77 | // Should not be null;
78 | Assert.IsNotInstanceOf(cube);
79 | // Duplicate our prefab
80 | var secondCube = cube.Duplicate("Super Box");
81 | // Check if our first one still exists
82 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Cube.prefab"));
83 | // And our second one is alive.
84 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Super Box.prefab"));
85 | }
86 |
87 |
88 | [Test]
89 | [Description("Tests to see if a file can be renamed.")]
90 | public void RenameFile()
91 | {
92 | // Get our file
93 | IFile cube = m_WorkingDirectroy.GetFiles("*Cylinder*").FirstOrDefault();
94 | // Should not be null;
95 | Assert.IsNotInstanceOf(cube);
96 | // Duplicate our prefab
97 | cube.Rename("Super Tube");
98 | // Check to make sure the original item does not exist
99 | Assert.IsNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Cylinder.prefab"), "Our old prefab still exists");
100 | // Check if the rename happened.
101 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Super Tube.prefab"), "The renamed prefab could not be found");
102 | }
103 |
104 |
105 | [Test]
106 | [Description("Tests to see if a file can be moved.")]
107 | public void MoveFile()
108 | {
109 | // Create directory to move stuff into.
110 | var moveTo = m_WorkingDirectroy.CreateDirectory("MoveTo");
111 | // Get our file
112 | IFile cube = m_WorkingDirectroy.GetFiles("*Plane*").FirstOrDefault();
113 | // Should not be null;
114 | Assert.IsNotInstanceOf(cube);
115 | // Duplicate our prefab
116 | cube.Move(moveTo.path);
117 | // Check to make sure the original item does not exist
118 | Assert.IsNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Plane.prefab"), "Our old prefab still exists");
119 | // Check if the rename happened.
120 | Assert.IsNotNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/MoveTo/Plane.prefab"), "The renamed prefab could not be found");
121 | }
122 |
123 | [Test]
124 | [Description("Tests to make sure we can delete files.")]
125 | public void DeleteFile()
126 | {
127 | // Create a prefab to delete.
128 | PrefabUtility.CreatePrefab(m_WorkingDirectroy.path + "/Delete Me.prefab", GameObject.CreatePrimitive(PrimitiveType.Plane));
129 | // Get our file
130 | var deleteMeFile = m_WorkingDirectroy.GetFiles("*Delete Me*").FirstOrDefault();
131 | // Delete it
132 | deleteMeFile.Delete();
133 | // Check to make sure the original item does not exist
134 | Assert.IsNull(AssetDatabase.LoadAssetAtPath(m_WorkingDirectroy.path + "/Delete Me.prefab"), "Our old prefab still exists");
135 | }
136 |
137 |
138 |
139 | [TearDown]
140 | public void Dispose()
141 | {
142 | IO.Root.IfSubDirectoryExists(GetType().Name).Delete();
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/FileChangesTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0ed2da6b4d3c20345b790bed20bbc447
3 | timeCreated: 1477243549
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/GetFilesTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | using NUnit.Framework;
31 | using UnityIO;
32 | using UnityIO.Interfaces;
33 |
34 | public class GetFilesTests : UnityIOTestBase
35 | {
36 | [Test(Description = "Check if you can find assets only at the top level in " + UNIT_TEST_LOADING_TEST_ASSETS)]
37 | public void GetTopLevelFiles()
38 | {
39 | // Setup our test.
40 | var loadingDir = SetupAssetLoadingTest();
41 | // Load all our assets
42 | var files = loadingDir.GetFiles();
43 | // Should only be root level which has a total of 3 files.
44 | Assert.AreEqual(files.Count, 3, "There should be 3 files in the root of the testing directory");
45 | }
46 |
47 | [Test(Description = "Check if you can find assets only at the top level with filter in " + UNIT_TEST_LOADING_TEST_ASSETS)]
48 | public void GetRecursiveFiles()
49 | {
50 | // Setup our test.
51 | var loadingDir = SetupAssetLoadingTest();
52 | // Get all
53 | var files = loadingDir.GetFiles(recursive: true);
54 | // Should be 10 assets
55 | Assert.AreEqual(files.Count, 10, "There should be 10 files in the testing directory");
56 | }
57 |
58 | [Test(Description = "Checks if you can verify if you can find only assets in the top level directory with a filter. In this case any file with the .anim extension in " + UNIT_TEST_LOADING_TEST_ASSETS)]
59 | public void GetTopLevelWithFilters()
60 | {
61 | // Setup our test.
62 | var loadingDir = SetupAssetLoadingTest();
63 | // We are going to try to only find files ending with .anim
64 | var files = loadingDir.GetFiles(filter:"*.anim");
65 | // There should be four.
66 | Assert.AreEqual(files.Count, 1, "There should be 1 file at the root that ends with .anim in our testing directory");
67 | }
68 |
69 | [Test(Description = "Checks if you can verify if you can find all assets with a filter. In this case any file with the .anim extension in " + UNIT_TEST_LOADING_TEST_ASSETS)]
70 | public void GetRecursiveWithFilters()
71 | {
72 | // Setup our test.
73 | var loadingDir = SetupAssetLoadingTest();
74 | // We are going to try to only find files ending with .anim
75 | var files = loadingDir.GetFiles(filter: "*.anim", recursive:true);
76 | // There should be four.
77 | Assert.AreEqual(files.Count, 4, "There should be 1 file at the root that ends with .anim in our testing directory");
78 | }
79 |
80 | [Test(Description = "Test to make sure the meta information about the file is correct")]
81 | public void FileNameProperties()
82 | {
83 | // Setup our test.
84 | var loadingDir = SetupAssetLoadingTest();
85 | // We are going to try to only find files ending with .anim
86 | var file = loadingDir.GetFiles(filter: "*.anim").FirstOrDefault();
87 | // Make sure it's the correct directory.
88 | Assert.AreEqual(loadingDir.path, file.directory.path, "The directory of the file does not match.");
89 | // Make sure it's the correct extension.
90 | Assert.AreEqual(".anim", file.extension, "The extension of this class should be '.anim'.");
91 | // Make sure it's the correct extension.
92 | Assert.AreEqual("Misc Animation", file.nameWithoutExtension, "The name of this class is not correct.");
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/GetFilesTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bcde37ea76b476c4986720754c9c3aad
3 | timeCreated: 1477174458
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7d718db3a233ef04c9895b1cebdf6155
3 | folderAsset: yes
4 | timeCreated: 1477173515
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fff32dcf1d6c6854fa3ce7d2c7d02527
3 | folderAsset: yes
4 | timeCreated: 1477188114
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Died.anim:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!74 &7400000
4 | AnimationClip:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_Name: Died
9 | serializedVersion: 6
10 | m_Legacy: 0
11 | m_Compressed: 0
12 | m_UseHighQualityCurve: 1
13 | m_RotationCurves: []
14 | m_CompressedRotationCurves: []
15 | m_EulerCurves: []
16 | m_PositionCurves: []
17 | m_ScaleCurves: []
18 | m_FloatCurves: []
19 | m_PPtrCurves: []
20 | m_SampleRate: 60
21 | m_WrapMode: 0
22 | m_Bounds:
23 | m_Center: {x: 0, y: 0, z: 0}
24 | m_Extent: {x: 0, y: 0, z: 0}
25 | m_ClipBindingConstant:
26 | genericBindings: []
27 | pptrCurveMapping: []
28 | m_AnimationClipSettings:
29 | serializedVersion: 2
30 | m_AdditiveReferencePoseClip: {fileID: 0}
31 | m_AdditiveReferencePoseTime: 0
32 | m_StartTime: 0
33 | m_StopTime: 1
34 | m_OrientationOffsetY: 0
35 | m_Level: 0
36 | m_CycleOffset: 0
37 | m_HasAdditiveReferencePose: 0
38 | m_LoopTime: 0
39 | m_LoopBlend: 0
40 | m_LoopBlendOrientation: 0
41 | m_LoopBlendPositionY: 0
42 | m_LoopBlendPositionXZ: 0
43 | m_KeepOriginalOrientation: 0
44 | m_KeepOriginalPositionY: 1
45 | m_KeepOriginalPositionXZ: 0
46 | m_HeightFromFeet: 0
47 | m_Mirror: 0
48 | m_EditorCurves: []
49 | m_EulerEditorCurves: []
50 | m_HasGenericRootTransform: 0
51 | m_HasMotionFloatCurves: 0
52 | m_GenerateMotionCurves: 0
53 | m_Events: []
54 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Died.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e9c621da2f87f64ea1d59cc9387ada2
3 | timeCreated: 1477188137
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Hit.anim:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!74 &7400000
4 | AnimationClip:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_Name: Hit
9 | serializedVersion: 6
10 | m_Legacy: 0
11 | m_Compressed: 0
12 | m_UseHighQualityCurve: 1
13 | m_RotationCurves: []
14 | m_CompressedRotationCurves: []
15 | m_EulerCurves: []
16 | m_PositionCurves: []
17 | m_ScaleCurves: []
18 | m_FloatCurves: []
19 | m_PPtrCurves: []
20 | m_SampleRate: 60
21 | m_WrapMode: 0
22 | m_Bounds:
23 | m_Center: {x: 0, y: 0, z: 0}
24 | m_Extent: {x: 0, y: 0, z: 0}
25 | m_ClipBindingConstant:
26 | genericBindings: []
27 | pptrCurveMapping: []
28 | m_AnimationClipSettings:
29 | serializedVersion: 2
30 | m_AdditiveReferencePoseClip: {fileID: 0}
31 | m_AdditiveReferencePoseTime: 0
32 | m_StartTime: 0
33 | m_StopTime: 1
34 | m_OrientationOffsetY: 0
35 | m_Level: 0
36 | m_CycleOffset: 0
37 | m_HasAdditiveReferencePose: 0
38 | m_LoopTime: 0
39 | m_LoopBlend: 0
40 | m_LoopBlendOrientation: 0
41 | m_LoopBlendPositionY: 0
42 | m_LoopBlendPositionXZ: 0
43 | m_KeepOriginalOrientation: 0
44 | m_KeepOriginalPositionY: 1
45 | m_KeepOriginalPositionXZ: 0
46 | m_HeightFromFeet: 0
47 | m_Mirror: 0
48 | m_EditorCurves: []
49 | m_EulerEditorCurves: []
50 | m_HasGenericRootTransform: 0
51 | m_HasMotionFloatCurves: 0
52 | m_GenerateMotionCurves: 0
53 | m_Events: []
54 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Hit.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d338a8efa10b87a419346471f5587222
3 | timeCreated: 1477188128
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Player Attack.anim:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!74 &7400000
4 | AnimationClip:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_Name: Player Attack
9 | serializedVersion: 6
10 | m_Legacy: 0
11 | m_Compressed: 0
12 | m_UseHighQualityCurve: 1
13 | m_RotationCurves: []
14 | m_CompressedRotationCurves: []
15 | m_EulerCurves: []
16 | m_PositionCurves: []
17 | m_ScaleCurves: []
18 | m_FloatCurves: []
19 | m_PPtrCurves: []
20 | m_SampleRate: 60
21 | m_WrapMode: 0
22 | m_Bounds:
23 | m_Center: {x: 0, y: 0, z: 0}
24 | m_Extent: {x: 0, y: 0, z: 0}
25 | m_ClipBindingConstant:
26 | genericBindings: []
27 | pptrCurveMapping: []
28 | m_AnimationClipSettings:
29 | serializedVersion: 2
30 | m_AdditiveReferencePoseClip: {fileID: 0}
31 | m_AdditiveReferencePoseTime: 0
32 | m_StartTime: 0
33 | m_StopTime: 1
34 | m_OrientationOffsetY: 0
35 | m_Level: 0
36 | m_CycleOffset: 0
37 | m_HasAdditiveReferencePose: 0
38 | m_LoopTime: 0
39 | m_LoopBlend: 0
40 | m_LoopBlendOrientation: 0
41 | m_LoopBlendPositionY: 0
42 | m_LoopBlendPositionXZ: 0
43 | m_KeepOriginalOrientation: 0
44 | m_KeepOriginalPositionY: 1
45 | m_KeepOriginalPositionXZ: 0
46 | m_HeightFromFeet: 0
47 | m_Mirror: 0
48 | m_EditorCurves: []
49 | m_EulerEditorCurves: []
50 | m_HasGenericRootTransform: 0
51 | m_HasMotionFloatCurves: 0
52 | m_GenerateMotionCurves: 0
53 | m_Events: []
54 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Animations/Player Attack.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f96f5041679414243a7c2c9762ce1a5b
3 | timeCreated: 1477188122
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/GUISkins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 317cdb94b58918c478b82f3702269029
3 | folderAsset: yes
4 | timeCreated: 1477188195
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/GUISkins/Dark Skin.guiskin.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6ab2315a58610a64cb797a60b7955b10
3 | timeCreated: 1477174500
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/GUISkins/Light Skin.guiskin.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 91811523d6de003488556863fb59a04e
3 | timeCreated: 1477188209
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Animation.anim:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!74 &7400000
4 | AnimationClip:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 0}
8 | m_Name: Misc Animation
9 | serializedVersion: 6
10 | m_Legacy: 0
11 | m_Compressed: 0
12 | m_UseHighQualityCurve: 1
13 | m_RotationCurves: []
14 | m_CompressedRotationCurves: []
15 | m_EulerCurves: []
16 | m_PositionCurves: []
17 | m_ScaleCurves: []
18 | m_FloatCurves: []
19 | m_PPtrCurves: []
20 | m_SampleRate: 60
21 | m_WrapMode: 0
22 | m_Bounds:
23 | m_Center: {x: 0, y: 0, z: 0}
24 | m_Extent: {x: 0, y: 0, z: 0}
25 | m_ClipBindingConstant:
26 | genericBindings: []
27 | pptrCurveMapping: []
28 | m_AnimationClipSettings:
29 | serializedVersion: 2
30 | m_AdditiveReferencePoseClip: {fileID: 0}
31 | m_AdditiveReferencePoseTime: 0
32 | m_StartTime: 0
33 | m_StopTime: 1
34 | m_OrientationOffsetY: 0
35 | m_Level: 0
36 | m_CycleOffset: 0
37 | m_HasAdditiveReferencePose: 0
38 | m_LoopTime: 0
39 | m_LoopBlend: 0
40 | m_LoopBlendOrientation: 0
41 | m_LoopBlendPositionY: 0
42 | m_LoopBlendPositionXZ: 0
43 | m_KeepOriginalOrientation: 0
44 | m_KeepOriginalPositionY: 1
45 | m_KeepOriginalPositionXZ: 0
46 | m_HeightFromFeet: 0
47 | m_Mirror: 0
48 | m_EditorCurves: []
49 | m_EulerEditorCurves: []
50 | m_HasGenericRootTransform: 0
51 | m_HasMotionFloatCurves: 0
52 | m_GenerateMotionCurves: 0
53 | m_Events: []
54 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Animation.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 81315ac56a97b5d4ba1e99e829619fd8
3 | timeCreated: 1477188147
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 1
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 1000010781637270}
13 | m_IsPrefabParent: 1
14 | --- !u!1 &1000010781637270
15 | GameObject:
16 | m_ObjectHideFlags: 0
17 | m_PrefabParentObject: {fileID: 0}
18 | m_PrefabInternal: {fileID: 100100000}
19 | serializedVersion: 4
20 | m_Component:
21 | - 4: {fileID: 4000011508447898}
22 | - 33: {fileID: 33000010640171400}
23 | - 135: {fileID: 135000012790499214}
24 | - 23: {fileID: 23000010649922698}
25 | m_Layer: 0
26 | m_Name: Misc Prefab
27 | m_TagString: Untagged
28 | m_Icon: {fileID: 0}
29 | m_NavMeshLayer: 0
30 | m_StaticEditorFlags: 0
31 | m_IsActive: 1
32 | --- !u!4 &4000011508447898
33 | Transform:
34 | m_ObjectHideFlags: 1
35 | m_PrefabParentObject: {fileID: 0}
36 | m_PrefabInternal: {fileID: 100100000}
37 | m_GameObject: {fileID: 1000010781637270}
38 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
39 | m_LocalPosition: {x: 0, y: 0, z: 0}
40 | m_LocalScale: {x: 1, y: 1, z: 1}
41 | m_Children: []
42 | m_Father: {fileID: 0}
43 | m_RootOrder: 0
44 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
45 | --- !u!23 &23000010649922698
46 | MeshRenderer:
47 | m_ObjectHideFlags: 1
48 | m_PrefabParentObject: {fileID: 0}
49 | m_PrefabInternal: {fileID: 100100000}
50 | m_GameObject: {fileID: 1000010781637270}
51 | m_Enabled: 1
52 | m_CastShadows: 1
53 | m_ReceiveShadows: 1
54 | m_MotionVectors: 1
55 | m_LightProbeUsage: 1
56 | m_ReflectionProbeUsage: 1
57 | m_Materials:
58 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
59 | m_SubsetIndices:
60 | m_StaticBatchRoot: {fileID: 0}
61 | m_ProbeAnchor: {fileID: 0}
62 | m_LightProbeVolumeOverride: {fileID: 0}
63 | m_ScaleInLightmap: 1
64 | m_PreserveUVs: 1
65 | m_IgnoreNormalsForChartDetection: 0
66 | m_ImportantGI: 0
67 | m_SelectedWireframeHidden: 0
68 | m_MinimumChartSize: 4
69 | m_AutoUVMaxDistance: 0.5
70 | m_AutoUVMaxAngle: 89
71 | m_LightmapParameters: {fileID: 0}
72 | m_SortingLayerID: 0
73 | m_SortingOrder: 0
74 | --- !u!33 &33000010640171400
75 | MeshFilter:
76 | m_ObjectHideFlags: 1
77 | m_PrefabParentObject: {fileID: 0}
78 | m_PrefabInternal: {fileID: 100100000}
79 | m_GameObject: {fileID: 1000010781637270}
80 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
81 | --- !u!135 &135000012790499214
82 | SphereCollider:
83 | m_ObjectHideFlags: 1
84 | m_PrefabParentObject: {fileID: 0}
85 | m_PrefabInternal: {fileID: 100100000}
86 | m_GameObject: {fileID: 1000010781637270}
87 | m_Material: {fileID: 0}
88 | m_IsTrigger: 0
89 | m_Enabled: 1
90 | serializedVersion: 2
91 | m_Radius: 0.5
92 | m_Center: {x: 0, y: 0, z: 0}
93 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Prefab.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2113cef6b0faa114185566f47da24c23
3 | timeCreated: 1477188180
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Misc Skin.guiskin.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0a435fda50452644f9b083844ea7e91f
3 | timeCreated: 1477188231
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Prefabs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fce111a28a4462d4cba8a03074927990
3 | folderAsset: yes
4 | timeCreated: 1477188107
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Prefabs/Player Character.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 0}
13 | m_IsPrefabParent: 1
14 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Prefabs/Player Character.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7f9fac0459335984488cefc3f67ff76e
3 | timeCreated: 1477174473
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Prefabs/Weapon.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 1
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 1000013934870762}
13 | m_IsPrefabParent: 1
14 | --- !u!1 &1000013934870762
15 | GameObject:
16 | m_ObjectHideFlags: 0
17 | m_PrefabParentObject: {fileID: 0}
18 | m_PrefabInternal: {fileID: 100100000}
19 | serializedVersion: 4
20 | m_Component:
21 | - 4: {fileID: 4000012708590042}
22 | - 33: {fileID: 33000011790802156}
23 | - 65: {fileID: 65000013194829368}
24 | - 23: {fileID: 23000010245363816}
25 | m_Layer: 0
26 | m_Name: Weapon
27 | m_TagString: Untagged
28 | m_Icon: {fileID: 0}
29 | m_NavMeshLayer: 0
30 | m_StaticEditorFlags: 0
31 | m_IsActive: 1
32 | --- !u!4 &4000012708590042
33 | Transform:
34 | m_ObjectHideFlags: 1
35 | m_PrefabParentObject: {fileID: 0}
36 | m_PrefabInternal: {fileID: 100100000}
37 | m_GameObject: {fileID: 1000013934870762}
38 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
39 | m_LocalPosition: {x: 0, y: 0, z: 0}
40 | m_LocalScale: {x: 1, y: 1, z: 1}
41 | m_Children: []
42 | m_Father: {fileID: 0}
43 | m_RootOrder: 0
44 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
45 | --- !u!23 &23000010245363816
46 | MeshRenderer:
47 | m_ObjectHideFlags: 1
48 | m_PrefabParentObject: {fileID: 0}
49 | m_PrefabInternal: {fileID: 100100000}
50 | m_GameObject: {fileID: 1000013934870762}
51 | m_Enabled: 1
52 | m_CastShadows: 1
53 | m_ReceiveShadows: 1
54 | m_MotionVectors: 1
55 | m_LightProbeUsage: 1
56 | m_ReflectionProbeUsage: 1
57 | m_Materials:
58 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
59 | m_SubsetIndices:
60 | m_StaticBatchRoot: {fileID: 0}
61 | m_ProbeAnchor: {fileID: 0}
62 | m_LightProbeVolumeOverride: {fileID: 0}
63 | m_ScaleInLightmap: 1
64 | m_PreserveUVs: 1
65 | m_IgnoreNormalsForChartDetection: 0
66 | m_ImportantGI: 0
67 | m_SelectedWireframeHidden: 0
68 | m_MinimumChartSize: 4
69 | m_AutoUVMaxDistance: 0.5
70 | m_AutoUVMaxAngle: 89
71 | m_LightmapParameters: {fileID: 0}
72 | m_SortingLayerID: 0
73 | m_SortingOrder: 0
74 | --- !u!33 &33000011790802156
75 | MeshFilter:
76 | m_ObjectHideFlags: 1
77 | m_PrefabParentObject: {fileID: 0}
78 | m_PrefabInternal: {fileID: 100100000}
79 | m_GameObject: {fileID: 1000013934870762}
80 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
81 | --- !u!65 &65000013194829368
82 | BoxCollider:
83 | m_ObjectHideFlags: 1
84 | m_PrefabParentObject: {fileID: 0}
85 | m_PrefabInternal: {fileID: 100100000}
86 | m_GameObject: {fileID: 1000013934870762}
87 | m_Material: {fileID: 0}
88 | m_IsTrigger: 0
89 | m_Enabled: 1
90 | serializedVersion: 2
91 | m_Size: {x: 1, y: 1, z: 1}
92 | m_Center: {x: 0, y: 0, z: 0}
93 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/Loading Assets/Prefabs/Weapon.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e50a17152ad73d748a6f997a7c10b419
3 | timeCreated: 1477188161
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/PathValidationTests.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | // Disable unused warning
31 | #pragma warning disable 0168
32 | using NUnit.Framework;
33 | using UnityIO;
34 |
35 | public class PathValidationTests
36 | {
37 |
38 | [Test]
39 | public void CorrectPath()
40 | {
41 | try
42 | {
43 | IO.ValidatePath("Assets/Folder");
44 | }
45 | catch
46 | {
47 | Assert.Fail("A valid path should not throw an exception");
48 | }
49 | }
50 |
51 | [Test]
52 | public void LeadingSlash()
53 | {
54 | Assert.Throws(() =>
55 | {
56 | IO.ValidatePath("Assets/Folder/");
57 | }, "This path ends with a leading forward slash and this should fail.");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/PathValidationTests.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c20474c44b8a3be4d868c9c4f7a1d1d2
3 | timeCreated: 1477159978
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/UnityIOTestBase.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | using NUnit.Framework;
31 | using System;
32 | using UnityEngine;
33 | using UnityIO;
34 | using UnityIO.Interfaces;
35 |
36 | public class UnityIOTestBase
37 | {
38 | public const string UNIT_TEST_LOADING_TEST_ASSETS = "UnityIO/Editor/Unit Tests/Loading Assets";
39 |
40 | ///
41 | /// Returns back an IDirectory for testing asset loading.
42 | ///
43 | ///
44 | public static IDirectory SetupAssetLoadingTest()
45 | {
46 | // We can only test if our testing directory exists
47 | Assume.That(IO.Root.SubDirectoryExists(UNIT_TEST_LOADING_TEST_ASSETS), "The testing directory this test is looking for does not exists at path '" + UNIT_TEST_LOADING_TEST_ASSETS + "'.");
48 | // Get our loading area
49 | return IO.Root[UNIT_TEST_LOADING_TEST_ASSETS];
50 | }
51 |
52 | ///
53 | /// Logs to the Unity Console.
54 | ///
55 | public void UnityLog(string log)
56 | {
57 | Debug.Log(log);
58 | }
59 |
60 | ///
61 | /// Logs to the test's console.
62 | ///
63 | public void TestLog(string log)
64 | {
65 | Console.WriteLine(log);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Editor/Unit Tests/UnityIOTestBase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5dd15397529fb4e498e69a2a194d37a6
3 | timeCreated: 1477766130
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Exceptions.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 |
30 | using System;
31 |
32 | namespace UnityIO.Exceptions
33 | {
34 | public class FileNotFoundException : Exception
35 | {
36 | public FileNotFoundException(string message) : base(message)
37 | {
38 |
39 | }
40 | }
41 |
42 | public class FileAlreadyExistsException : Exception
43 | {
44 | public FileAlreadyExistsException(string message) : base(message)
45 | {
46 |
47 | }
48 | }
49 |
50 | public class DirectoryNotFoundException : Exception
51 | {
52 | public DirectoryNotFoundException(string message) : base(message)
53 | {
54 |
55 | }
56 | }
57 |
58 | public class MoveException : Exception
59 | {
60 | public static string Format(string message, string from, string to)
61 | {
62 | return "Unable to move " + from + " to " + to + " because " + message;
63 | }
64 |
65 | public MoveException(string message, string from, string to) : base(Format(message, from, to))
66 | {
67 | }
68 | }
69 |
70 | public class RenameException : Exception
71 | {
72 | public static string Format(string message, string from, string to)
73 | {
74 | return "Unable to rename " + from + " to " + to + " because " + message;
75 | }
76 |
77 | public RenameException(string message, string from, string to) : base(Format(message, from, to))
78 | {
79 | }
80 | }
81 |
82 | ///
83 | /// This exception is thrown when you try to rename or move a directory and one
84 | /// already exists at that location.
85 | ///
86 | public class DirectroyAlreadyExistsException : Exception
87 | {
88 | public DirectroyAlreadyExistsException(string message) : base(message)
89 | {
90 | }
91 | }
92 |
93 | ///
94 | /// This exception is thrown when you try to name a file or directory that contains
95 | /// invalid characters.
96 | ///
97 | public class InvalidNameException : Exception
98 | {
99 | public InvalidNameException(string message) : base(message)
100 | {
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/Exceptions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ceb2f6fea9809774680ecff05aaf0d46
3 | timeCreated: 1477233237
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/proj.unity/Assets/UnityIO/File.cs:
--------------------------------------------------------------------------------
1 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2 | UnityIO was released with an MIT License.
3 | Arther: Byron Mayne
4 | Twitter: @ByMayne
5 |
6 |
7 | MIT License
8 |
9 | Copyright(c) 2016 Byron Mayne
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29 | using UnityIO.Interfaces;
30 | using UnityEngine;
31 | using UnityIO.Exceptions;
32 | using sIO = System.IO;
33 | using UnityIO.AssetDatabaseWrapper;
34 |
35 | namespace UnityIO.Classes
36 | {
37 | public class File : IFile
38 | {
39 | private string m_Directory;
40 | private string m_Extension;
41 | private string m_FileName;
42 |
43 | ///
44 | /// Gets the full path to this file starting from the Assets folder.
45 | ///
46 | public string path
47 | {
48 | get { return m_Directory + "/" + m_FileName + m_Extension; }
49 | }
50 |
51 | ///
52 | /// Gets the path to this file starting from the root of your system.
53 | ///
54 | public string systemPath
55 | {
56 | get { return IO.AssetPathToSystemPath(path); }
57 | }
58 |
59 | ///
60 | /// Gets the name of this file with it's extension.
61 | ///
62 | public string name
63 | {
64 | get { return m_FileName + m_Extension; }
65 | }
66 |
67 | ///
68 | /// Gets the name of this file without it's extension.
69 | ///
70 | public string nameWithoutExtension
71 | {
72 | get { return m_FileName; }
73 | }
74 |
75 | ///
76 | /// Gets the extension of this file.
77 | ///
78 | public string extension
79 | {
80 | get { return m_Extension; }
81 | }
82 |
83 | ///
84 | /// Creates a new instance of a file.
85 | ///
86 | public File(string path)
87 | {
88 | m_Extension = sIO.Path.GetExtension(path);
89 | m_FileName = sIO.Path.GetFileNameWithoutExtension(path);
90 | m_Directory = sIO.Path.GetDirectoryName(path);
91 | }
92 |
93 | ///
94 | /// Returns the directory that this file exists in.
95 | ///
96 | public IDirectory directory
97 | {
98 | get
99 | {
100 | return new Directory(m_Directory);
101 | }
102 | }
103 |
104 | ///
105 | /// Delete this file from disk.
106 | ///
107 | public void Delete()
108 | {
109 | // Deletes the asset
110 | AssetDatabase.DeleteAsset(path);
111 | }
112 |
113 | public IFile Duplicate()
114 | {
115 | // Get our path.
116 | string copyDir = AssetDatabase.GenerateUniqueAssetPath(path);
117 | // Copy our asset
118 | AssetDatabase.CopyAsset(path, copyDir);
119 | // Return new IFile
120 | return new File(copyDir);
121 | }
122 |
123 | ///
124 | /// Creates a copy of this file with a new name. The new name should not contain the extension
125 | /// that will be preserved automatically.
126 | ///
127 | /// The new name of the file (excluding the extension)
128 | ///
129 | public IFile Duplicate(string newName)
130 | {
131 | if(string.IsNullOrEmpty(newName))
132 | {
133 | throw new System.ArgumentNullException("You can't send a empty or null string to rename an asset. Trying to rename " + path);
134 | }
135 | // Make sure we don't have an extension.
136 | if(!string.IsNullOrEmpty(sIO.Path.GetExtension(newName)))
137 | {
138 | throw new InvalidNameException("When you duplicate an asset it should not have an extension " + newName);
139 | }
140 | // Make sure it's a valid name.
141 | if (!AssetDatabase.IsValidFileName(newName))
142 | {
143 | throw new InvalidNameException("The name '" + newName + "' contains invalid characters");
144 | }
145 | // Get our current directory
146 | string directory = System.IO.Path.GetDirectoryName(path);
147 | // and the extension
148 | string extension = System.IO.Path.GetExtension(path);
149 | // Get our path.
150 | string copyDir = AssetDatabase.GenerateUniqueAssetPath(directory + "/" + newName + extension);
151 | // Copy our asset
152 | AssetDatabase.CopyAsset(path, copyDir);
153 | // Return new IFile
154 | return new File(copyDir);
155 | }
156 |
157 | ///
158 | /// Moves the files from it's current directory to another.
159 | ///
160 | /// The directory you want to move it too
161 | public void Move(IDirectory targetDirectory)
162 | {
163 | Move(targetDirectory.path);
164 | }
165 |
166 | ///
167 | /// Moves the files from it's current directory to another.
168 | ///
169 | /// The directory you want to move it too
170 | public void Move(string targetDirectory)
171 | {
172 | // Make sure we have a valid path
173 | IO.ValidatePath(targetDirectory);
174 | // And the directory exists
175 | if(!AssetDatabase.IsValidFolder(targetDirectory))
176 | {
177 | throw new DirectoryNotFoundException("Unable to find the directory at " + targetDirectory);
178 | }
179 |
180 | // Get the current name of our file.
181 | string name = System.IO.Path.GetFileName(path);
182 |
183 | // Append the name to the end. Move can't rename.
184 | targetDirectory = targetDirectory + "/" + name;
185 |
186 | // Check to see if there will be an error.
187 | string error = AssetDatabase.ValidateMoveAsset(path, targetDirectory);
188 |
189 | // CHeck
190 | if (!string.IsNullOrEmpty(error))
191 | {
192 | // We messed up.
193 | throw new MoveException(error, path, targetDirectory);
194 | }
195 | else
196 | {
197 | // Move it we are good to go.
198 | AssetDatabase.MoveAsset(path, targetDirectory);
199 | }
200 | }
201 |
202 | ///
203 | /// Renames this file to a new name.
204 | ///
205 | public void Rename(string newName)
206 | {
207 | if (!UnityEditorInternal.InternalEditorUtility.IsValidFileName(newName))
208 | {
209 | throw new InvalidNameException("The name '" + newName + "' contains invalid characters");
210 | }
211 |
212 | if (newName.Contains("/"))
213 | {
214 | throw new RenameException("Rename can't be used to change a files location use Move(string newPath) instead.", path, newName);
215 | }
216 |
217 | string tempPath = m_Directory + "/" + newName;
218 |
219 | Object preExistingAsset = AssetDatabase.LoadAssetAtPath