-
Notifications
You must be signed in to change notification settings - Fork 190
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 #29 from kimsama/feature/array-support
Feature/array support
- Loading branch information
Showing
65 changed files
with
44,748 additions
and
567 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// BaseEditor.cs | ||
/// | ||
/// (c)2016 Kim, Hyoun Woo | ||
/// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
using UnityEngine; | ||
using UnityEditor; | ||
using System.Collections; | ||
|
||
namespace UnityQuickSheet | ||
{ | ||
/// <summary> | ||
/// Base class which draws properties of the created scriptableobject. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class BaseEditor<T> : Editor where T : ScriptableObject | ||
{ | ||
protected SerializedObject targetObject; | ||
protected SerializedProperty spreadsheetProp; | ||
protected SerializedProperty worksheetProp; | ||
protected SerializedProperty serializedData; | ||
|
||
protected GUIStyle brown; | ||
protected bool isGUISkinInitialized = false; | ||
|
||
/// <summary> | ||
/// Create SerialliedObject and initialize related SerializedProperty objects | ||
/// which are needed to draw data on the Inspector view. | ||
/// </summary> | ||
public virtual void OnEnable() | ||
{ | ||
T t = (T)target; | ||
targetObject = new SerializedObject(t); | ||
|
||
spreadsheetProp = targetObject.FindProperty("SheetName"); | ||
if (spreadsheetProp == null) | ||
Debug.LogError("Failed to find 'SheetName' property."); | ||
|
||
worksheetProp = targetObject.FindProperty("WorksheetName"); | ||
if (worksheetProp == null) | ||
Debug.LogError("Failed to find 'WorksheetName' property."); | ||
|
||
serializedData = targetObject.FindProperty("dataArray"); | ||
if (serializedData == null) | ||
Debug.LogError("Failed to find 'dataArray' member field."); | ||
} | ||
|
||
/// <summary> | ||
/// Create and initialize a new gui style which can be used for representing | ||
/// each element of dataArray. | ||
/// </summary> | ||
protected void InitGUIStyle() | ||
{ | ||
brown = new GUIStyle("box"); | ||
brown.normal.background = Resources.Load("brown", typeof(Texture2D)) as Texture2D; | ||
brown.border = new RectOffset(4, 4, 4, 4); | ||
brown.margin = new RectOffset(3, 3, 3, 3); | ||
brown.padding = new RectOffset(4, 4, 4, 4); | ||
} | ||
|
||
/// <summary> | ||
/// Draw serialized properties on the Inspector view. | ||
/// </summary> | ||
/// <param name="useGUIStyle"></param> | ||
protected void DrawInspector(bool useGUIStyle = true) | ||
{ | ||
// Draw 'spreadsheet' and 'worksheet' name. | ||
EditorGUILayout.TextField(spreadsheetProp.name, spreadsheetProp.stringValue); | ||
EditorGUILayout.TextField(worksheetProp.name, worksheetProp.stringValue); | ||
|
||
// Draw properties of the data class. | ||
if (useGUIStyle && !isGUISkinInitialized) | ||
{ | ||
isGUISkinInitialized = true; | ||
InitGUIStyle(); | ||
} | ||
|
||
if (useGUIStyle) | ||
GUIHelper.DrawSerializedProperty(serializedData, brown); | ||
else | ||
GUIHelper.DrawSerializedProperty(serializedData, brown); | ||
} | ||
|
||
/// | ||
/// Called when 'Update'(or 'Download' for google data) button is pressed. | ||
/// It should be reimplemented in the derived class. | ||
/// | ||
public virtual bool Load() | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
6 changes: 5 additions & 1 deletion
6
.../GDataPlugin/Runtime/BaseDatabase.cs.meta → Assets/QuickSheet/Editor/BaseEditor.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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.