예제 #1
0
        public void ConvertRectTransformToTransform()
        {
            IsUI = false;
            QuickPolygon copy = Create("", ShapeMeshIndex, false);

            copy.transform.name       = name;
            copy.transform.position   = transform.position;
            copy.transform.rotation   = transform.rotation;
            copy.transform.localScale = transform.localScale;
            List <Component> componentList = new List <Component>(GetComponents <Component>());

            for (int i = 0; i < componentList.Count; i++)
            {
                if (componentList[i].GetComponent <Transform>() && componentList[i].GetComponent <MeshFilter>() && componentList[i].GetComponent <MeshRenderer>() && componentList[i].GetComponent <QuickPolygon>())
                {
                    componentList.Remove(GetComponent <Transform>());
                    componentList.Remove(GetComponent <MeshFilter>());
                    componentList.Remove(GetComponent <MeshRenderer>());
                    componentList.Remove(GetComponent <QuickPolygon>());
                }
                if (componentList.Count > 0)
                {
                    copy.gameObject.AddComponent(componentList[0].GetType());
                }
            }
            SerializationClass.Deserialize(copy, SerializationClass.Serialize(this), true);
            Helpers.Destroy(this.gameObject);
                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Selection.activeObject = copy.gameObject;
            }
                        #endif
            RecalculateMesh();
        }
예제 #2
0
 public PresetsRecord(string presetName, QuickPolygon shape)
 {
     this.name           = presetName;
     this.meshType       = (int)shape.ShapeMeshIndex;
     this.timesUsed      = 0;
     this.polySerialised = SerializationClass.Serialize(shape);
 }
예제 #3
0
 public static void LoadPresetFor(PresetsRecord presetRecord, QuickPolygon shape, bool loadMesh = false)
 {
     if (presetRecord == null)
     {
         throw new Exception(MSG.Errors.PRESET_LOAD_NOT_EXIST);
     }
     else
     {
         lastGOpreset = presetsContainer.GetObjectID(presetRecord);
         presetRecord.timesUsed++;
         SerializationClass.Deserialize(shape, presetRecord.polySerialised, shape.AllowLoadPresetGeometry);
         shape.CurrentPresetName = presetRecord.name;
         if (loadMesh)
         {
             shape.ShapeMeshIndex = (MeshType)presetRecord.meshType;
         }
     }
 }
예제 #4
0
        public static string Serialize(QuickPolygon shape)
        {
            var serializationClass = new SerializationClass
            {
                ShapeMeshIndex = (int)shape.ShapeMeshIndex,
                ShapeFillIndex = (int)shape.ShapeFillIndex,
                UseShapeBorder = (int)shape.UseShapeBorder,

                SquareShape   = shape.SquareShape,
                CircleShape   = shape.CircleShape,
                StarShape     = shape.StarShape,
                DiamondShape  = shape.DiamondShape,
                TriangleShape = shape.TriangleShape,
                HexagonShape  = shape.HexagonShape,
                PentagonShape = shape.PentagonShape,

                EmptyFill          = shape.EmptyFill,
                SingleColorFill    = shape.SingleColorFill,
                LinearGradientFill = shape.LinearGradientFill,
                RadialGradientFill = shape.RadialGradientFill,
                StandardBorder     = shape.StandardBorder,

                PivotModifier        = shape.PivotModifier,
                ProportionsModifier  = shape.ProportionsModifier,
                FacingModifier       = shape.FacingModifier,
                SortingLayerModifier = shape.SortingLayerModifier,

                IsUI     = shape.IsUI,
                Lighting = shape.Lighting
            };

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerializationClass));

            using (StringWriter textWriter = new StringWriter())
            {
                xmlSerializer.Serialize(textWriter, serializationClass);
                return(textWriter.ToString());
            }
        }
예제 #5
0
        public static void Deserialize(QuickPolygon shape, string str, bool loadGeometry)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SerializationClass));

            TextReader         reader             = new StringReader(str);
            SerializationClass serializationClass = (SerializationClass)serializer.Deserialize(reader);

            reader.Close();
            if (loadGeometry)
            {
                shape.ShapeMeshIndex = (MeshType)serializationClass.ShapeMeshIndex;

                shape.SquareShape   = serializationClass.SquareShape;
                shape.CircleShape   = serializationClass.CircleShape;
                shape.StarShape     = serializationClass.StarShape;
                shape.DiamondShape  = serializationClass.DiamondShape;
                shape.TriangleShape = serializationClass.TriangleShape;
                shape.HexagonShape  = serializationClass.HexagonShape;
                shape.PentagonShape = serializationClass.PentagonShape;
            }
            shape.ShapeFillIndex = (FillType)serializationClass.ShapeFillIndex;
            shape.UseShapeBorder = (BorderFillType)serializationClass.UseShapeBorder;

            shape.EmptyFill          = serializationClass.EmptyFill;
            shape.SingleColorFill    = serializationClass.SingleColorFill;
            shape.LinearGradientFill = serializationClass.LinearGradientFill;
            shape.RadialGradientFill = serializationClass.RadialGradientFill;
            shape.StandardBorder     = serializationClass.StandardBorder;

            shape.PivotModifier        = serializationClass.PivotModifier;
            shape.ProportionsModifier  = serializationClass.ProportionsModifier;
            shape.FacingModifier       = serializationClass.FacingModifier;
            shape.SortingLayerModifier = serializationClass.SortingLayerModifier;

            shape.IsUI     = serializationClass.IsUI;
            shape.Lighting = serializationClass.Lighting;
        }
예제 #6
0
 public void Update(QuickPolygon shape)
 {
     this.polySerialised = SerializationClass.Serialize(shape);
     this.meshType       = (int)shape.ShapeMeshIndex;
 }