From 37eac5c2c88429d102912b8e81d8276e91b08f5a Mon Sep 17 00:00:00 2001 From: karl- Date: Mon, 22 May 2017 09:23:33 -0400 Subject: [PATCH] Support back to Unity 4.7 --- Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs | 5 ++++- Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs | 4 ++++ Assets/pb_Stl/Editor/pb_Stl_Menu.cs | 7 +++++++ Assets/pb_Stl/pb_Stl_Exporter.cs | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs b/Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs index e413541..7c1c335 100644 --- a/Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs +++ b/Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs @@ -1,4 +1,6 @@ -using UnityEngine; +#if !UNITY_4_7 + +using UnityEngine; using UnityEditor; using NUnit.Framework; using System.Collections.Generic; @@ -159,3 +161,4 @@ private bool CompareFiles(string left, string right) return true; } } +#endif diff --git a/Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs b/Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs index f16df55..a6cc521 100644 --- a/Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs +++ b/Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs @@ -26,7 +26,11 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del string prefab_path = string.Format("{0}/{1}.prefab", dir, name); +#if UNITY_4_7 + GameObject prefab_source = (GameObject) AssetDatabase.LoadAssetAtPath(prefab_path, typeof(GameObject)); +#else GameObject prefab_source = AssetDatabase.LoadAssetAtPath(prefab_path); +#endif GameObject prefab = new GameObject(); prefab.name = name; if(prefab_source == null) diff --git a/Assets/pb_Stl/Editor/pb_Stl_Menu.cs b/Assets/pb_Stl/Editor/pb_Stl_Menu.cs index e9b7cfd..47b4dab 100644 --- a/Assets/pb_Stl/Editor/pb_Stl_Menu.cs +++ b/Assets/pb_Stl/Editor/pb_Stl_Menu.cs @@ -47,9 +47,16 @@ private static void ExportWithFileDialog(GameObject[] gameObjects, FileType type if(full.Contains(Application.dataPath)) { string relative = full.Replace(Application.dataPath, "Assets"); + +#if UNITY_4_7 + Object o = (Object) AssetDatabase.LoadAssetAtPath(relative, typeof(Object)); +#else Object o = AssetDatabase.LoadAssetAtPath(relative); +#endif + if(o != null) EditorGUIUtility.PingObject(o); + AssetDatabase.Refresh(); } } diff --git a/Assets/pb_Stl/pb_Stl_Exporter.cs b/Assets/pb_Stl/pb_Stl_Exporter.cs index 1d23043..bdd2f9f 100644 --- a/Assets/pb_Stl/pb_Stl_Exporter.cs +++ b/Assets/pb_Stl/pb_Stl_Exporter.cs @@ -24,7 +24,7 @@ public static bool Export(string path, GameObject[] gameObjects, FileType type) } for(int i = 0; meshes != null && i < meshes.Length; i++) - GameObject.DestroyImmediate(meshes[i]); + Object.DestroyImmediate(meshes[i]); return success; } @@ -51,7 +51,7 @@ private static Mesh[] CreateWorldSpaceMeshesWithTransforms(IList tran // copy all transforms to new root gameobject foreach(Transform t in transforms) { - GameObject go = GameObject.Instantiate(t.gameObject); + GameObject go = (GameObject) GameObject.Instantiate(t.gameObject); go.transform.SetParent(t.parent, false); go.transform.SetParent(root.transform, true); }