Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change property drawers and gitignore #44

Merged
merged 10 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
**/.DS_Store
# Supyrb .gitignore standalone v0.1.4

# Unity generated
/Temp/**
/Library/**
/obj/**

# Visual Studio / MonoDevelop generated
/ExportedObj/**
/obj
/.vs/**
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj

*.csproj
*.cache
*Resharper*
*ReSharper*
*.orig
*.orig.*
*sln*
.idea/**

# OS generated
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
report.xml
~$*

# Custom
/Builds/**
/Data/**
/Assets/Temp/**
/Assets/Temp.meta
6 changes: 6 additions & 0 deletions Assets/Difficulty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public enum Difficulty
{
Easy,
Medium,
Hard
}
12 changes: 12 additions & 0 deletions Assets/Difficulty.cs.meta

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

9 changes: 9 additions & 0 deletions Assets/Editor.meta

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

46 changes: 46 additions & 0 deletions Assets/Editor/ExcelExampleAssetPostProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using UnityQuickSheet;

///
/// !!! Machine generated code !!!
///
public class ExcelExampleAssetPostprocessor : AssetPostprocessor
{
private static readonly string filePath = "Assets/Example.xlsx";
private static readonly string assetFilePath = "Assets/ExcelExample.asset";
private static readonly string sheetName = "ExcelExample";

static void OnPostprocessAllAssets (string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (string asset in importedAssets)
{
if (!filePath.Equals (asset))
continue;

ExcelExample data = (ExcelExample)AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ExcelExample));
if (data == null) {
data = ScriptableObject.CreateInstance<ExcelExample> ();
data.SheetName = filePath;
data.WorksheetName = sheetName;
AssetDatabase.CreateAsset ((ScriptableObject)data, assetFilePath);
//data.hideFlags = HideFlags.NotEditable;
}

//data.dataArray = new ExcelQuery(filePath, sheetName).Deserialize<ExcelExampleData>().ToArray();

//ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
//EditorUtility.SetDirty (obj);

ExcelQuery query = new ExcelQuery(filePath, sheetName);
if (query != null && query.IsValid())
{
data.dataArray = query.Deserialize<ExcelExampleData>().ToArray();
ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
EditorUtility.SetDirty (obj);
}
}
}
}
12 changes: 12 additions & 0 deletions Assets/Editor/ExcelExampleAssetPostProcessor.cs.meta

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

36 changes: 36 additions & 0 deletions Assets/Editor/ExcelExampleEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using UnityQuickSheet;

///
/// !!! Machine generated code !!!
///
[CustomEditor(typeof(ExcelExample))]
public class ExcelExampleEditor : BaseExcelEditor<ExcelExample>
{
public override bool Load()
{
ExcelExample targetData = target as ExcelExample;

string path = targetData.SheetName;
if (!File.Exists(path))
return false;

string sheet = targetData.WorksheetName;

ExcelQuery query = new ExcelQuery(path, sheet);
if (query != null && query.IsValid())
{
targetData.dataArray = query.Deserialize<ExcelExampleData>().ToArray();
EditorUtility.SetDirty(targetData);
AssetDatabase.SaveAssets();
return true;
}
else
return false;
}
}
12 changes: 12 additions & 0 deletions Assets/Editor/ExcelExampleEditor.cs.meta

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

Binary file added Assets/Example.xlsx
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Example.xlsx.meta

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

56 changes: 56 additions & 0 deletions Assets/ExcelExample.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f7f4603b26f53c42a635564f38424ff, type: 3}
m_Name: ExcelExample
m_EditorClassIdentifier:
SheetName: Assets/Example.xlsx
WorksheetName: ExcelExample
dataArray:
- id: 0
name: Goblin
strength: 5
difficulty: 0
- id: 1
name: Wolf
strength: 5
difficulty: 0
- id: 2
name: Scavanger
strength: 7
difficulty: 0
- id: 3
name: Lurker
strength: 9
difficulty: 0
- id: 4
name: Sceleton
strength: 11
difficulty: 1
- id: 5
name: Ghost
strength: 13
difficulty: 1
- id: 6
name: Orc
strength: 15
difficulty: 1
- id: 7
name: Hydra
strength: 17
difficulty: 2
- id: 8
name: Undead
strength: 19
difficulty: 2
- id: 9
name: Dragon
strength: 21
difficulty: 2
9 changes: 9 additions & 0 deletions Assets/ExcelExample.asset.meta

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

43 changes: 43 additions & 0 deletions Assets/ExcelExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

///
/// !!! Machine generated code !!!
///
/// A class which deriveds ScritableObject class so all its data
/// can be serialized onto an asset data file.
///
[System.Serializable]
public class ExcelExample : ScriptableObject
{
[HideInInspector] [SerializeField]
public string SheetName = "";

[HideInInspector] [SerializeField]
public string WorksheetName = "";

// Note: initialize in OnEnable() not here.
public ExcelExampleData[] dataArray;

void OnEnable()
{
//#if UNITY_EDITOR
//hideFlags = HideFlags.DontSave;
//#endif
// Important:
// It should be checked an initialization of any collection data before it is initialized.
// Without this check, the array collection which already has its data get to be null
// because OnEnable is called whenever Unity builds.
//
if (dataArray == null)
dataArray = new ExcelExampleData[0];

}

//
// Highly recommand to use LINQ to query the data sources.
//

}
12 changes: 12 additions & 0 deletions Assets/ExcelExample.cs.meta

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

27 changes: 27 additions & 0 deletions Assets/ExcelExampleData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;
using System.Collections;

///
/// !!! Machine generated code !!!
/// !!! DO NOT CHANGE Tabs to Spaces !!!
///
[System.Serializable]
public class ExcelExampleData
{
[SerializeField]
int id;
public int Id { get {return id; } set { id = value;} }

[SerializeField]
string name;
public string Name { get {return name; } set { name = value;} }

[SerializeField]
float strength;
public float Strength { get {return strength; } set { strength = value;} }

[SerializeField]
Difficulty difficulty;
public Difficulty DIFFICULTY { get {return difficulty; } set { difficulty = value;} }

}
12 changes: 12 additions & 0 deletions Assets/ExcelExampleData.cs.meta

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

Loading