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 - gonzalez.martin90

Pages: [1] 2
1
Support / Screenshot from Clipped Camera
« on: April 24, 2015, 02:38:34 pm »
Hi!
 I'm trying to do a screenshot with a clipped camera but i have an error, "Trying to read pixels out of bounds". So i'm giving bad parameters of where to read the pixels.
 example: I have a screen of 1000 pixels and what i want to do is to use 3/4 of camera and the other 1/4 GUI. I think i'm doing ok the clipping but when i want to take the screenshot i have that error.

This is the code:

The clipping:

Code: [Select]
void Awake()
{
if(tk2dCam == null)
{
tk2dCam = this.GetComponent<tk2dCamera>();
}

int posX = (int)(tk2dFullScreenCam.ScreenExtents.width * screenGUIPercentResize);
float resizeX = tk2dFullScreenCam.ScreenExtents.width * screenCamPercentResize;
float resizeY = tk2dFullScreenCam.ScreenExtents.height;

tk2dCam.viewportRegion = new Vector4(posX,0,resizeX,resizeY);
}

The Screenshot:

Code: [Select]
public Texture2D TakeScreenShot (Camera camera)
{
#if UNITY_ANDROID || UNITY_IPHONE
Texture2D snapShot = new Texture2D((int)camera.pixelWidth, (int)camera.pixelHeight, TextureFormat.ARGB32, false );
RenderTexture snapShotRT = new RenderTexture(Screen.width, Screen.height , 24, RenderTextureFormat.ARGB32);
RenderTexture.active = snapShotRT;
camera.targetTexture = snapShotRT;
camera.Render();
tk2dCamera cam = camera.GetComponent<tk2dCamera>();
snapShot.ReadPixels( new Rect(cam.ScreenExtents.x, cam.ScreenExtents.y, cam.ScreenExtents.width, cam.ScreenExtents.height), 0, 0, false );
RenderTexture.active = null;
camera.targetTexture = null;
snapShotRT.Release();
snapShotRT = null;
return snapShot;
#endif
return null;
}

i'm missing something?

2
Support / Re: Creating a FullScreen texture problem
« on: April 06, 2015, 04:20:47 pm »
Same thing applies to Unity textures as well.

Worked!

Thanks

3
Support / Re: Creating a FullScreen texture problem
« on: April 06, 2015, 03:58:19 pm »
Either
1. Resize your sprite to fit the ScreenExtents. This won't be pixel perfect, or even have square pixels for obvious reasons.
or
2. Create a second tk2dCamera that holds the background (use layer masks to make it only draw in there) with override set to StretchToFit. This will stretch the background to fit the screen, but won't be pixel perfect or have square pixels for obvious reasons.
or
3. Make your background sprite bigger to fit all the aspect ratios you care about, so when it draws more it has something to draw.

Thanks for the answer but the texture that im creating is a Unity Texture2D
 This is the problem.
I have a coloring app that the image is in black and white (black the borders)
So i want to take a screenshot with RenderTexture that its working fine and create a texture with the screenshot i took and put to it the screen size. But if i put screen.width and height depending the resolution is smaller.

Here i took a picture.

4
Support / Creating a FullScreen texture problem
« on: April 06, 2015, 02:06:47 pm »
Hi!
 i'm using a tk2d camera with the native resolution 960x640 and when i want to create a texture (Unity texture) of the Screen.width and Screen.height it doesnt fit unless the resolution is 960x640.
 Also it depends on the aspect ratio.

 is there a solution to create a full screen texture?

Thanks!

5
Support / Create Atlas in Runtime?
« on: April 01, 2015, 12:20:35 am »
Can i create an atlas in runtime?
 Im taking a screenshot and i would like to create 2 or 3 atlas to have textures with lower size.

Thanks!

6
Support / Re: Zoom with Pixel Per Meter
« on: March 02, 2015, 12:38:58 pm »
is that code Ok? The value Pixel Per Meter in Tk2dCamera is not changing.

7
Support / Re: Zoom with Pixel Per Meter
« on: February 27, 2015, 01:22:42 pm »
If the camera frustum is scaling surely you'd see less or more of something that is inside it? Why isn't that happening for you?

I'm modifying the OrthoPixelPerMeter value but in the inspector the camera still have 1 (my default value) but the screen is doing somthing strange. If i manipulate the value from the inspector it does what i want.

My code here

Code: [Select]
void Start()
{
EasyTouch.On_PinchIn += HandleOn_PinchIn;
EasyTouch.On_PinchOut += HandleOn_PinchOut;

camera = Camera.main.GetComponent<tk2dCamera>();
}

void HandleOn_PinchOut (Gesture gesture)
{
Debug.Log(gesture.deltaPinch);

camera.CameraSettings.orthographicPixelsPerMeter -= gesture.deltaPinch * Time.deltaTime * 5;

}

void HandleOn_PinchIn (Gesture gesture)
{
Debug.Log(gesture.deltaPinch);

camera.CameraSettings.orthographicPixelsPerMeter += gesture.deltaPinch * Time.deltaTime * 5;
}

8
Support / Zoom with Pixel Per Meter
« on: February 26, 2015, 06:15:13 pm »
Hi!
 I'm trying to make zoom in and out but i want to use the pixel per meter. The thing is that i have items achored. Is there a way to override or do something to do zooming and avoid anchors to reposition?
 Actually i'm modifying the Zoom Factor but it make no zoom. Seems to scale the camera frustrum but the images still the same size.

Any idea?

9
Support / Text 2x & 4x
« on: February 24, 2015, 04:42:58 pm »
Hi!
 Is there a way to set 2x and 4x text like Sprite collections?

Thanks!

10
Support / Re: Render Testure of Tk2d Camera Clipped
« on: January 16, 2015, 05:11:27 pm »
it seems to be offset because if i modify this

Code: [Select]
snapShot.ReadPixels( new Rect( camera.pixelRect.xMin, camera.pixelRect.xMin-40, (int)camera.pixelWidth, (int)camera.pixelHeight), 0, 0, false );
that 40 modify the Y offset but depends on the resolution. I cant know which calculation i have to do to have the exactly point and size

11
Support / Re: Render Testure of Tk2d Camera Clipped
« on: January 16, 2015, 04:54:33 pm »
Thanks for answering.
 Yes i understood it, but what i want is to take a screenshot of that clipped camera and have a "full screen" screenshot.
I did a new method that works like this:

Code: [Select]
public Texture2D TakeScreenShot(Camera camera, Bounds bound)
{
#if UNITY_ANDROID
Texture2D snapShot = new Texture2D((int)camera.pixelWidth , (int)camera.pixelHeight, TextureFormat.RGB24, false );
snapShot.ReadPixels( new Rect( camera.pixelRect.xMin, camera.pixelRect.xMin, (int)camera.pixelWidth, (int)camera.pixelHeight), 0, 0, false );
snapShot.Apply();
return snapShot;
#endif
return new Texture2D(100,100);
}

The code seems to be ok, but the height of the screenshot is more than expected


12
Support / Render Testure of Tk2d Camera Clipped
« on: January 16, 2015, 04:27:29 pm »
Hey! I'm trying to make a screenshot of a certain camera (tk2d Cam clipped) and something strage is giving me as texture.
Seems that what the camera sees its ok but its doing like something strange around.
Any idea? I'm using RenderTexture

Thanks!

13
Support / Re: Unable to find any tk2dUICameras ScrollArea
« on: January 16, 2015, 02:21:38 pm »
I done it.

 For other user who wants to change just have a variable of the scroll and equal the ContentLength to MeasureContentLength();

14
Support / Re: Unable to find any tk2dUICameras ScrollArea
« on: January 16, 2015, 02:19:03 pm »
No i did not but i drag one into my camera. No works but i have another issue.
 Can i change de Content Lenght in runtime?

15
Support / Unable to find any tk2dUICameras ScrollArea
« on: January 16, 2015, 01:52:59 pm »
Hi, i dropped teh ScrolleableVertical prefab into the scene and tried to test it with one of my screens but this error is coming up and i cannot scroll.

Unable to find any tk2dUICameras, and no cameras are connected to the tk2dUIManager. You will not be able to interact with the UI.

I dont know why is not finding the camera.

Thanks!

Pages: [1] 2