Hi,
I’m sry for my c# understanding, i started with c# a few days ago.
I want to record only the Emission Color of each Cube in the Parent GameObject of my Spectrogram, because if i record all Propertys of the MeshRenderer, Unity starts to lag and dont record correctly. i was searching on Google how i can do it but i didnt found a tutorial or something how it works for my way.
It should work with “EditorCurveBinding.FloatCurve”, but i dont know directly whats the right name of the Property.
Thats the important Code, with my last try.
This Script is on the GameObject “AudioPeer”:
public class AudioPeer : MonoBehaviour
{
[Header("GameObjects")]
[Space(5)]
public GameObject _gameObjectParent;
[Header("Record Options")]
[Space(5)]
public AnimationClip Animclip;
public bool Record = false;
GameObjectRecorder m_Recorder;
string _objName;
private ParamCube _paramCube;
// Use this for initialization
void Start()
{
_paramCube = GameObject.Find("parametric-cube").GetComponent<ParamCube>();
m_Recorder = new GameObjectRecorder();
_objName = _paramCube._name;
EditorCurveBinding binding = EditorCurveBinding.FloatCurve(_objName, typeof(MeshRenderer), "m_Material._EmissionColor");
m_Recorder.root = this._gameObjectParent;
m_Recorder.BindComponent<Transform>(_gameObjectParent, true);
//m_Recorder.BindComponent<MeshRenderer>(_gameObjectParent, true);
m_Recorder.Bind(binding);
}
void LateUpdate()
{
if (Animclip == null)
return;
if (Record)
{
// As long as "record" is on: take a snapshot.
m_Recorder.TakeSnapshot(Time.fixedDeltaTime);
}
else if (m_Recorder.isRecording)
{
// "record" is off, but we were recording:
// save to clip and clear recording.
m_Recorder.SaveToClip(Animclip);
m_Recorder.ResetRecording();
}
}
}
Its also a Script on each Cube what is called “ParamCube”, it changes the EmissionColor, transforms and other, what i want to record, but i think its not important to post it.
Thats the Hierachy: