I created a game object and added a SpriteStuff
script to it that I created with a various properties and functions for the game object. I also made a few copies of the object.
After, I made a GroupSpriteStuff
game object which has the following property
public List<SpriteStuff> spriteStuffs;
I added an editor script for GroupSpriteStuff
(GroupSpriteStuffEditor
) that iterates through spriteStuffs
to move each object using a slider.
The movement of objects in spriteStuffs
is only seen when I select the objects after moving the slider, if I don't select the objects after moving the slider the changes are aren't visible in the scene view. Below is the GroupSpriteStuffEditor
:
GroupSpriteStuff groupSpriteStuff;
float groupSpritesMvmtSliderValue = 0.0f;
void OnEnable()
{
groupSpriteStuff = (GroupSpriteStuff)target;
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUI.BeginChangeCheck();
groupSpritesMvmtSliderValue = EditorGUILayout.Slider("Group Movement", groupSpriteStuff.originalGroupSpritesMvmtSliderValue, 0.0f, 1.0f);
if (!Mathf.Approximately(groupSpriteStuff.originalGroupSpritesMvmtSliderValue, groupSpritesMvmtSliderValue))
{
for (int i = 0; i < groupSpriteStuff.spriteStuffs.Count; i++)
{
spriteStuffs[i].UseTestMovement(0.2f);
}
groupSpriteStuff.originalGroupSpritesMvmtSliderValue = groupSpritesMvmtSliderValue;
}
if (EditorGUI.EndChangeCheck())
{
SceneView.RepaintAll();
}
}
How can I get the scene view to update/recognise the changes in movement I make with the slider?