Skip to content

Commit

Permalink
Replaced deprecated code in the DemoTextPixels class. Removed unused …
Browse files Browse the repository at this point in the history
…code in the DemoBoxes class. Updated project settings.
  • Loading branch information
zachkinstner committed Sep 30, 2015
1 parent afd0478 commit d817753
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Core/Solution/Hover.Common/Hover.Common.csproj
Expand Up @@ -42,7 +42,7 @@
<Reference Include="UnityEngine">
<HintPath>..\..\Packages\Unity\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="UnityEngine.UI">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Packages\Unity\GUISystem\UnityEngine.UI.dll</HintPath>
</Reference>
Expand Down
2 changes: 0 additions & 2 deletions Unity/Assets/Hover/Demo/BoardKeys/DemoBoxes.cs
Expand Up @@ -40,8 +40,6 @@ public class BoxData : MonoBehaviour {
////////////////////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------------------------*/
public void Awake() {
var rand = new System.Random();

for ( int xi = 0 ; xi < Width ; ++xi ) {
for ( int yi = 0 ; yi < Height ; ++yi ) {
var mainTex = new Texture2D(1, 1);
Expand Down
59 changes: 22 additions & 37 deletions Unity/Assets/Hover/Demo/BoardKeys/DemoTextPixels.cs
Expand Up @@ -27,58 +27,43 @@ public class DemoTextPixels {
/*--------------------------------------------------------------------------------------------*/
public float[,] GetPixels(char pLetter, out int pWidth, out int pHeight) {
Texture2D tex = vUiLabel.Texture;
//string data = "";
CharacterInfo charInfo;

if ( !vUiLabel.FontObject.GetCharacterInfo(pLetter, out charInfo) ) {
throw new Exception("Character pixels not found: "+pLetter);
}

int x = (int)Math.Round(charInfo.uv.x*tex.width);
int y = (int)Math.Round(charInfo.uv.y*tex.height);
int w = (int)Math.Round(charInfo.uv.width*tex.width);
int h = (int)Math.Round(charInfo.uv.height*tex.height);
int x0 = (int)Math.Round(charInfo.uvTopLeft.x*tex.width);
int y0 = (int)Math.Round(charInfo.uvTopLeft.y*tex.height);
int x1 = (int)Math.Round(charInfo.uvBottomRight.x*tex.width);
int y1 = (int)Math.Round(charInfo.uvBottomRight.y*tex.height);
int texW = x1-x0;
int texH = y1-y0;
bool xPos = (texW > 0);
bool yPos = (texH > 0);

if ( w < 0 ) {
w *= -1;
x -= w;
}

if ( h < 0 ) {
h *= -1;
y -= h;
}
texW = Math.Abs(texW);
texH = Math.Abs(texH);
bool swap = (texW == charInfo.glyphHeight && texH == charInfo.glyphWidth);

var pixels = new float[w, h];
pWidth = (swap ? texH : texW);
pHeight = (swap ? texW : texH);

for ( int hi = y ; hi < y+h ; ++hi ) {
for ( int wi = x ; wi < x+w ; ++wi ) {
float a = tex.GetPixel(wi, hi).a;
pixels[wi-x, hi-y] = a;
//data += (a < 0.25f ? " " : (a < 0.5f ? "." : (a < 0.75f ? "*" : "#")));
}
Debug.Log("WH: "+x0+"/"+x1+" ... "+y0+"/"+y1+" ... "+xPos+"/"+yPos+" ... "+
pWidth+"/"+pHeight+" ... "+charInfo.glyphWidth+"/"+charInfo.glyphHeight+" ... "+swap);

//data += "\n";
}
var pixels = new float[pWidth, pHeight];

if ( charInfo.flipped ) {
float[,] oldPixels = pixels;

pixels = new float[h, w];
for ( int yi = 0 ; yi < texH ; yi++ ) {
for ( int xi = 0 ; xi < texW ; xi++ ) {
int xt = (xPos ? x0+xi : x0-xi);
int yt = (yPos ? y0+yi : y0-yi);
float a = tex.GetPixel(xt, yt).a;

for ( int hi = 0 ; hi < h ; ++hi ) {
for ( int wi = 0 ; wi < w ; ++wi ) {
pixels[hi, w-wi-1] = oldPixels[wi, hi];
}
pixels[(swap ? yi : xi), (swap ? xi : yi)] = a;
}

int old = h;
h = w;
w = old;
}

pWidth = w;
pHeight = h;
return pixels;
}

Expand Down
3 changes: 3 additions & 0 deletions Unity/ProjectSettings/EditorSettings.asset
Expand Up @@ -10,3 +10,6 @@ EditorSettings:
m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d
m_DefaultBehaviorMode: 0
m_SpritePackerMode: 2
m_SpritePackerPaddingPower: 1
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
m_ProjectGenerationRootNamespace:
2 changes: 2 additions & 0 deletions Unity/ProjectSettings/ProjectSettings.asset
Expand Up @@ -261,6 +261,8 @@ PlayerSettings:
ps4pnGameCustomData: 1
playerPrefsSupport: 0
ps4ReprojectionSupport: 0
ps4UseAudio3dBackend: 0
ps4Audio3dVirtualSpeakerCount: 14
ps4attribUserManagement: 0
ps4attribMoveSupport: 0
ps4attrib3DSupport: 0
Expand Down
2 changes: 1 addition & 1 deletion Unity/ProjectSettings/ProjectVersion.txt
@@ -1,2 +1,2 @@
m_EditorVersion: 5.2.1f1
m_EditorVersion: 5.2.1p1
m_StandardAssetsVersion: 0
Binary file modified Unity/ProjectSettings/UnityAdsSettings.asset
Binary file not shown.
Binary file modified Unity/ProjectSettings/UnityAnalyticsManager.asset
Binary file not shown.

0 comments on commit d817753

Please sign in to comment.