@@ -52,33 +52,44 @@ public OculusRecommendedSettings()
5252 {
5353 if ( v )
5454 {
55- try
55+ string asmdefFullPath = Path . GetFullPath ( ASMDEFS_PATH ) ;
56+ if ( ! Directory . Exists ( asmdefFullPath ) )
5657 {
57- string asmdefFullPath = Path . GetFullPath ( ASMDEFS_PATH ) ;
58- if ( ! Directory . Exists ( asmdefFullPath ) )
59- {
60- MonoScript script = MonoScript . FromScriptableObject ( VIUProjectSettings . Instance ) ;
61- string path = AssetDatabase . GetAssetPath ( script ) ;
62- asmdefFullPath = Path . GetFullPath ( AssetDatabase . GetAssetPath ( script ) + "/../../../.asmdefs/Oculus/" ) ;
63- Debug . Log ( "asmdefFullPath=" + asmdefFullPath ) ;
64- }
65- string oculusFullPath = Path . GetFullPath ( OCULUS_SDK_PATH ) ;
66- File . Copy ( asmdefFullPath + AVATAR_ASMDEF_FILE_NAME , oculusFullPath + "Avatar/" + AVATAR_ASMDEF_FILE_NAME ) ;
67- File . Copy ( asmdefFullPath + LIPSYNC_ASMDEF_FILE_NAME , oculusFullPath + "LipSync/" + LIPSYNC_ASMDEF_FILE_NAME ) ;
68- File . Copy ( asmdefFullPath + LIPSYNC_EDITOR_ASMDEF_FILE_NAME , oculusFullPath + "LipSync/Editor/" + LIPSYNC_EDITOR_ASMDEF_FILE_NAME ) ;
69- File . Copy ( asmdefFullPath + SPATIALIZER_ASMDEF_FILE_NAME , oculusFullPath + "Spatializer/" + SPATIALIZER_ASMDEF_FILE_NAME ) ;
70- File . Copy ( asmdefFullPath + SPATIALIZER_EDITOR_ASMDEF_FILE_NAME , oculusFullPath + "Spatializer/Editor/" + SPATIALIZER_EDITOR_ASMDEF_FILE_NAME ) ;
71- AssetDatabase . Refresh ( ) ;
72- }
73- catch ( System . Exception e )
74- {
75- Debug . LogException ( e ) ;
58+ MonoScript script = MonoScript . FromScriptableObject ( VIUProjectSettings . Instance ) ;
59+ string path = AssetDatabase . GetAssetPath ( script ) ;
60+ asmdefFullPath = Path . GetFullPath ( AssetDatabase . GetAssetPath ( script ) + "/../../../.asmdefs/Oculus/" ) ;
61+ //Debug.Log("asmdefFullPath=" + asmdefFullPath);
7662 }
63+ string oculusFullPath = Path . GetFullPath ( OCULUS_SDK_PATH ) ;
64+ SafeCopy ( asmdefFullPath + AVATAR_ASMDEF_FILE_NAME , oculusFullPath + "Avatar/" + AVATAR_ASMDEF_FILE_NAME ) ;
65+ SafeCopy ( asmdefFullPath + LIPSYNC_ASMDEF_FILE_NAME , oculusFullPath + "LipSync/" + LIPSYNC_ASMDEF_FILE_NAME ) ;
66+ SafeCopy ( asmdefFullPath + LIPSYNC_EDITOR_ASMDEF_FILE_NAME , oculusFullPath + "LipSync/Editor/" + LIPSYNC_EDITOR_ASMDEF_FILE_NAME ) ;
67+ SafeCopy ( asmdefFullPath + SPATIALIZER_ASMDEF_FILE_NAME , oculusFullPath + "Spatializer/" + SPATIALIZER_ASMDEF_FILE_NAME ) ;
68+ SafeCopy ( asmdefFullPath + SPATIALIZER_EDITOR_ASMDEF_FILE_NAME , oculusFullPath + "Spatializer/Editor/" + SPATIALIZER_EDITOR_ASMDEF_FILE_NAME ) ;
69+ AssetDatabase . Refresh ( ) ;
7770 }
7871 } ,
7972 recommendedValue = true ,
8073 } ) ;
8174 }
75+
76+ private static bool SafeCopy ( string src , string dst )
77+ {
78+ try
79+ {
80+ if ( ! File . Exists ( dst ) )
81+ {
82+ File . Copy ( src , dst ) ;
83+ return true ;
84+ }
85+ }
86+ catch ( System . Exception e )
87+ {
88+ Debug . LogException ( e ) ;
89+ }
90+
91+ return false ;
92+ }
8293 }
8394
8495 public static partial class VIUSettingsEditor
0 commit comments