Procedural Generation Chunks

This commit is contained in:
GamerClassN7 2022-01-29 22:04:46 +01:00
parent a141a6b50a
commit 0df4c44b40
15 changed files with 296 additions and 83 deletions

View File

@ -9,6 +9,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2957714535164430066}
- component: {fileID: 5113105489977215987}
- component: {fileID: -6971605353857731775}
m_Layer: 0
m_Name: level chunk 1
m_TagString: Untagged
@ -37,6 +39,26 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &5113105489977215987
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Mesh: {fileID: 0}
--- !u!114 &-6971605353857731775
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &615591915067152208
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -9,6 +9,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2957714535164430066}
- component: {fileID: -2509422500240301154}
- component: {fileID: -4978173286257615179}
m_Layer: 0
m_Name: level chunk 2
m_TagString: Untagged
@ -37,6 +39,26 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &-2509422500240301154
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Mesh: {fileID: 0}
--- !u!114 &-4978173286257615179
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &2372393751796009491
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -9,6 +9,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2957714535164430066}
- component: {fileID: 1311810020695435140}
- component: {fileID: 4501625178067468098}
m_Layer: 0
m_Name: level chunk 3
m_TagString: Untagged
@ -44,6 +46,26 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1311810020695435140
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Mesh: {fileID: 0}
--- !u!114 &4501625178067468098
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1316835597118596560}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1277388495838480138
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -31,7 +31,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2628890434173161083}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2628890433357983121
MeshFilter:
@ -114,7 +114,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2628890434173161083}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2628890433674921145
MeshFilter:
@ -166,7 +166,7 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &2628890433950335203
--- !u!1 &2628890434173161082
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -174,46 +174,63 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2628890433950335200}
- component: {fileID: 2628890433950335198}
- component: {fileID: 2628890433950335201}
- component: {fileID: 2628890434173161083}
- component: {fileID: 7045065836637454982}
- component: {fileID: 411423064055404482}
- component: {fileID: 459485775853362848}
- component: {fileID: 2187729912207573111}
m_Layer: 0
m_Name: base
m_TagString: Untagged
m_Name: Platform Start
m_TagString: platform
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2628890433950335200
--- !u!4 &2628890434173161083
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890433950335203}
m_GameObject: {fileID: 2628890434173161082}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2628890434173161083}
m_Children:
- {fileID: 2628890433357983123}
- {fileID: 2628890433674921147}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2628890433950335198
--- !u!65 &7045065836637454982
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890434173161082}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 5, y: 0.5, z: 5}
m_Center: {x: 0, y: 0.25, z: 0}
--- !u!33 &411423064055404482
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890433950335203}
m_GameObject: {fileID: 2628890434173161082}
m_Mesh: {fileID: 4300000, guid: 2d25f54cf972ab3408281f398c5b22eb, type: 3}
--- !u!23 &2628890433950335201
--- !u!23 &459485775853362848
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890433950335203}
m_GameObject: {fileID: 2628890434173161082}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
@ -249,51 +266,15 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &2628890434173161082
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2628890434173161083}
- component: {fileID: 7045065836637454982}
m_Layer: 0
m_Name: Platform Start
m_TagString: platform
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2628890434173161083
Transform:
--- !u!114 &2187729912207573111
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890434173161082}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2628890433950335200}
- {fileID: 2628890433357983123}
- {fileID: 2628890433674921147}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &7045065836637454982
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2628890434173161082}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 5, y: 0.5, z: 5}
m_Center: {x: 0, y: 0.25, z: 0}
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -97,6 +97,7 @@ GameObject:
- component: {fileID: 8768991388683709948}
- component: {fileID: 1430690303722568316}
- component: {fileID: 8238111678033492397}
- component: {fileID: -5509448037057392871}
m_Layer: 0
m_Name: Platform_Blue
m_TagString: platform
@ -213,3 +214,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 5.03, y: 0.7, z: 5}
m_Center: {x: 0, y: 0.1, z: 0}
--- !u!114 &-5509448037057392871
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -113,6 +113,7 @@ GameObject:
- component: {fileID: 8768991388683709950}
- component: {fileID: 3339862426328537977}
- component: {fileID: 3865253352867341094}
- component: {fileID: -7597049073915248875}
m_Layer: 0
m_Name: Platform_Green
m_TagString: platform
@ -214,6 +215,18 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 5.03, y: 0.7, z: 5}
m_Center: {x: 0, y: 0.1, z: 0}
--- !u!114 &-7597049073915248875
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8985668614484660023
GameObject:
m_ObjectHideFlags: 0

View File

@ -113,6 +113,7 @@ GameObject:
- component: {fileID: 6650340373999088095}
- component: {fileID: 1183598848765291555}
- component: {fileID: 6218203028538785626}
- component: {fileID: 1204402889283165505}
m_Layer: 0
m_Name: Platform_Orange
m_TagString: platform
@ -213,3 +214,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 3.3, y: 0.5, z: 5}
m_Center: {x: 0, y: 0.25, z: 0}
--- !u!114 &1204402889283165505
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6650340373999088090}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -113,6 +113,7 @@ GameObject:
- component: {fileID: 8768991388683709950}
- component: {fileID: 3861707493128515586}
- component: {fileID: 5316890779910729157}
- component: {fileID: -142748814437030588}
m_Layer: 0
m_Name: Platform_Red
m_TagString: platform
@ -213,3 +214,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 5.03, y: 0.7, z: 5}
m_Center: {x: 0, y: 0.1, z: 0}
--- !u!114 &-142748814437030588
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -10,13 +10,14 @@ GameObject:
m_Component:
- component: {fileID: 8768991388683709944}
- component: {fileID: -6007548423464394236}
- component: {fileID: 5458493816772439993}
m_Layer: 0
m_Name: Platform_empty
m_TagString: platform
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &8768991388683709944
Transform:
m_ObjectHideFlags: 0
@ -40,3 +41,15 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Mesh: {fileID: 4300000, guid: 8e5a3b6be3a077042965d2dbb744c259, type: 3}
--- !u!114 &5458493816772439993
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -113,6 +113,7 @@ GameObject:
- component: {fileID: 8768991388683709950}
- component: {fileID: 7821003709828495146}
- component: {fileID: 4344779564172896453}
- component: {fileID: 5433657018731068073}
m_Layer: 0
m_Name: Platform_yellow
m_TagString: platform
@ -213,3 +214,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 3.4, y: 0.5, z: 5}
m_Center: {x: 0, y: 0.25, z: 0}
--- !u!114 &5433657018731068073
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8768991388683709947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -96,6 +96,7 @@ GameObject:
- component: {fileID: 5928557084490550214}
- component: {fileID: 6189155224637060765}
- component: {fileID: -443919199017515566}
- component: {fileID: -731181381576803345}
m_Layer: 0
m_Name: platform 2 power
m_TagString: Untagged
@ -196,3 +197,15 @@ MonoBehaviour:
m_EditorClassIdentifier:
type: 0
speed: 5
--- !u!114 &-731181381576803345
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7678802340880963262}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dae18984b7ff147ab1d77fb817687a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -12,26 +12,43 @@ public class ProceduralGeneration : MonoBehaviour
private int spavnetobjectIndex = 0;
private int maximumNumberOfPlatformsAtScene = 100;
private float maximumDistanceOfPlatformFromPlayer = 20.0f;
private GameObject levelParrent = null;
GameObject drawPlatform(GameObject lastObject, GameObject objToSpawn)
Bounds getPrefabBounds(GameObject go)
{
MeshFilter meshfilter = lastObject.GetComponent<MeshFilter>();
Bounds bounds = meshfilter.mesh.bounds;
Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
float scale = meshfilter.transform.localScale.x;
Bounds b = new Bounds(bounds.center * scale, bounds.size * scale);
if (renderers.Length > 0)
{
Bounds bounds = renderers[0].bounds;
for (int i = 1, ni = renderers.Length; i < ni; i++)
{
bounds.Encapsulate(renderers[i].bounds);
}
return bounds;
}
else
{
return new Bounds();
}
}
GameObject drawPlatform(GameObject lastObject, GameObject objToSpawn, GameObject parentLevelObject)
{
Bounds bounds = this.getPrefabBounds(lastObject);
Bounds b = new Bounds(bounds.center, bounds.size);
Vector3 nextBlockLocation = new Vector3(lastObject.transform.position.x, lastObject.transform.position.y, lastObject.transform.position.z + b.size.z + 1.0f);
return Instantiate(objToSpawn, nextBlockLocation, (Quaternion.identity));
GameObject newObject = Instantiate(objToSpawn, nextBlockLocation, (Quaternion.identity));
newObject.transform.parent = parentLevelObject.transform;
return newObject;
}
List<GameObject> spawnSpiralOfPlatforms(GameObject lastObject, GameObject objToSpawn)
List<GameObject> spawnSpiralOfPlatforms(GameObject lastObject, GameObject objToSpawn, GameObject parentLevelObject)
{
// configuration:
float horizontalDistancePerPlatform = (float)Random.Range(1.0f, levelBlocks.Count); ;
float horizontalDistancePerPlatform = (float)Random.Range(0.5f, 2.0f); ;
List<GameObject> levelBlocksSpawnTemp = new List<GameObject>();
// Debug.Log("Building LOOP");
@ -40,11 +57,8 @@ public class ProceduralGeneration : MonoBehaviour
float radius = (pieceCount / 2) * 2;
float angle = 360f / (float)pieceCount;
MeshFilter meshfilter = lastObject.GetComponent<MeshFilter>();
Bounds bounds = meshfilter.mesh.bounds;
float scale = meshfilter.transform.localScale.x;
Bounds b = new Bounds(bounds.center * scale, bounds.size * scale);
Bounds bounds = this.getPrefabBounds(lastObject);
Bounds b = new Bounds(bounds.center, bounds.size);
Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), lastObject.transform.position.z + b.size.z + 1.0f);
@ -56,7 +70,9 @@ public class ProceduralGeneration : MonoBehaviour
Vector3 direction = rotation * Vector3.down;
Vector3 position = (lastObject.transform.position + (direction * radius));
levelBlocksSpawnTemp.Add(Instantiate(objToSpawn, new Vector3(position.x, position.y + heightOffset, position.z + (float)(i * horizontalDistancePerPlatform)), rotation));
GameObject newObject = Instantiate(objToSpawn, new Vector3(position.x, position.y + heightOffset, position.z + (float)(i * horizontalDistancePerPlatform)), rotation);
newObject.transform.parent = parentLevelObject.transform;
levelBlocksSpawnTemp.Add(newObject);
}
return levelBlocksSpawnTemp;
@ -65,9 +81,12 @@ public class ProceduralGeneration : MonoBehaviour
// Start is called before the first frame update
void Start()
{
levelParrent = this.gameObject;
lastBlockPrefab = this.gameObject.transform.GetChild(0).gameObject;
lastBlock = this.gameObject.transform.GetChild(0).gameObject;
this.spawnedLevelBlocks.Add(lastBlock);
}
// Update is called once per frame
@ -76,6 +95,11 @@ public class ProceduralGeneration : MonoBehaviour
Vector3 playerPosition = this.player.transform.position;
PlayerController playerControlsSript = this.player.GetComponent<PlayerController>();
if (playerControlsSript.isFalling)
{
return;
}
for (var i = 0; i < this.spawnedLevelBlocks.Count; i++)
{
float distance = Vector3.Distance(this.spawnedLevelBlocks[i].transform.position, playerPosition);
@ -98,8 +122,7 @@ public class ProceduralGeneration : MonoBehaviour
int blockToSpawn = Random.Range(0, (levelBlocks.Count + 1));
if (playerControlsSript.isFalling == false) ;
{
if (blockToSpawn > 31 && (blockToSpawn < levelBlocks.Count) && levelBlocks[blockToSpawn].name == lastBlockPrefab.name)
{
Debug.Log("Same Block");
@ -108,17 +131,17 @@ public class ProceduralGeneration : MonoBehaviour
blockToSpawn = Random.Range(0, levelBlocks.Count);
}
}
}
if (blockToSpawn > -1 && (blockToSpawn < levelBlocks.Count))
{
blockObjToSpawn = levelBlocks[blockToSpawn];
instantiatedGameObject = this.drawPlatform(this.lastBlock, this.levelBlocks[blockToSpawn]);
instantiatedGameObject = this.drawPlatform(this.lastBlock, this.levelBlocks[blockToSpawn], this.levelParrent);
this.spawnedLevelBlocks.Add(instantiatedGameObject);
}
else
{
List<GameObject> instantiatedGameObjectLists = this.spawnSpiralOfPlatforms(lastBlock, levelBlocks[0]);
List<GameObject> instantiatedGameObjectLists = this.spawnSpiralOfPlatforms(lastBlock, levelBlocks[0], this.levelParrent);
foreach (var spavnedBlock in instantiatedGameObjectLists)
{
this.spawnedLevelBlocks.Add(spavnedBlock);

View File

@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gizmoManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
void OnDrawGizmos()
{
Bounds bounds = GetChildRendererBounds(gameObject);
Gizmos.DrawWireCube(bounds.center, bounds.size);
}
Bounds GetChildRendererBounds(GameObject go)
{
Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
if (renderers.Length > 0)
{
Bounds bounds = renderers[0].bounds;
for (int i = 1, ni = renderers.Length; i < ni; i++)
{
bounds.Encapsulate(renderers[i].bounds);
}
return bounds;
}
else
{
return new Bounds();
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 61dae18984b7ff147ab1d77fb817687a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: