-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0767d82
Showing
17 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
using Smoothie.MonetColors.Runtime; | ||
|
||
namespace Smoothie.MonetColors.Editor | ||
{ | ||
[CustomEditor(typeof(MonetColorer), true), CanEditMultipleObjects] | ||
public class MonetColorerCustomEditor : UnityEditor.Editor | ||
{ | ||
private SerializedProperty _color; | ||
|
||
private void OnEnable() | ||
{ | ||
_color = serializedObject.FindProperty("_color"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
var uiElement = target as MonetColorer; | ||
uiElement.UpdateColor(); | ||
EditorGUILayout.PropertyField(_color); | ||
EditorGUILayout.LabelField(Colors.Names[_color.intValue]); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Unity.Smoothie.MonetColors.Editor", | ||
"rootNamespace": "Smoothie.MonetColors.Editor", | ||
"references": [ | ||
"GUID:e96f0dfb32d62404bb04759d4f531986" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
BSD 2-Clause License | ||
|
||
Copyright (c) 2022, -Smooth-E- | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(Camera))] | ||
public class CameraMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
var component = GetComponent<Camera>(); | ||
_colorValue.a = component.backgroundColor.a; | ||
component.backgroundColor = _colorValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using UnityEngine; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
public partial class Colors | ||
{ | ||
public const int ColorsAmount = 65; | ||
public static string[] Names { get; } = new string[ColorsAmount] { | ||
"accent1_0", | ||
"accent1_10", | ||
"accent1_50", | ||
"accent1_100", | ||
"accent1_200", | ||
"accent1_300", | ||
"accent1_400", | ||
"accent1_500", | ||
"accent1_600", | ||
"accent1_700", | ||
"accent1_800", | ||
"accent1_900", | ||
"accent1_1000", | ||
"accent2_0", | ||
"accent2_10", | ||
"accent2_50", | ||
"accent2_100", | ||
"accent2_200", | ||
"accent2_300", | ||
"accent2_400", | ||
"accent2_500", | ||
"accent2_600", | ||
"accent2_700", | ||
"accent2_800", | ||
"accent2_900", | ||
"accent2_1000", | ||
"accent3_0", | ||
"accent3_10", | ||
"accent3_50", | ||
"accent3_100", | ||
"accent3_200", | ||
"accent3_300", | ||
"accent3_400", | ||
"accent3_500", | ||
"accent3_600", | ||
"accent3_700", | ||
"accent3_800", | ||
"accent3_900", | ||
"accent3_1000", | ||
"neutral1_0", | ||
"neutral1_10", | ||
"neutral1_50", | ||
"neutral1_100", | ||
"neutral1_200", | ||
"neutral1_300", | ||
"neutral1_400", | ||
"neutral1_500", | ||
"neutral1_600", | ||
"neutral1_700", | ||
"neutral1_800", | ||
"neutral1_900", | ||
"neutral1_1000", | ||
"neutral2_0", | ||
"neutral2_10", | ||
"neutral2_50", | ||
"neutral2_100", | ||
"neutral2_200", | ||
"neutral2_300", | ||
"neutral2_400", | ||
"neutral2_500", | ||
"neutral2_600", | ||
"neutral2_700", | ||
"neutral2_800", | ||
"neutral2_900", | ||
"neutral2_1000", | ||
}; | ||
|
||
public static Color GetColor(int index) | ||
{ | ||
Color color = _fallbackPalette[index]; | ||
if (Application.platform == RuntimePlatform.Android) | ||
{ | ||
AndroidJavaClass versionClass = new AndroidJavaClass("android.os.Build$VERSION"); | ||
int sdkInt = versionClass.GetStatic<int>("SDK_INT"); | ||
if (sdkInt > 30) | ||
{ | ||
AndroidJavaClass colorClass = new AndroidJavaClass("android.R$color"); | ||
int colorInt = colorClass.GetStatic<int>("system_" + Names[index]); | ||
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
AndroidJavaObject context = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); | ||
int colorValue = context.Call<AndroidJavaObject>("getResources").Call<int>("getColor", colorInt); | ||
colorClass = new AndroidJavaClass("android.graphics.Color"); | ||
AndroidJavaObject colorObject = colorClass.CallStatic<AndroidJavaObject>("valueOf", colorValue); | ||
float red = colorObject.Call <float>("red"); | ||
float green = colorObject.Call <float>("green"); | ||
float blue = colorObject.Call <float>("blue"); | ||
color = new Color(red, green, blue); | ||
} | ||
} | ||
return color; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using UnityEngine; | ||
|
||
namespace Smoothie.MonetColors.Runtime { | ||
public partial class Colors | ||
{ | ||
private static Color[] _fallbackPalette { get; } = new Color[ColorsAmount] { | ||
new Color32(255, 255, 255, 255), | ||
new Color32(249, 252, 255, 255), | ||
new Color32(224, 243, 255, 255), | ||
new Color32(193, 232, 255, 255), | ||
new Color32(118, 209, 255, 255), | ||
new Color32(75, 182, 232, 255), | ||
new Color32(33, 155, 204, 255), | ||
new Color32(0, 127, 172, 255), | ||
new Color32(0, 102, 139, 255), | ||
new Color32(0, 76, 105, 255), | ||
new Color32(0, 53, 73, 255), | ||
new Color32(0, 30, 44, 255), | ||
new Color32(0, 0, 0, 255), | ||
new Color32(255, 255, 255, 255), | ||
new Color32(249, 252, 255, 255), | ||
new Color32(224, 243, 255, 255), | ||
new Color32(209, 229, 244, 255), | ||
new Color32(181, 202, 215, 255), | ||
new Color32(154, 174, 187, 255), | ||
new Color32(128, 148, 160, 255), | ||
new Color32(101, 121, 133, 255), | ||
new Color32(78, 97, 108, 255), | ||
new Color32(55, 73, 85, 255), | ||
new Color32(32, 51, 61, 255), | ||
new Color32(9, 30, 40, 255), | ||
new Color32(0, 0, 0, 255), | ||
new Color32(255, 255, 255, 255), | ||
new Color32(255, 251, 255, 255), | ||
new Color32(245, 238, 255, 255), | ||
new Color32(230, 222, 255, 255), | ||
new Color32(202, 193, 234, 255), | ||
new Color32(174, 166, 206, 255), | ||
new Color32(147, 140, 177, 255), | ||
new Color32(120, 114, 150, 255), | ||
new Color32(96, 90, 124, 255), | ||
new Color32(72, 66, 100, 255), | ||
new Color32(50, 44, 76, 255), | ||
new Color32(29, 23, 54, 255), | ||
new Color32(0, 0, 0, 255), | ||
new Color32(255, 255, 255, 255), | ||
new Color32(252, 252, 255, 255), | ||
new Color32(240, 240, 243, 255), | ||
new Color32(225, 227, 229, 255), | ||
new Color32(197, 199, 201, 255), | ||
new Color32(170, 171, 174, 255), | ||
new Color32(143, 145, 147, 255), | ||
new Color32(116, 118, 121, 255), | ||
new Color32(92, 95, 97, 255), | ||
new Color32(69, 71, 73, 255), | ||
new Color32(46, 49, 51, 255), | ||
new Color32(25, 28, 30, 255), | ||
new Color32(0, 0, 0, 255), | ||
new Color32(255, 255, 255, 255), | ||
new Color32(249, 252, 255, 255), | ||
new Color32(235, 241, 248, 255), | ||
new Color32(220, 227, 233, 255), | ||
new Color32(192, 199, 205, 255), | ||
new Color32(165, 172, 178, 255), | ||
new Color32(138, 146, 151, 255), | ||
new Color32(112, 119, 124, 255), | ||
new Color32(88, 95, 101, 255), | ||
new Color32(64, 72, 77, 255), | ||
new Color32(42, 49, 54, 255), | ||
new Color32(22, 28, 32, 255), | ||
new Color32(0, 0, 0, 255), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(Image))] | ||
public class ImageMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
var component = GetComponent<Image>(); | ||
_colorValue.a = component.color.a; | ||
component.color = _colorValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using UnityEngine; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
public class MonetColorer : MonoBehaviour | ||
{ | ||
[SerializeField, Range(0, 51)] protected int _color; | ||
|
||
protected Color _colorValue; | ||
|
||
private void Awake() => UpdateColor(); | ||
|
||
public virtual void UpdateColor() => _colorValue = Colors.GetColor(_color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(Outline))] | ||
public class OutlineMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
Outline outline = null; | ||
foreach (var component in GetComponents<Outline>()) if (component.GetType() == typeof(Outline)) outline = component; | ||
if (outline != null) | ||
{ | ||
_colorValue.a = outline.effectColor.a; | ||
outline.effectColor = _colorValue; | ||
} | ||
else throw new NullReferenceException("You don't have an Outline component. or something went wrong..."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(RawImage))] | ||
public class RawImageMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
var component = GetComponent<RawImage>(); | ||
_colorValue.a = component.color.a; | ||
component.color = _colorValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(Shadow))] | ||
public class ShadowMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
Shadow shadow = null; | ||
foreach (var component in GetComponents<Shadow>()) if (component.GetType() == typeof(Shadow)) shadow = component; | ||
if (shadow != null) | ||
{ | ||
_colorValue.a = shadow.effectColor.a; | ||
shadow.effectColor = _colorValue; | ||
} | ||
else throw new NullReferenceException("You don't have a Shadow component. or something went wrong..."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Smoothie.MonetColors.Runtime | ||
{ | ||
[RequireComponent(typeof(Text))] | ||
public class TextMonetColorer : MonetColorer | ||
{ | ||
public override void UpdateColor() | ||
{ | ||
base.UpdateColor(); | ||
var component = GetComponent<Text>(); | ||
_colorValue.a = component.color.a; | ||
component.color = _colorValue; | ||
} | ||
} | ||
} |
Oops, something went wrong.