Add prototype gameplay loop with character/battlefield assets and server game APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public static class AuditAnimalWalk
|
||||
{
|
||||
const string Root = "Assets/Bundles/Characters/Animal/RockBall";
|
||||
static GameObject Spawn(string path) => Object.Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>(path));
|
||||
public static string Capture()
|
||||
{
|
||||
string dir = Path.GetFullPath(Path.Combine(Application.dataPath, "../../Tools/output/rockball_walk_audit"));
|
||||
Directory.CreateDirectory(dir);
|
||||
var scene = EditorSceneManager.NewPreviewScene();
|
||||
try
|
||||
{
|
||||
var unit = Spawn(Root + "/RockBall_Rigged.prefab");
|
||||
SceneManager.MoveGameObjectToScene(unit, scene);
|
||||
var anim = unit.GetComponentInChildren<Animator>();
|
||||
anim.enabled = false;
|
||||
var clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(Root + "/Clips/Walk.anim");
|
||||
var light = new GameObject("AuditLight").AddComponent<Light>();
|
||||
SceneManager.MoveGameObjectToScene(light.gameObject, scene);
|
||||
light.type = LightType.Directional;
|
||||
light.intensity = 1.5f;
|
||||
light.transform.rotation = Quaternion.Euler(45, -30, 0);
|
||||
var cam = new GameObject("AuditCamera").AddComponent<Camera>();
|
||||
SceneManager.MoveGameObjectToScene(cam.gameObject, scene);
|
||||
cam.scene = scene;
|
||||
cam.clearFlags = CameraClearFlags.SolidColor;
|
||||
cam.backgroundColor = new Color(.45f,.53f,.59f);
|
||||
cam.transform.position = new Vector3(1.1f,.75f,-1.6f);
|
||||
cam.transform.LookAt(new Vector3(0,.28f,0));
|
||||
cam.orthographic = true;
|
||||
cam.orthographicSize = .43f;
|
||||
cam.nearClipPlane = .01f;
|
||||
var rt = new RenderTexture(512,512,24);
|
||||
cam.targetTexture = rt;
|
||||
var tex = new Texture2D(512,512,TextureFormat.RGB24,false);
|
||||
var previous = RenderTexture.active;
|
||||
try
|
||||
{
|
||||
for (int i = -1; i < 4; i++)
|
||||
{
|
||||
if (i >= 0) clip.SampleAnimation(anim.gameObject, clip.length * i / 4f);
|
||||
cam.Render();
|
||||
RenderTexture.active = rt;
|
||||
tex.ReadPixels(new Rect(0,0,512,512),0,0);
|
||||
tex.Apply();
|
||||
File.WriteAllBytes(Path.Combine(dir, i < 0 ? "bind.png" : "walk_" + i + ".png"), tex.EncodeToPNG());
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
RenderTexture.active = previous;
|
||||
cam.targetTexture = null;
|
||||
rt.Release();
|
||||
Object.DestroyImmediate(rt);
|
||||
Object.DestroyImmediate(tex);
|
||||
}
|
||||
}
|
||||
finally { EditorSceneManager.ClosePreviewScene(scene); }
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user