-
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.
Merge pull request #4 from mohsinkhan26/Development
button extension added
- Loading branch information
Showing
26 changed files
with
247 additions
and
33 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
Unity Project/Assets/MK Assets/Common/Editor/Extension/ButtonExtensionEditor.cs
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,39 @@ | ||
/* | ||
* Author : Mohsin Khan | ||
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/ | ||
* Github : https://github.com/mohsinkhan26/ | ||
* BitBucket : https://bitbucket.org/unbounded-eagle/ | ||
*/ | ||
using UnityEngine.UI; | ||
|
||
namespace UnityEditor.UI | ||
{ | ||
[CustomEditor(typeof(ButtonExtension), true)] | ||
[CanEditMultipleObjects] | ||
public class ButtonExtensionEditor : ButtonEditor | ||
{ | ||
SerializedProperty m_Text; | ||
SerializedProperty m_Animator; | ||
|
||
protected override void OnEnable() | ||
{ | ||
base.OnEnable(); | ||
|
||
m_Text = serializedObject.FindProperty("m_textComponent"); | ||
m_Animator = serializedObject.FindProperty("m_animator"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
base.OnInspectorGUI(); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
serializedObject.Update(); | ||
EditorGUILayout.PropertyField(m_Text); | ||
EditorGUILayout.PropertyField(m_Animator); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Unity Project/Assets/MK Assets/Common/Editor/Extension/ButtonExtensionEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, 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
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
4 changes: 3 additions & 1 deletion
4
Unity Project/Assets/MK Assets/Common/Editor/Miscellaneous/GameUtilities.cs
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
75 changes: 75 additions & 0 deletions
75
Unity Project/Assets/MK Assets/Common/Extensions/ButtonExtension.cs
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,75 @@ | ||
/* | ||
* Author : Mohsin Khan | ||
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/ | ||
* Github : https://github.com/mohsinkhan26/ | ||
* BitBucket : https://bitbucket.org/unbounded-eagle/ | ||
*/ | ||
using System; | ||
|
||
|
||
namespace UnityEngine.UI | ||
{ | ||
/// <summary> | ||
/// It extends Button component makes accesible of its Text component and animator if attached | ||
/// </summary> | ||
[AddComponentMenu("UI/Extensions/Button Extended"), RequireComponent(typeof(RectTransform))] | ||
public class ButtonExtension : Button | ||
{ | ||
[Header("Extended Properties")] | ||
[SerializeField] | ||
Text | ||
m_textComponent; | ||
|
||
[SerializeField] | ||
Animator | ||
m_animator; | ||
|
||
public Text TextComponent | ||
{ | ||
get | ||
{ | ||
if (m_textComponent == null) | ||
throw new NullReferenceException("Text component is not set in Inspector on " + name); | ||
else | ||
return m_textComponent; | ||
} | ||
set | ||
{ | ||
m_textComponent = value; | ||
} | ||
} | ||
|
||
public string text | ||
{ // to get Text or TextExtension component, you must have to assign one at a time | ||
get | ||
{ | ||
if (m_textComponent == null) | ||
throw new NullReferenceException("Text component is not set in Inspector on " + name); | ||
else | ||
return m_textComponent.text; | ||
} | ||
set | ||
{ | ||
if (m_textComponent != null) | ||
m_textComponent.text = value; | ||
} | ||
} | ||
|
||
public Animator AnimatorController | ||
{ | ||
get | ||
{ | ||
if (m_animator == null) | ||
throw new NullReferenceException("Animator component is not set in Inspector on " + name); | ||
else | ||
return m_animator; | ||
} | ||
set | ||
{ | ||
m_animator = value; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
Unity Project/Assets/MK Assets/Common/Extensions/ButtonExtension.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
Unity Project/Assets/MK Assets/Common/Extensions/MonoExtension.cs
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
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
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
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
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
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
4 changes: 3 additions & 1 deletion
4
Unity Project/Assets/MK Assets/Common/Managers/SceneController.cs
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
Oops, something went wrong.