Commit d17e7188 authored by Luke Smith's avatar Luke Smith

Setup of border script. Skeleton made, implimentation needed.

parent 36b87a7e
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Borders : MonoBehaviour
{
public int top = 2, right = 2, bottom = 2, left = 2; // Border sizes by pixel
private enum Direction{none, t, r, rt, b, bt, br, brt, l, lt, lr, lrt, lb, lbt, lbr, lbrt}
// Binary representation:
// lbrt
// 0000
// Use this for initialization
void Start ()
{
SpriteRenderer sr = GetComponent<SpriteRenderer>();
if(sr != null)
{
Texture2D tex = sr.sprite.texture;
Color32[] pixels = tex.GetPixels32();
tex.SetPixels32(setBorders(pixels, tex.width, tex.height, Direction.lbrt));
}
}
Color32[] setBorders(Color32[] pixels, int width, int height, Direction d)
{
if((d & Direction.t) > 0) // top
{
for(int i = left; i < width - right; i++)
{
for(int j = 0; j < top; j++)
{
pixels[(j+top)*width + i] = pixels[j*width + i];
}
}
}
if((d & Direction.r) > 0) // right
{
}
if((d & Direction.b) > 0) // bottom
{
for(int i = left; i < width - right; i++)
{
for(int j = height - bottom; j < height; j++)
{
pixels[j*width + i] = pixels[(j-bottom)*width + i];
}
}
}
if((d & Direction.l) > 0) // left
{
}
return pixels;
}
}
fileFormatVersion: 2
guid: 99517dc8d8fd9524a90fa289b59bf635
timeCreated: 1487785654
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment