public static void LoadPose(Skin skin, Transform root) { SerializedObject skinSO = new SerializedObject(skin); SerializedProperty entriesProp = skinSO.FindProperty("m_SkinEntries"); List <Skin> skins = new List <Skin>(); for (int i = 0; i < entriesProp.arraySize; i++) { SerializedProperty element = entriesProp.GetArrayElementAtIndex(i); Transform skinTransform = root.Find(element.FindPropertyRelative("path").stringValue); if (skinTransform) { SpriteMeshInstance skinComponent = skinTransform.GetComponent <SpriteMeshInstance>(); Undo.RecordObject(skinTransform.GetComponent <SpriteMeshInstance>(), "Load Skin"); skinComponent.spriteMesh = element.FindPropertyRelative("skin").objectReferenceValue as SpriteMesh; } } SerializedProperty entriesProp1 = skinSO.FindProperty("m_FaceEntries"); List <SpriteMesh> faces = new List <SpriteMesh>(); for (int i = 0; i < entriesProp1.arraySize; i++) { SerializedProperty element = entriesProp1.GetArrayElementAtIndex(i); faces.Add(element.FindPropertyRelative("skin").objectReferenceValue as SpriteMesh); } SpriteMeshAnimation sma = root.Find(entriesProp1.GetArrayElementAtIndex(0).FindPropertyRelative("path").stringValue).GetComponent <SpriteMeshAnimation>(); if (faces.Count >= 1) { sma.frames = faces.ToArray(); sma.frame = 0; Undo.RecordObject(sma, "Load Skin"); } EditorUtility.SetDirty(sma); //EditorUpdater.SetDirty("Load Skin"); }
void GetReferences() { rb = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); sounds = GameObject.Find("Manager").GetComponent <SoundManager>(); footOrigin = transform.GetChild(0); frontOrigin = transform.GetChild(1); backOrigin = transform.GetChild(2); dizzyEffect = transform.GetChild(5).gameObject; burstButtons = transform.GetChild(6).gameObject; burstButtons.GetComponent <DizzyButtons>().myPlayer = this; burstButtons.GetComponent <DizzyButtons>().playerNum = playerNum; normalGrav = rb.gravityScale; respawnPos = transform.position; // Gets a reference to every mesh. GameObject meshSkeleton = transform.GetChild(3).gameObject; for (int i = 0; i < meshSkeleton.transform.childCount; i++) { GameObject currentMesh = meshSkeleton.transform.GetChild(i).gameObject; SpriteMeshInstance smi = currentMesh.GetComponent <SpriteMeshInstance>(); meshes.Add(smi); if (i == 0) { sign = currentMesh.GetComponent <SpriteMeshAnimation>(); } if (i == 1) { emblem = currentMesh.GetComponent <SpriteMeshAnimation>(); } } impactAudio = gameObject.AddComponent <AudioSource>(); actionAudio = gameObject.AddComponent <AudioSource>(); loopingAudio = gameObject.AddComponent <AudioSource>(); loopingAudio.loop = true; }
private void Start() { faceCotroller = GetComponentInChildren <SpriteMeshAnimation>(); }
// Use this for initialization void Start() { sma = GetComponent <SpriteMeshAnimation>(); myPlayer = GameObject.Find("ARMS_P" + PlayerNum).GetComponent <Player>(); }
public static string GetSpriteMeshPath(Transform root, SpriteMeshAnimation spm) { return(GetPath(root, spm.transform)); }