Skip to content
Permalink
Browse files

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 a82bbb962c89b1bcc97c545d09af803543ea66da
@@ -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]
@@ -123,7 +123,6 @@ public static T LoadData<T>(string fileName)

}


/// <summary>
/// Delete a local file.
/// </summary>
@@ -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>();
@@ -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);

}

@@ -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);

}

@@ -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);

}

@@ -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);
@@ -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)
{

@@ -12,6 +12,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(Enum))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class EnumMaskAttribute : PropertyAttribute
{

@@ -138,6 +138,7 @@ private void OnGUI()

}

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

@@ -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))
{
@@ -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;
@@ -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;
@@ -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();

}

@@ -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
@@ -9,6 +11,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(RangedFloat))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class RangedSliderAttribute : PropertyAttribute
{

@@ -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);
@@ -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;

@@ -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
@@ -9,6 +11,7 @@ namespace CandyCoded
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(RangedFloat))]
#endif
// ReSharper disable once RequiredBaseTypesIsNotInherited
public class RangedStepSliderAttribute : PropertyAttribute
{

@@ -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);
@@ -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;

@@ -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));

}

@@ -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;

}

@@ -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);

@@ -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;

}

0 comments on commit a82bbb9

Please sign in to comment.
You can’t perform that action at this time.