Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Code formatting (#118)
* Updated .editorconfig

* Update manifest.json

* Whitespace.

* Whitespace.

* Whitespace.

* Added missing comment header.

* Syntax update.

* Removed local references to retrieved pool objects.

* Disable warnings.

* Syntax update.

* Disabled warning.

* Added missing test conditionals.

* Added missing comment header.
  • Loading branch information
neogeek committed Aug 24, 2019
1 parent 429109d commit a82bbb9
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 79 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Expand Up @@ -8,7 +8,6 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = off

# CSharp and Visual Basic code style settings:
[*.cs]
Expand Down
Expand Up @@ -123,7 +123,6 @@ public static T LoadData<T>(string fileName)

}


/// <summary>
/// Delete a local file.
/// </summary>
Expand Down
21 changes: 14 additions & 7 deletions Assets/Plugins/CandyCoded/Scripts/Animate.cs
Expand Up @@ -11,7 +11,8 @@ public static class Animate

private delegate void AnimationFunc(float elapsedTime);

private static IEnumerator Loop(GameObject gameObject, string coroutineKey, bool isLooping, float maxTime, AnimationFunc animationFunc)
private static IEnumerator Loop(GameObject gameObject, string coroutineKey, bool isLooping, float maxTime,
AnimationFunc animationFunc)
{

var runner = gameObject.AddOrGetComponent<Runner>();
Expand Down Expand Up @@ -89,7 +90,8 @@ public static void Fade(AnimationCurve animationCurve, float elapsedTime, Animat
foreach (var materialData in animationData.Materials)
{

materialData.Material.color = Materials.SetColorAlpha(materialData.Material.color, materialData.StartColor.a * globalAlpha);
materialData.Material.color = Materials.SetColorAlpha(materialData.Material.color,
materialData.StartColor.a * globalAlpha);

}

Expand Down Expand Up @@ -244,10 +246,12 @@ public static Coroutine PositionRelative(GameObject gameObject, Vector3Animation
/// <param name="elapsedTime">The time elapsed since the animation started.</param>
/// <param name="animationData">AnimationData object containing cached transform data.</param>
/// <returns>void</returns>
public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime, AnimationData animationData)
public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve animationCurve,
float elapsedTime, AnimationData animationData)
{

gameObject.transform.localPosition = animationData.TransformData.Position + animationCurve.Evaluate(elapsedTime);
gameObject.transform.localPosition =
animationData.TransformData.Position + animationCurve.Evaluate(elapsedTime);

}

Expand All @@ -258,12 +262,14 @@ public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve
/// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param>
/// <param name="elapsedTime">The time elapsed since the animation started.</param>
/// <returns>void</returns>
public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime)
public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve animationCurve,
float elapsedTime)
{

var animationData = gameObject.AddOrGetComponent<AnimationData>();

gameObject.transform.localPosition = animationData.TransformData.Position + animationCurve.Evaluate(elapsedTime);
gameObject.transform.localPosition =
animationData.TransformData.Position + animationCurve.Evaluate(elapsedTime);

}

Expand Down Expand Up @@ -417,7 +423,8 @@ public static Coroutine ScaleRelative(GameObject gameObject, Vector3AnimationCur
/// <param name="elapsedTime">The time elapsed since the animation started.</param>
/// <param name="animationData">AnimationData object containing cached transform data.</param>
/// <returns>void</returns>
public static void ScaleRelative(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime, AnimationData animationData)
public static void ScaleRelative(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime,
AnimationData animationData)
{

gameObject.transform.localScale = animationData.TransformData.Scale + animationCurve.Evaluate(elapsedTime);
Expand Down
27 changes: 3 additions & 24 deletions Assets/Plugins/CandyCoded/Scripts/Calculation.cs
Expand Up @@ -28,34 +28,13 @@ public static Bounds ParentBounds(GameObject gameObject)

var childBounds = renderer.bounds;

if (min.HasValue)
{
min = min.HasValue ? Vector3.Min(min.Value, childBounds.min) : childBounds.min;

min = Vector3.Min(min.Value, childBounds.min);

}
else
{

min = childBounds.min;

}

if (max.HasValue)
{

max = Vector3.Max(max.Value, childBounds.max);

}
else
{

max = childBounds.max;

}
max = max.HasValue ? Vector3.Max(max.Value, childBounds.max) : childBounds.max;

}

// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (min.HasValue && max.HasValue)
{

Expand Down
1 change: 1 addition & 0 deletions Assets/Plugins/CandyCoded/Scripts/CustomEditor/EnumMask.cs
Expand Up @@ -12,6 +12,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(Enum))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class EnumMaskAttribute : PropertyAttribute
{

Expand Down
20 changes: 16 additions & 4 deletions Assets/Plugins/CandyCoded/Scripts/CustomEditor/EventProfiler.cs
Expand Up @@ -138,6 +138,7 @@ private void OnGUI()

}

// ReSharper disable once UnusedMember.Local
private void ShowButton(Rect rect)
{

Expand All @@ -151,7 +152,10 @@ private void DrawEvents(MemberInfo ev, IReadOnlyList<ExtendedMethodInfo> methods
{

GUILayout.Space(spaceBeforeEventListHeight);
GUILayout.Label(string.Format(eventListHeaderTemplate, ObjectNames.NicifyVariableName(ev.Name), methods.Count), EditorStyles.boldLabel);

GUILayout.Label(
string.Format(eventListHeaderTemplate, ObjectNames.NicifyVariableName(ev.Name), methods.Count),
EditorStyles.boldLabel);

if (!scrollPositions.ContainsKey(ev.Name))
{
Expand All @@ -170,7 +174,9 @@ private void DrawEvents(MemberInfo ev, IReadOnlyList<ExtendedMethodInfo> methods

GUILayout.BeginHorizontal();

if (GUILayout.Button(prefabIcon, EditorStyles.label, GUILayout.Width(EditorGUIUtility.singleLineHeight), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
if (GUILayout.Button(prefabIcon, EditorStyles.label,
GUILayout.Width(EditorGUIUtility.singleLineHeight),
GUILayout.Height(EditorGUIUtility.singleLineHeight)))
{

Selection.activeGameObject = methods[i].gameObject;
Expand All @@ -179,7 +185,8 @@ private void DrawEvents(MemberInfo ev, IReadOnlyList<ExtendedMethodInfo> methods

}

if (GUILayout.Button(string.Format(eventListItemTemplate, i + 1, methods[i].label), EditorStyles.label))
if (GUILayout.Button(string.Format(eventListItemTemplate, i + 1, methods[i].label),
EditorStyles.label))
{

Selection.activeGameObject = methods[i].gameObject;
Expand Down Expand Up @@ -211,7 +218,12 @@ public static List<ExtendedMethodInfo> GetSubscribedMethodsToEvent(MulticastDele
if (multicastDelegate != null)
{

return multicastDelegate.GetInvocationList().Select(i => new ExtendedMethodInfo { gameObject = ((MonoBehaviour)i.Target).gameObject, methodInfo = i.Method }).ToList();
return multicastDelegate.GetInvocationList().Select(i =>
new ExtendedMethodInfo
{
gameObject = ((MonoBehaviour)i.Target).gameObject, methodInfo = i.Method
})
.ToList();

}

Expand Down
@@ -1,3 +1,5 @@
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.

#if UNITY_EDITOR
using UnityEditor;
#endif
Expand All @@ -9,6 +11,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(RangedFloat))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class RangedSliderAttribute : PropertyAttribute
{

Expand Down Expand Up @@ -51,10 +54,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
EditorGUI.indentLevel = 0;

var minLabelRect = new Rect(prefixLabel.x, prefixLabel.y, labelRectWidth, rectHeight);
var sliderRect = new Rect(minLabelRect.xMax, prefixLabel.y, prefixLabel.width - labelRectWidth * 2, rectHeight);

var sliderRect = new Rect(minLabelRect.xMax, prefixLabel.y, prefixLabel.width - labelRectWidth * 2,
rectHeight);

var maxLabelRect = new Rect(sliderRect.xMax, prefixLabel.y, labelRectWidth, rectHeight);

EditorGUI.LabelField(minLabelRect, minValue.ToString("F2"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft });
EditorGUI.LabelField(minLabelRect, minValue.ToString("F2"),
new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft });

EditorGUI.BeginChangeCheck();
EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, limits.MinLimit, limits.MaxLimit);
Expand All @@ -65,7 +72,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
property.FindPropertyRelative("max").floatValue = maxValue;
}

EditorGUI.LabelField(maxLabelRect, maxValue.ToString("F2"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight });
EditorGUI.LabelField(maxLabelRect, maxValue.ToString("F2"),
new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight });

EditorGUI.indentLevel = prevIndentLevel;

Expand Down
@@ -1,3 +1,5 @@
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.

#if UNITY_EDITOR
using UnityEditor;
#endif
Expand All @@ -9,6 +11,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(RangedFloat))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class RangedStepSliderAttribute : PropertyAttribute
{

Expand Down Expand Up @@ -55,10 +58,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
EditorGUI.indentLevel = 0;

var minLabelRect = new Rect(prefixLabel.x, prefixLabel.y, labelRectWidth, rectHeight);
var sliderRect = new Rect(minLabelRect.xMax, prefixLabel.y, prefixLabel.width - labelRectWidth * 2, rectHeight);

var sliderRect = new Rect(minLabelRect.xMax, prefixLabel.y, prefixLabel.width - labelRectWidth * 2,
rectHeight);

var maxLabelRect = new Rect(sliderRect.xMax, prefixLabel.y, labelRectWidth, rectHeight);

EditorGUI.LabelField(minLabelRect, minValue.ToString("F2"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft });
EditorGUI.LabelField(minLabelRect, minValue.ToString("F2"),
new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft });

EditorGUI.BeginChangeCheck();
EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, limits.MinLimit, limits.MaxLimit);
Expand All @@ -72,7 +79,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
property.FindPropertyRelative("max").floatValue = maxValue;
}

EditorGUI.LabelField(maxLabelRect, maxValue.ToString("F2"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight });
EditorGUI.LabelField(maxLabelRect, maxValue.ToString("F2"),
new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight });

EditorGUI.indentLevel = prevIndentLevel;

Expand Down
13 changes: 9 additions & 4 deletions Assets/Plugins/CandyCoded/Scripts/CustomExtensions.cs
Expand Up @@ -197,7 +197,8 @@ public static LayerMask GetLayerMask(this GameObject gameObject)
public static bool IsLooping(this AnimationCurve animationCurve)
{

return animationCurve != null && (animationCurve.postWrapMode.Equals(WrapMode.Loop) || animationCurve.postWrapMode.Equals(WrapMode.PingPong));
return animationCurve != null && (animationCurve.postWrapMode.Equals(WrapMode.Loop) ||
animationCurve.postWrapMode.Equals(WrapMode.PingPong));

}

Expand All @@ -212,7 +213,8 @@ public static bool IsVisible(this Transform transform, Camera camera)

var positionInViewport = camera.WorldToViewportPoint(transform.position);

return positionInViewport.x >= 0 && positionInViewport.x <= 1 && positionInViewport.y >= 0 && positionInViewport.y <= 1;
return positionInViewport.x >= 0 && positionInViewport.x <= 1 && positionInViewport.y >= 0 &&
positionInViewport.y <= 1;

}

Expand All @@ -228,7 +230,8 @@ public static Quaternion LookAt2D(this Transform transform, Transform target, Ve

Vector2 angle = target.position - transform.position;

var deg = Vector3.Angle(Vector3.forward, direction) * Mathf.Sign(Vector3.Cross(Vector3.forward, direction).x);
var deg = Vector3.Angle(Vector3.forward, direction) *
Mathf.Sign(Vector3.Cross(Vector3.forward, direction).x);

return Quaternion.AngleAxis(Mathf.Atan2(angle.y, angle.x) * Mathf.Rad2Deg + deg, Vector3.forward);

Expand Down Expand Up @@ -256,7 +259,9 @@ public static Quaternion LookAt2D(this Transform transform, Transform target)
public static float MaxTime(this AnimationCurve animationCurve)
{

return animationCurve != null && animationCurve.keys.Length > 0 ? animationCurve.keys[animationCurve.keys.Length - 1].time : 0;
return animationCurve != null && animationCurve.keys.Length > 0
? animationCurve.keys[animationCurve.keys.Length - 1].time
: 0;

}

Expand Down

0 comments on commit a82bbb9

Please sign in to comment.