Skip to main content

Posts

Showing posts from January, 2013

A Few Pointers On Switching From JavaScript To C#

One does not simply add to an array. In JavaScript you might have familiarity with using arrays. You might also be familiar with "adding" to arrays. Well Unity sugarcoated that for you. Arrays are not really re-sizable. When you declare an array in c#,  you have to define it right there. If your looking for something similar to re-sizable arrays, use lists. To use Lists in Unity c#, you must add the line " using System.Collections.Generic; " At the top of your code. Declaring a list of Game Objects would go something like this List<GameObject> myGameObjectList = new List<GameObject>(); Then adding to the list would is as simple as myGameObjectList.Add(gameObjectInstance); Then if you really just want an array you would say something like GameObject[] gameObjectArray = myGameObjectList.ToArray(); The API is not what it always seems. Unity has also sugar coated some of its API, some parts to the point where its practically ...

Making Multiple Instances of Windows With Same Window Method

So when developing a small little web-player, I ran into the problem of trying to render multiple instances of the same window function. My plan was for my user interface component to iterate through all the thought components and for each thought, render its contents in a new window. The windows need to be draggable also. My first attempt of this implementation failed. Rect thoughtRect = new Rect(20, 20, 200, 100); void OnGUI(){ for (int i = 0; i < allthoughts.Length; i++){ thoughtRect = GUI.Window(0+i, thoughtRect, DoThoughtWindow, ""+allthoughts[i].GetContent()); } } void DoThoughtWindow(int windowID) { GUI.DragWindow (new Rect(0, 0, 10000, 10000)); } For those who don't see the problem with this, I'll explain. All three windows are using the same Rect  thoughtRect  so all the windows are drawn on top of eachother. You might think this won't pose a problem due to the windows be...

Fixing Sketch Up blank window (white box) problem

When downgrading my OS over Christmas, I was faced with many problems, one of which is getting my Google sketch-up working. Almost everything was working perfectly, except one little thing, The 3D Warehouse. It was just displaying a blank screen . At first I thought I had blocked permissions for giving it internet access.  Though my computer said it was allowing it to go over the network. I tried turning off my firewall and still nothing happened. I don't have any anti-virus software so I didn't worry about that. Guess what fixed it this annoying problem? Updating INTERNET EXPLORER. Just check for updates, and updates for what ever you computers default browser is also. Now everything's back in harmony

Choose Binding Time Consciously, Awake and Start functions for Initialization

So I ran into a simple but annoying problem when I was trying to hurry up and finish a game I have been working on for a while so I could move on to start a new idea. I was being stupid an hard coding the last features I wanted to include in the game, and of course came across a problem that I spent 30 minutes on that I could of easily avoided if I was thinking. Here is how the problem began. I needed a way to keep up with all the Light projectors in my scene and figure out which ones are close to me. This sounded easy enough, but alas I managed to screw it up. The code I wrote  used an array that was set on the awake  method using GameObject.FindGameObjectsWithTag("TagName"); In my scene, the player is already in my scene, and the lights are not. When my scene is played, a script called GameInit calls the city generator which in turn calls the multiple factories, one being the factory that generates all the lights in my game. Although it looks like when my scen...