bool ValidateText2D(Shape shape, MessageHandler handler) { Text2DHandler textHandler = (Text2DHandler)handler; Text2D text2DReference = (Text2D)textHandler.CreateSerialisationShapeFor(shape.ID); Text2D text2D = (Text2D)shape; bool ok = true; if (string.Compare(text2D.Text, text2DReference.Text) != 0) { Debug.LogError($"Text mismatch : {text2D.Text} != {text2DReference.Text}"); ok = false; } return(ok); }
bool ValidateText2D(Shape shape, MessageHandler handler) { bool ok = true; Text2D text2D = (Text2D)shape; Text2DHandler textHandler = handler as Text2DHandler; if (textHandler == null) { Debug.LogError(string.Format("Wrong handler for Text2D: {0}", textHandler.Name)); ok = false; // Nothing more to test. return(false); } Text2DHandler.Text2DManager textManager = textHandler.PersistentText; Text2DHandler.TextEntry textEntry = null; foreach (var text in textManager.Entries) { if (text.ID == text2D.ID) { textEntry = text; break; } } if (textEntry == null) { Debug.LogError("Failed to find matching text entry."); ok = false; // Nothing more to test. return(false); } if (textEntry.Category != text2D.Category) { Debug.LogError("Category mismatch."); ok = false; } if (textEntry.ObjectFlags != text2D.Flags) { Debug.LogError("Flags mismatch."); ok = false; } if (textEntry.Position != Tes.Maths.Vector3Ext.ToUnity(shape.Position)) { Debug.LogError(string.Format("Position mismatch: {0} != {1}", textEntry.Position, Tes.Maths.Vector3Ext.ToUnity(shape.Position))); ok = false; } Color32 c1 = textEntry.Colour; Color32 c2 = Tes.Handlers.ShapeComponent.ConvertColour(shape.Colour); if (c1.r != c2.r || c1.g != c2.g || c1.b != c2.b || c1.a != c2.a) { Debug.LogError("Colour mismatch."); ok = false; } if (string.Compare(textEntry.Text, text2D.Text) != 0) { Debug.LogError(string.Format("Text mismatch : {0} != {1}", textEntry.Text, text2D.Text)); ok = false; } return(ok); }