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,85 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>Persistent two-character review, isolated from the general review scene.</summary>
|
||||
public static class ReviewRockBallWalk
|
||||
{
|
||||
const string Folder="Assets/Bundles/Scenes/Review";
|
||||
public static string Build()
|
||||
{
|
||||
if(EditorApplication.isPlaying) throw new InvalidOperationException("Use Edit Mode");
|
||||
for(int i=0;i<SceneManager.sceneCount;i++)
|
||||
if(SceneManager.GetSceneAt(i).isDirty) throw new InvalidOperationException("Save pending scene edits before building Walk review");
|
||||
var scene=EditorSceneManager.NewScene(NewSceneSetup.EmptyScene,NewSceneMode.Single);
|
||||
var floorMaterial=AssetDatabase.LoadAssetAtPath<Material>(Folder+"/RockBallWalkFloor.mat");
|
||||
if(floorMaterial==null)
|
||||
{
|
||||
floorMaterial=new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
||||
floorMaterial.color=new Color(.48f,.56f,.50f);
|
||||
AssetDatabase.CreateAsset(floorMaterial,Folder+"/RockBallWalkFloor.mat");
|
||||
}
|
||||
var floor=GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
floor.name="Ground_Y0";
|
||||
floor.transform.localScale=Vector3.one*.6f;
|
||||
floor.GetComponent<Renderer>().sharedMaterial=floorMaterial;
|
||||
for(int i=0;i<2;i++)
|
||||
{
|
||||
string root="Assets/Bundles/Characters/Animal/RockBall/";
|
||||
string asset=i==0 ? "RockBall.prefab" : "RockBall_Rigged.prefab";
|
||||
var go=(GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(root+asset));
|
||||
go.name=i==0 ? "ApprovedStatic" : "WalkVerified";
|
||||
go.transform.position=new Vector3(i==0 ? -.5f : .5f,0,0);
|
||||
var label=new GameObject("NameLabel");
|
||||
label.transform.SetParent(go.transform,false);
|
||||
label.transform.position=go.transform.position+Vector3.up*.77f;
|
||||
var text=label.AddComponent<TextMesh>();
|
||||
text.text=i==0 ? "Approved static" : "12-bone rig";
|
||||
text.anchor=TextAnchor.MiddleCenter;
|
||||
label.transform.localScale=Vector3.one/go.transform.lossyScale.x;
|
||||
text.characterSize=.012f; text.fontSize=42;
|
||||
text.color=new Color(.12f,.18f,.2f);
|
||||
var marker=GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
marker.name="ForwardMinusZ";
|
||||
marker.transform.SetParent(go.transform,false);
|
||||
// World dimensions: the approved static prefab root carries scale.
|
||||
marker.transform.position=go.transform.position+new Vector3(0,.012f,-.4f);
|
||||
marker.transform.localScale=new Vector3(.04f,.015f,.23f)/go.transform.lossyScale.x;
|
||||
if(i==1)
|
||||
{
|
||||
var cycle=go.AddComponent<CharacterReviewAnimCycle>();
|
||||
var so=new SerializedObject(cycle);
|
||||
var names=so.FindProperty("motionNames");
|
||||
names.arraySize=1; names.GetArrayElementAtIndex(0).stringValue="Walk";
|
||||
so.ApplyModifiedPropertiesWithoutUndo();
|
||||
cycle.enabled=false; cycle.enabled=true;
|
||||
}
|
||||
}
|
||||
var sun=new GameObject("Sun").AddComponent<Light>();
|
||||
sun.type=LightType.Directional; sun.intensity=1.3f; sun.shadows=LightShadows.Soft;
|
||||
sun.transform.rotation=Quaternion.Euler(48,-30,0);
|
||||
var camera=new GameObject("ReviewCamera").AddComponent<Camera>();
|
||||
camera.tag="MainCamera";
|
||||
camera.clearFlags=CameraClearFlags.SolidColor;
|
||||
camera.backgroundColor=new Color(.66f,.76f,.81f);
|
||||
camera.transform.position=new Vector3(1.15f,1.05f,-3.1f);
|
||||
camera.transform.LookAt(new Vector3(0,.35f,0));
|
||||
camera.orthographic=true; camera.orthographicSize=.85f;
|
||||
camera.nearClipPlane=.05f; camera.farClipPlane=30;
|
||||
camera.gameObject.AddComponent<AudioListener>();
|
||||
RenderSettings.ambientMode=UnityEngine.Rendering.AmbientMode.Trilight;
|
||||
RenderSettings.ambientSkyColor=new Color(.65f,.72f,.8f);
|
||||
RenderSettings.ambientEquatorColor=new Color(.45f,.5f,.48f);
|
||||
RenderSettings.ambientGroundColor=new Color(.3f,.28f,.25f);
|
||||
AssetDatabase.SaveAssets();
|
||||
string path=Folder+"/RockBallWalkReview.unity";
|
||||
EditorSceneManager.SaveScene(scene,path);
|
||||
var view=SceneView.lastActiveSceneView;
|
||||
if(view!=null) { view.LookAt(new Vector3(0,.3f,0),Quaternion.Euler(12,-12,0),1.8f); view.Repaint(); }
|
||||
return path;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user