You've already forked taptap2024_GJ_chidouren
增加编辑器工具
This commit is contained in:
191
Assets/Scripts/Game/Component/SceneProp/Editor/GameSceneTools.cs
Normal file
191
Assets/Scripts/Game/Component/SceneProp/Editor/GameSceneTools.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Component.SceneProp.Editor
|
||||
{
|
||||
public class GameSceneTools
|
||||
{
|
||||
//编辑器场景快速创建工具
|
||||
//加载预制体
|
||||
public static GameObject LoadPrefab (string path)
|
||||
{
|
||||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject> (path);
|
||||
return prefab;
|
||||
}
|
||||
|
||||
public static Vector3 CreatePos ()
|
||||
{
|
||||
//获取选择目标的位置, 如果有父物体直接用父物体位置
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
return target.position;
|
||||
}
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
//创建红色道具
|
||||
[MenuItem("GameObject/场景道具/创建传送门red", false, 10)]
|
||||
public static void CreateRedProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/redProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
//保持预制体关联
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建蓝色道具
|
||||
[MenuItem("GameObject/场景道具/创建加速道具blue", false, 10)]
|
||||
public static void CreateBlueProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/blueProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建绿色道具
|
||||
[MenuItem("GameObject/场景道具/创建减速道具green", false, 10)]
|
||||
public static void CreateGreenProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/greenProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建白色道具
|
||||
[MenuItem("GameObject/场景道具/创建惊悚buff道具white", false, 10)]
|
||||
public static void CreateWhiteProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/whiteProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建普通道具
|
||||
[MenuItem("GameObject/场景道具/创建普通豆子normal" , false, 10)]
|
||||
public static void CreateNormalProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/normalProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建敌人a
|
||||
[MenuItem("GameObject/场景敌人/创建敌人a" , false, 10)]
|
||||
public static void CreateEnemyA (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/GamePool/enemy_A.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建敌人b
|
||||
[MenuItem("GameObject/场景角色/创建敌人b" , false, 10)]
|
||||
public static void CreateEnemyB (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/GamePool/enemy_B.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建敌人c
|
||||
[MenuItem("GameObject/场景角色/创建敌人c" , false, 10)]
|
||||
public static void CreateEnemyC (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/GamePool/enemy_C.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建敌人witch
|
||||
[MenuItem("GameObject/场景角色/创建敌人witch" , false, 10)]
|
||||
public static void CreateEnemyWitch (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/GamePool/enemy_Witch.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac86259eea0d40a4b7010e3bb988653b
|
||||
timeCreated: 1729322765
|
||||
Reference in New Issue
Block a user