Unity, also referred to as Unity3D, is a cross-platform game engine with a built-in IDE developed by Unity Technologies. It is a commercial development platform for creating games, interactive 3D applications, training simulations, and medical and architectural visualizations.

learn more… | top users | synonyms

1
vote
1answer
40 views

Creating custom control in Unity3D that has same UI but different behavior

I made some custom control named Range Control in Unity. It has two buttons a "plus" and a "minus" and an input field that shows the current value. The control has (for now) two implementations: None-...
3
votes
2answers
113 views

Wait for multiple functions to run

In my loading scene I want to run multiple functions (IO from the disk) and start the app after they are completed. This is in my loading class. (Note: This is unity 3d and the public variables to ...
5
votes
1answer
76 views

Pulsing Alpha Channel

The following script makes an image pulse in Unity by fluctuating its alpha channel. However, I feel like there is a lot of duplicate code in the update method. How can I clean up that code to have ...
7
votes
0answers
117 views

Multiple similar manager classes for handling scroll lists

I am working on my first object-oriented programming project, written in C# for Unity. My code does what I want it to do, but I am wondering if there is a better way to do it. I think I am building ...
4
votes
1answer
127 views

Snake game in Unity

I've made a simple snake game in Unity and it has 3 different types of foods. Note - 5 blocks = 1 point This is a screenshot from the game here I'm colliding with myself and the game is restarted ...
5
votes
1answer
88 views

Simon says in Unity

I've made the Simon says game in Unity You start by guessing a pattern of 3 colors and each time you complete the pattern a new, random one, is generated and the length of the pattern is incremented ...
3
votes
1answer
68 views

Object Pooling in Unity

I've made 2 object pooling classes - MonoObjectPooler : MonoBehaviour - can hold a single bucket of pooled objects of 1 type. ...
7
votes
1answer
159 views

Sliding puzzle game of fifteen

I've made the Game of Fifteen in Unity this is how it looks : The code is rather short there's one class for the pieces and one for the game logic : MovablePiece : MonoBehaviour ...
0
votes
1answer
38 views

Disabling child scaling, when parent scales with Math

I think this code is only simple math, but I'm posting it, because almost everyone fakes the scaling with unparenting, then parenting again. ...
2
votes
0answers
37 views

Z sorting implementation for a 2D isometric game

This is a naive implementation of a Z-sorting in order to fake 3D depth using sprites in a 2D scene. I would appreciate feedback on this, especially for performance as this has to be called each frame ...
2
votes
0answers
48 views

Splines on Unity3D

I've written this small code chunk to implement a very basic spline system for object motions. As I've only used C# on Unity3D so far I would appreciate feedbacks on this, especially on access levels, ...
5
votes
2answers
356 views

Visual boardgame

The visual board game is currently a game in unity, where I've created a map and a grid. The visualization is like this: Making this code obviously needed nested for loops and the like, but ...
2
votes
2answers
162 views

High performance, branchless Intersection testing: sphere-aabb & aabb-aabb

From my tests: AABB-Sphere: 2954.8 tests per ms. AABB-AABB: 1087.0 tests per ms. The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number ...
3
votes
0answers
43 views

Reading log file of subprocess

I run subprocesses with lot of output (compilation of Unity 3D projects). I use log parsers to find known issues. ...
3
votes
0answers
230 views

Blocking TCP Client with Threads vs. Non-Blocking TCP Client with Unitys Update

I'm not sure if this is the right subsite of stackexchange because it's not only about code review but a bit about design eihter. I'm currently developing a network application. I need to connect a (...
1
vote
1answer
109 views

Object spawning script Unity

I'm trying to make a random object spawning script in Unity. Bellow is the code, any suggestions for improvement / changes? I'm new to both Unity and C#. ...
4
votes
1answer
88 views

A* Algorithm speed improvement

Currently I have a very general purpose A* algorithm, which I've submitted as open sourced at https://github.com/kd7uiy/AStar . I've been trying to speed it up for the last month or so, and while I'm ...
3
votes
2answers
197 views

RPG character, levelUp system and stat checking for object usage

So I am working on a small RPG in Unity. Right now I am writing some business classes, POCOs, that have no link to Unity except being in the required C# flavor and using Debug.Log and stuff. I have ...
2
votes
1answer
207 views

Tic Tac Toe (decoupling patterns and component based design)

I'm learning Unity with C# programming and am trying to learn game design. I know the that the best way to learn games programming is to recreate some existing games, and this is my code to create Tic ...
7
votes
1answer
108 views

Hotkey detection for UI elements

I have several UI elements that can be opened using hotkeys for example the settings menu's key is Escape. The problem is that I have the Keycode stored in ...
3
votes
3answers
125 views

Custom struct design: Range

I had a need for some inventory management in a recent project. I decided to create a custom struct for managing the concept of a number range. It allows for easy navigation of a collection. It ...
2
votes
1answer
57 views

Updating the player statistics text

I'm developing a game in Unity 5.3.5, I have a player statistics system with 10 different stats, as in probably every game the user is able to see the points put in each stats and also the benefit ...
2
votes
1answer
90 views

Moving a player around a board, by choice and by chance

Recently I had to add 2 different sets of logic for moving my player around the board. One lets the player pick a location and move him there while the other uses a dice. I'm reusing code for both ...
1
vote
1answer
96 views

Choosing/creating/setting an NPC dialogue - follow-up

Initial post: Sequentially displaying a list of game objects This file creates a dialogue box and sets the chat history box too inactive. It finds which NPC dialogue to display, creates the list and ...
4
votes
1answer
112 views

Sequentially displaying a list of game objects

A chat background is created and text[0] is displayed with a button created under it. The created button iterates thru text[] ...
4
votes
2answers
187 views

Spell and cooldown system for an Unity game

So I have doubts about my code and if it is any good. I have a parent class Spell: ...
3
votes
1answer
57 views

AudioController class for managing audio in Unity games

I'm looking for a critique of this audio management system I wrote for Unity games. It references a JSON file to trigger the clips by events. The main AudioController.cs class is pasted below. The ...
4
votes
1answer
99 views

Voxel Islands - Level terrain generation

In Voxel Islands, each individual voxel is represented by their own unique class. Each of those unique classes is a subclass of a parent, Voxel class: ...
6
votes
1answer
1k views

TCP authentication server and client

This is the first time I'm dealing with C# as I'm accustomed to Java sockets, so I do want your full review and anything you think I can accomplish better or optimize in the code will be very ...
3
votes
1answer
55 views

Player projectile shooting

I am wondering if my code is needlessly redundant. I noticed, when looking over my code, that I had a unnecessary variable and if statement. Both ...
1
vote
1answer
41 views

Unity3d class that inherits from button and add OnHold Event

I made my own class that inherits from button and has an OnHold event. It seems to work ok but I'm wondering if I can improve it or if you can spot any glaring ...
2
votes
1answer
58 views

Range class to represent limited values, like HP, Stamina and so on

I made a small script for Unity3D, meant to be use as GameComponent for GameObjects. It is supposed to represent values that have a max value, and an actual value. In games that would be the case, for ...
4
votes
1answer
100 views

How to separate data from logic when serializing types - grid tile map example

I am creating a tile based game in Unity and ran into a problem with my architecture of the Map and Tile types. The tile class contains logic like events when the tile type changes. When I tried to ...
4
votes
2answers
346 views

Voxel Islands - Dynamic mesh generation

While I can often understand the performance reasons behind using fixed-size arrays to store vertex, triangle and UV data, I've often found it annoying because it makes dynamically generating meshes ...
3
votes
2answers
103 views

Obstacle-spawning and movement scripts

I have these scripts I made that work absolutely perfectly as I need them to. Is there any improvements that can be done to these scripts and make them more efficient for Mobile Platforms? Or even ...
1
vote
1answer
52 views

Changing height of an UI panel using Array content

I've created following code which works just fine: ...
3
votes
1answer
71 views

Wall-runner type game

I'm working on a Wall-runner reaction based game. Whilst I know my way around a lot of the features Unity provides, I'm still in the beginner phase when it comes to working with several classes and ...
3
votes
1answer
48 views

Unity3D DirectionalSprite

I've created a simple utility class for use in my Unity2D project, which allows a Sprite to have separate sprites for when it is facing East, North, West, or South (that's the order that z-axis ...
4
votes
3answers
549 views

Simple Q&A game

I just wanted to get some criticism on my programming to make me better. I made a game in Unity, just a simple question and answer game. Demo ...
3
votes
2answers
184 views

Changing a sprite depending on variables

I have code here which will change a sprite depending on the variables called gunUpgrade and moveUpgrade. Any way to make the code simpler or shorter? I'm using Unity 3D. ...
2
votes
1answer
782 views

Controlling a drone in Unity3D

I'm currently building a game called "Drones! Attack!", and I needed a drone controller that the player can use. It's currently very simple and only supports a small amount of actions, such as: Basic ...
2
votes
1answer
92 views

2D Unity game using 3D objects, gather points and avoid obstacles

I've been messing around with some stuff in Unity and are now working with 5 classes in my project. As I am very new to the engine, and even C#, I believe I made a rather messy code, even though it ...
6
votes
2answers
388 views

Type-Safe Event System

I have recently started writing C# from a strong JavaScript background, and found myself wanting to do something I do all the time in JavaScript: events. Since I have a type system at my disposal, I ...
1
vote
0answers
548 views

Observer Pattern with C# and Unity

I want to see if I used the Observer pattern correctly. Right now I'm using a VolumeManager.cs that implements ISubject and a <...
1
vote
3answers
246 views

Make C# Unity Script database methods more re-usable and concise

I have a C# file, that makes some modifications on screen (changes the text on the user interface) but I have some doubts: How I can re-use the below methods to be more concise and reusable? How I ...
2
votes
1answer
69 views

Abstract factory pattern for implementing AdNetworks on multiple platforms [closed]

Here's the link to the github project. I want to implement abstract factory instead of adding platform-dependent compilation flags in just one file and make it ugly, hence decoupled code. Moreover, ...
2
votes
1answer
104 views

Unity3D script for controlling a character

This is a Unity3D script I wrote for my game to control a character. I don't consider myself a highly-skilled coder, so I come here to ask for suggestions. Is my code clean enough? How can I improve ...
4
votes
1answer
95 views

Method for obtaining adjacent chunk positions

I'm currently in the process of making a 2D tile based game. This game has an "infinite" world that can be traversed and modified as needed. I am creating the chunks with a mesh and I apply a texture ...
2
votes
1answer
74 views

Writing strings to the screen over time

The following methods just write strings to the screen over time to make it look like a typing effect, instead of all at once. The only difference is the argument in the ...
7
votes
1answer
131 views

My game manager

This is my game manager script and is there anyway i can improve this code. ...