checkpoints and AI prefab
This commit is contained in:
parent
1b41468536
commit
ed4d84590c
@ -214,22 +214,155 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: c250747ddb036f14faf25789ceb28a34, type: 3}
|
m_Script: {fileID: 11500000, guid: c250747ddb036f14faf25789ceb28a34, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
checkpoints:
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
hoverHeight: 3
|
hoverHeight: 3
|
||||||
positionAdjustmentSpeed: 5
|
positionAdjustmentSpeed: 10
|
||||||
raycastDistance: 10
|
raycastDistance: 20
|
||||||
terrainLayer:
|
terrainLayer:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 0
|
m_Bits: 0
|
||||||
movementSpeed: 50
|
movementSpeed: 100
|
||||||
acceleration: 5
|
acceleration: 2
|
||||||
deceleration: 7
|
deceleration: 2
|
||||||
rotationSpeed: 100
|
rotationSpeed: 125
|
||||||
waypoints: []
|
checkpointThreshold: 5
|
||||||
waypointThreshold: 5
|
randomSteeringProbability: 0.2
|
||||||
enableRubberBanding: 1
|
randomSteeringMaxOffset: 0.75
|
||||||
rubberBandingCoefficient: 0.1
|
slowdownDistance: 10
|
||||||
maxSpeedMultiplier: 1.5
|
slowdownStrength: 0.5
|
||||||
minSpeedMultiplier: 0.8
|
timeBeforeReset: 3
|
||||||
|
trackRaycastDistance: 10
|
||||||
|
trackTag: Track
|
||||||
|
avoidanceRadius: 5
|
||||||
|
avoidanceSteeringStrength: 0.5
|
||||||
|
avoidanceSlowdownMultiplier: 0.5
|
||||||
|
racerTag: Racer
|
||||||
--- !u!114 &8696968540172343143
|
--- !u!114 &8696968540172343143
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
7018
Assets/Prefabs/Checkpoints (1).prefab
Normal file
7018
Assets/Prefabs/Checkpoints (1).prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/Checkpoints (1).prefab.meta
Normal file
7
Assets/Prefabs/Checkpoints (1).prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0f449b42922c2f441bafbe9b6730d77d
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -229,6 +229,133 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: a58d34a4aed97c74b9dc8d93fe5594bf, type: 3}
|
m_Script: {fileID: 11500000, guid: a58d34a4aed97c74b9dc8d93fe5594bf, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
checkpoints:
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
hoverHeight: 3
|
hoverHeight: 3
|
||||||
positionAdjustmentSpeed: 5
|
positionAdjustmentSpeed: 5
|
||||||
raycastDistance: 10
|
raycastDistance: 10
|
||||||
@ -239,6 +366,9 @@ MonoBehaviour:
|
|||||||
acceleration: 3
|
acceleration: 3
|
||||||
deceleration: 2
|
deceleration: 2
|
||||||
rotationSpeed: 125
|
rotationSpeed: 125
|
||||||
|
timeBeforeReset: 3
|
||||||
|
trackRaycastDistance: 10
|
||||||
|
trackTag: Track
|
||||||
--- !u!114 &7105996084223619230
|
--- !u!114 &7105996084223619230
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -253,8 +253,8 @@ MonoBehaviour:
|
|||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: 120V
|
m_text: 120V
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: dc36b3fdc14f47ebb36fd484a67e268a, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2140032, guid: dc36b3fdc14f47ebb36fd484a67e268a, type: 2}
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
m_fontSharedMaterials: []
|
m_fontSharedMaterials: []
|
||||||
m_fontMaterial: {fileID: 0}
|
m_fontMaterial: {fileID: 0}
|
||||||
m_fontMaterials: []
|
m_fontMaterials: []
|
||||||
@ -963,6 +963,63 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 2739604471974086380, guid: dd7b06eb9076d6c429cee20c704cae64, type: 3}
|
m_CorrespondingSourceObject: {fileID: 2739604471974086380, guid: dd7b06eb9076d6c429cee20c704cae64, type: 3}
|
||||||
m_PrefabInstance: {fileID: 6388558628322318749}
|
m_PrefabInstance: {fileID: 6388558628322318749}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1001 &1707139190
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 134.5819
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: -67.20555
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: -0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: -0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: -8679921383154817045, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 919132149155446097, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Checkpoints
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: ee2201930da315a46991ca44e2200d6e, type: 3}
|
||||||
--- !u!1 &1746292606
|
--- !u!1 &1746292606
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1528,3 +1585,4 @@ SceneRoots:
|
|||||||
- {fileID: 2140683070}
|
- {fileID: 2140683070}
|
||||||
- {fileID: 860760551}
|
- {fileID: 860760551}
|
||||||
- {fileID: 433397977}
|
- {fileID: 433397977}
|
||||||
|
- {fileID: 1707139190}
|
||||||
|
8
Assets/Scripts/Editor.meta
Normal file
8
Assets/Scripts/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f72097fa2d71924697eeb57009cb41d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
63
Assets/Scripts/Editor/AutoIncrementer.cs
Normal file
63
Assets/Scripts/Editor/AutoIncrementer.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AutoIncrementer : EditorWindow
|
||||||
|
{
|
||||||
|
private GameObject parentObject;
|
||||||
|
private string fieldName = "desiredField"; // Replace with the field name if you want
|
||||||
|
|
||||||
|
[MenuItem("Tools/Auto Increment Field")]
|
||||||
|
public static void ShowWindow()
|
||||||
|
{
|
||||||
|
GetWindow<AutoIncrementer>("Auto Incrementer");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Label("Auto-Increment Field", EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
// Select the parent GameObject (if the objects are grouped)
|
||||||
|
parentObject = (GameObject)EditorGUILayout.ObjectField("Parent Object", parentObject, typeof(GameObject), true);
|
||||||
|
|
||||||
|
fieldName = EditorGUILayout.TextField("Field Name", fieldName);
|
||||||
|
|
||||||
|
if (GUILayout.Button("Auto-Increment"))
|
||||||
|
{
|
||||||
|
if (parentObject != null)
|
||||||
|
{
|
||||||
|
AutoIncrement();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Please select a parent GameObject containing the objects.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AutoIncrement()
|
||||||
|
{
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
foreach (Transform child in parentObject.transform)
|
||||||
|
{
|
||||||
|
var component = child.GetComponent<MonoBehaviour>(); // Assuming a custom MonoBehaviour script
|
||||||
|
|
||||||
|
if (component != null)
|
||||||
|
{
|
||||||
|
var field = component.GetType().GetField(fieldName);
|
||||||
|
|
||||||
|
if (field != null && field.FieldType == typeof(int))
|
||||||
|
{
|
||||||
|
field.SetValue(component, counter);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Field '{fieldName}' not found or not of type 'int' on {child.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("Auto-incrementing finished!");
|
||||||
|
}
|
||||||
|
}
|
2
Assets/Scripts/Editor/AutoIncrementer.cs.meta
Normal file
2
Assets/Scripts/Editor/AutoIncrementer.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6f08c72d4d9a6e44abc5069ce7a3b64e
|
71
Assets/Scripts/Editor/PopulateTransformList.cs
Normal file
71
Assets/Scripts/Editor/PopulateTransformList.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
public class PopulateTransformArray : EditorWindow
|
||||||
|
{
|
||||||
|
private GameObject parentObject;
|
||||||
|
private MonoBehaviour targetScript;
|
||||||
|
private string arrayFieldName = "transformArray"; // Change this as needed
|
||||||
|
|
||||||
|
[MenuItem("Tools/Populate Transform Array")]
|
||||||
|
public static void ShowWindow()
|
||||||
|
{
|
||||||
|
GetWindow<PopulateTransformArray>("Populate Transform Array");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Label("Populate Array of Transforms", EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
// Select the GameObject whose subchildren will populate the array
|
||||||
|
parentObject = (GameObject)EditorGUILayout.ObjectField("Parent Object", parentObject, typeof(GameObject), true);
|
||||||
|
|
||||||
|
// Select the script containing the array field
|
||||||
|
targetScript = (MonoBehaviour)EditorGUILayout.ObjectField("Target Script", targetScript, typeof(MonoBehaviour), true);
|
||||||
|
|
||||||
|
arrayFieldName = EditorGUILayout.TextField("Array Field Name", arrayFieldName);
|
||||||
|
|
||||||
|
if (GUILayout.Button("Populate Array"))
|
||||||
|
{
|
||||||
|
if (parentObject != null && targetScript != null)
|
||||||
|
{
|
||||||
|
PopulateArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Please assign both a parent object and a target script.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateArray()
|
||||||
|
{
|
||||||
|
var targetType = targetScript.GetType();
|
||||||
|
var arrayField = targetType.GetField(arrayFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
|
if (arrayField == null || arrayField.FieldType != typeof(Transform[]))
|
||||||
|
{
|
||||||
|
Debug.LogError($"Field '{arrayFieldName}' not found or is not a Transform[] array.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gather all subchildren into an array
|
||||||
|
Transform[] transformArray = new Transform[parentObject.transform.childCount];
|
||||||
|
int index = 0;
|
||||||
|
foreach (Transform child in parentObject.transform)
|
||||||
|
{
|
||||||
|
transformArray[index] = child;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Record the change for Unity serialization
|
||||||
|
Undo.RecordObject(targetScript, "Populate Transform Array");
|
||||||
|
arrayField.SetValue(targetScript, transformArray);
|
||||||
|
|
||||||
|
// Mark the object as dirty to ensure changes are saved
|
||||||
|
EditorUtility.SetDirty(targetScript);
|
||||||
|
|
||||||
|
Debug.Log($"Array populated with {transformArray.Length} transforms from {parentObject.name}");
|
||||||
|
}
|
||||||
|
}
|
2
Assets/Scripts/Editor/PopulateTransformList.cs.meta
Normal file
2
Assets/Scripts/Editor/PopulateTransformList.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 408e578cb457ab04a8196d220d6f5261
|
Loading…
x
Reference in New Issue
Block a user