Skip to content

Commit

Permalink
Added opacity as state feature
Browse files Browse the repository at this point in the history
  • Loading branch information
afauch committed Dec 8, 2017
1 parent 15d36b9 commit 759f7c0
Show file tree
Hide file tree
Showing 37 changed files with 93 additions and 2,454 deletions.
8 changes: 6 additions & 2 deletions crayon-dev/Assets/Crayon/Editor/CrayonStateEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CrayonStateEditor : Editor
SerializedProperty tweenAppearanceMode;
SerializedProperty material;
SerializedProperty color;
SerializedProperty opacity;

SerializedProperty tweenPosition;
SerializedProperty relativePosition;
Expand Down Expand Up @@ -61,6 +62,7 @@ void OnEnable()
tweenAppearanceMode = serializedObject.FindProperty ("_tweenAppearanceMode");
material = serializedObject.FindProperty ("_material");
color = serializedObject.FindProperty ("_color");
opacity = serializedObject.FindProperty ("_opacity");

tweenPosition = serializedObject.FindProperty ("_tweenPosition");
relativePosition = serializedObject.FindProperty ("_relativePosition");
Expand Down Expand Up @@ -128,8 +130,10 @@ public override void OnInspectorGUI()
EditorGUI.EndDisabledGroup ();
break;
case 2:
// Debug.Log ("Opacity feature not yet implemented.");
break;
EditorGUI.BeginDisabledGroup (_isDefault);
EditorGUILayout.PropertyField (opacity, GUIContent.none);
EditorGUI.EndDisabledGroup ();
break;
}
}
EditorGUILayout.EndHorizontal ();
Expand Down
1 change: 1 addition & 0 deletions crayon-dev/Assets/Crayon/Scripts/CrayonState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class CrayonState : MonoBehaviour
public CrayonTweenAppearanceMode _tweenAppearanceMode = CrayonTweenAppearanceMode.Material;
public Material _material;
public Color _color = Color.black;
public float _opacity = 1.0f;

public bool _tweenPosition = true;
public Vector3 _relativePosition;
Expand Down
6 changes: 5 additions & 1 deletion crayon-dev/Assets/Crayon/Scripts/CrayonStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public void AddState()
public void ChangeState(CrayonStateType stateType, string customState = "")
{
// Call the delegate so any downstream items know to change as well.
if (OnChangeState != null) {
if (OnChangeState != null)
{
OnChangeState (stateType, customState);
}

Expand Down Expand Up @@ -181,6 +182,9 @@ public void ChangeState(CrayonStateType stateType, string customState = "")
case CrayonTweenAppearanceMode.Color:
gameObject.SetColor (state._color, state._duration, state._easing, state._customEasing);
break;
case CrayonTweenAppearanceMode.Opacity:
gameObject.SetOpacity (state._opacity, state._duration, state._easing, state._customEasing);
break;
}
}

Expand Down
9 changes: 6 additions & 3 deletions crayon-dev/Assets/Scenes/19 -sprite test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,10 @@ MonoBehaviour:
_customEasing:
_duration: 0.8
_tweenAppearance: 1
_tweenAppearanceMode: 1
_tweenAppearanceMode: 2
_material: {fileID: 2100000, guid: 02027b24a6f994a2a99e9db34785abda, type: 2}
_color: {r: 1, g: 0.75973624, b: 0.24264705, a: 1}
_opacity: 0.2
_tweenPosition: 1
_relativePosition: {x: 0, y: 0, z: 0}
_tweenRotation: 1
Expand All @@ -886,9 +887,10 @@ MonoBehaviour:
_customEasing:
_duration: 0.8
_tweenAppearance: 1
_tweenAppearanceMode: 1
_tweenAppearanceMode: 2
_material: {fileID: 2100000, guid: d28f7acebbbed4f7a8b4d1c96c71934b, type: 2}
_color: {r: 1, g: 0.6397059, b: 0.6397059, a: 1}
_opacity: 0.8
_tweenPosition: 1
_relativePosition: {x: 0, y: 0, z: -1}
_tweenRotation: 1
Expand All @@ -913,9 +915,10 @@ MonoBehaviour:
_customEasing:
_duration: 0.8
_tweenAppearance: 1
_tweenAppearanceMode: 1
_tweenAppearanceMode: 2
_material: {fileID: 2100000, guid: 156b041c2262a4f2883e74e01888798e, type: 2}
_color: {r: 0, g: 0, b: 0, a: 1}
_opacity: 1
_tweenPosition: 1
_relativePosition: {x: 0, y: 0, z: 0}
_tweenRotation: 1
Expand Down
Loading

0 comments on commit 759f7c0

Please sign in to comment.