Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
- If the folders in database does not exist, now create it.
- Add new ID in team when create a new one
  • Loading branch information
mperez01 committed May 6, 2018
1 parent d35ac30 commit 2f5a92e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Characters.meta

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

2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Skills.meta

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

2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/SpecializedClasses.meta

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

2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Teams.meta

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

14 changes: 10 additions & 4 deletions Assets/TRPGMaker/Editor/Windows/Database/CharacterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ private void createButtonReorderableList()
Character character = (Character)ScriptableObject.CreateInstance(typeof(Character));
character.init();

var _exists = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Characters/NewCharacter.asset", typeof(Character));
var characterPath = "Assets/TRPGMaker/Database/Characters";
var _exists = AssetDatabase.LoadAssetAtPath(characterPath + "/NewCharacter.asset", typeof(Character));
if (_exists == null)
{
//Create the folder if doesn't exist
if (!System.IO.Directory.Exists(characterPath))
{
System.IO.Directory.CreateDirectory(characterPath);
}
character.name = "NewCharacter";
AssetDatabase.CreateAsset(character, "Assets/TRPGMaker/Database/Characters/NewCharacter.asset");
AssetDatabase.CreateAsset(character, characterPath + "/NewCharacter.asset");
}
else
{
Expand All @@ -141,11 +147,11 @@ private void createButtonReorderableList()
int i = 0;
while (i <= existAssets.Length && !seted)
{
var _existsNumber = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Characters/NewCharacter(" + (i + 1) + ").asset", typeof(Character));
var _existsNumber = AssetDatabase.LoadAssetAtPath(characterPath + "/NewCharacter(" + (i + 1) + ").asset", typeof(Character));
if (_existsNumber == null)
{
character.name = "NewCharacter(" + (i + 1) + ")";
AssetDatabase.CreateAsset(character, "Assets/TRPGMaker/Database/Characters/NewCharacter(" + (i + 1) + ").asset");
AssetDatabase.CreateAsset(character, characterPath + "/NewCharacter(" + (i + 1) + ").asset");
seted = true;
}
i++;
Expand Down
14 changes: 10 additions & 4 deletions Assets/TRPGMaker/Editor/Windows/Database/ItemWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ private void createButtonReorderableList()
listItems.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
Item item = (Item)ScriptableObject.CreateInstance(typeof(Item));

var _exists = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Items/New Item.asset", typeof(Item));
var itemPath = "Assets/TRPGMaker/Database/Items";
var _exists = AssetDatabase.LoadAssetAtPath(itemPath + "/New Item.asset", typeof(Item));
if (_exists == null)
{
//Create the folder if doesn't exist
if (!System.IO.Directory.Exists(itemPath))
{
System.IO.Directory.CreateDirectory(itemPath);
}
item.name = "New Item";
AssetDatabase.CreateAsset(item, "Assets/TRPGMaker/Database/Items/New Item.asset");
AssetDatabase.CreateAsset(item, itemPath + "/New Item.asset");
}
else
{
Expand All @@ -139,11 +145,11 @@ private void createButtonReorderableList()
int i = 0;
while (i <= existAssets.Length && !seted)
{
var _existsNumber = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Items/New Item(" + (i + 1) + ").asset", typeof(Item));
var _existsNumber = AssetDatabase.LoadAssetAtPath(itemPath + "/New Item(" + (i + 1) + ").asset", typeof(Item));
if (_existsNumber == null)
{
item.name = "New Item(" + (i + 1) + ")";
AssetDatabase.CreateAsset(item, "Assets/TRPGMaker/Database/Items/New Item(" + (i + 1) + ").asset");
AssetDatabase.CreateAsset(item, itemPath + "/New Item(" + (i + 1) + ").asset");
seted = true;
}
i++;
Expand Down
14 changes: 10 additions & 4 deletions Assets/TRPGMaker/Editor/Windows/Database/SkillsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,17 @@ private void createButtonReorderableList()
listSkills.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
Skills skill = (Skills)ScriptableObject.CreateInstance(typeof(Skills));

var _exists = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Skills/NewSkill.asset", typeof(Skills));
var skillPath = "Assets/TRPGMaker/Database/Skills";
var _exists = AssetDatabase.LoadAssetAtPath(skillPath + "/NewSkill.asset", typeof(Skills));
if (_exists == null)
{
//Create the folder if doesn't exist
if (!System.IO.Directory.Exists(skillPath))
{
System.IO.Directory.CreateDirectory(skillPath);
}
skill.name = "NewSkill";
AssetDatabase.CreateAsset(skill, "Assets/TRPGMaker/Database/Skills/NewSkill.asset");
AssetDatabase.CreateAsset(skill, skillPath + "/NewSkill.asset");
}
else
{
Expand All @@ -140,11 +146,11 @@ private void createButtonReorderableList()
int i = 0;
while (i <= existAssets.Length && !seted)
{
var _existsNumber = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Skills/NewSkill(" + (i + 1) + ").asset", typeof(Skills));
var _existsNumber = AssetDatabase.LoadAssetAtPath(skillPath + "/NewSkill(" + (i + 1) + ").asset", typeof(Skills));
if (_existsNumber == null)
{
skill.name = "NewSkill(" + (i + 1) + ")";
AssetDatabase.CreateAsset(skill, "Assets/TRPGMaker/Database/Skills/NewSkill(" + (i + 1) + ").asset");
AssetDatabase.CreateAsset(skill, skillPath + "/NewSkill(" + (i + 1) + ").asset");
seted = true;
}
i++;
Expand Down
14 changes: 10 additions & 4 deletions Assets/TRPGMaker/Editor/Windows/Database/SpecializedClassWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ private void createButtonReorderableList()
SpecializedClass specializedClass = (SpecializedClass)ScriptableObject.CreateInstance(typeof(SpecializedClass));
specializedClass.Init();

var _exists = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset", typeof(SpecializedClass));
var specializedClassesPath = "Assets/TRPGMaker/Database/SpecializedClasses";
var _exists = AssetDatabase.LoadAssetAtPath(specializedClassesPath + "/NewSpecializedClass.asset", typeof(SpecializedClass));
if (_exists == null)
{
//Create the folder if doesn't exist
if (!System.IO.Directory.Exists(specializedClassesPath))
{
System.IO.Directory.CreateDirectory(specializedClassesPath);
}
specializedClass.name = "New Specialized Class";
AssetDatabase.CreateAsset(specializedClass, "Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset");
AssetDatabase.CreateAsset(specializedClass, specializedClassesPath + "/NewSpecializedClass.asset");
}
else
{
Expand All @@ -141,11 +147,11 @@ private void createButtonReorderableList()
int i = 0;
while(i <= existAssets.Length && !seted)
{
var _existsNumber = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass(" + (i + 1) + ").asset", typeof(SpecializedClass));
var _existsNumber = AssetDatabase.LoadAssetAtPath(specializedClassesPath + "/NewSpecializedClass(" + (i + 1) + ").asset", typeof(SpecializedClass));
if(_existsNumber == null)
{
specializedClass.name = "New Specialized Class (" + (i+1) + ")";
AssetDatabase.CreateAsset(specializedClass, "Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass(" + (i+1) + ").asset");
AssetDatabase.CreateAsset(specializedClass, specializedClassesPath + "/NewSpecializedClass(" + (i+1) + ").asset");
seted = true;
}
i++;
Expand Down
17 changes: 12 additions & 5 deletions Assets/TRPGMaker/Editor/Windows/Database/TeamsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void createButtonReorderableList()
var element = listTeams.serializedProperty.GetArrayElementAtIndex(index);
var team = element.objectReferenceValue as Team;
rect.y += 2;
EditorGUI.LabelField(rect, team.id + ": " + team.name);
EditorGUI.LabelField(rect, team.name);
};

// On select team
Expand All @@ -126,11 +126,18 @@ private void createButtonReorderableList()
listTeams.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
Team team = (Team)ScriptableObject.CreateInstance(typeof(Team));

var _exists = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Teams/NewTeam.asset", typeof(Team));
var teamPath = "Assets/TRPGMaker/Database/Teams";
var _exists = AssetDatabase.LoadAssetAtPath(teamPath + "/NewTeam.asset", typeof(Team));
team.id = Database.Instance.teams.Count;
if (_exists == null)
{
//Create the folder if doesn't exist
if (!System.IO.Directory.Exists(teamPath))
{
System.IO.Directory.CreateDirectory(teamPath);
}
team.name = "NewTeam";
AssetDatabase.CreateAsset(team, "Assets/TRPGMaker/Database/Teams/NewTeam.asset");
AssetDatabase.CreateAsset(team, teamPath + "/NewTeam.asset");
}
else
{
Expand All @@ -139,11 +146,11 @@ private void createButtonReorderableList()
int i = 0;
while (i <= existAssets.Length && !seted)
{
var _existsNumber = AssetDatabase.LoadAssetAtPath("Assets/TRPGMaker/Database/Teams/NewTeam(" + (i + 1) + ").asset", typeof(Team));
var _existsNumber = AssetDatabase.LoadAssetAtPath(teamPath + "/NewTeam(" + (i + 1) + ").asset", typeof(Team));
if (_existsNumber == null)
{
team.name = "NewTeam(" + (i + 1) + ")";
AssetDatabase.CreateAsset(team, "Assets/TRPGMaker/Database/Teams/NewTeam(" + (i + 1) + ").asset");
AssetDatabase.CreateAsset(team, teamPath + "/NewTeam(" + (i + 1) + ").asset");
seted = true;
}
i++;
Expand Down

0 comments on commit 2f5a92e

Please sign in to comment.