Exemple #1
0
 internal int GetObjectID(PresetsRecord loadedPreset)
 {
     if (loadedPreset == null || !PresetExist(loadedPreset))
     {
         return(-1);
     }
     return(PresetsGOList.IndexOf(loadedPreset));
 }
Exemple #2
0
        public void RemovePreset(string presetName)
        {
            PresetsRecord presetToDelete = FindPresetByName(presetName);

            if (presetToDelete == null)
            {
                throw new Exception(MSG.Errors.PRESET_DELETE_NOT_EXIST);
            }
            PresetsGOList.Remove(presetToDelete);
            Save();
        }
Exemple #3
0
        public int GetIDByName(string presetName)
        {
            PresetsRecord x = FindPresetByName(presetName);

            if (x != null)
            {
                return(GetObjectID(x));
            }
            else
            {
                return(-1);
            }
        }
Exemple #4
0
 private static bool PresetExist(List <PresetsRecord> list, PresetsRecord presetRecord)
 {
     if (list.Count == 0)
     {
         return(false);
     }
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].IsTheSame(presetRecord))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
        public static QuickPolygon CreateFromLastPreset(string name, MeshType meshIndex, Vector3 position, Quaternion rotation, bool isUI)
        {
            PresetsRecord lastPreset = PresetsManager.GetLastUsedPreset();
            QuickPolygon  mesh       = Create(name, meshIndex, position, rotation, isUI);

            if (lastPreset != null && PresetsManager.IsPresetExists(lastPreset))
            {
                PresetsManager.LoadPresetFor(lastPreset, mesh);
            }
            else
            {
                Debug.LogWarning(MSG.Warnings.PRESET_LAST_NOT_FOUND);
            }
            mesh.RecalculateMesh();
            return(mesh);
        }
Exemple #6
0
 public bool IsTheSame(PresetsRecord p)
 {
     if (this.name != p.name)
     {
         return(false);
     }
     if (this.meshType != p.meshType)
     {
         return(false);
     }
     if (this.polySerialised != p.polySerialised)
     {
         return(false);
     }
     return(true);
 }
Exemple #7
0
        public static void SavePreset(string presetName, QuickPolygon shape)
        {
            PresetsRecord presetRecord = presetsContainer.FindPresetByName(presetName);

            if (presetRecord == null)
            {
                presetRecord = new PresetsRecord(presetName, shape);
                presetsContainer.AddNewRecord(presetRecord);
            }
            else
            {
                presetRecord.Update(shape);
                presetsContainer.Save();
            }
            shape.CurrentPresetName = presetName;
            RefreshPresetContainer();
        }
Exemple #8
0
        public static string GetMostUsedPreset()
        {
            if (presetsContainer == null || presetsContainer.PresetsGOList.Count < 1)
            {
                RefreshPresetContainer();
            }
            PresetsRecord mostUsedRecord = presetsContainer.GetMostUsedPreset();

            if (mostUsedRecord != null)
            {
                return(mostUsedRecord.polySerialised);
            }
            else
            {
                return("");
            }
        }
Exemple #9
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;
         }
     }
 }
Exemple #10
0
        public static void LoadPresetFor(string presetName, QuickPolygon shape, bool loadMesh = false)
        {
            PresetsRecord loadedPreset = presetsContainer.FindPresetByName(presetName);

            LoadPresetFor(loadedPreset, shape, loadMesh);
        }
Exemple #11
0
 public static bool IsPresetExists(PresetsRecord presetsRecord)
 {
     return(presetsContainer.PresetExist(presetsRecord));
 }
Exemple #12
0
 public void AddNewRecord(PresetsRecord presetRecord)
 {
     PresetsGOList.Add(presetRecord);
     this.Save();
 }
Exemple #13
0
 public bool PresetExist(PresetsRecord preset)
 {
     return(PresetExist(PresetsGOList, preset));
 }