Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Assets/GILES/Code/Classes/Extension/pb_CollectionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ namespace GILES
*/
public static class pb_CollectionUtil
{
/**
* Return an array filled with `value` and of length.
*/

///<summary>
///Return an array filled with `value` and of length.
///</summary>
/// <returns>
/// Returns an array of T
/// </returns>
/// <param name="T">The type.</param>
/// <param name="length">The lenght of the array.</param>
public static T[] Fill<T>(T value, int length)
{
T[] arr = new T[length];
Expand All @@ -19,4 +25,4 @@ public static T[] Fill<T>(T value, int length)
}

}
}
}
18 changes: 9 additions & 9 deletions Assets/GILES/Code/Classes/Extension/pb_ComponentExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace GILES
*/
public static class pb_ComponentExtension
{
/**
* Attempts to add a component from a pb_ISerializable object. If `component` is not a type
* inheriting `UnityEngine.Component`, a null value is returned. Otherwise the component is
* added to the gameObject `go` and it's fields are populated using the values stored in the
* dictionary as set by pb_ISerializable.PopulateDictionaryValues().
*/
///<summary>
/// Attempts to add a component from a pb_ISerializable object. If `component` is not a type
/// inheriting `UnityEngine.Component`, a null value is returned. Otherwise the component is
/// added to the gameObject `go` and it's fields are populated using the values stored in the
/// dictionary as set by pb_ISerializable.PopulateDictionaryValues().
///</summary>
public static Component AddComponent(this GameObject go, pb_ISerializable component)
{
if( !typeof(Component).IsAssignableFrom(component.type) )
Expand All @@ -30,9 +30,9 @@ public static Component AddComponent(this GameObject go, pb_ISerializable compon
return c;
}

/**
* Shortcut for if(!GetComponent<T>) AddComponent<T>.
*/
///<summary>
/// Shortcut for if(!GetComponent<T>) AddComponent<T>.
///</summary>
public static T DemandComponent<T>(this GameObject go) where T : UnityEngine.Component
{
T component = go.GetComponent<T>();
Expand Down
10 changes: 7 additions & 3 deletions Assets/GILES/Code/Classes/Extension/pb_InputExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ namespace GILES
*/
public static class pb_InputExtension
{

///<summary>
/// Returns true if any shift button is pressed.
///</summary>
public static bool Shift()
{
return Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
}

///<summary>
/// Returns true if any control button is pressed.
///</summary>
public static bool Control()
{
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
}
}
}
}
18 changes: 10 additions & 8 deletions Assets/GILES/Code/Classes/Extension/pb_ObjectUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@ namespace GILES
{
public static class pb_ObjectUtility
{
/**
* Add an empty gameObject as a child to `go`.
*/
///<summary>
/// Add an empty gameObject as a child to `go`.
///</summary>
public static GameObject AddChild(this GameObject go)
{
GameObject child = new GameObject();
child.transform.SetParent(go.transform);
return child;
}

/**
* Add an empty gameObject as a child to `trs`.
*/
///<summary>
/// Add an empty gameObject as a child to `trs`.
///</summary>
public static Transform AddChild(this Transform trs)
{
Transform go = new GameObject().GetComponent<Transform>();
go.SetParent(trs);
return go;
}

///<summary>
///Calculates the min dist. to the bounds.
///</summary>
public static float CalcMinDistanceToBounds(Camera cam, Bounds bounds)
{
float frustumHeight = Mathf.Max(Mathf.Max(bounds.size.x, bounds.size.y), bounds.size.z);
Expand All @@ -38,4 +40,4 @@ public static void Destroy<T>(T obj) where T : UnityEngine.Object
GameObject.Destroy(obj);
}
}
}
}
9 changes: 5 additions & 4 deletions Assets/GILES/Code/Classes/Extension/pb_TransformExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ namespace GILES
*/
public static class pb_TransformExtension
{
/**
* Set a UnityEngine.Transform with a Runtime.pb_Transform.
*/
///<summary>
/// Set a UnityEngine.Transform with a Runtime.pb_Transform.
///</summary>

public static void SetTRS(this Transform transform, pb_Transform pbTransform)
{
transform.position = pbTransform.position;
transform.localRotation = pbTransform.rotation;
transform.localScale = pbTransform.scale;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override void InitializeGUI()

_transform = (Transform) target;

pb_TypeInspector position_inspector = pb_InspectorResolver.GetInspector(typeof(Vector3));
pb_TypeInspector position_inspector = pb_InspectorResolver.GetInspector(typeof(Vector3));
pb_TypeInspector rotation_inspector = pb_InspectorResolver.GetInspector(typeof(Vector3));
pb_TypeInspector scale_inspector = pb_InspectorResolver.GetInspector(typeof(Vector3));

Expand Down Expand Up @@ -53,10 +53,13 @@ object UpdatePosition(int index)

void OnSetPosition(int index, object value)
{
_transform.position = (Vector3) value;
pb_Selection.OnExternalUpdate();
if (value != null)
{
_transform.position = (Vector3)value;
pb_Selection.OnExternalUpdate();

pb_ComponentDiff.AddDiff(target, "position", _transform.position);
pb_ComponentDiff.AddDiff(target, "position", _transform.position);
}
}

object UpdateRotation(int index)
Expand Down
101 changes: 48 additions & 53 deletions Assets/GILES/Code/Classes/GUI/Type Inspectors/pb_EnumInspector.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,69 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;

namespace GILES.Interface
{
/**
/**
* Field editor for enum types.
*/
[pb_TypeInspector(typeof(System.Enum))]
public class pb_EnumInspector : pb_TypeInspector
{
object value;
[pb_TypeInspector(typeof(System.Enum))]
public class pb_EnumInspector : pb_TypeInspector
{
object value;

public Text title;
public Button button;
public Text currentEnumValue;
string[] enumNames; /// the available names of this enum
System.Array enumValues; /// the available values of this enum
public Text title;
public Dropdown dropdown;
string[] enumNames; /// the available names of this enum
System.Array enumValues; /// the available values of this enum

void OnGUIChanged()
{
SetValue(value);
}
void OnGUIChanged()
{
SetValue(value);
}

public override void InitializeGUI()
{
title.text = GetName().SplitCamelCase();
button.onClick.AddListener( OnClick );
public override void InitializeGUI()
{
title.text = GetName().SplitCamelCase();
dropdown.onValueChanged.AddListener(OnClick);

enumNames = System.Enum.GetNames(declaringType);
enumValues = System.Enum.GetValues(declaringType);
}
enumNames = System.Enum.GetNames(declaringType);
enumValues = System.Enum.GetValues(declaringType);
RefreshDropdown();
}

void OnClick()
{
// cycle enum value
if(enumValues != null)
{
int len = enumValues.Length;
void OnClick(int index)
{
// cycle enum value
if (enumValues != null)
{
int len = enumValues.Length;
value = enumValues.GetValue(index);

// values may not be linear, or integers at all
int index = System.Array.IndexOf(enumValues, value);
OnGUIChanged();
}
}

index++;
protected override void OnUpdateGUI()
{
value = GetValue<object>();

if(index >= len)
index = 0;
RefreshDropdown();
}

value = enumValues.GetValue(index);
void RefreshDropdown()
{
dropdown.ClearOptions();
List<string> options = new List<string>();

RefreshText();

OnGUIChanged();
}
}
for (int i = 0; i < enumValues.Length; i++)
{
options.Add(enumNames[i].ToString());
}
dropdown.AddOptions(options);
}

protected override void OnUpdateGUI()
{
value = GetValue<object>();

RefreshText();
}

void RefreshText()
{
if(enumNames != null)
currentEnumValue.text = value.ToString();// enumNames[value];
else
currentEnumValue.text = "Enum: " + value.ToString();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace GILES.Interface
[pb_TypeInspector(typeof(object))]
public class pb_ObjectInspector : pb_TypeInspector
{
object value;
object value;

//private static readonly RectOffset RectOffset_Zero = new RectOffset(0,0,0,0);
private const int VERTICAL_LAYOUT_SPACING = 0;
Expand All @@ -25,11 +25,11 @@ void OnGUIChanged()

public override void InitializeGUI()
{
value = GetValue<object>();
value = GetValue<object>();

pb_GUIUtility.AddVerticalLayoutGroup(gameObject, new RectOffset(0,0,0,0), VERTICAL_LAYOUT_SPACING, true, false);
pb_GUIUtility.AddVerticalLayoutGroup(gameObject, new RectOffset(0, 0, 0, 0), VERTICAL_LAYOUT_SPACING, true, false);

BuildInspectorTree();
BuildInspectorTree();
}

protected override void OnUpdateGUI()
Expand Down Expand Up @@ -66,4 +66,5 @@ void BuildInspectorTree()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GILES.Interface
[pb_TypeInspector(typeof(Vector3))]
public class pb_Vector3Inspector : pb_TypeInspector
{
Vector3 vector;
Vector3 vector = new Vector3();

public UnityEngine.UI.Text title;

Expand Down Expand Up @@ -41,7 +41,7 @@ public override void InitializeGUI()

protected override void OnUpdateGUI()
{
vector = GetValue<Vector3>();
vector = GetValue<Vector3>();

input_x.text = vector.x.ToString();
input_y.text = vector.y.ToString();
Expand Down
Loading