Skip to content

Commit

Permalink
Merge pull request #4 from mohsinkhan26/Development
Browse files Browse the repository at this point in the history
button extension added
  • Loading branch information
mohsinkhan26 committed Jul 13, 2017
2 parents b1139b7 + 7c2ba9c commit 4b5570d
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 33 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Also, It is structured properly with the namespace that it would not conflict wi
* **WebData** - allows you to download text data from given URL

### Editor Module/Feature list: ###
* **TextExtension** - extended Text component with text Id field added
* **ButtonExtension** - extended Button component with text and animator field added
* **TextExtension** - extended Text component with text Id and animator field added
* **ToggleExtension** - extended Toggle component to add support for Text and TextExtension to edit text of toggle, animator
* Anchors selected UI to corners
* Find gameObjects which have missing scripts
Expand Down
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();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEngine.UI;

Expand All @@ -11,12 +13,14 @@ namespace UnityEditor.UI
public class TextExtensionEditor : TextEditor
{
SerializedProperty m_TextId;
SerializedProperty m_Animator;

protected override void OnEnable()
{
base.OnEnable();

m_TextId = serializedObject.FindProperty("m_textId");
m_Animator = serializedObject.FindProperty("m_animator");
}

public override void OnInspectorGUI()
Expand All @@ -27,6 +31,7 @@ public override void OnInspectorGUI()

serializedObject.Update();
EditorGUILayout.PropertyField(m_TextId);
EditorGUILayout.PropertyField(m_Animator);

serializedObject.ApplyModifiedProperties();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEngine.UI;

Expand All @@ -20,7 +22,7 @@ protected override void OnEnable()

m_Text = serializedObject.FindProperty("m_textComponent");
m_TextExtension = serializedObject.FindProperty("m_textExtensionComponent");
m_Animator = serializedObject.FindProperty("m_Animator");
m_Animator = serializedObject.FindProperty("m_animator");
}

public override void OnInspectorGUI()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEditor;
using UnityEngine;
Expand Down
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;
}
}
}
}


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using System;
using UnityEngine;
Expand Down
27 changes: 25 additions & 2 deletions Unity Project/Assets/MK Assets/Common/Extensions/TextExtension.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* 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 Toggle component makes accesible of its Text component
/// It extends Toggle component makes accesible of its Text component and animator if attached
/// </summary>
[AddComponentMenu("UI/Extensions/Text Extended"), RequireComponent(typeof(RectTransform))]
public class TextExtension : Text
Expand All @@ -15,6 +19,10 @@ public class TextExtension : Text
string
m_textId;

[SerializeField]
Animator
m_animator;

public string textId
{
get
Expand All @@ -26,6 +34,21 @@ public string textId
m_textId = 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;
}
}
}
}

Expand Down
35 changes: 24 additions & 11 deletions Unity Project/Assets/MK Assets/Common/Extensions/ToggleExtension.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* 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 Toggle component makes accesible of its Text component
/// It extends Toggle component makes accesible of its Text, TextExtension component and animator if attached
/// </summary>
[AddComponentMenu("UI/Extensions/Toggle Extended"), RequireComponent(typeof(RectTransform))]
public class ToggleExtension : Toggle
Expand All @@ -18,11 +22,18 @@ public class ToggleExtension : Toggle
TextExtension
m_textExtensionComponent;

[SerializeField]
Animator
m_animator;

public Text TextComponent
{
get
{
return m_textComponent;
if (m_textComponent == null)
throw new NullReferenceException("Text component is not set in Inspector on " + name);
else
return m_textComponent;
}
set
{
Expand All @@ -34,7 +45,10 @@ public TextExtension TextExtensionComponent
{
get
{
return m_textExtensionComponent;
if (m_textExtensionComponent == null)
throw new NullReferenceException("TextExtension component is not set in Inspector on " + name);
else
return m_textExtensionComponent;
}
set
{
Expand All @@ -51,7 +65,7 @@ public string text
else if (m_textExtensionComponent != null)
return m_textExtensionComponent.text;
else
return null;
throw new NullReferenceException("TextExtension or Text component is not set in Inspector on " + name);
}
set
{
Expand All @@ -62,19 +76,18 @@ public string text
}
}

[SerializeField]
Animator
m_Animator;

public Animator AnimatorController
{
get
{
return m_Animator;
if (m_animator == null)
throw new NullReferenceException("Animator component is not set in Inspector on " + name);
else
return m_animator;
}
set
{
m_Animator = value;
m_animator = value;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Unity Project/Assets/MK Assets/Common/GameLogger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using System;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEngine;
using System;
Expand Down
4 changes: 3 additions & 1 deletion Unity Project/Assets/MK Assets/Common/Helpers/WebData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEngine;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Author : Mohsin Khan
* Website : http://mohsinkhan.000webhostapp.com/
* LinkedIn : http://pk.linkedin.com/in/mohsinkhan26/
* Github : https://github.com/mohsinkhan26/
* BitBucket : https://bitbucket.org/unbounded-eagle/
*/
using UnityEngine;
using MK.Common.Utilities;
Expand Down
Loading

0 comments on commit 4b5570d

Please sign in to comment.