Hello Guest

Author Topic: Unity closes (not crashes) any time I try to commit to a Sprite Collection  (Read 3947 times)

MBoffin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
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  :'(
« Last Edit: December 29, 2015, 11:40:53 pm by MBoffin »

MBoffin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #1 on: December 30, 2015, 01:57:01 am »
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)

kenglou.lee

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #2 on: December 30, 2015, 06:13:41 am »
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

MBoffin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #3 on: December 30, 2015, 07:54:46 am »
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.

kenglou.lee

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #4 on: December 30, 2015, 08:59:51 am »
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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #5 on: December 31, 2015, 01:35:47 pm »
Ugh, my bad. Find and replace is bad :( I shall fix that now.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unity closes (not crashes) any time I try to commit to a Sprite Collection
« Reply #6 on: December 31, 2015, 01:38:15 pm »
The code should be
Code: [Select]
// 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.