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 - Ezro

Pages: [1] 2
1
Support / Re: Issue with SetSprite
« on: February 05, 2015, 02:20:04 am »
Hey everyone,

Figure I'd update this, in case anyone comes across this issue as well.

In my code, I was rebuilding the player gameobject, as sent from my server. The rebuilt GO had a tk2dSprite component on it already, with a valid texture.

Instead of using the code to switch to modelID+1 then back to modelID, I'm now adding a new tk2dSprite component to it.
(As such, I've removed the tk2dSprite component from the server template, and am also adding the component on the server)


2
Support / Re: Issue with SetSprite
« on: January 20, 2015, 05:53:44 pm »
Sorry for the delay.

I'm using 2.4.0 currently.

Here's my code:

ClientController
Code: [Select]
void BuildCharacterGO()
    {
        string serializedCharacter = "";
        foreach(string segment in serializedCharacterParts)
        {
            serializedCharacter += segment;
        }
        byteArr = System.Convert.FromBase64String(serializedCharacter);
        byteArr.LoadObjectTree();
       
        selectedCharacter = GameObject.FindGameObjectWithTag("Player");
        selectedCharacter.GetComponent<MovementController>().Initialize();
        selectedCharacter.GetComponent<EquipmentController>().Initialize();
        selectedCharacter.GetComponent<ModelController>().Initialize();       
    }

ModelController
Code: [Select]
public void Initialize()
    {
        spriteManager = GameObject.FindGameObjectWithTag("Sprite Manager").GetComponent<SpriteManager>();
        LoadModel();
    }

public void LoadModel()
    {
        //HACK - Fix this
        //For some reason, the SetSprite won't properly display unless it's set to a different sprite, then set back
        this.GetComponent<tk2dSprite>().SetSprite(spriteManager.GetCharacterModels(), modelID+1);
        this.GetComponent<tk2dSprite>().SetSprite(spriteManager.GetCharacterModels(), modelID);
        this.GetComponent<tk2dSprite>().scale = new Vector3(1, 1, 1);
        Debug.Log("Sprite scale set");
    }

SpriteManager()
Code: [Select]
public tk2dSpriteCollectionData characterModels;

    public tk2dSpriteCollectionData GetCharacterModels()
    {
        return characterModels;
    }

3
Support / Issue with SetSprite
« on: January 13, 2015, 06:51:16 pm »
Hi everyone,

I'm having a bit of difficulty using SetSprite.

Here is my current code:
Code: [Select]
this.GetComponent<tk2dSprite>().SetSprite(spriteManager.GetCharacterModels(), modelID);
My game successfully runs that command, and I'm able to see the sprite loaded in the Unity inspector, but it doesn't actually appear in my game.

In order to get around this, I've been switching sprites to refresh it:
Code: [Select]
this.GetComponent<tk2dSprite>().SetSprite(spriteManager.GetCharacterModels(), modelID+1);
this.GetComponent<tk2dSprite>().SetSprite(spriteManager.GetCharacterModels(), modelID);


Does anyone know how I can resolve this cleanly?

Thanks.

4
Support / 2D Multiple Resolution Support
« on: June 19, 2014, 03:47:03 pm »
Hi everyone,

I'm working on a game, and am a bit stuck.

I am currently still coding functionality, but the majority of my functionality is built using a temporary GUI, with improper dimensions/scaling. Before I continue with adding the front-end aspects, I would like to iron out my approach on multiple resolution handling.

Background
The game will be a top-down 2D RPG. It is currently being developed for PC, but I would like to be able to port it to mobile devices, and consoles as well. This means that the game would need to have support from very low resolutions, all the way up to HD resolutions.

Character models should be very detailed, as cosmetic items will be a large part of the game; I would ultimately want the game to look crisp on all resolutions, even if it's a lower resolution.

Outstanding Questions
From what I've read, the textures would need to be designed at a base resolution of 960x640 (2x), with a low resolution of 480x320 (1x). If I were to do that, though, I would also need a set at 1920x1080 (4x), for PC support.

  • How well would non-vector art scale at non-native resolutions? (Texture clarity at resolutions which aren't 1x, 2x, 4x)
  • How to prevent stretching/skewing when scaling, to prevent relative distances between objects from changing?
  • How well vector art would work for this?
  • How well pre-rendered 3D models would work for this?

Regards,
Ezro

5
Support / Re: Difficulty with TK2D UIText Input
« on: March 28, 2014, 12:30:04 am »
You can fix the corrupted text by doing this:
http://2dtoolkit.com/forum/index.php/topic,3530.0.html
Its a nasty Unity bug.

Your main camera needs to be set to orthographic with orthographic size set to 1, thats the native size for the widgets. If you're still stuck, zip up your project and email to support at unikronsoftware.com

Ah. That fixed the text issue.

I'm still running into the original issue with the UIText Input, though.

I'll still zip up my project, though, and send it your way.

I think, going forward, all of my UI should be on a scale of 1, using the orthographic size set 1; I'm just not sure what I would have to change in my project in order to accommodate that, though.

6
Support / Re: Difficulty with TK2D UIText Input
« on: March 27, 2014, 11:12:15 pm »
OK. What were your camera settings? tk2d UI is built to work out of the box with ortho size of 1 - you can use a tk2dCamera or a normal orthographic camera, and everything should be the right size then.

Unikron,

I broke everything.  :-X

I realized that I was using an older version of 2D Toolkit (2.1), and upgraded to 2.4.

After upgrading, my UI and buttons stayed the same, but none of my text is readable.

My current setup works as follows:

Tk 2d UIManager holds the UI Camera (Main Camera)
Main Camera is set to Orthographic projection with type 1 pixels per meter.

Not sure how to proceed...

7
Support / Re: Difficulty with TK2D UIText Input
« on: March 27, 2014, 05:34:54 pm »
I can't commit to any release date. Things have never gone to plan when I've done that in the past.

Before I go through the font size / sprite collection thing - why do you need to scale it in the first place?

I don't have the project in front of me, but the issue was that when I copied the game object over from the demo, it was a tiny dot on my game's menu screen.

8
Support / Re: Difficulty with TK2D UIText Input
« on: March 27, 2014, 02:04:51 pm »
Hmm. it looks like it isn't coping properly with the scale. I thought I'd fixed this in a previous version, but it looks like it isn't.

You can get it to behave properly if you don't scale the individual things but rather use the font at the correct size, etc. Or use a second camera for UI so you don't have to scale it. I'm looking into improving the text input control for the next version anyway to make it simpler to use and set up, I'll get this fixed at the same time.

Ah, I see.

Do you know ~when the next version is to be released?

Also, could you please elaborate on the font size correction workaround?

Regards,
Ezro

9
Support / Difficulty with TK2D UIText Input
« on: March 27, 2014, 01:36:14 am »
Hey everyone,

I’m having a bit of difficulty using the tk2d UIText Input script.
 
I copied the whole ‘TextInput’ game object from the ‘1 - UI demo’. For my project, however, I have scaled TextInput by (400,400,0).
 
After scaling, I am able to see that the ‘EmptyDisplayText’ is displaying correctly. However, whenever I try to set the text to anything explicitly, it’s not visible on my screen.
 
Also, when I click on the ‘InputText’ GO, I don’t see anything listed under ‘Text’. I know that It is storing it, though, since I have to backspace and remove the contents before the ‘EmptyDisplayText’ appears again.
 
Oddly enough, if I were to manually set InputText’s ‘Text’ field, via the Inspector, I am able to see it populate as I would expect.
 
I tried digging through the code, and debugging to see what’s going on when I input text.
From my investigation, it looks like the following line in ‘FormatTextForDisplay’ is always true:
while (inputLabel.renderer.bounds.extents.x * 2 > fieldLength)
 
At this point, I’m not sure what to do. I feel that this is a very minor issue, but am not able to resolve it without spending a lot more time fiddling with it.
 
Does anyone know how to resolve this issue?

Regards,
Ezro

10
Support / Re: Static + Dynamic Display for Menu Options
« on: July 10, 2013, 03:35:28 pm »
Thanks, Unikron.

I'll check that out.

Regards,
Ezro

11
Support / Static + Dynamic Display for Menu Options
« on: July 10, 2013, 03:22:04 pm »
Hi all,

I'm working on my menu system, and I ran into a small bump. I'm looking to accomplish the following:

The left half of the screen will always be the same.
Depending on what you select on the right side, different menu options will be loaded on the right side.

I'm thinking that I can have tracking for whichever screen is currently active, and then switch between other screens by disabling & hide the functionality of menu options which aren't currently active.

Does 2D Toolkit come with this sort of functionality built-in, or would I have to code my own functions to handle this?

Regards,
Ezro

12
Support / Re: Question about static sprite batcher collider
« on: July 02, 2013, 05:56:50 pm »
Unikron,

After using the method you outlined, I was successfully able to get the sprite batcher to work as expected.

Thanks again for the help.

Regards,
Ezro

13
Yup that should work. Thats how its set up with the demo sprites.

Thanks a lot for the help, Unikron.

I also have some follow-up questions about collision.

For collision detection, I see that it's mostly done with rigidbody + colliders.

I was thinking of avoiding rigidbodies, and going with raycasting + colliders for walls, and box intersection for enemies, in an attempt to increase the performance. (All movement being done by transform changes, instead of addForce)

Do you think that this would be advantageous, or would it be better to just stick with rigidbodies?

Regards,
Justin

14
Support / Re: Question about static sprite batcher collider
« on: July 01, 2013, 03:30:28 pm »
How are you creating the box collider? Do you have it set up on the sprite itself in the sprite collection? The static sprite batcher only supports that right now - if you add colliders yourself, its not likely to work properly.

Oh, I see.

I was just creating individual 2dtk sprite objects. I'm not familiar with the sprite collection, yet.  :-X
Are these steps correct?

- Create my source sprites
- Create a sprite collection, and add the source sprites (with colliders)
- Parent the individual sprites to a SSB

Regards,
Ezro

15
Support / Re: Question about static sprite batcher collider
« on: July 01, 2013, 03:02:57 pm »
Sorry, I think I may have misread your question.
Are you creating sprites with custom box colliders on them? What exactly goes wrong?

I created a 2dtk SSB object, and then created a separate 2dtk sprite, in the hierarchy.

For the sprite, I set a box collider (and also tried using a mesh collider), duplicated it 4-5 times and repositioned the clones.

Once everything was set up, I parented them to the SSB object.

My SSB object was set to generate a collider, but when I committed it, no collider was created for it.

Additionally, when I edited it again, the sprites sometimes lost their colliders.


All I'm trying to do is batch together a lot of sprites to use for platforms/walls, that way I can just perform collision detection against that single batch collider, instead of against lots of individual colliders (or any other collision detection means).

Regards,
Justin

Pages: [1] 2