// Copy this event params to an other event params public void CopyTo(Uni2DAnimationFrameInfos a_rOtherEventParams) { a_rOtherEventParams.stringInfo = stringInfo; a_rOtherEventParams.intInfo = intInfo; a_rOtherEventParams.floatInfo = floatInfo; a_rOtherEventParams.objectInfo = objectInfo; }
// Is this event params is different from an event params public bool IsDifferentFrom(Uni2DAnimationFrameInfos a_rOtherEventParams) { return(stringInfo != a_rOtherEventParams.stringInfo || intInfo != a_rOtherEventParams.intInfo || floatInfo != a_rOtherEventParams.floatInfo || objectInfo != a_rOtherEventParams.objectInfo); }
// Is this event params is different from an event params public bool IsDifferentFrom(Uni2DAnimationFrameInfos a_rOtherEventParams) { return stringInfo != a_rOtherEventParams.stringInfo || intInfo != a_rOtherEventParams.intInfo || floatInfo != a_rOtherEventParams.floatInfo || objectInfo != a_rOtherEventParams.objectInfo; }
// Displays the animation frame GUI // Returns the performed user action public static AnimationGUIAction DisplayAnimationFrame(Uni2DAnimationFrame a_rAnimationFrame, Uni2DTextureAtlas a_rGlobalAtlas, ref bool a_bEventFoldout) { AnimationGUIAction eAction = AnimationGUIAction.None; // Box EditorGUILayout.BeginVertical(EditorStyles.textField); { ///// Top toolbar ///// EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { // ^ if (GUILayout.Button("\u25B2" /*"\u2191"*/, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { eAction = AnimationGUIAction.MoveUp; } // v if (GUILayout.Button("\u25BC" /*"\u2193"*/, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { eAction = AnimationGUIAction.MoveDown; } // + ^ if (GUILayout.Button("+ \u25B2" /*"+ \u2191"*/, EditorStyles.toolbarButton, GUILayout.ExpandWidth(true))) { eAction = AnimationGUIAction.AddUp; } // X if (GUILayout.Button("X", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { eAction = AnimationGUIAction.Close; } } EditorGUILayout.EndHorizontal( ); /////////////// EditorGUILayout.Space( ); ///// Animation Frame box ///// EditorGUILayout.BeginHorizontal( ); { Texture2D rFrameTexture = a_rAnimationFrame.textureContainer; string rFrameTextureGUID = a_rAnimationFrame.textureContainer.GUID; bool bHasFrameTextureChanged; // Display frame texture on the left Rect oClipTextureRect = GUILayoutUtility.GetRect(64.0f, 64.0f, 64.0f, 64.0f, GUILayout.ExpandWidth(false)); EditorGUI.BeginChangeCheck( ); { rFrameTexture = (Texture2D)EditorGUI.ObjectField(oClipTextureRect, GUIContent.none, rFrameTexture, typeof(Texture2D), false); } bHasFrameTextureChanged = EditorGUI.EndChangeCheck( ); EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true)); { // Frame texture name GUILayout.Label(rFrameTexture != null ? rFrameTexture.name : "(No Texture)", EditorStyles.boldLabel, GUILayout.ExpandWidth(false)); // Frame Name a_rAnimationFrame.name = EditorGUILayout.TextField("Frame Name", a_rAnimationFrame.name); // Frame atlas EditorGUILayout.BeginHorizontal( ); { // Disable popup menu if global atlas is set EditorGUI.BeginDisabledGroup(a_rGlobalAtlas != null); { // Atlas popup string[] oTextureGUID = (rFrameTexture != null) ? new string[1] { rFrameTextureGUID } : new string[0]; EditorGUILayout.PrefixLabel("Use Atlas"); a_rAnimationFrame.atlas = Uni2DEditorGUIUtils.AtlasPopup(a_rAnimationFrame.atlas, oTextureGUID); } EditorGUI.EndDisabledGroup( ); // Atlas select button EditorGUI.BeginDisabledGroup(a_rAnimationFrame.atlas == null); { if (GUILayout.Button("Select", GUILayout.Width(80.0f))) { EditorGUIUtility.PingObject(a_rAnimationFrame.atlas.gameObject); } } EditorGUI.EndDisabledGroup( ); } EditorGUILayout.EndHorizontal( ); // Trigger? a_rAnimationFrame.triggerEvent = EditorGUILayout.Toggle("Trigger Event", a_rAnimationFrame.triggerEvent); // Event param a_bEventFoldout = EditorGUILayout.Foldout(a_bEventFoldout, "Frame Infos"); if (a_bEventFoldout) { Uni2DAnimationFrameInfos rFrameInfos = a_rAnimationFrame.frameInfos; ++EditorGUI.indentLevel; { rFrameInfos.stringInfo = EditorGUILayout.TextField("String Info", rFrameInfos.stringInfo); rFrameInfos.intInfo = EditorGUILayout.IntField("Int Info", rFrameInfos.intInfo); rFrameInfos.floatInfo = EditorGUILayout.FloatField("Float Info", rFrameInfos.floatInfo); rFrameInfos.objectInfo = EditorGUILayout.ObjectField("Object Info", rFrameInfos.objectInfo, typeof(Object), true); } --EditorGUI.indentLevel; } EditorGUILayout.Space( ); } EditorGUILayout.EndVertical( ); if (bHasFrameTextureChanged) { // Save texture in texture container, keep reference to the asset if not using an atlas a_rAnimationFrame.textureContainer = new Texture2DContainer(rFrameTexture, a_rGlobalAtlas == null); } } EditorGUILayout.EndHorizontal( ); /////////////// EditorGUILayout.Space( ); ///// Bottom toolbar ///// EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { // + v if (GUILayout.Button("+ \u25BC" /*"+ \u2193"*/, EditorStyles.toolbarButton, GUILayout.ExpandWidth(true))) { eAction = AnimationGUIAction.AddDown; } } EditorGUILayout.EndHorizontal( ); } EditorGUILayout.EndVertical( ); return(eAction); }