Skip to content

Commit

Permalink
Merge pull request #44 from virtual-cast/update/to-v0.43.1
Browse files Browse the repository at this point in the history
Update to VCI v0.43.1
  • Loading branch information
amamagi authored Jan 21, 2025
2 parents 4c6ddd5 + 7803edf commit 65b50d5
Show file tree
Hide file tree
Showing 33 changed files with 527 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Assets/Effekseer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.thirdparty.effekseer",
"displayName": "Effekseer",
"version": "0.42.1",
"version": "0.43.1",
"unity": "2022.3",
"description": "",
"dependencies": {}
Expand Down
2 changes: 1 addition & 1 deletion Assets/NAudio/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.thirdparty.naudio",
"displayName": "NAudio",
"version": "0.42.1",
"version": "0.43.1",
"unity": "2022.3",
"description": "",
"dependencies": {}
Expand Down
19 changes: 17 additions & 2 deletions Assets/VCI/UniVCI/Editor/Inspectors/VCISubItemEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ namespace VCI
[CanEditMultipleObjects]
public sealed class VCISubItemEditor : Editor
{
private static readonly string[] CameraMaskOptions = { "Visible to Camera Items", "Invisible to Camera Items" };
private SerializedProperty grabbable;
private SerializedProperty scalable;
private SerializedProperty uniform;
private SerializedProperty attractable;
private SerializedProperty attractableDistance;
private SerializedProperty group;
private SerializedProperty isVisibleToCamera;

private void OnEnable()
{
Expand All @@ -21,6 +23,7 @@ private void OnEnable()
attractable = serializedObject.FindProperty("Attractable");
attractableDistance = serializedObject.FindProperty("AttractableDistance");
group = serializedObject.FindProperty("GroupId");
isVisibleToCamera = serializedObject.FindProperty("IsVisibleToCamera");
}

public override void OnInspectorGUI()
Expand All @@ -31,12 +34,17 @@ public override void OnInspectorGUI()
subItemParent == null ||
subItemParent.GetComponent<VCIObject>() == null ||
subItemParent.parent != null
) {
)
{
EditorGUILayout.HelpBox(VCIConfig.GetText("warning_subitem_not_under_vciobject"), MessageType.Error);
}


serializedObject.Update();
{
// 利用環境によらない設定
EditorGUILayout.LabelField("Common", EditorStyles.boldLabel);

using (var check = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(grabbable);
Expand All @@ -45,7 +53,6 @@ public override void OnInspectorGUI()
attractable.boolValue = grabbable.boolValue;
}
}

using (new EditorGUI.IndentLevelScope())
{
using (new EditorGUI.DisabledGroupScope(!grabbable.boolValue))
Expand Down Expand Up @@ -73,6 +80,14 @@ public override void OnInspectorGUI()
else if (!scalable.boolValue) uniform.boolValue = false;

EditorGUILayout.PropertyField(group);

// ルーム専用の設定
EditorGUILayout.LabelField("For Room", EditorStyles.boldLabel);

// カメラマスク
var selectedCameraMaskOption = isVisibleToCamera.boolValue ? 0 : 1;
selectedCameraMaskOption = EditorGUILayout.Popup("Camera Mask", selectedCameraMaskOption, CameraMaskOptions);
isVisibleToCamera.boolValue = selectedCameraMaskOption == 0; // 0: Visible, 1: Invisible
}

serializedObject.ApplyModifiedProperties();
Expand Down
12 changes: 8 additions & 4 deletions Assets/VCI/UniVCI/Editor/MenuExecutions/VCITemplateMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public static class VCITemplateMenu
[MenuItem("GameObject/VCI/Simple VCI", false, 0)]
public static void CreateSimpleVCI()
{
var vciObjectComponent = CreateVCIObject();
var vciObject = CreateVCIObject();

var vciSubItem = GameObject.CreatePrimitive(PrimitiveType.Cube);
vciSubItem.name = "Cube";
vciSubItem.transform.SetParent(vciObjectComponent.transform);
vciSubItem.transform.SetParent(vciObject.transform);
var vciSubItemObjectComponent = vciSubItem.AddComponent<VCISubItem>();
vciSubItemObjectComponent.Grabbable = true;

Undo.RegisterCreatedObjectUndo(vciObject, "Create Simple VCI");
}

[MenuItem("GameObject/VCI/Text", false, 0)]
Expand All @@ -30,9 +32,11 @@ public static void CreateVCIText()
tmp.enableWordWrapping = false;
tmp.alignment = TextAlignmentOptions.Center;
rt.sizeDelta = Vector2.one;

Undo.RegisterCreatedObjectUndo(go, "Create VCI Text");
}

private static VCIObject CreateVCIObject()
private static GameObject CreateVCIObject()
{
var vciObject = new GameObject("VCIObject");
var vciObjectComponent = vciObject.AddComponent<VCIObject>();
Expand All @@ -53,7 +57,7 @@ private static VCIObject CreateVCIObject()
};
vciObjectComponent.Scripts = new List<VciScript> {script};

return vciObjectComponent;
return vciObject;
}

}
Expand Down
2 changes: 2 additions & 0 deletions Assets/VCI/UniVCI/Scripts/Components/VCISubItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void InitializeKey()
/// <summary>VCI内で一意となる値</summary>
/// <remarks>0 の時は未設定と見なす</remarks>
public int Key;
public bool IsVisibleToCamera = true;

public static readonly float DefaultAttractableDistance = 20;

Expand All @@ -75,6 +76,7 @@ public VCISubItem CopyTo(GameObject go)
subItem.GroupId = GroupId;
subItem.NodeIndex = NodeIndex;
subItem.Key = Key;
subItem.IsVisibleToCamera = IsVisibleToCamera;
return subItem;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Serialization;

namespace VCI
{
Expand All @@ -17,5 +18,6 @@ public sealed class glTF_VCAST_vci_item
public float attractableDistance;
public int groupId;
public int key;
public bool isVisibleToCamera;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public sealed class RigidbodyJsonObject
public float angularDrag = 0.05f;
public bool useGravity = true;
public bool isKinematic = false;
public string interpolate;
public string collisionDetection;

// PhysicsRigidbodyImporterでは不明値をInterpolateとして扱っている。
// 該当箇所のコメントに(なぜ?)と書かれているので、経緯を確認する必要がある。
// Rigidbodyを新しく作成したときの値に合わせて、ここではデフォルト値をNoneとしておく。
public string interpolate = NoneInterpolateString;
public string collisionDetection = DiscreteCollisionDetectionString;

public bool freezePositionX = false;
public bool freezePositionY = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public static glTF_VCAST_vci_item Deserialize(JsonNode parsed)
continue;
}

if(key=="isVisibleToCamera"){
value.isVisibleToCamera = kv.Value.GetBoolean();
continue;
}

}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public static void Serialize(JsonFormatter f, glTF_VCAST_vci_item value)
f.Value(value.key);
}

if(true){
f.Key("isVisibleToCamera");
f.Value(value.isVisibleToCamera);
}

f.EndMap();
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/VCI/UniVCI/Scripts/Format/VCIVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public static class VCIVersion
public const string VCI_VERSION = "UniVCI-" + VERSION;

public const int MAJOR = 0;
public const int MINOR = 42;
public const int MINOR = 43;
public const int PATCH = 1;

public const string VERSION = "0.42";
public const string VERSION = "0.43";
public const string PATCH_NUMBER = "1";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static glTF_VCAST_vci_item ExportSubItem(Transform node)
attractableDistance = item.AttractableDistance,
groupId = item.GroupId,
key = item.Key,
isVisibleToCamera = item.IsVisibleToCamera,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ public static class PhysicsRigidbodyImporter
public static async Task<Dictionary<Rigidbody, RigidbodySetting>> LoadAsync(VciData vciData, IReadOnlyList<Transform> unityNodes, IAwaitCaller awaitCaller)
{
var rigidBodySettings = new Dictionary<Rigidbody, RigidbodySetting>();
var rigidbodyNodeIndices = new HashSet<int>();

var rigidbodyCount = 0;
foreach (var (nodeIdx, rigidbodyExtension) in vciData.RigidbodyNodes)
{
rigidbodyNodeIndices.Add(nodeIdx);
var gameObject = unityNodes[nodeIdx].gameObject;
foreach (var rigidbodyJsonObject in rigidbodyExtension.rigidbodies)
{
Expand All @@ -42,28 +40,6 @@ public static async Task<Dictionary<Rigidbody, RigidbodySetting>> LoadAsync(VciD
}
}

foreach (var (nodeIdx, subItemExtension) in vciData.SubItemNodes)
{
if (rigidbodyNodeIndices.Contains(nodeIdx)) continue;

// NOTE: SubItem 拡張を持つが、Rigidbody 拡張を持たない、過去の VCI に対応する.
// TODO: 最古 public な UniVCI v0.15 でもそのような仕様はないため、必要がない処理の可能性が高い. 消したい.
var gameObject = unityNodes[nodeIdx].gameObject;
var rb = gameObject.GetOrAddComponent<Rigidbody>();
rb.isKinematic = true;
rb.useGravity = false;
rigidBodySettings.Add(rb, new RigidbodySetting(rb));

// NOTE: ロード中に Rigidbody が動くべきではない. ロード終了後に EnablePhysicalBehaviour で有効になる.
PhysicalBehaviourChanger.DisableRigidbody(rb);

rigidbodyCount += 1;
if (rigidbodyCount % AwaitIntervalCount == 0)
{
await awaitCaller.NextFrame();
}
}

await awaitCaller.NextFrame();

return rigidBodySettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static void Load(VciData vciData, IReadOnlyList<Transform> unityNodes)
item.GroupId = subItemExtension.groupId;
// NOTE: UniVCI 0.37 で追加した項目。それ以前の VCI では NodeIndex を Key とする。
item.Key = vciData.VciMigrationFlags.IsSubItemKeyUndefined ? nodeIdx : subItemExtension.key;
// NOTE: UniVCI 0.43 で追加した項目。それ以前の VCI では true とする。
item.IsVisibleToCamera = vciData.VciMigrationFlags.IsSubItemVisibilityUndefined || subItemExtension.isVisibleToCamera;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public static async Task<List<TextMeshPro>> LoadAsync(

texts.Add(tmp);

// 初期状態は非表示
tmp.renderer.enabled = false;

// NOTE: TMP の追加は非常にスパイクが大きい。(2ms)
await awaitCaller.NextFrame();
}
Expand Down
8 changes: 8 additions & 0 deletions Assets/VCI/UniVCI/Scripts/IO/Migrators.meta

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

69 changes: 69 additions & 0 deletions Assets/VCI/UniVCI/Scripts/IO/Migrators/VciMigrator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections.Generic;
using UniGLTF;

namespace VCI
{
public static class VciMigrator
{
/// <summary>
/// 現行のVCI仕様に合致しない部分を修正して、<see cref="VciData"/>を生成する。
/// 副作用がある(渡された値が変更される)ため注意。
/// 現状、呼び出し元でこのメソッドに渡される値はVciDataに格納する以外の用途がないため問題ない。
/// </summary>
public static VciData Migrate(
GltfData gltfData,
VciMigrationFlags vciMigrationFlags, // 将来的に消したい
glTF_VCAST_vci_meta meta,
glTF_VCAST_vci_embedded_script script,
glTF_VCAST_vci_audios audios,
glTF_VCAST_vci_material_unity unityMaterials,
glTF_VCAST_vci_location_lighting locationLighting,
glTF_VCAST_vci_location_bounds locationBounds,
glTF_VCAST_vci_spring_bone springBone,
glTF_Effekseer effekseer,
List<(int gltfNodeIdx, glTF_VCAST_vci_audio_sources ext)> audioSourcesNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_animation ext)> animationNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_attachable extension)> attachableNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_lightmap extension)> lightmapNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_reflectionProbe extension)> reflectionProbeNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_colliders extension)> collidersNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_joints extension)> jointsNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_rigidbody extension)> rigidbodyNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_item extension)> subItemNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_player_spawn_point extension)> playerSpawnPointNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_player_spawn_point_restriction extension)> playerSpawnPointRestrictionNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_text extension)> textNodes,
List<(int gltfNodeIdx, glTF_VCAST_vci_rectTransform extension)> rectTransformNodes,
List<(int gltfNodeIdx, glTF_Effekseer_emitters extension)> effekseerEmittersNodes)
{
VciPhysicsMigrator.Migrate(gltfData, collidersNodes, rigidbodyNodes, subItemNodes);

return new VciData(
gltfData,
vciMigrationFlags,
meta,
script,
audios,
unityMaterials,
locationLighting,
locationBounds,
springBone,
effekseer,
audioSourcesNodes,
animationNodes,
attachableNodes,
lightmapNodes,
reflectionProbeNodes,
collidersNodes,
jointsNodes,
rigidbodyNodes,
subItemNodes,
playerSpawnPointNodes,
playerSpawnPointRestrictionNodes,
textNodes,
rectTransformNodes,
effekseerEmittersNodes
);
}
}
}
3 changes: 3 additions & 0 deletions Assets/VCI/UniVCI/Scripts/IO/Migrators/VciMigrator.cs.meta

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

Loading

0 comments on commit 65b50d5

Please sign in to comment.