live2D (sdk가 6.5 미지원으로 sprite로 대응)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
[English](Description.md) / [日本語](Description.ja.md)
|
||||
|
||||
---
|
||||
|
||||
# Reycasting
|
||||
|
||||
このサンプルは、Raycasting機能を示しています。
|
||||
Raycastingは手動で設定する必要がありますが、設定はそれほど面倒ではありません。
|
||||
モデルのGameObjectに``CubismRaycaster``コンポーネントを追加し、Raycastに使用にしたいDrawableに``CubismRaycastable``を追加するだけです。
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55d1a8cf935ae4494b48f5d36e0f590b
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Live2D/Cubism/Samples/Raycasting/Description.md
Normal file
9
Assets/Live2D/Cubism/Samples/Raycasting/Description.md
Normal file
@@ -0,0 +1,9 @@
|
||||
[English](Description.md) / [日本語](Description.ja.md)
|
||||
|
||||
---
|
||||
|
||||
# Raycasting
|
||||
|
||||
This sample demonstrates the raycasting functionality.
|
||||
Raycasting must be set up manually, but setting it up isn't too cumbersome.
|
||||
You simply have to add a ``CubismRaycaster`` component to the model game object, and ``CubismRaycastable``s to any drawable you want to be raycastable.
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13d11fb76b46cda49b56632c893c303c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
104
Assets/Live2D/Cubism/Samples/Raycasting/RaycastHitDisplay.cs
Normal file
104
Assets/Live2D/Cubism/Samples/Raycasting/RaycastHitDisplay.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* Copyright(c) Live2D Inc. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by the Live2D Open Software license
|
||||
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
|
||||
*/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
using Live2D.Cubism.Core;
|
||||
using Live2D.Cubism.Framework.Raycasting;
|
||||
|
||||
|
||||
namespace Live2D.Cubism.Samples.Raycasting
|
||||
{
|
||||
/// <summary>
|
||||
/// Casts rays against a <see cref="Model"/> and displays results.
|
||||
/// </summary>
|
||||
public sealed class RaycastHitDisplay : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="CubismModel"/> to cast rays against.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public CubismModel Model;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// UI element to display results in.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Text ResultsText;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CubismRaycaster"/> attached to <see cref="Model"/>.
|
||||
/// </summary>
|
||||
private CubismRaycaster Raycaster { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Buffer for raycast results.
|
||||
/// </summary>
|
||||
private CubismRaycastHit[] Results { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Hit test.
|
||||
/// </summary>
|
||||
private void DoRaycast()
|
||||
{
|
||||
// Cast ray from pointer position.
|
||||
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
var hitCount = Raycaster.Raycast(ray, Results);
|
||||
|
||||
|
||||
// Return early if nothing was hit.
|
||||
if (hitCount == 0)
|
||||
{
|
||||
ResultsText.text = "0";
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Show results.
|
||||
ResultsText.text = hitCount + "\n";
|
||||
|
||||
|
||||
for (var i = 0; i < hitCount; i++)
|
||||
{
|
||||
ResultsText.text += Results[i].Drawable.name + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
#region Unity Event Handling
|
||||
|
||||
/// <summary>
|
||||
/// Called by Unity. Initializes instance.
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
Raycaster = Model.GetComponent<CubismRaycaster>();
|
||||
Results = new CubismRaycastHit[4];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by Unity. Triggers raycasting.
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
// Return early in case of no user interaction.
|
||||
if (!Input.GetMouseButtonDown(0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DoRaycast();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 130e9390e7f495a4a919c8b132a34b75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Live2D/Cubism/Samples/Raycasting/Raycasting.unity
LFS
Normal file
BIN
Assets/Live2D/Cubism/Samples/Raycasting/Raycasting.unity
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6640aff93e523e41ab5f43ed853091a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: RaycastingSettings
|
||||
serializedVersion: 9
|
||||
m_EnableBakedLightmaps: 0
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 1
|
||||
m_BakeBackend: 1
|
||||
m_LightmapMaxSize: 1024
|
||||
m_LightmapSizeFixed: 0
|
||||
m_UseMipmapLimits: 1
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 3
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 2
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_EnableWorkerProcessBaking: 1
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 1
|
||||
m_PVRFilteringGaussRadiusAO: 1
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a9ad696dd9be794cade26eaaffbbd48
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user