// remove them from me and all my descendants. public void RemoveITweenComponentsTree() { RemoveITweenComponents(); foreach (Transform child in this.transform) { PositionToggler pt = child.GetComponent <PositionToggler>(); if (pt != null) { pt.RemoveITweenComponentsTree(); } } }
public void SwapBarSlotPositions() { Bar bar = this.GetComponent <Bar>(); if (bar) { foreach (BarSlot slot in bar.barSlotList) { PositionToggler ptglr = slot.GetComponent <PositionToggler>(); if (ptglr != null) { ptglr.Swap01(); } } } }
public void SetState(int stateIdx) { curState = stateIdx; if (childBar != null) { childBar.SetState(curState); // sets the location of the bar underneath us. } // sets the positions of the slots beneath us to match our current state foreach (BarSlot bs in barSlotList) { PositionToggler tglr = bs.GetComponent <PositionToggler>(); if (tglr != null) { tglr.SetState(curState); } } }
public override void OnInspectorGUI() { DrawDefaultInspector(); PositionToggler myScript = (PositionToggler)target; if (GUILayout.Button("Set Keyframe")) { myScript.SetKeyframe(); } if (GUILayout.Button("Align xpos")) { myScript.AlignXpos(); } if (GUILayout.Button("Test Toggle")) { myScript.ToggleNext(); } #if QUICKHACK_EDITS // iTween bug keeps creating iTween components in editor if (GUILayout.Button("Remove itween components")) { myScript.RemoveITweenComponentsTree(); } // hack: do this automatically myScript.RemoveITweenComponents(); #endif #if false // one time edit hack if (GUILayout.Button("Swap BarSlot PositionToggler 0 and 1")) { myScript.SwapBarSlotPositions(); } #endif }
void Start() { posToggler = GetComponent <PositionToggler>(); posToggler.AddOnToggleCallback(this); }