// ------------------- static public TouchButtonSpriteAnimator CreateButtonAnimator( TouchButton target, string nameSuffix, Sprite sprite, float scale, string undoLabel = null) { RectTransform subObj = CreateSubRectTr(target.transform, target.name + nameSuffix, scale); // Create Sprite animator... TouchButtonSpriteAnimator sprAnimator = subObj.gameObject.AddComponent <TouchButtonSpriteAnimator>(); sprAnimator.autoConnectToSource = true; sprAnimator.SetSourceControl(target); sprAnimator.SetStateSprite(TouchButtonSpriteAnimator.ControlState.Neutral, sprite); SetImagePreserveAspectRatio(subObj.gameObject, true); if (undoLabel != null) { Undo.RegisterCreatedObjectUndo(subObj.gameObject, undoLabel); } return(sprAnimator); }
// --------------- public override void OnInspectorGUI() { TouchButtonSpriteAnimator target = this.target as TouchButtonSpriteAnimator; if ((target == null)) { return; } if (!TouchControlSpriteAnimatorInspector.DrawSourceGUI(target)) { return; } if (target.sourceControl == null) { } //InspectorUtils.DrawErrorBox("Source Button is not connected!"); else { InspectorUtils.BeginIndentedSection(new GUIContent("Sprite Settings")); this.spriteNeutral.Draw(target.spriteNeutral, target, true, false); { EditorGUILayout.Space(); this.spritePressed.Draw(target.spritePressed, target, target.IsIllegallyAttachedToSource()); if (((TouchButton)target.sourceControl).toggle) { EditorGUILayout.Space(); this.spriteToggled.Draw(target.spriteToggled, target, target.IsIllegallyAttachedToSource()); EditorGUILayout.Space(); this.spriteToggledAndPressed.Draw(target.spriteToggledAndPressed, target, target.IsIllegallyAttachedToSource()); } } InspectorUtils.EndIndentedSection(); } }