2D Toolkit > Support

2d Toolkit deprecated on store

<< < (2/3) > >>

Arnold:
I'm really curious if open sourcing it would enable a community based continuation of the plugin.
I'm a super novice programmer and always used 2DTK because it is so easy and abstracts away most
of the bullshit you have to put up with Unity's 3D nature or it's 2D implementation.
This kind of community stuff still needs supervising so again i'm not sure how feasible it would be.

Finnegan:

--- Quote from: unikronsoftware on October 12, 2019, 02:13:36 pm ---2D Toolkit is a project very dear to me.
--- End quote ---

Hi Dinesh, thank you a lot for all the hard work! I worked with 2D toolkit full-time in 2013-2015 and it was a pleasure to use.

Best of luck with your next projects!

habitoti:
Still happily using it with Unity 2019.3 (just a minor fix for Editor required, which was straightforward and easy). No real alternative to the great platform support (20% of my Android user base still needing a 2x resolution).

That being said: for iOS I could well just go with 4x graphics. What would be a good way to not deliver 2x atlases for iOS, but 2x and 4x for Android?

baconbanditgames:

--- Quote from: habitoti on April 06, 2020, 02:50:53 pm ---Still happily using it with Unity 2019.3 (just a minor fix for Editor required, which was straightforward and easy). No real alternative to the great platform support (20% of my Android user base still needing a 2x resolution).

That being said: for iOS I could well just go with 4x graphics. What would be a good way to not deliver 2x atlases for iOS, but 2x and 4x for Android?

--- End quote ---

That's good to hear about 2019.3. You mentioned you needed a minor fix for the editor - could you post that fix here, to help out other people that might need it?

As for 2x, 4x, etc. - I use the following, use at your own risk! Just place the file in an Editor folder in your project.

If your build fails, this will leave any files that it moved in OnPreprocessBuild in /Assets, so you'll need to move them back manually (easy if using source control). If the build completes normally, it will put everything back automatically.

The way it works is that it moves sprite collection files that aren't wanted for a given build, out of Resources folders, so that they are not included in the build, and then it moves them back after the build completes. You can tell it's working as you'll see a reduced build size.

Feel free to use/modify as you see fit.

If anyone has an easier way to handle this, let me know, thanks! Would be great if there was a quick code change we could make somewhere to exclude certain atlas sizes from builds. :)


--- Code: ---using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

class LocalBuildPrePost : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
struct Tk2dResourceToRestore
{
public string fileName;
public string pathAndFileNameToRestoreTo;

public Tk2dResourceToRestore(string fileName, string pathAndFileNameToRestoreTo)
{
this.fileName = fileName;
this.pathAndFileNameToRestoreTo = pathAndFileNameToRestoreTo;
}
}

public int callbackOrder { get { return 0; } }

private List<Tk2dResourceToRestore> mTk2dResourcesToRestore;

public void OnPreprocessBuild(BuildReport report)
{
BuildTarget target = report.summary.platform;
string path = report.summary.outputPath;

Debug.Log("LocalBuildPrePost.OnPreprocessBuild for target " + target + " at path " + path);

mTk2dResourcesToRestore = new List<Tk2dResourceToRestore>();

// iterate through all tk2dResource instances in Resources/TK2D so that we can exclude any that include "@1x", "@2x", or whatever we're wanting to exclude
tk2dResource[] tk2dResources = Resources.LoadAll<tk2dResource>("TK2D");

//Debug.Log("Resources/TK2D contents:");
foreach (var resource in tk2dResources)
{
//Debug.Log("resource.name: {0} -> objectReference.name: {1}", resource.name, resource.objectReference.name);

// any objectReference name that contains "@#x" (according to checks below) will get moved to /Assets temporarily (along with the corresponding .meta file), then will get moved back to Resources/TK2D when the build is done
#if UNITY_ANDROID
// keep @2x only
if (resource.objectReference.name.Contains("@1x") || resource.objectReference.name.Contains("@4x"))
#else
// keep @2x, @4x
if (resource.objectReference.name.Contains("@1x"))
#endif
{
string resourceAssetPath = AssetDatabase.GetAssetPath(resource);
string resourceFileName = Path.GetFileName(resourceAssetPath);

string resourceMetaFileAssetPath = resourceAssetPath + ".meta";
string resourceMetaFileName = resourceFileName + ".meta";

// cache this resource and it's original path so that we can restore it after the build
mTk2dResourcesToRestore.Add(new Tk2dResourceToRestore(resourceFileName, resourceAssetPath));

// cache the corresponding meta file
mTk2dResourcesToRestore.Add(new Tk2dResourceToRestore(resourceMetaFileName, resourceMetaFileAssetPath));

// move the file from Resources/TK2D to /Assets
FileUtil.MoveFileOrDirectory(resourceAssetPath, resourceFileName);

// move the meta file from Resources/TK2D to /Assets
FileUtil.MoveFileOrDirectory(resourceMetaFileAssetPath, resourceMetaFileName);
}
}

Debug.Log("moved {0} assets out of /Resources/TK2D temporarily", mTk2dResourcesToRestore.Count);
    }

public void OnPostprocessBuild(BuildReport report)
{
BuildTarget target = report.summary.platform;
string path = report.summary.outputPath;
BuildResult result = report.summary.result;

Debug.Log("LocalBuildPrePost.OnPostprocessBuild for target " + target + " at path " + path + ", result: " + result);
Debug.Log("moving {0} assets from /Assets back to /Resources/TK2D", mTk2dResourcesToRestore.Count);

// iterate through mTk2dResourcesToRestore and move the files back to their original location
foreach (Tk2dResourceToRestore resource in mTk2dResourcesToRestore)
{
// move the file from /Assets to Resources/TK2D
FileUtil.MoveFileOrDirectory(resource.fileName, resource.pathAndFileNameToRestoreTo);
}
}
}

--- End code ---

habitoti:
Hi,

sorry, seems like the forum isn't sending notifications any longer, so I missed your response.
Your code works in principle, however tk2d goes frenzy with lots of missing reference exceptions during the build once part of it's index files where moved out. No clue how this affects the overall build and haven't found how to make tk2d more resilient (and silent) towards a missing platform index file (w/o on the other hand supressing valid errors). It would be great if we'd get some information on where the loop lives that iterates over platforms to move them over to the build folder.Haven't spotted it so far, but then we could just except the unwanted platforms in that loop.

For the camera fix: the way tk2d determines the editor game window size does no longer work, however there is an official way of determining it now, so you just have to replace Editor__GetGameViewSize function in tk2dcamera.cs by:


--- Code: ---public static bool Editor__GetGameViewSize(out float width, out float height, out float aspect) {
  Vector2 screenSize = Handles.GetMainGameViewSize();
  width = screenSize.x;
  height = screenSize.y;
  aspect = (float)width / (float)height;
  return true;
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version