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: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.* export-ignore
/Documentation~ export-ignore
/Tests export-ignore
/Tests.meta export-ignore


77 changes: 77 additions & 0 deletions .yamato/upm-ci-SpringBone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
yamato_name: SpringBone
test_editors:
- version: 2019.4
- version: 2020.3
- version: 2021.1
test_platforms:
- name: win
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
- name: mac
type: Unity::VM::osx
image: package-ci/mac:stable
flavor: m1.mac
---
pack:
name: Pack {{ yamato_name }}
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
commands:
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
- upm-ci package pack
artifacts:
{{ yamato_name }}_pack_artifacts:
paths:
- "upm-ci~/**/*"

{% for editor in test_editors %}
{% for platform in test_platforms %}
test_{{ platform.name }}_{{ editor.version }}:
name : Test {{ yamato_name }} using {{ editor.version }} on {{ platform.name }}
agent:
type: {{ platform.type }}
image: {{ platform.image }}
flavor: {{ platform.flavor}}
commands:
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
- upm-ci package test --unity-version {{ editor.version }}
triggers:
branches:
only:
- "/.*/"
artifacts:
{{ yamato_name }}_test_results:
paths:
- "upm-ci~/test-results/**/*"
dependencies:
- .yamato/upm-ci-{{ yamato_name }}.yml#pack
{% endfor %}
{% endfor %}

publish:
name: Publish {{ yamato_name }} to Internal Registry
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
commands:
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
- upm-ci package publish
triggers:
tags:
only:
- /^(r|R)(c|C)-\d+\.\d+\.\d+(-preview(\.\d+)?)?$/
artifacts:
{{ yamato_name }}_publish_artifacts:
paths:
- "upm-ci~/packages/*.tgz"
dependencies:
- .yamato/upm-ci-{{ yamato_name }}.yml#pack
{% for editor in test_editors %}
{% for platform in test_platforms %}
- .yamato/upm-ci-{{ yamato_name }}.yml#test_{{ platform.name }}_{{ editor.version }}
{% endfor %}
{% endfor %}
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# 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: 12 additions & 0 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>>>
**_Springbone Documentation_**

Work in progress

## Document revision history
>>>

|Date|Reason|
|---|---|
|Oct 16, 2021|Document created. Matches package version 1.2.2-preview|
>>>
7 changes: 7 additions & 0 deletions Editor/AssmblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#if UNITY_2020_1_OR_NEWER
using Localization = UnityEditor.LocalizationAttribute;
#else
using Localization = UnityEditor.Localization.Editor.LocalizationAttribute;
#endif

[assembly: Localization]
11 changes: 11 additions & 0 deletions Editor/AssmblyInfo.cs.meta

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

5 changes: 5 additions & 0 deletions Editor/AutoSpringBoneSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
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: 1 addition & 0 deletions Editor/GUI/Inspectors/SpringBonePivotInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public override void OnInspectorGUI()
{
InitializeData();

SpringBoneGUIStyles.ReacquireStyles();
if (GUILayout.Button("ボーンを選択", SpringBoneGUIStyles.ButtonStyle))
{
Selection.objects = bones.Select(bone => bone.gameObject).ToArray();
Expand Down
81 changes: 53 additions & 28 deletions Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
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>(
"スプリングボーンセットアップを読み込む");
var editorWindow = GetWindow<LoadSpringBoneSetupWindow>(Styles.editorWindowTitle);
if (editorWindow != null)
{
editorWindow.SelectObjectsFromSelection();
Expand All @@ -35,8 +70,6 @@ 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 @@ -74,11 +107,11 @@ private void ShowImportSettingsUI(ref Rect uiRect)
importSettings = new DynamicsSetup.ImportSettings();
}

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

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

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

if (springBoneRoot == null)
{
errorMessage = SelectObjectRootsMessage;
errorMessage = Styles.selectObjectRootsMessage;
return false;
}
return true;
Expand Down Expand Up @@ -169,11 +202,10 @@ 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(ResultFormat, path, boneCount, colliderCount);
var resultMessage = string.Format(Styles.resultFormat, path, boneCount, colliderCount);
Debug.Log(resultMessage);
}

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

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

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

var sourceText = FileUtil.ReadAllText(path);
Expand All @@ -216,16 +247,10 @@ private void BrowseAndLoadSpringSetup()
}
else
{
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);
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);
}
Close();
}
Expand Down
Loading