void Record(EMSimpleMotion motion) { if (!inRec) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); string label = "Record"; if (inRec) { label = "Stop record"; } if (GUILayout.Button(label, GUILayout.Width(100))) { if (!inRec) { startRect.InitAllFromRectTransform(motion.rectTransform(), motion.GetComponentInParent <CanvasGroup>().alpha); if (motion.simpleProp.isMove && motion.simpleProp.moveDirection == EMMotionProperties.MotionDirection.UserDefined) { motion.rectTransform().anchorMin = motion.simpleProp.transform.anchorMin; motion.rectTransform().anchorMax = motion.simpleProp.transform.anchorMax; motion.rectTransform().anchoredPosition = motion.simpleProp.transform.position; } if (motion.simpleProp.isRotate) { motion.rectTransform().localRotation = Quaternion.Euler(motion.simpleProp.transform.rotation); } if (motion.simpleProp.isScale) { motion.rectTransform().localScale = motion.simpleProp.transform.scale; } if (motion.simpleProp.isAlpha) { motion.rectTransform().GetComponentInParent <CanvasGroup>().alpha = motion.simpleProp.transform.alpha; } } else { startRect.ApplyAllToRectTransform(motion.rectTransform(), motion.rectTransform().GetComponentInParent <CanvasGroup>()); } inRec = !inRec; } GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }
public virtual void Awake() { cachedTransform = this.rectTransform(); cachedCanvasGroup = GetComponent <CanvasGroup>(); cachedCanvasScaler = GetComponentInParent <CanvasScaler>(); if (cachedCanvasScaler != null) { //Debug.LogWarning("Canvas scaler is missing"); startTransform.InitAllFromRectTransform(cachedTransform, alpha); // Helper originOffset = GetOriginOffset(startTransform.anchorMin); EMMotionManager.instance.RegisterMotion(this); } }