备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
public class ConvertFromArtPrefabToGamePrefab : EditorWindow
|
||||
{
|
||||
[MenuItem("Tools/Creat IB Prefabs")]
|
||||
public static void ConvertPrefabs()
|
||||
{
|
||||
Object[] artPrefabs = Selection.objects;
|
||||
PhysicsMaterial2D pm = AssetDatabase.LoadAssetAtPath<PhysicsMaterial2D>("Assets/ABPackage/InfiniteBuildingPrefabs/PhysicMat_Block.physicsMaterial2D");
|
||||
string dest = "Assets/ABPackage/InfiniteBuildingPrefabs/";
|
||||
foreach (Object artGO in artPrefabs)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(artGO);
|
||||
GameObject artPrefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
GameObject artInstance = PrefabUtility.InstantiatePrefab(artPrefab) as GameObject;
|
||||
Debug.Log(assetPath);
|
||||
if (artInstance == null)
|
||||
continue;
|
||||
string artName = artPrefab.name;
|
||||
BoxCollider artBc = artInstance.GetComponent<BoxCollider>();
|
||||
Vector3 colliderSize = artBc.size;
|
||||
Vector3 colliderCenter = artBc.center;
|
||||
DestroyImmediate(artBc, true);
|
||||
|
||||
GameObject go = new GameObject();
|
||||
go.name = artName;
|
||||
go.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
go.transform.localScale = Vector3.one;
|
||||
artInstance.transform.parent = go.transform;
|
||||
artInstance.transform.position = Vector3.zero;
|
||||
Rigidbody2D rb = go.AddComponent<Rigidbody2D>();
|
||||
rb.drag = 4;
|
||||
rb.angularDrag = 1;
|
||||
BoxCollider2D bc = go.AddComponent<BoxCollider2D>();
|
||||
bc.sharedMaterial = pm;
|
||||
bc.isTrigger = false;
|
||||
bc.offset = new Vector2(-colliderCenter.x, colliderCenter.z);
|
||||
bc.size = new Vector2(colliderSize.x, colliderSize.z);
|
||||
go.AddComponent<Block>();
|
||||
PrefabUtility.SaveAsPrefabAsset(go, dest + go.name + ".prefab");
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"Converted colliders in prefab: {go.name}");
|
||||
DestroyImmediate(go, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc6578f9d1b69ad4cb9e685605e185dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "InfiniteBuilding.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:f720a012c494ab7478b1926183db234f"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ea8c55f787d445a8bcb69e94dd0cf9b
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user