Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gary-unikronsoftware

Pages: 1 [2] 3 4
16
Support / Re: set sprite
« on: September 12, 2013, 10:17:06 am »
Hi,

I wrote this little test script (although it's in c#), which works on one of my sprite collections. 

Code: [Select]
using UnityEngine;
using System.Collections;

public class SpriteLoad : MonoBehaviour {

public tk2dSpriteCollectionData mySpriteData;

void Start ()
{
int spriteID = mySpriteData.GetSpriteIdByName("eye");
GameObject go = new GameObject();
tk2dSprite.AddComponent(go, mySpriteData, spriteID);
}
}

So if you drag your sprite collection data object to mySpriteData and change the GetSpriteIdByName to "ball", does that work for you?

Also, are you using platform collections?

17
Support / Re: How to change sprite animation at run time with c#?
« on: September 10, 2013, 10:04:34 am »
Hi,

I've made a simple c# script that loads in another sprite animation resource and plays a clip when 'x' is pressed.  You should be able to convert it so it does what you want...

Code: [Select]
using UnityEngine;
using System.Collections;

public class ChangeAnimation : MonoBehaviour {

public tk2dSpriteAnimator myAnimator;

void Update ()
{
if(Input.GetKey("x"))
{
tk2dSpriteAnimation newAnimationLibrary = Resources.Load ("shipAnim", typeof(tk2dSpriteAnimation)) as tk2dSpriteAnimation;
myAnimator.Library = newAnimationLibrary;
tk2dSpriteAnimationClip myClip = myAnimator.GetClipByName("shipdestroy");
myAnimator.Play(myClip);
}
}
}

Remember, any resources you want to load in at run time need to go in a folder called 'Resources' in the assets folder.  Also, a sprite animator should exist in the Hierarchy window and be dragged to the 'myAnimator' slot on the script.

Hope this helps.

18
Support / Re: Resize tk2dUIScrollableArea on real time
« on: September 06, 2013, 10:19:28 am »
Hi,

First off I'll start by saying I haven't tried this so don't know how successful it will be...

The problem is the tk2dUIItemBoundsHelper code is part of the Editor and as such can't be called at runtime.  However, the class is a static class so doesn't depend on an instance of it being created, so you could try copying the code into a non-Editor class (changing the name of the class obviously) and tweak the code where necessary need to get the same functionality.

Unikron may be around shortly with a better idea, but you can try that in the meantime :-)


19
Support / Re: Chaning tk2dUIItem event sprite image
« on: September 05, 2013, 09:24:44 am »
Hi,

You can add the component tk2dUIUpDownButton to your tk2dUIItem game object, then specify 2 different sprites for the object and drag them to the 'Up State GameObject' and the 'Down State Game Obect' slots on the component.

20
Support / Re: Crazy error when trying to make new animations
« on: September 05, 2013, 09:08:06 am »
Hi,

Which version of the toolkit are you using and which version of Unity?

Thanks.

21
Support / Re: editable textMesh
« on: September 05, 2013, 09:00:36 am »
Hi,

In the TK2DROOT > tk2dUI_demo > ControlPrefabs folder there is a TextInput prefab that will allow the user to enter text.  If you want to allow the text to run over multiple lines then enable Word Wrap in the InputText Text Mesh component.  Hope this is what you're after.

22
Support / Re: Closing dropdown with script (tk2dUIDropDownMenu)
« on: September 04, 2013, 01:44:27 pm »
Hi Martin,

I'm not sure exactly what you did with 'CollapseList' but I have managed to get it working.  I just created a simple script that will collapse the list when 'x' is pressed:

Code: [Select]
public class DropDownMenuCollapse : MonoBehaviour {

public tk2dUIDropDownMenu ddm;

void Update ()
{
if(Input.GetKey("x"))
{
ddm.CollapseList();
}
}
}

Bear in mind that in tk2dUIDropDownItem, CollapseList is a private function so in order to make it work like in the example you will need to change it to public.

Hope this helps.

23
Support / Re: Problems with atlasing long, narrow images (2.1)
« on: September 04, 2013, 10:06:33 am »
Hi,

I tried this myself by creating 17 images of 1440 x 144 and packing them into a 2048 x 2048 atlas and you can see the results attached.  As you can see for those images it worked.  I'm guessing for your images although they are 1440 x 144, some of them have a lot of transparent areas which will be stripped making the images different sizes and is affecting the algorithm (yes, the algorithm isn't perfect...).  In the SpriteCollection window in settings, try checking the 'Disable Trimming' box to see if that fixes the problem.

24
Support / Re: Positioning with different resolutions
« on: September 03, 2013, 10:40:10 am »
Hi,

The tk2d camera lets you specify Overrides to specify how your game displays in different situations.  E.g. If you develop a game at a resolution of 480 x 320 and set this as the native resolution, you can go into the Overrides section on the camera to specify what it does at double the size, 960 x 640.  So in this example, if you choose Match By Resolution and Auto Scale Fit Visible (or in this situation 'Closest Multiple of Two would also work') then the game objects would be proportionally the same on the screen for both resolutions.

If you are using different sprites for SD and HD then this just will affect the amount of details that is shown and not the actual size of the sprites so won't be a problem.

25
Support / Re: tk2dTextMesh at runtime
« on: September 03, 2013, 09:30:18 am »
It looks like you've missed assigning a font e.g. textMesh.font = ...

You can just create a public tk2dFont object and assign it in the editor.

26
Support / Re: MoleScript Question
« on: September 03, 2013, 09:15:56 am »
The reason I put the yield there (after the 'do') rather than at the end (before the 'while') was because if it had been just before the 'while', the count of the number of active moles would have been done, then a yield to the next frame, then the test while(molesActive >= moleLimit) would have been done, but with the yield just after the 'do', then the count and the test can be done in the same frame and drop out of the loop if there aren't enough active moles.  Strictly speaking it doesn't make a great deal of difference and you probably wouldn't notice it in the game.

If you're asking why the yield is there at all - 1)  The function needs to run once per frame, 2) if the yield wasn't there loop would continue running unnecessarily until the condition was met to drop out of the loop - it only needs to be checked once per frame.

27
Support / Re: Will sunshafts work with 2dtk?
« on: September 02, 2013, 12:14:20 pm »
Hi,

We've just had a play around with this here in the office.  Whilst it worked okay on 3d objects it didn't really work at all on 2d sprites, so I wouldn't recommend shelling out for a pro license just to use sun shafts with 2d toolkit.

28
Support / Re: Zoom factor
« on: September 02, 2013, 11:21:15 am »
Hi,

Yes there is a slight coding error in the camera code which means perspective zooming works the opposite way to orthographic zooming.  This will be fixed in the toolkit shortly, but in the meantime in tk2dCamera.cs if you find the line:
Code: [Select]
float fov = inheritedCameraSettings.fieldOfView * ZoomFactor;

and change it to

Code: [Select]
float fov = Mathf.Min(179.9f, inheritedCameraSettings.fieldOfView / Mathf.Max(0.001f, ZoomFactor));
this should fix it.

29
Support / Re: Time Bar in 2D Toolkit
« on: August 30, 2013, 09:52:42 am »
Hi, 

The good news is I managed to get your code sort of working.  I haven't tried the entire code - just concentrating on the MoveProgressBar function...

1)  progressBar.Value is clamped between 0 and 1 as it represents a percentage.   So your line progressBar.Value < 2f will ALWAYS be true and the function will not continue past that while loop.

2)  Are you actually calling MoveProgressBar from anywhere?  I can't see it being called in the code...  Bear in mind it is a Coroutine and will need to be called with StartCoroutine(MoveProgressBar())

3)  After the initialisation of startTime in the Start function, in the Update you assign to it twice in a row: startTime = startMinutes + startSeconds and startTime = Time.time.  Time.time will overwrite the startMinutes + startSeconds value.  Did you mean to do this?

4)  You are also updating startTime in MoveProgressBar.  As this is a coroutine it will be called every frame whilst it is active, and the Update function is called every frame too.  So startTime will be set in Update, then in MoveProgressBar, then in Update, then in MoveProgressBar and so on.  I don't think this is what you want to happen.

I hope this is sufficient to get you on your way to fixing your code.

30
Releases / Re: 2D Toolkit 2.2 beta 1
« on: August 27, 2013, 04:00:56 pm »
1) I had been using the same camera I set up when going through the 2.1 instructions, which had me set up the UI Manager and I just threw it on the Camera for ease of use. It had worked no problem until the update. Knowing now that it will stay persistent I'll try to figure this out. I'm not sure how though since I need to drag a reference to the main camera in each scene. I'm probably just missing something, I'll toy around with it a bit after work today.

2) It's odd, I can't directly reproduce it with anything that's in the UI Layout Demo scene consistently. For instance if I try using the DistributedButtons that are already set up, it happens only once in every 15 times I load the scene, and only if I set them to Vertical so far. HOWEVER, here are steps that get it to happen every time.

  • Load the UI Layout Demo scene
  • Add empty game object to the scene with GameObject -> Create Empty
  • Component -> 2D Toolkit -> UI -> Core -> Tk2dUILayoutContainerSizer
  • Drag four Buttons from the ControlPrefabs/Layout folder on to the GameObject
  • Select the GameObject and hit the Proportional button
  • In the Items list, select BasicButton 3
  • Click in the Proportion field, hit backspace and type in a '3'
  • Disable the LayoutDemo game object if you want to see it better

Following those steps exactly, each time, give me this result

I have managed to recreate the problem and it would appear that when you hit backspace to change the proportion number, it treats this as a zero and sizes the button accordingly but causes some of button information to be set incorrectly.  Then when you enter a correct proportion value, it tries to calculate the size and position but because some of the information is correct now, it doesn't work properly.  A quick fix for this is to not allow any zero proportion values, so in the file tk2dUILayoutContainerSizer.cs, partway through the function there should be this code:

Code: [Select]
for (int i = 0; i < n; ++i) {
var item = layoutItems[i];
if (!item.fixedSize && item.fillPercentage <= 0) {
childSize[i] = space * item.sizeProportion / proportionSum;
}
}

If you change it to this:

Code: [Select]
for (int i = 0; i < n; ++i) {
var item = layoutItems[i];
if (!item.fixedSize && item.fillPercentage <= 0) {
childSize[i] = space * item.sizeProportion / proportionSum;
}

if(Mathf.Approximately(childSize[i], 0.0f) || childSize[i] < 0.0f) return;
}

That should provide a temp fix until it is fixed in the next release.

Pages: 1 [2] 3 4