Skip to content

Commit

Permalink
Retarget to net 3.5 also added extra function to support this, nameof…
Browse files Browse the repository at this point in the history
… as it is from net 4.x.
  • Loading branch information
sigr3s committed Dec 11, 2018
1 parent ac5af5e commit a8babcb
Show file tree
Hide file tree
Showing 24 changed files with 8,053 additions and 13,587 deletions.
21,288 changes: 7,902 additions & 13,386 deletions Assets/Skinnable/Demos/Scenes/Skinned_0.unity

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions Assets/Skinnable/Demos/Scripts.meta

This file was deleted.

25 changes: 0 additions & 25 deletions Assets/Skinnable/Demos/Scripts/ToggleStyle.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Skinnable/Demos/Scripts/ToggleStyle.cs.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/Skinnable/Demos/Styles.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/Skinnable/Demos/Styles/User toggle.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/Skinnable/Demos/Styles/User toggle/Toggle.meta

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 9 additions & 3 deletions Assets/Skinnable/Scripts/DefaultStyles/ButtonStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ public override void ApplyStyle(ref System.Object targetObject)
{
Button button = targetObject as Button;
if (button != null) {
if(ShouldApply(nameof(buttonColorBlock))) button.colors = buttonColorBlock;
if(ShouldApply(nameof(spriteState))) button.spriteState = spriteState;

if(ShouldApply(nameof(buttonSprite))){
if(ShouldApply(this.nameof(b => b.buttonColorBlock)))
{
button.colors = buttonColorBlock;
}
if(ShouldApply(this.nameof(b => b.spriteState))){
button.spriteState = spriteState;
}

if(ShouldApply(this.nameof(b => b.buttonSprite))){
Image image = button.targetGraphic as Image;
if(image != null) image.sprite = buttonSprite;
}
Expand Down
11 changes: 9 additions & 2 deletions Assets/Skinnable/Scripts/DefaultStyles/ImageStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ public class ImageStyle : BaseStyle<Image> {
public override void ApplyStyle (ref System.Object targetObject) {
Image img = targetObject as Image;
if (img != null) {
if(ShouldApply(nameof(color)) ) img.color = color;
if(ShouldApply(nameof(defaultSprite)) ) img.sprite = defaultSprite;
if(ShouldApply(this.nameof(b => b.color)) )
{
img.color = color;
}

if(ShouldApply(this.nameof(b => b.defaultSprite)) )
{
img.sprite = defaultSprite;
}
}
}
}
Expand Down
17 changes: 14 additions & 3 deletions Assets/Skinnable/Scripts/DefaultStyles/TextStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ public class TextStyle : BaseStyle<Text> {
public override void ApplyStyle (ref System.Object targetObject) {
Text text = targetObject as Text;
if (text != null) {
if(ShouldApply(nameof(font)) ) text.font = font;
if(ShouldApply(nameof(fontColor)) ) text.color = fontColor;
if(ShouldApply(nameof(fontSize)) ) text.fontSize = fontSize;
if(ShouldApply(this.nameof(b => b.font)) )
{
text.font = font;
}

if(ShouldApply(this.nameof(b => b.fontColor)) )
{
text.color = fontColor;
}

if(ShouldApply(this.nameof(b => b.fontSize)) )
{
text.fontSize = fontSize;
}
}
}
}
Expand Down
59 changes: 41 additions & 18 deletions Assets/Skinnable/Scripts/DefaultThemes/ColorBlockTheme.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
using Skinnable;
using UnityEngine;
using UnityEngine.UI;

public class ColorBlockTheme : BaseStyle<ColorBlock> {
namespace Skinnable {
public class ColorBlockTheme : BaseStyle<ColorBlock> {

public Color normalColor = Color.white;
public Color highlightedColor = Color.white;
public Color pressedColor = Color.white;
public Color disabledColor = Color.white;
public float colorMultiplier = 1.0f;
public float fadeDuration = 0.1f;
public Color normalColor = Color.white;
public Color highlightedColor = Color.white;
public Color pressedColor = Color.white;
public Color disabledColor = Color.white;
public float colorMultiplier = 1.0f;
public float fadeDuration = 0.1f;

public override void ApplyStyle(ref object targetObject)
{
ColorBlock colorBlock = (ColorBlock) targetObject;
public override void ApplyStyle(ref object targetObject)
{
ColorBlock colorBlock = (ColorBlock) targetObject;

if(ShouldApply(nameof(normalColor)) ) colorBlock.normalColor = normalColor;
if(ShouldApply(nameof(highlightedColor)) ) colorBlock.highlightedColor = highlightedColor;
if(ShouldApply(nameof(pressedColor)) ) colorBlock.pressedColor = pressedColor;
if(ShouldApply(nameof(disabledColor)) ) colorBlock.disabledColor = disabledColor;
if(ShouldApply(nameof(colorMultiplier)) ) colorBlock.colorMultiplier = colorMultiplier;
if(ShouldApply(nameof(fadeDuration)) ) colorBlock.fadeDuration = fadeDuration;
if(ShouldApply(this.nameof(b => b.normalColor)) )
{
colorBlock.normalColor = normalColor;
}

targetObject = colorBlock;
if(ShouldApply(this.nameof(b => b.highlightedColor)) )
{
colorBlock.highlightedColor = highlightedColor;
}

if(ShouldApply(this.nameof(b => b.pressedColor)) )
{
colorBlock.pressedColor = pressedColor;
}

if(ShouldApply(this.nameof(b => b.disabledColor)) )
{
colorBlock.disabledColor = disabledColor;
}

if(ShouldApply(this.nameof(b => b.colorMultiplier)) )
{
colorBlock.colorMultiplier = colorMultiplier;
}

if(ShouldApply(this.nameof(b => b.fadeDuration)) ){
colorBlock.fadeDuration = fadeDuration;
}

targetObject = colorBlock;
}
}
}
18 changes: 11 additions & 7 deletions Assets/Skinnable/Scripts/DefaultThemes/ColorTheme.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using Skinnable;
using UnityEngine;
using UnityEngine.UI;

[ExecuteInEditMode]
public class ColorTheme : BaseStyle<Color> {
public Color color = Color.white;
public override void ApplyStyle (ref System.Object targetObject) {
if(ShouldApply(nameof(color)) ) targetObject = color;
}
namespace Skinnable {

public class ColorTheme : BaseStyle<Color> {
public Color color = Color.white;
public override void ApplyStyle (ref System.Object targetObject) {
if(ShouldApply(this.nameof(b => b.color)) )
{
targetObject = color;
}
}

}
}
16 changes: 10 additions & 6 deletions Assets/Skinnable/Scripts/DefaultThemes/FontTheme.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using Skinnable;
using UnityEngine;

public class FontTheme : BaseStyle<Font> {
public Font font;
namespace Skinnable {
public class FontTheme : BaseStyle<Font> {
public Font font;

public override void ApplyStyle(ref object targetObject)
{
if(ShouldApply(nameof(font)) ) targetObject = font;
public override void ApplyStyle(ref object targetObject)
{
if(ShouldApply(this.nameof(f => f.font)) )
{
targetObject = font;
}
}
}
}
15 changes: 9 additions & 6 deletions Assets/Skinnable/Scripts/DefaultThemes/SizeTheme.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

using Skinnable;

public class SizeTheme : BaseStyle<int> {
public int size;
public override void ApplyStyle (ref System.Object targetObject) {
if(ShouldApply(nameof(size)) ) targetObject = size;
namespace Skinnable {
public class SizeTheme : BaseStyle<int> {
public int size;
public override void ApplyStyle (ref System.Object targetObject) {
if(ShouldApply(this.nameof(s => s.size)) )
{
targetObject = size;
}
}
}
}
39 changes: 26 additions & 13 deletions Assets/Skinnable/Scripts/DefaultThemes/SpriteStateTheme.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
using Skinnable;
using UnityEngine;
using UnityEngine.UI;

public class SpriteStateTheme : BaseStyle<SpriteState>
namespace Skinnable
{
public Sprite highlightedSprite;
public Sprite pressedSprite;
public Sprite disabledSprite;

public override void ApplyStyle(ref object targetObject)
public class SpriteStateTheme : BaseStyle<SpriteState>
{
SpriteState spriteState = (SpriteState) targetObject;
if(ShouldApply(nameof(highlightedSprite)) ) spriteState.highlightedSprite = highlightedSprite;
if(ShouldApply(nameof(pressedSprite)) ) spriteState.pressedSprite = pressedSprite;
if(ShouldApply(nameof(disabledSprite)) ) spriteState.disabledSprite = disabledSprite;
public Sprite highlightedSprite;
public Sprite pressedSprite;
public Sprite disabledSprite;

public override void ApplyStyle(ref object targetObject)
{
SpriteState spriteState = (SpriteState) targetObject;
if(ShouldApply(this.nameof(st => st.highlightedSprite)) )
{
spriteState.highlightedSprite = highlightedSprite;
}

if(ShouldApply(this.nameof(st => st.pressedSprite)) )
{
spriteState.pressedSprite = pressedSprite;
}

if(ShouldApply(this.nameof(st => st.disabledSprite)) )
{
spriteState.disabledSprite = disabledSprite;
}


targetObject = spriteState;
targetObject = spriteState;
}
}

}
Loading

0 comments on commit a8babcb

Please sign in to comment.