Развитие гоночек
This commit is contained in:
1 parent
ec60c47652
commit
b54083521f
532 files changed
+16091
-28231
No files matched your search
@@ -0,0 +1,39 @@
|
||||
namespace Code.Example.Race.Track.WellEditor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public static class CheckPointAsset
|
||||
{
|
||||
[MenuItem("GameObject/Track/CheckPoint", false, 1)]
|
||||
private static void CreateCustomPrefab()
|
||||
{
|
||||
// Define the path to your prefab in the Project (must be in an "Assets" relative path)
|
||||
var prefabPath = "Assets/Resources/Example/Misc/Point.prefab"; // Update with your actual path
|
||||
|
||||
// Load the prefab asset
|
||||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||
|
||||
if (!prefab)
|
||||
{
|
||||
Debug.LogError("Prefab not found at path: " + prefabPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Instantiate the prefab in the scene
|
||||
var newInstance = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
|
||||
// Ensure it is placed correctly in the Hierarchy and is undoable
|
||||
Undo.RegisterCreatedObjectUndo(newInstance, "Create Custom Prefab");
|
||||
Selection.activeGameObject = newInstance;
|
||||
|
||||
// Set parent if an object is selected
|
||||
if (!Selection.activeTransform)
|
||||
{
|
||||
newInstance.transform.parent = Selection.activeTransform;
|
||||
newInstance.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user