private void CreateInputViewerPrefab() { var go = new GameObject(InputViewer.PrefabResourcePath); var viewer = go.AddComponent <InputViewer>(); var script = MonoScript.FromMonoBehaviour(viewer); var scriptPath = AssetDatabase.GetAssetPath(script); var scriptDirPath = Path.GetDirectoryName(scriptPath); var resourcesDirPath = scriptDirPath + "/Resources"; if (!Directory.Exists(resourcesDirPath)) { AssetDatabase.CreateFolder(scriptDirPath, "Resources"); } var prefabPath = resourcesDirPath + "/" + InputViewer.PrefabResourcePath + ".prefab"; if (!File.Exists(prefabPath)) { PrefabUtility.SaveAsPrefabAsset(go, prefabPath); } Object.DestroyImmediate(go); _inputViewer = AssetDatabase.LoadAssetAtPath <InputViewer>(prefabPath); _inputViewerSo = new SerializedObject(_inputViewer); _timeoutToHideInactiveAxesInputProp = _inputViewerSo.FindProperty("_timeoutToHideInactiveAxesInput"); _inputViewerAxesProp = _inputViewerSo.FindProperty("_axes"); }
private void DestroyInputViewerPrefab() { _timeoutToHideInactiveAxesInputProp = null; _inputViewerSo = null; _inputViewer = null; var go = new GameObject(InputViewer.PrefabResourcePath); var viewer = go.AddComponent <InputViewer>(); var script = MonoScript.FromMonoBehaviour(viewer); var scriptPath = AssetDatabase.GetAssetPath(script); var scriptDirPath = Path.GetDirectoryName(scriptPath); var resourcesDirPath = scriptDirPath + "/Resources"; if (Directory.Exists(resourcesDirPath)) { AssetDatabase.DeleteAsset(resourcesDirPath); } Object.DestroyImmediate(go); }