mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 22:39:39 -05:00
VRM10Object を作成するステップ
* VRM10Object が無いときにエラー表示 * VRM10Object が無ければ VRM10Instance を停止させる
This commit is contained in:
@@ -35,15 +35,15 @@ namespace UniGLTF
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string GetDir(string title, string name)
|
||||
public static string GetDir(string title, string dir = null)
|
||||
{
|
||||
string directory = m_lastExportDir;
|
||||
string directory = string.IsNullOrEmpty(dir) ? m_lastExportDir : dir;
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
{
|
||||
directory = Directory.GetParent(Application.dataPath).ToString();
|
||||
}
|
||||
|
||||
var path = EditorUtility.SaveFolderPanel(title, directory, name);
|
||||
var path = EditorUtility.SaveFolderPanel(title, directory, null);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/");
|
||||
|
||||
@@ -115,6 +115,21 @@ namespace UniVRM10
|
||||
return loaded;
|
||||
}
|
||||
|
||||
static string GetSaveName(Vrm10Instance instance)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return "Assets/vrm-1.0.assets";
|
||||
}
|
||||
|
||||
if (VRMShaders.PathObject.TryGetFromAsset(instance, out var asset))
|
||||
{
|
||||
return (asset.Parent.Child(instance.name + ".asset")).UnityAssetPath;
|
||||
}
|
||||
|
||||
return $"Assets/{instance.name}.assets";
|
||||
}
|
||||
|
||||
void SetupVRM10Object(Vrm10Instance instance)
|
||||
{
|
||||
if (!CheckHumanoid(instance.gameObject))
|
||||
@@ -124,10 +139,17 @@ namespace UniVRM10
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Humanoid OK.", MessageType.Info);
|
||||
|
||||
// VRM10Object
|
||||
var prop = serializedObject.FindProperty(nameof(Vrm10Instance.Vrm));
|
||||
if (prop.objectReferenceValue == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("No VRM10Object.", MessageType.Error);
|
||||
}
|
||||
if (GUILayout.Button("Create new VRM10Object"))
|
||||
{
|
||||
var saveName = (instance.name ?? "vrm-1.0");
|
||||
var dir = SaveFileDialog.GetDir(SaveTitle, saveName);
|
||||
var saveName = GetSaveName(instance);
|
||||
var dir = SaveFileDialog.GetDir(SaveTitle, System.IO.Path.GetDirectoryName(saveName));
|
||||
if (!string.IsNullOrEmpty(dir))
|
||||
{
|
||||
var expressions = new Dictionary<ExpressionPreset, VRM10Expression>();
|
||||
@@ -146,7 +168,6 @@ namespace UniVRM10
|
||||
{
|
||||
// update editor
|
||||
serializedObject.Update();
|
||||
var prop = serializedObject.FindProperty(nameof(Vrm10Instance.Vrm));
|
||||
prop.objectReferenceValue = asset;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,13 @@ namespace UniVRM10
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (Vrm == null)
|
||||
{
|
||||
Debug.LogError("no VRM10Object");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// cause new Vrm10Runtime.
|
||||
// init LookAt init rotation.
|
||||
var runtime = Runtime;
|
||||
|
||||
@@ -161,14 +161,22 @@ namespace VRMShaders
|
||||
}
|
||||
|
||||
var assetPath = AssetDatabase.GetAssetPath(src);
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
dst = default;
|
||||
return false;
|
||||
dst = FromUnityAssetPath(assetPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
dst = FromUnityAssetPath(assetPath);
|
||||
return true;
|
||||
var prefab = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(src);
|
||||
if (!string.IsNullOrEmpty(prefab))
|
||||
{
|
||||
dst = FromUnityAssetPath(prefab);
|
||||
return true;
|
||||
}
|
||||
|
||||
dst = default;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void ImportAsset()
|
||||
|
||||
Reference in New Issue
Block a user