UnauthorizedAccessException

0 votes
asked Mar 14, 2017 in Issue by nealruggles1 (150 points)
reopened Mar 24, 2017 by admin
Hello,

I just imported Material into my Unity project. When I startup unity i get multiple exceptions from Material saying "System.UnauthorizedAccessException: Access to the path "C:\MaterialUIData" is denied"

It doesn't break anything (that I can tell). How do i fix this?

Thanks!
commented Mar 14, 2017 by admin (31,720 points)

It looks like MaterialUIDataTool's GetMaterialUIPath() method isn't working as it should. Are you able to insert:

Debug.Log(materialUiDirectories[i]);

in the for loop, just before the 'if(Directory.Exists..." part, and show me what it prints?

Do you have the MaterialUI folder within another folder in the project?

~ Declan.

commented Mar 14, 2017 by nealruggles1 (150 points)
it looks looks like materialUIDirectories is returning an empty array.

I do have MaterialUI within another folder. I like to group packages in the assets folder under a UnityPackages folder
commented Mar 15, 2017 by admin (31,720 points)

Try turning this line (just above that 'if(Directory.Exists..." line):

string[] materialUiDirectories = Directory.GetDirectories(Application.dataPath, "MaterialUI");

into this:

string[] materialUiDirectories = Directory.GetDirectories(Application.dataPath, "MaterialUI", SearchOption.AllDirectories);

and let me know if that helps :)

~ Declan.

commented Mar 23, 2017 by nealruggles1 (150 points)
that did it! thank you so much for the help

1 Answer

0 votes
answered Mar 24, 2017 by admin (31,720 points)
 
Best answer

The issue was that the author moved the MaterialUI folder inside another folder. And here's the fix:

Try turning this line (just above that 'if(Directory.Exists..." line):

string[] materialUiDirectories = Directory.GetDirectories(Application.dataPath, "MaterialUI");

into this:

string[] materialUiDirectories = Directory.GetDirectories(Application.dataPath, "MaterialUI", SearchOption.AllDirectories);

and let me know if that helps :)

~ Declan.

commented Jan 18, 2018 by Harald
We had the same issue. Do you wanna incorporate the fix into the main code stream?
Welcome to MaterialUI support! Ask us anything :)
...