Created
May 23, 2015 18:50
-
-
Save flarb/32a34c1e75f165f1b25c to your computer and use it in GitHub Desktop.
Revisions
-
flarb renamed this gist
May 23, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
flarb created this gist
May 23, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ using UnityEngine; using System.Collections; using UnityEditor; using System.IO; public class SDKSwap : EditorWindow { static string _cardboardPath; static string _OVRPath; static string _manifestPath = "/Plugins/Android/AndroidManifest.xml"; [MenuItem ("Window/Tools/SDK Switch")] static void Init() { SDKSwap window = (SDKSwap)EditorWindow.GetWindow(typeof(SDKSwap)); window.Show(); } void OnGUI() { GUILayout.Label("Manifest Paths", EditorStyles.boldLabel); GUILayout.Space(10f); GUILayout.Label("Cardboard Manifest", EditorStyles.label); GUILayout.TextField(_cardboardPath); if (GUILayout.Button("Set Cardboard Manifest")) { foreach (Object o in Selection.objects) { _cardboardPath = AssetDatabase.GetAssetPath(o); EditorPrefs.SetString("cardboardPath", _cardboardPath); break; } } GUILayout.Label("OVR Manifest", EditorStyles.label); GUILayout.TextField(_OVRPath); if (GUILayout.Button ("Set OVR Manifest")) { foreach (Object o in Selection.objects) { _OVRPath = AssetDatabase.GetAssetPath(o); EditorPrefs.SetString("OVRPath", _OVRPath); break; } } GUILayout.Space(10f); GUILayout.Label("Swap SDKs", EditorStyles.boldLabel); if (GUILayout.Button("OVR Mode")) { SwapOVR(); } if (GUILayout.Button("Cardboard Mode")) { SwapCardboard(); } } void OnEnable() { _cardboardPath = EditorPrefs.GetString("cardboardPath", null); _OVRPath = EditorPrefs.GetString("OVRPath", null); } //[MenuItem ("Window/Tools/Cardboard")] static void SwapCardboard() { string trimPath = _cardboardPath.Substring(6, _cardboardPath.Length - 6); string fullPath = Application.dataPath + trimPath; Debug.Log("FP: " + fullPath + " to " + GetManifestPath()); FileUtil.ReplaceFile(fullPath, GetManifestPath()); AssetDatabase.Refresh(); } //[MenuItem("Window/Tools/OVR Mobile")] static void SwapOVR() { string trimPath = _OVRPath.Substring(6, _OVRPath.Length - 6); string fullPath = Application.dataPath + trimPath; Debug.Log("FP: " + fullPath + " to " + GetManifestPath()); FileUtil.ReplaceFile(fullPath, GetManifestPath()); AssetDatabase.Refresh(); } static string GetManifestPath() { string path = Application.dataPath + _manifestPath; return(path); } }