Skip to content
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
6 changes: 0 additions & 6 deletions .gitattributes

This file was deleted.

77 changes: 0 additions & 77 deletions .yamato/upm-ci-SpringBone.yml

This file was deleted.

19 changes: 1 addition & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Changelog
All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.2.2] - 2021-10-15
### Added
- *conditional* localization attribute definition. Fixes editor script import on 2020.3 while preserving functions on 2019.4.

### Fixed
- Gizmos are not shown when scaled.
- Null pointer exception when SpringBonePivot is selected on the hierarchy.


## [1.2.1-preview] - 2020-12-10
### Fixed
- Assembly issue during buid.

## [1.2.0-preview] - 2020-12-02
### Changed
- Set default language to English. Except Inspector GUI yet.
- Minimum supported Unity version is 2019.4

## [1.1.0] - 2019-10-31
*This is the first version of UnityChan Spring Bone in the package form.*

Expand Down
12 changes: 0 additions & 12 deletions Documentation~/index.md

This file was deleted.

7 changes: 0 additions & 7 deletions Editor/AssmblyInfo.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Editor/AssmblyInfo.cs.meta

This file was deleted.

5 changes: 0 additions & 5 deletions Editor/AutoSpringBoneSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
#if UNITY_2020_2_OR_NEWER
using Localization = UnityEditor.L10n;
#else
using Localization = UnityEditor.Localization.Editor.Localization;
#endif

namespace Unity.Animations.SpringBones
{
Expand Down
1 change: 0 additions & 1 deletion Editor/GUI/Inspectors/SpringBonePivotInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public override void OnInspectorGUI()
{
InitializeData();

SpringBoneGUIStyles.ReacquireStyles();
if (GUILayout.Button("ボーンを選択", SpringBoneGUIStyles.ButtonStyle))
{
Selection.objects = bones.Select(bone => bone.gameObject).ToArray();
Expand Down
81 changes: 28 additions & 53 deletions Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,15 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
#if UNITY_2020_2_OR_NEWER
using Localization = UnityEditor.L10n;
#else
using Localization = UnityEditor.Localization.Editor.Localization;
#endif

namespace Unity.Animations.SpringBones
{
public class LoadSpringBoneSetupWindow : EditorWindow
{
private static class Styles
{
public static readonly string editorWindowTitle = Localization.Tr("Load spring bone setup");
public static readonly string stopPlayModeMessage = Localization.Tr("Do not setup in Play Mode");
public static readonly string selectObjectRootsMessage = Localization.Tr("Select parent object of the spring bone");
public static readonly string resultFormat = Localization.Tr("Set up complete:{0}\nNumber of bones: {1} Number of colliders: {2}");
public static readonly string csvFile = Localization.Tr("CSV File");
public static readonly string textFile = Localization.Tr("Text File");
public static readonly string loadSpringBoneSetup = Localization.Tr("Load spring bone setup");
public static readonly string errorFormat = Localization.Tr(
"SpringBone setup failed.\n"
+ "Souce data may contain errors,\n"
+ "or the data don't match the character.\n"
+ "Please refer console logs for further info.\n"
+ "\n"
+ "Character: {0}\n"
+ "\n"
+ "Path: {1}");

public static readonly string springBoneSetup = Localization.Tr("SpringBone Setup");
public static readonly string springBoneSetupFailedFormat = Localization.Tr("SpringBone Setup failed:{0}\nPath:{1}");
public static readonly string labelSpringBoneRoot = Localization.Tr("SpringBone Root");

public static readonly GUIContent labelLoadingConfig = new GUIContent(Localization.Tr("Loading Configuration"));
public static readonly GUIContent labelSpringBone = new GUIContent(Localization.Tr("SpringBone"));
public static readonly GUIContent labelCollider = new GUIContent(Localization.Tr("Collider"));

public static readonly GUIContent labelSelectFromRoot = new GUIContent(Localization.Tr("Get root from selection"));
public static readonly GUIContent labelSetupLoadCSV = new GUIContent(Localization.Tr("Set up from CSV file"));
}

public static void ShowWindow()
{
var editorWindow = GetWindow<LoadSpringBoneSetupWindow>(Styles.editorWindowTitle);
var editorWindow = GetWindow<LoadSpringBoneSetupWindow>(
"スプリングボーンセットアップを読み込む");
if (editorWindow != null)
{
editorWindow.SelectObjectsFromSelection();
Expand All @@ -70,6 +35,8 @@ ref int yPos

// private

private const string StopPlayModeMessage = "再生モードでセットアップしないでください。";
private const string SelectObjectRootsMessage = "スプリングボーンの親オブジェクトを指定してください。";
private const int UIRowHeight = 24;
private const int UISpacing = 8;
private const int LabelWidth = 200;
Expand Down Expand Up @@ -107,11 +74,11 @@ private void ShowImportSettingsUI(ref Rect uiRect)
importSettings = new DynamicsSetup.ImportSettings();
}

GUI.Label(uiRect, Styles.labelLoadingConfig, SpringBoneGUIStyles.HeaderLabelStyle);
GUI.Label(uiRect, "読み込み設定", SpringBoneGUIStyles.HeaderLabelStyle);
uiRect.y += uiRect.height;
importSettings.ImportSpringBones = GUI.Toggle(uiRect, importSettings.ImportSpringBones, Styles.labelSpringBone, SpringBoneGUIStyles.ToggleStyle);
importSettings.ImportSpringBones = GUI.Toggle(uiRect, importSettings.ImportSpringBones, "スプリングボーン", SpringBoneGUIStyles.ToggleStyle);
uiRect.y += uiRect.height;
importSettings.ImportCollision = GUI.Toggle(uiRect, importSettings.ImportCollision, Styles.labelCollider, SpringBoneGUIStyles.ToggleStyle);
importSettings.ImportCollision = GUI.Toggle(uiRect, importSettings.ImportCollision, "コライダー", SpringBoneGUIStyles.ToggleStyle);
uiRect.y += uiRect.height;
}

Expand All @@ -123,9 +90,9 @@ private void OnGUI()

var uiWidth = (int)position.width - UISpacing * 2;
var yPos = UISpacing;
springBoneRoot = DoObjectPicker(Styles.labelSpringBoneRoot, springBoneRoot, uiWidth, UIRowHeight, ref yPos);
springBoneRoot = DoObjectPicker("スプリングボーンのルート", springBoneRoot, uiWidth, UIRowHeight, ref yPos);
var buttonRect = new Rect(UISpacing, yPos, uiWidth, ButtonHeight);
if (GUI.Button(buttonRect, Styles.labelSelectFromRoot, SpringBoneGUIStyles.ButtonStyle))
if (GUI.Button(buttonRect, "選択からルートを取得", SpringBoneGUIStyles.ButtonStyle))
{
SelectObjectsFromSelection();
}
Expand All @@ -137,7 +104,7 @@ private void OnGUI()
string errorMessage;
if (IsOkayToSetup(out errorMessage))
{
if (GUI.Button(buttonRect, Styles.labelSetupLoadCSV, SpringBoneGUIStyles.ButtonStyle))
if (GUI.Button(buttonRect, "CSVを読み込んでセットアップ", SpringBoneGUIStyles.ButtonStyle))
{
BrowseAndLoadSpringSetup();
}
Expand All @@ -155,13 +122,13 @@ private bool IsOkayToSetup(out string errorMessage)
errorMessage = "";
if (EditorApplication.isPlaying)
{
errorMessage = Styles.stopPlayModeMessage;
errorMessage = StopPlayModeMessage;
return false;
}

if (springBoneRoot == null)
{
errorMessage = Styles.selectObjectRootsMessage;
errorMessage = SelectObjectRootsMessage;
return false;
}
return true;
Expand Down Expand Up @@ -202,10 +169,11 @@ public void Perform()
setup.Build();
AssetDatabase.Refresh();

const string ResultFormat = "セットアップ完了: {0}\nボーン数: {1} コライダー数: {2}";
var boneCount = springBoneRoot.GetComponentsInChildren<SpringBone>(true).Length;
var colliderCount = SpringColliderSetup.GetColliderTypes()
.Sum(type => springBoneRoot.GetComponentsInChildren(type, true).Length);
var resultMessage = string.Format(Styles.resultFormat, path, boneCount, colliderCount);
var resultMessage = string.Format(ResultFormat, path, boneCount, colliderCount);
Debug.Log(resultMessage);
}

Expand All @@ -216,17 +184,18 @@ public void Perform()

private void BrowseAndLoadSpringSetup()
{
if (!IsOkayToSetup(out var checkErrorMessage))
string checkErrorMessage;
if (!IsOkayToSetup(out checkErrorMessage))
{
Debug.LogError(checkErrorMessage);
return;
}

// var initialPath = "";
var initialDirectory = ""; // System.IO.Path.GetDirectoryName(initialPath);
var fileFilters = new string[] { Styles.csvFile, "csv", Styles.textFile, "txt" };
var fileFilters = new string[] { "CSVファイル", "csv", "テキストファイル", "txt" };
var path = EditorUtility.OpenFilePanelWithFilters(
Styles.loadSpringBoneSetup, initialDirectory, fileFilters);
"スプリングボーンセットアップを読み込む", initialDirectory, fileFilters);
if (path.Length == 0) { return; }

var sourceText = FileUtil.ReadAllText(path);
Expand All @@ -247,10 +216,16 @@ private void BrowseAndLoadSpringSetup()
}
else
{
var resultErrorMessage = string.Format(Styles.errorFormat, springBoneRoot.name, path);
EditorUtility.DisplayDialog(Styles.springBoneSetup, resultErrorMessage, "OK");
Debug.LogFormat(LogType.Error, LogOption.None, springBoneRoot,
Styles.springBoneSetupFailedFormat, springBoneRoot.name, path);
const string ErrorFormat =
"スプリングボーンセットアップが失敗しました。\n"
+ "元データにエラーがあるか、もしくは\n"
+ "キャラクターにデータが一致しません。\n"
+ "詳しくはConsoleのログをご覧下さい。\n\n"
+ "キャラクター: {0}\n\n"
+ "パス: {1}";
var resultErrorMessage = string.Format(ErrorFormat, springBoneRoot.name, path);
EditorUtility.DisplayDialog("スプリングボーンセットアップ", resultErrorMessage, "OK");
Debug.LogError("スプリングボーンセットアップ失敗: " + springBoneRoot.name + "\n" + path);
}
Close();
}
Expand Down
Loading