Skip to content

Commit

Permalink
Support back to Unity 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
karl- committed May 22, 2017
1 parent bbc8a47 commit 37eac5c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Assets/pb_Stl/Editor/Test/pb_Stl_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using UnityEngine;
#if !UNITY_4_7

using UnityEngine;
using UnityEditor;
using NUnit.Framework;
using System.Collections.Generic;
Expand Down Expand Up @@ -159,3 +161,4 @@ private bool CompareFiles(string left, string right)
return true;
}
}
#endif
4 changes: 4 additions & 0 deletions Assets/pb_Stl/Editor/pb_Stl_AssetPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameObject>(prefab_path);
#endif
GameObject prefab = new GameObject();
prefab.name = name;
if(prefab_source == null)
Expand Down
7 changes: 7 additions & 0 deletions Assets/pb_Stl/Editor/pb_Stl_Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>(relative);
#endif

if(o != null)
EditorGUIUtility.PingObject(o);

AssetDatabase.Refresh();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/pb_Stl/pb_Stl_Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -51,7 +51,7 @@ private static Mesh[] CreateWorldSpaceMeshesWithTransforms(IList<Transform> 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);
}
Expand Down

0 comments on commit 37eac5c

Please sign in to comment.