Hello Guest

Recent Posts

Pages: [1] 2 3 ... 10
1
Support / Is there a way to change the speed of an animation in code?
« Last post by negative_zero on December 11, 2020, 02:45:27 am »
I've been trying this, but it doesn't change anything?

gameObject.GetComponent<tk2dSpriteAnimator> ().ClipFps = 12.0f;

No matter what I do, whenever I read the variable it just returns -1.
2
Support / Re: Thank You for making this asset
« Last post by unikronsoftware on August 09, 2020, 09:12:41 am »
You're welcome :)

2D Toolkit had a good long run, and I'm happy to have played some (tiny!) part helping you launch your dev career.
3
Support / Thank You for making this asset
« Last post by kris8360 on July 27, 2020, 03:11:31 pm »
Dear Unikron Software!

I'm sorry to hear, this asset is now deprecated from the Unity store, I bought it in 2013, and made my very first 2D game with it, that helped me launch my developer career.
It had truly revolutionary features, that Unity didn't even have at the time, and with the new Unity UI, 2D toolkit still has some better implementations.

Thank you for making, and supporting this amazing asset through the years!
4
Support / UnityEditor.PrefabUtility GetCorrespondingObjectFromSource issue
« Last post by coshea on June 26, 2020, 08:54:23 am »
Hi

I updated TK2d to 2.5.8.9 on Unity 2017.4.40 project and now get this error:

Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapBuilderUtil.cs(120,38): error CS0117: `UnityEditor.PrefabUtility' does not contain a definition for `GetCorrespondingObjectFromSource'

I'm actually not using tilemaps at all, I tried deleting the tk2dtilemap folder but then I get a whole bunch of errors for tk2dEditorUtility.cs

Do you know how to fix the above issue?

Thanks
Chris

5
Support / Re: 2d Toolkit deprecated on store
« Last post by habitoti on April 28, 2020, 04:54:41 pm »
Do you mind sharing where you had to include null checks? I'm not using Unity 2019 yet, but probably will upgrade to it in the next few months. Thanks!

Sure thing:

Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteCollectionData.cs:
Code: [Select]
Line 381 (replace):  public int Count { get { return inst == null ? 0 : inst.spriteDefinitions.Length; } }
Line 578 (replace):  platformSpecificData?.Init(); // awake is never called, so we initialize explicitly

Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSprite.cs
Code: [Select]
Line 69 (insert):  if (collectionInst == null) return;

Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSlicedSprite.cs
Code: [Select]
Line 262 (insert):  if (CurrentSprite == null) return;

Assets/TK2DROOT/tk2d/Code/Sprites/tk2dBaseSprite.cs
Code: [Select]
Line 954 (replace):  if ( Collection != null && Collection.inst != null && GetComponent<Renderer>() != null&& GetComponent<Renderer>().sharedMaterial == null && Collection.inst.needMaterialInstance) {

I am just using Sprites and Sliced Sprites. You might need more if you touch other artefacts also.
6
Support / Re: 2d Toolkit deprecated on store
« Last post by baconbanditgames on April 27, 2020, 09:16:00 pm »
Your explanation makes totally sense, but maybe 2019.3 fires different events or other triggers that makes tk2d get control during the build. It runs into null pointers in like 5-6 different places for every missing index file during the build (which doesn‘t affect the result, though, but is very annoying), however I now just included null pointer checks in those places and now it runs w/o any more complaints ;-)

Ah, yeah that makes sense that Unity 2019 could be doing something different.

Do you mind sharing where you had to include null checks? I'm not using Unity 2019 yet, but probably will upgrade to it in the next few months. Thanks!
7
Support / Re: 2d Toolkit deprecated on store
« Last post by habitoti on April 27, 2020, 08:38:05 pm »
Your explanation makes totally sense, but maybe 2019.3 fires different events or other triggers that makes tk2d get control during the build. It runs into null pointers in like 5-6 different places for every missing index file during the build (which doesn‘t affect the result, though, but is very annoying), however I now just included null pointer checks in those places and now it runs w/o any more complaints ;-)
8
Support / Re: 2d Toolkit deprecated on store
« Last post by baconbanditgames on April 25, 2020, 10:37:35 pm »
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).
That's really strange. I'm using this exact code in two different games, and have done hundreds of builds for them on iOS and Android without any issues. No tk2d code should be running after those files have been moved - they're moved out, build occurs, and they're moved back.

I'm doing this in a Unity 2017.4 project, as well as Unity 2018.4. Both are using the newest version of tk2d.

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.
There is no code that moves the platform files over to the build folder - they're included in builds because they're in a Resources folder.

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: [Select]
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;
}
Awesome, thanks for the fix, it works great! :)
9
Support / Re: 2d Toolkit deprecated on store
« Last post by habitoti on April 25, 2020, 08:58:11 am »
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: [Select]
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;
}
10
Support / Re: 2d Toolkit deprecated on store
« Last post by baconbanditgames on April 06, 2020, 04:38:08 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?

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: [Select]
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);
}
}
}
Pages: [1] 2 3 ... 10