2D Toolkit Forum
2D Toolkit => Support => Topic started by: MBoffin on December 29, 2015, 11:21:32 pm
-
Not sure what is up here, but it's infuriating. I'm using 2D Toolkit 2.5.5 with Unity 5.3.1f1. Here are the steps to reproduce:
- Start a new 2D (or 3D) project
- Open Asset Store and import 2D Toolkit
- Create a tk2dcamera in the Hierarchy tab
- In the Project tab, click Create -> tk2d -> Sprite Collection
- Give it a name (say, Tiles.prefab)
- Select the Sprite Collection in the Project Tab
- Click Open Editor in the Inspector
- Change anything in the Settings of the Sprite Collection, say Physics 3D to Physics 2D or the PPM
- Click Commit
- Watch Unity close immediately with no errors
- Cry :'(
-
Things I have tried to do to solve this:
- Re-install 2D Toolkit (both from Asset Store and from the package available on this site)
- Re-install Unity
- Tried running Unity in Administrator Mode
- Tried just adding sprites to the collection (instead of changing settings)
-
I think I found the reason why it crashes, in tk2dUtil.cs, I found that the "SetDirty" functions keep pointing back to itself due to the "UNITY_EDITOR" pragma, I change it to as below and it seems solve my problem. Hope that helps you. I had report this to moderator and hopefully to get a fix ASAP.
// Replicate old pre-5.3 behaviour
public static void SetDirty(UnityEngine.Object @object)
{
#if UNITY_EDITOR
//tk2dUtil.SetDirty(@object); //take away this as it keep pointing back to itself
#if (UNITY_5_3 || UNITY_5_4 || UNITY_5_6 || UNITY_5_7 || UNITY_5_8 || UNITY_5_9 || UNITY_6_0)
if (!string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(@object)))
{
string scenePath = UnityEditor.AssetDatabase.GetAssetOrScenePath(@object);
var scene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneByPath(scenePath);
if (scene.IsValid())
{
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(scene);
}
}
#else
EditorUtility.SetDirty(@object); //added this so it still functioning for previous version.
#endif
#endif // UNITY_EDITOR
-
Thank you! That definitely solved it. Just out of curiosity, though, what did you do to find that as the culprit? I'd like to be able to debug this kind of thing on my own in the future, even if I don't solve it. Just finding where it's failing would be a big help.
-
I did a comparison with previous version that works, and dig into scripts in Editor with naming like Sprite Collection or Atlas and from there link to this file. Glad that this helps you.
-
Ugh, my bad. Find and replace is bad :( I shall fix that now.
-
The code should be
// Replicate old pre-5.3 behaviour
public static void SetDirty(UnityEngine.Object @object)
{
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(@object);
#if (UNITY_5_3 || UNITY_5_4 || UNITY_5_6 || UNITY_5_7 || UNITY_5_8 || UNITY_5_9 || UNITY_6_0)
if (!string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(@object)))
{
string scenePath = UnityEditor.AssetDatabase.GetAssetOrScenePath(@object);
var scene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneByPath(scenePath);
if (scene.IsValid())
{
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(scene);
}
}
#endif
#endif // UNITY_EDITOR
}
It shouldn't be in the else.