actually-breakable-wall #3
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||||
|
* you may not use the Oculus SDK except in compliance with the License,
|
||||||
|
* which is provided at the time of installation or download, or which
|
||||||
|
* otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://developer.oculus.com/licenses/oculussdk/
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SampleVirtualFrames : MonoBehaviour
|
||||||
|
{
|
||||||
|
public OVRSceneManager _sceneManager;
|
||||||
|
|
||||||
|
public SimpleResizable _doorPrefab;
|
||||||
|
public SimpleResizable _windowPrefab;
|
||||||
|
|
||||||
|
public SimpleResizable _wallPrefab;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
MarcsWebLogger.Log("SampleVirtualFrames::Awake()");
|
||||||
|
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_ANDROID
|
||||||
|
OVRManager.eyeFovPremultipliedAlphaModeEnabled = false;
|
||||||
|
#endif
|
||||||
|
_sceneManager.SceneModelLoadedSuccessfully += InitializeRoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeRoom()
|
||||||
|
{
|
||||||
|
MarcsWebLogger.Log("SampleVirtualFrames::InitializeRoom()");
|
||||||
|
OVRSceneAnchor[] sceneAnchors = FindObjectsOfType<OVRSceneAnchor>();
|
||||||
|
if (sceneAnchors != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sceneAnchors.Length; i++)
|
||||||
|
{
|
||||||
|
OVRSceneAnchor instance = sceneAnchors[i];
|
||||||
|
OVRSemanticClassification classification = instance.GetComponent<OVRSemanticClassification>();
|
||||||
|
|
||||||
|
if (classification.Contains(OVRSceneManager.Classification.WallFace))
|
||||||
|
{
|
||||||
|
var randomNumber = UnityEngine.Random.Range(10000, 99999);
|
||||||
|
MarcsWebLogger.Log($"{randomNumber} | FOUND A WALL");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SimpleResizer resizer = new SimpleResizer();
|
||||||
|
SimpleResizable prefab = _wallPrefab;
|
||||||
|
Vector3 dimensions = instance.transform.GetChild(0).localScale;
|
||||||
|
if (prefab.GetComponent<ResizablePadding>())
|
||||||
|
{
|
||||||
|
dimensions += prefab.GetComponent<ResizablePadding>().dimensionPadding;
|
||||||
|
}
|
||||||
|
resizer.CreateResizedObject(dimensions, sceneAnchors[i].gameObject, prefab);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MarcsWebLogger.Log($"{randomNumber} | Error: {e.Message}");
|
||||||
|
}
|
||||||
|
MarcsWebLogger.Log($"{randomNumber} | PLACED A WALL");
|
||||||
|
//i = 99999;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else if (classification.Contains(OVRSceneManager.Classification.WindowFrame) ||
|
||||||
|
classification.Contains(OVRSceneManager.Classification.DoorFrame))
|
||||||
|
{
|
||||||
|
windows.Add(instance.transform);
|
||||||
|
|
||||||
|
SimpleResizer resizer = new SimpleResizer();
|
||||||
|
SimpleResizable prefab = classification.Contains(OVRSceneManager.Classification.DoorFrame) ? _doorPrefab : _windowPrefab;
|
||||||
|
Vector3 dimensions = instance.transform.GetChild(0).localScale;
|
||||||
|
|
||||||
|
// spawn an optional butterfly
|
||||||
|
if (classification.Contains(OVRSceneManager.Classification.DoorFrame) && _butterflyPrefab && !butterflyAdded)
|
||||||
|
{
|
||||||
|
GameObject butterfly = Instantiate(_butterflyPrefab, instance.transform);
|
||||||
|
butterfly.transform.localPosition = Vector3.zero;
|
||||||
|
butterfly.transform.rotation = Quaternion.LookRotation(instance.transform.forward, Vector3.up);
|
||||||
|
// this is to only spawn one, regardless of door count
|
||||||
|
butterflyAdded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the Resizer scales the mesh so that the bounds are flush with the window extents
|
||||||
|
// in this case, we want the mesh frame to extend "outside" of the extents, so we adjust it
|
||||||
|
// as well, the vines on the door also require special treatment
|
||||||
|
if (prefab.GetComponent<ResizablePadding>())
|
||||||
|
{
|
||||||
|
dimensions += prefab.GetComponent<ResizablePadding>().dimensionPadding;
|
||||||
|
}
|
||||||
|
resizer.CreateResizedObject(dimensions, sceneAnchors[i].gameObject, prefab);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MarcsWebLogger.Log("NO ANCHORS FOUND. ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 71fceb9e405ea76c58f1c1cc46118097
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,144 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &814842801368627604
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6455794010493476198}
|
||||||
|
- component: {fileID: 4469256713305699264}
|
||||||
|
- component: {fileID: 6006842473380119943}
|
||||||
|
- component: {fileID: 8535292912872443155}
|
||||||
|
- component: {fileID: 1908277671756111771}
|
||||||
|
- component: {fileID: 8707393823814613456}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Breakable Wall (just a cube)
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &6455794010493476198
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0.01}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 0.01}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!33 &4469256713305699264
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &6006842473380119943
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: a384b583426023d4da68d3f25e868451, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!65 &8535292912872443155
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1908277671756111771
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 39b243a9b1035c94e9f75c4e11283893, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
ScalingX: 0
|
||||||
|
PaddingX: 0
|
||||||
|
PaddingXMax: 0
|
||||||
|
ScalingY: 0
|
||||||
|
PaddingY: 0
|
||||||
|
PaddingYMax: 0
|
||||||
|
ScalingZ: 3
|
||||||
|
PaddingZ: 0
|
||||||
|
PaddingZMax: 0
|
||||||
|
_pivotTransform: {fileID: 6455794010493476198}
|
||||||
|
--- !u!114 &8707393823814613456
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 814842801368627604}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a4aa4c87388bd1250aef8d89d8f58ed7, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
dimensionPadding: {x: 0, y: 0, z: 0}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d0dff8f7a3ef4c1d5b55c1e07e1ecb0b
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,162 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1001 &6402218498956519874
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: -9003323146575883303, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: 4ddb30289dc6d6a47a05448ca7275e5c, type: 2}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -7023974396876390944, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: a384b583426023d4da68d3f25e868451, type: 2}
|
||||||
|
- target: {fileID: -2268138116939433651, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: a384b583426023d4da68d3f25e868451, type: 2}
|
||||||
|
- target: {fileID: -241587437493983680, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: 5e85b5e82c1a1a84186c3baf89e174c7, type: 2}
|
||||||
|
- target: {fileID: 882129737928793925, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: 0141bc0de40b03c47a7d54dba3567d7e, type: 2}
|
||||||
|
- target: {fileID: 919132149155446097, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Breakable Wall
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2786534777698132407, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: 0576b3490a5948442aace3fadba823bb, type: 2}
|
||||||
|
- target: {fileID: 7339356831882890532, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: a384b583426023d4da68d3f25e868451, type: 2}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 5026953953504289645}
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 1133447161263397491}
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 527367603987909277}
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
--- !u!1 &6059687977031947411 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 6402218498956519874}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &5026953953504289645
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6059687977031947411}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 39b243a9b1035c94e9f75c4e11283893, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
ScalingX: 0
|
||||||
|
PaddingX: 0
|
||||||
|
PaddingXMax: 0
|
||||||
|
ScalingY: 0
|
||||||
|
PaddingY: 0
|
||||||
|
PaddingYMax: 0
|
||||||
|
ScalingZ: 3
|
||||||
|
PaddingZ: 0
|
||||||
|
PaddingZMax: 0
|
||||||
|
_pivotTransform: {fileID: 6868981949592079913}
|
||||||
|
--- !u!114 &1133447161263397491
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6059687977031947411}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a4aa4c87388bd1250aef8d89d8f58ed7, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
dimensionPadding: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!65 &527367603987909277
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6059687977031947411}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 0.1, y: 2, z: 2}
|
||||||
|
m_Center: {x: 0.05, y: 0, z: 0}
|
||||||
|
--- !u!4 &6868981949592079913 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: b3bd50a8a2657294a93a3165603b6a56, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 6402218498956519874}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1c12386686cd2aaf09eda99c926dbb25
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -66,7 +66,7 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
propertyPath: m_LocalScale.z
|
propertyPath: m_LocalScale.z
|
||||||
value: 0.01
|
value: 0.02
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f8de10649cc7114186efa4fe62d54d5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
||||||
|
Shader "Custom/DepthReserve"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
}
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType" = "Opaque" "Queue"="Geometry-1" }
|
||||||
|
LOD 100
|
||||||
|
|
||||||
|
Blend Zero One
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c8802f56ded4d78df84aa2ec0992fc6b
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,71 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1001 &3261728088016311268
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 502283750161808342, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_Materials.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2100000, guid: e4b262845911bcbde9e1332532b2fc12, type: 2}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1132682185376712905, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalScale.z
|
||||||
|
value: 0.05
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7364228411325162552, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8999845180316542267, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Window Variant
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: 891349029806e4144812ff2d304d9cf9, type: 3}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3bfafa2f9779de6b0ac817be7114b04d
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,89 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Window
|
||||||
|
m_Shader: {fileID: 4800000, guid: c8802f56ded4d78df84aa2ec0992fc6b, type: 3}
|
||||||
|
m_Parent: {fileID: 0}
|
||||||
|
m_ModifiedSerializedProperties: 0
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords:
|
||||||
|
- _ALPHAPREMULTIPLY_ON
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_LockedProperties:
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SpecGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 10
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 3
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 0
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 0, b: 0.8072939, a: 0.3372549}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e4b262845911bcbde9e1332532b2fc12
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b20686972cc7b0618e409fe9e61daa5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||||
|
* you may not use the Oculus SDK except in compliance with the License,
|
||||||
|
* which is provided at the time of installation or download, or which
|
||||||
|
* otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://developer.oculus.com/licenses/oculussdk/
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ResizablePadding : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Vector3 dimensionPadding = Vector3.zero;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a4aa4c87388bd1250aef8d89d8f58ed7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3a4289cf3e9109226bbbd1f42a6f53d7
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class SimpleResizable : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Vector3 PivotPosition => _pivotTransform.position; //Vector3.zero;
|
||||||
|
|
||||||
|
[Space(15)] public Method ScalingX;
|
||||||
|
[Range(0, 0.5f)] public float PaddingX;
|
||||||
|
|
||||||
|
[Range(-0.5f, 0)] public float PaddingXMax;
|
||||||
|
|
||||||
|
[Space(15)] public Method ScalingY;
|
||||||
|
[Range(0, 0.5f)] public float PaddingY;
|
||||||
|
|
||||||
|
[Range(-0.5f, 0)] public float PaddingYMax;
|
||||||
|
|
||||||
|
[Space(15)] public Method ScalingZ;
|
||||||
|
[Range(0, 0.5f)] public float PaddingZ;
|
||||||
|
|
||||||
|
[Range(-0.5f, 0)] public float PaddingZMax;
|
||||||
|
|
||||||
|
public enum Method
|
||||||
|
{
|
||||||
|
Adapt,
|
||||||
|
AdaptWithAsymmetricalPadding,
|
||||||
|
Scale,
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 NewSize {get; set; }
|
||||||
|
public Vector3 DefaultSize {get; private set; }
|
||||||
|
public Mesh Mesh { get; private set; }
|
||||||
|
|
||||||
|
private Bounds _bounds;
|
||||||
|
|
||||||
|
[SerializeField] private Transform _pivotTransform;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Mesh = GetComponent<MeshFilter>().sharedMesh;
|
||||||
|
DefaultSize = Mesh.bounds.size;
|
||||||
|
if(!_pivotTransform)
|
||||||
|
_pivotTransform = transform.Find("Pivot");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
DefaultSize = Mesh.bounds.size;
|
||||||
|
NewSize = DefaultSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
if (!_pivotTransform) return;
|
||||||
|
|
||||||
|
Gizmos.color = Color.red;
|
||||||
|
float lineSize = 0.1f;
|
||||||
|
|
||||||
|
Vector3 startX = _pivotTransform.position + Vector3.left * lineSize * 0.5f;
|
||||||
|
Vector3 startY = _pivotTransform.position + Vector3.down * lineSize * 0.5f;
|
||||||
|
Vector3 startZ = _pivotTransform.position + Vector3.back * lineSize * 0.5f;
|
||||||
|
|
||||||
|
Gizmos.DrawRay(startX, Vector3.right * lineSize);
|
||||||
|
Gizmos.DrawRay(startY, Vector3.up * lineSize);
|
||||||
|
Gizmos.DrawRay(startZ, Vector3.forward * lineSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDrawGizmosSelected()
|
||||||
|
{
|
||||||
|
DefaultSize = Mesh.bounds.size;
|
||||||
|
|
||||||
|
if (GetComponent<MeshFilter>().sharedMesh == null)
|
||||||
|
{
|
||||||
|
// The furniture piece was not customized yet, nothing to do here
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_bounds = GetComponent<MeshFilter>().sharedMesh.bounds;
|
||||||
|
Gizmos.matrix = transform.localToWorldMatrix;
|
||||||
|
Vector3 newCenter = _bounds.center;
|
||||||
|
|
||||||
|
Gizmos.color = new Color(1, 0, 0, 0.5f);
|
||||||
|
switch (ScalingX)
|
||||||
|
{
|
||||||
|
case Method.Adapt:
|
||||||
|
Gizmos.DrawWireCube(newCenter, new Vector3(NewSize.x * PaddingX * 2, NewSize.y, NewSize.z));
|
||||||
|
break;
|
||||||
|
case Method.AdaptWithAsymmetricalPadding:
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(
|
||||||
|
NewSize.x * PaddingX, 0, 0), new Vector3(0, NewSize.y, NewSize.z));
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(
|
||||||
|
NewSize.x * PaddingXMax, 0, 0), new Vector3(0, NewSize.y, NewSize.z));
|
||||||
|
break;
|
||||||
|
case Method.None:
|
||||||
|
Gizmos.DrawWireCube(newCenter, NewSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gizmos.color = new Color(0, 1, 0, 0.5f);
|
||||||
|
switch (ScalingY)
|
||||||
|
{
|
||||||
|
case Method.Adapt:
|
||||||
|
Gizmos.DrawWireCube(newCenter, new Vector3(NewSize.x, NewSize.y * PaddingY * 2, NewSize.z));
|
||||||
|
break;
|
||||||
|
case Method.AdaptWithAsymmetricalPadding:
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(0, NewSize.y * PaddingY, 0),
|
||||||
|
new Vector3(NewSize.x, 0, NewSize.z));
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(0, NewSize.y * PaddingYMax, 0),
|
||||||
|
new Vector3(NewSize.x, 0, NewSize.z));
|
||||||
|
break;
|
||||||
|
case Method.None:
|
||||||
|
Gizmos.DrawWireCube(newCenter, NewSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gizmos.color = new Color(0, 0, 1, 0.5f);
|
||||||
|
switch (ScalingZ)
|
||||||
|
{
|
||||||
|
case Method.Adapt:
|
||||||
|
Gizmos.DrawWireCube(newCenter, new Vector3(NewSize.x, NewSize.y, NewSize.z * PaddingZ * 2));
|
||||||
|
break;
|
||||||
|
case Method.AdaptWithAsymmetricalPadding:
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(0, 0, NewSize.z * PaddingZ),
|
||||||
|
new Vector3(NewSize.x, NewSize.y, 0));
|
||||||
|
Gizmos.DrawWireCube(newCenter + new Vector3(0, 0, NewSize.z * PaddingZMax),
|
||||||
|
new Vector3(NewSize.x, NewSize.y, 0));
|
||||||
|
break;
|
||||||
|
case Method.None:
|
||||||
|
Gizmos.DrawWireCube(newCenter, NewSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gizmos.color = new Color(0, 1, 1, 1);
|
||||||
|
Gizmos.DrawWireCube(newCenter, NewSize);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39b243a9b1035c94e9f75c4e11283893
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,144 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SimpleResizer
|
||||||
|
{
|
||||||
|
public void CreateResizedObject(Vector3 newSize, GameObject parent, SimpleResizable sourcePrefab)
|
||||||
|
{
|
||||||
|
MarcsWebLogger.Log($"Resize {newSize}");
|
||||||
|
var prefab = MonoBehaviour.Instantiate(sourcePrefab.gameObject, Vector3.zero, Quaternion.identity);
|
||||||
|
prefab.name = sourcePrefab.name;
|
||||||
|
|
||||||
|
var resizable = prefab.GetComponent<SimpleResizable>();
|
||||||
|
resizable.NewSize = newSize;
|
||||||
|
if (resizable == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Resizable component missing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resizedMesh = ProcessVertices(resizable, newSize);
|
||||||
|
|
||||||
|
MeshFilter mf = prefab.GetComponent<MeshFilter>();
|
||||||
|
mf.sharedMesh = resizedMesh;
|
||||||
|
mf.sharedMesh.RecalculateBounds();
|
||||||
|
|
||||||
|
// child it after creation so the bounds math plays nicely
|
||||||
|
prefab.transform.parent = parent.transform;
|
||||||
|
prefab.transform.localPosition = Vector3.zero;
|
||||||
|
prefab.transform.localRotation = Quaternion.identity;
|
||||||
|
|
||||||
|
// Marc Scale fix
|
||||||
|
// Calculate the texture scale based on the ratio of new size to default size
|
||||||
|
Vector2 textureScale = new Vector2(newSize.x / resizable.DefaultSize.x, newSize.y / resizable.DefaultSize.y);
|
||||||
|
prefab.GetComponent<Renderer>().material.mainTextureScale = textureScale;
|
||||||
|
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
MonoBehaviour.Destroy(resizable);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
private Mesh ProcessVertices(SimpleResizable resizable, Vector3 newSize)
|
||||||
|
{
|
||||||
|
Mesh originalMesh = resizable.Mesh;
|
||||||
|
Vector3 originalBounds = originalMesh.bounds.size;
|
||||||
|
|
||||||
|
// Force scaling if newSize is smaller than the original mesh
|
||||||
|
SimpleResizable.Method methodX = (originalBounds.x < newSize.x)
|
||||||
|
? resizable.ScalingX
|
||||||
|
: SimpleResizable.Method.Scale;
|
||||||
|
SimpleResizable.Method methodY = (originalBounds.y < newSize.y)
|
||||||
|
? resizable.ScalingY
|
||||||
|
: SimpleResizable.Method.Scale;
|
||||||
|
SimpleResizable.Method methodZ = (originalBounds.z < newSize.z)
|
||||||
|
? resizable.ScalingZ
|
||||||
|
: SimpleResizable.Method.Scale;
|
||||||
|
|
||||||
|
Vector3[] resizedVertices = originalMesh.vertices;
|
||||||
|
|
||||||
|
float pivotX = (1 / resizable.DefaultSize.x) * resizable.PivotPosition.x;
|
||||||
|
float pivotY = (1 / resizable.DefaultSize.y) * resizable.PivotPosition.y;
|
||||||
|
float pivotZ = (1 / resizable.DefaultSize.z) * resizable.PivotPosition.z;
|
||||||
|
|
||||||
|
for (int i = 0; i < resizedVertices.Length; i++)
|
||||||
|
{
|
||||||
|
Vector3 vertexPosition = resizedVertices[i];
|
||||||
|
vertexPosition.x = CalculateNewVertexPosition(
|
||||||
|
methodX,
|
||||||
|
vertexPosition.x,
|
||||||
|
originalBounds.x,
|
||||||
|
newSize.x,
|
||||||
|
resizable.PaddingX,
|
||||||
|
resizable.PaddingXMax,
|
||||||
|
pivotX);
|
||||||
|
|
||||||
|
vertexPosition.y = CalculateNewVertexPosition(
|
||||||
|
methodY,
|
||||||
|
vertexPosition.y,
|
||||||
|
originalBounds.y,
|
||||||
|
newSize.y,
|
||||||
|
resizable.PaddingY,
|
||||||
|
resizable.PaddingYMax,
|
||||||
|
pivotY);
|
||||||
|
|
||||||
|
vertexPosition.z = CalculateNewVertexPosition(
|
||||||
|
methodZ,
|
||||||
|
vertexPosition.z,
|
||||||
|
originalBounds.z,
|
||||||
|
newSize.z,
|
||||||
|
resizable.PaddingZ,
|
||||||
|
resizable.PaddingZMax,
|
||||||
|
pivotZ);
|
||||||
|
resizedVertices[i] = vertexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh clonedMesh = MonoBehaviour.Instantiate(originalMesh);
|
||||||
|
clonedMesh.vertices = resizedVertices;
|
||||||
|
|
||||||
|
return clonedMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float CalculateNewVertexPosition(
|
||||||
|
SimpleResizable.Method resizeMethod,
|
||||||
|
float currentPosition,
|
||||||
|
float currentSize,
|
||||||
|
float newSize,
|
||||||
|
float padding,
|
||||||
|
float paddingMax,
|
||||||
|
float pivot)
|
||||||
|
{
|
||||||
|
float resizedRatio = currentSize / 2
|
||||||
|
* (newSize / 2 * (1 / (currentSize / 2)))
|
||||||
|
- currentSize / 2;
|
||||||
|
|
||||||
|
switch (resizeMethod)
|
||||||
|
{
|
||||||
|
case SimpleResizable.Method.Adapt:
|
||||||
|
if (Mathf.Abs(currentPosition) >= padding)
|
||||||
|
currentPosition = resizedRatio * Mathf.Sign(currentPosition) + currentPosition;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SimpleResizable.Method.AdaptWithAsymmetricalPadding:
|
||||||
|
if (currentPosition >= padding)
|
||||||
|
currentPosition = resizedRatio * Mathf.Sign(currentPosition) + currentPosition;
|
||||||
|
if (currentPosition <= paddingMax)
|
||||||
|
currentPosition = resizedRatio * Mathf.Sign(currentPosition) + currentPosition;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SimpleResizable.Method.Scale:
|
||||||
|
currentPosition = newSize / (currentSize / currentPosition);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SimpleResizable.Method.None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
float pivotPos = newSize * (-pivot);
|
||||||
|
currentPosition += pivotPos;
|
||||||
|
|
||||||
|
return currentPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 85f4ec0cb9fef7b4e9223c280e418389
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,109 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3bd50a8a2657294a93a3165603b6a56
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 22200
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
materials:
|
||||||
|
materialImportMode: 2
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
materialLocation: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleCurves: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
removeConstantScaleCurves: 0
|
||||||
|
motionNodeName:
|
||||||
|
rigImportErrors:
|
||||||
|
rigImportWarnings:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
importAnimatedCustomProperties: 0
|
||||||
|
importConstraints: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
extraUserProperties: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 0
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
useSRGBMaterialColor: 1
|
||||||
|
sortHierarchyByName: 1
|
||||||
|
importPhysicalCameras: 1
|
||||||
|
importVisibility: 1
|
||||||
|
importBlendShapes: 1
|
||||||
|
importCameras: 1
|
||||||
|
importLights: 1
|
||||||
|
nodeNameCollisionStrategy: 1
|
||||||
|
fileIdsGeneration: 2
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
bakeAxisConversion: 0
|
||||||
|
preserveHierarchy: 0
|
||||||
|
skinWeightsMode: 0
|
||||||
|
maxBonesPerVertex: 4
|
||||||
|
minBoneWeight: 0.001
|
||||||
|
optimizeBones: 1
|
||||||
|
meshOptimizationFlags: -1
|
||||||
|
indexFormat: 0
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVMarginMethod: 1
|
||||||
|
secondaryUVMinLightmapResolution: 40
|
||||||
|
secondaryUVMinObjectScale: 1
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
strictVertexDataChecks: 0
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
normalCalculationMode: 4
|
||||||
|
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||||
|
blendShapeNormalImportMode: 1
|
||||||
|
normalSmoothingSource: 0
|
||||||
|
referencedClips: []
|
||||||
|
importAnimation: 1
|
||||||
|
humanDescription:
|
||||||
|
serializedVersion: 3
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
globalScale: 1
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
hasExtraRoot: 0
|
||||||
|
skeletonHasParents: 1
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
autoGenerateAvatarMappingIfUnspecified: 1
|
||||||
|
animationType: 2
|
||||||
|
humanoidOversampling: 1
|
||||||
|
avatarSetup: 0
|
||||||
|
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||||
|
importBlendShapeDeformPercent: 1
|
||||||
|
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
|
@ -139,6 +139,8 @@ PlayerSettings:
|
||||||
bundleVersion: 0.1
|
bundleVersion: 0.1
|
||||||
preloadedAssets:
|
preloadedAssets:
|
||||||
- {fileID: 11400000, guid: 29d72bf9f28086693968cedbdc8f08cd, type: 2}
|
- {fileID: 11400000, guid: 29d72bf9f28086693968cedbdc8f08cd, type: 2}
|
||||||
|
- {fileID: 11400000, guid: 541751c4fa90967d68ef779a22ee43f3, type: 2}
|
||||||
|
- {fileID: -3127938587913570544, guid: 8eb28e39ec717d0799039f01965f0533, type: 2}
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
m_HolographicPauseOnTrackingLoss: 1
|
m_HolographicPauseOnTrackingLoss: 1
|
||||||
|
|
Loading…
Reference in New Issue