private void CloneGear(GFGear gear, Vector3 direction) { GameObject newGearGO = gear.Clone(direction); // Mark new gear as dirty UnityEditor.EditorUtility.SetDirty(newGearGO); // Set focus on new gear Selection.activeGameObject = newGearGO; }
void AddGears() { if (numberOfInstances < 1) { numberOfInstances = 1; } if (numberOfInstances > 1) { GFGear gear = null; int seqLen = 0; int repeat = 0; int n = 0; Vector3 dir; for (int i = 0; i < numberOfInstances - 1; i += seqLen) { if (repeat == 1) { repeat = 0; seqLen++; } else { repeat++; } for (int g = 0; g < seqLen; g++) { if (instances.Count == numberOfInstances - 1) { i = 0; break; } gear = instances.Count > 0 ? instances[instances.Count - 1] : gearToTest; dir = Quaternion.AngleAxis(90f * n, Vector3.back) * Vector3.right; GFGear newGear = gear.Clone(dir).GetComponent <GFGear>(); instances.Add(newGear); } n++; if (n >= 4) { n = 0; } } machine.RecalculateGears(); } }