Style Guide - SDSU-GCO/Gamesword_Legacy GitHub Wiki
Below is sample Unity C# code following the proper style. The comments explain each style (not the code, like a normal comment).
//In general, keep a limit of one statement per line.
//Also, limit extra space between lines to 1 line.
//Using statements are kept at the top of the script file.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//All code in Gamesword Legacy must be wrapped in the GS namespace
namespace GS
{
//Classes are named with PascalCase.
//Names are chosen TODO.
public class PoolableObject : MonoBehaviour
{
//public member variables have the 'm_' prefix and are camelCase.
//Names are chosen TODO.
public int m_objectNum;
[Header("Collision Parameters")]
[Tooltip("The number of stars that show up when this object gets hit by a collider.")]
public float StarsRed;
public float StarsBlue;
[Space(10)]
public float Bounceback;
//Important MonoBehavior inherited functions (Start, Update, Etc.)
//should be placed TODO.
void Start()
{
}
//public member functions are in camelCase.
//These should be placed TODO
public virtual void reset()
{
gameObject.SetActive(true);
}
[SerializeField]
private float m_MitchellFoodCount;
public float MitchellFoodCount
{
get
{
return m_MitchellFoodCount + 1;
}
set
{
m_MitchellFoodCount = value - 1;
}
};
/// <summary>
/// Default implementation for use cases which does not require further processing.
/// Base class expects concave collider in last child if not the collider we hit.
/// </summary>
/// <param name="pEvent"></param>
public virtual void Spawn(ParticleCollisionEvent pEvent)
{
}
Spawn (e);
Spawn(e);
if (fadfasfadf)
func()
{
}
while ()
{
}
Spawn();
if ()
{
}
else if ()
{
}
else
{
}
//no mitch, just ... no
if() {
} else if() {
} else {
}
myint += 3;
//not
myint+=3;
if (i != null)
for (i = 0; i < 5; ++i)
{
j++; //Doesn't matter where the pluses go.
}
const int RATE_OF_FIRE;
}
}