public override void DoRedo() { bool CleanSelection = DecalsControler.Current.AllDecals.Count != Decals.Length || DecalsInfo.Current.DecalSettingsUi.IsCreating || !DecalsInfo.Current.gameObject.activeInHierarchy; if (CleanSelection) { Selection.SelectionManager.Current.CleanSelection(); } DecalsControler.ChangeDecalsList(Decals.ToList <Decal>()); if (CleanSelection) { Undo.Current.EditMenu.ChangeCategory(5); DecalsInfo.Current.GoToSelection(); } //Selection.SelectionManager.Current.FinishSelectionChange(); }
public static void AddDecal(Decal dc) { if (dc == null) { Debug.LogWarning("Trying to add NULL Decal"); return; } if (!AllDecals.Contains(dc)) { if (!dc.Obj.CreationObject) { AllDecals.Add(dc); DecalsControler.Sort(); } } }
public void MoveTop() { if (SelectionManager.Current.Selection.Ids.Count == 0) { return; } HashSet <OzoneDecal> Sd = SelectedDecals; if (Sd.Count > 0) { Undo.RegisterUndo(new UndoHistory.HistoryDecalsChange()); } foreach (OzoneDecal Odec in Sd) { DecalsControler.MoveTop(Odec.Dec); } DecalsControler.Sort(); }
public void MoveBottom() { if (SelectionManager.Current.Selection.Ids.Count == 0) { return; } HashSet <OzoneDecal> Sd = SelectedDecals; if (Sd.Count > 0) { Undo.Current.RegisterDecalsOrderChange(); } foreach (OzoneDecal Odec in Sd) { DecalsControler.MoveBottom(Odec.Dec); } DecalsControler.Sort(); }
public IEnumerator LoadDecals() { Current = this; LoadingDecals = true; UnloadDecals(); MargeDecals(); List <Decal> Props = ScmapEditor.Current.map.Decals; const int YieldStep = 500; int LoadCounter = YieldStep; int Count = Props.Count; LoadedCount = 0; //Debug.Log("Decals count: " + Count); for (int i = 0; i < Count; i++) { CreateGameObjectFromDecal(ScmapEditor.Current.map.Decals[i]); if (ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_ALBEDO && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_NORMALS && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_NORMALS_ALPHA && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_GLOW && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_GLOW_MASK) { Debug.LogWarning("Found different decal type! " + ScmapEditor.Current.map.Decals[i].Type, ScmapEditor.Current.map.Decals[i].Obj.gameObject); } LoadedCount++; LoadCounter--; if (LoadCounter <= 0) { LoadCounter = YieldStep; yield return(null); } } DecalsControler.Sort(); yield return(null); LoadingDecals = false; }
public void CopyAction() { CopyData = new List <CopyDecalData>(); int count = DecalsControler.AllDecals.Count; List <GameObject> Objs = SelectionManager.GetAllSelectedGameobjects(false); Debug.Log("Copied " + Objs.Count + " decal"); int selectionCount = Objs.Count; for (int i = 0; i < count; i++) { for (int s = 0; s < selectionCount; s++) { if (Objs[s] == DecalsControler.AllDecals[i].Obj.gameObject) { CopyData.Add( new CopyDecalData(DecalsControler.AllDecals[i].Shared, DecalsControler.AllDecals[i].Obj.tr.localPosition, DecalsControler.AllDecals[i].Obj.tr.localRotation, DecalsControler.AllDecals[i].Obj.tr.localScale, DecalsControler.AllDecals[i].CutOffLOD, DecalsControler.AllDecals[i].NearCutOffLOD, DecalsControler.AllDecals[i].OwnerArmy) ); CopyCenterPoint += DecalsControler.AllDecals[i].Obj.tr.localPosition; break; } } } if (CopyData.Count > 0) { CopyCenterPoint /= CopyData.Count; } DecalsControler.Sort(); }
public void GoToSelection() { /* * if (!MarkersInfo.MarkerPageChange) * { * Selection.SelectionManager.Current.CleanSelection(); * } */ int[] AllTypes; SelectionManager.Current.SetAffectedGameObjects(DecalsControler.GetAllDecalsGo(out AllTypes), SelectionManager.SelectionControlTypes.Decal); SelectionManager.Current.SetAffectedTypes(AllTypes); //SelectionManager.Current.SetCustomSettings(true, true, true); PlacementManager.Clear(); if (ChangeControlerType.Current) { ChangeControlerType.Current.UpdateButtons(); } UpdateTotalCount(); }
private void OnDestroy() { //if(CreationObject) DecalsControler.RemoveDecal(Dec); }
public IEnumerator LoadDecals() { Current = this; LoadingDecals = true; UnloadDecals(); MargeDecals(); List <Decal> Props = ScmapEditor.Current.map.Decals; const int YieldStep = 500; int LoadCounter = YieldStep; int Count = Props.Count; LoadedCount = 0; //Debug.Log("Decals count: " + Count); for (int i = 0; i < Count; i++) { CreateGameObjectFromDecal(ScmapEditor.Current.map.Decals[i]); /* * GameObject NewDecalObject = Instantiate(DecalPrefab, DecalPivot); * OzoneDecal Dec = NewDecalObject.GetComponent<OzoneDecal>(); * Decal Component = ScmapEditor.Current.map.Decals[i]; * Dec.Dec = Component; * Dec.tr = NewDecalObject.transform; * * Dec.tr.localRotation = Quaternion.Euler(Component.Rotation * Mathf.Rad2Deg); * Dec.tr.localScale = new Vector3(Component.Scale.x * 0.1f, Component.Scale.x * 0.1f, Component.Scale.z * 0.1f); * * Dec.CutOffLOD = Component.CutOffLOD; * Dec.NearCutOffLOD = Component.NearCutOffLOD; * * Dec.MovePivotPoint(ScmapEditor.ScmapPosToWorld(Component.Position)); * * Dec.Material = Component.Shared.SharedMaterial; */ if (ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_ALBEDO && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_NORMALS && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_NORMALS_ALPHA && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_GLOW && ScmapEditor.Current.map.Decals[i].Type != TerrainDecalType.TYPE_GLOW_MASK) { Debug.LogWarning("Found different decal type! " + ScmapEditor.Current.map.Decals[i].Type, ScmapEditor.Current.map.Decals[i].Obj.gameObject); } LoadedCount++; LoadCounter--; if (LoadCounter <= 0) { LoadCounter = YieldStep; yield return(null); } } DecalsControler.Sort(); yield return(null); LoadingDecals = false; }
public bool Save(string Filename, int MapFileVersion) { if (!string.IsNullOrEmpty(Filename) & Filename != this.Filename) { this.Filename = Filename; } else { Filename = this.Filename; } if (MapFileVersion <= 0) { MapFileVersion = VersionMinor; } if (MapFileVersion <= 0) { MapFileVersion = 56; } if (MapFileVersion != VersionMinor) { VersionMinor = MapFileVersion; } Debug.Log("Save file version: " + VersionMinor); System.IO.FileStream fs = new System.IO.FileStream(Filename, System.IO.FileMode.Create, System.IO.FileAccess.Write); BinaryWriter Stream = new BinaryWriter(fs); var _with2 = Stream; //# Header Section # _with2.Write(MAP_MAGIC); _with2.Write(MAP_VERSION); _with2.Write(Unknown10); //? always EDFE EFBE _with2.Write(Unknown11); //? always 2 _with2.Write((float)Width); //Map Width (in float) _with2.Write((float)Height); //Map Height (in float) _with2.Write(Unknown12); //? always 0 _with2.Write(Unknown13); //? always 0 //byte[] SaveData = new byte[0]; //SaveData = PreviewTex.GetRawTextureData(); //_with2.Write(SaveData.Length); //_with2.Write(SaveData); //Debug.Log(PreviewTex.GetRawTextureData().Length); TextureLoader.GetHeaderBGRA(PreviewTex, ref PreviewTextHeader); SaveTexture(_with2, TextureLoader.ConvertToBGRA(PreviewTex), PreviewTextHeader); //_with2.Write(PreviewImageLength); //_with2.Write(PreviewData); //Debug.Log( _with2.BaseStream.Length ); //# Heightmap Section # _with2.Write(MapFileVersion); _with2.Write(Width); _with2.Write(Height); _with2.Write(HeightScale); //Height Scale, usually 1/128 //_with2.Write(HeightmapData); for (int i = 0; i < HeightmapData.Length; i++) { _with2.Write(HeightmapData[i]); } if (MapFileVersion >= 56) { //_with2.Write(Convert.ToByte(0)); _with2.Write(Unknown15); } //Always 0? //# Texture Definition Section # _with2.Write(TerrainShader, true); //usually "TTerrain" _with2.Write(TexPathBackground, true); _with2.Write(TexPathSkyCubemap, true); if (VersionMinor >= 56) { _with2.Write(EnvCubemapsName.Length); for (int i = 0; i < EnvCubemapsName.Length; i++) { _with2.Write(EnvCubemapsName[i], true); _with2.Write(EnvCubemapsFile[i], true); } } else { if (EnvCubemapsFile.Length >= 1) { _with2.Write(EnvCubemapsFile[0], true); } else { _with2.Write(Convert.ToByte(0)); } } _with2.Write(LightingMultiplier); _with2.Write(SunDirection); _with2.Write(SunAmbience); _with2.Write(SunColor); _with2.Write(ShadowFillColor); _with2.Write(SpecularColor); _with2.Write(Bloom); _with2.Write(FogColor); _with2.Write(FogStart); _with2.Write(FogEnd); Water.Save(_with2); _with2.Write(WaveGenerators.Count); for (int i = 0; i < WaveGenerators.Count; i++) { WaveGenerators[i].Save(_with2); } if (VersionMinor < 56) { _with2.Write("No Tileset", true); _with2.Write(6); for (int i = 0; i <= 4; i++) { Layers[i].Save(_with2); } Layers[Layers.Count - 1].Save(_with2); } else { _with2.Write(MinimapContourInterval); int color = 0; color |= MinimapDeepWaterColor.a << 24; color |= MinimapDeepWaterColor.r << 16; color |= MinimapDeepWaterColor.g << 8; color |= MinimapDeepWaterColor.b; _with2.Write(color); int color2 = 0; color2 |= MinimapContourColor.a << 24; color2 |= MinimapContourColor.r << 16; color2 |= MinimapContourColor.g << 8; color2 |= MinimapContourColor.b; _with2.Write(color2); int color3 = 0; color3 |= MinimapShoreColor.a << 24; color3 |= MinimapShoreColor.r << 16; color3 |= MinimapShoreColor.g << 8; color3 |= MinimapShoreColor.b; _with2.Write(color3); int color4 = 0; color4 |= MinimapLandStartColor.a << 24; color4 |= MinimapLandStartColor.r << 16; color4 |= MinimapLandStartColor.g << 8; color4 |= MinimapLandStartColor.b; _with2.Write(color4); int color5 = 0; color5 |= MinimapLandEndColor.a << 24; color5 |= MinimapLandEndColor.r << 16; color5 |= MinimapLandEndColor.g << 8; color5 |= MinimapLandEndColor.b; _with2.Write(color5); if (VersionMinor > 56) { _with2.Write(Unknown14); } for (int i = 0; i < Layers.Count; i++) { Layers[i].SaveAlbedo(_with2); } for (int i = 0; i < Layers.Count - 1; i++) { Layers[i].SaveNormal(_with2); } } _with2.Write(Unknown7); //? _with2.Write(Unknown8); //? Decals = DecalsControler.GetAllDecals(); _with2.Write(Decals.Count); for (int i = 0; i < Decals.Count; i++) { Decals[i].Save(_with2, i); } _with2.Write(DecalGroups.Count); for (int i = 0; i < DecalGroups.Count; i++) { DecalGroups[i].Save(_with2); } _with2.Write(Width); //Width again _with2.Write(Height); //Height again _with2.Write(1); TextureLoader.GetHeaderDxt5(NormalmapTex, ref NormalmapHeader); SaveTexture(_with2, NormalmapTex, NormalmapHeader); //Format.Dxt5 if (VersionMinor < 56) { _with2.Write(1); } TextureLoader.GetHeaderBGRA(TexturemapTex, ref TextureMapHeader); SaveTexture(_with2, TextureLoader.ConvertToBGRA(TexturemapTex), TextureMapHeader); if (VersionMinor >= 56) { TextureLoader.GetHeaderBGRA(TexturemapTex2, ref TextureMap2Header); SaveTexture(_with2, TextureLoader.ConvertToBGRA(TexturemapTex2), TextureMap2Header); } _with2.Write(1); TextureLoader.GetHeaderDxt5(WatermapTex, ref WatermapHeader); SaveTexture(_with2, WatermapTex, WatermapHeader); _with2.Write(WaterFoamMask); _with2.Write(WaterFlatnessMask); _with2.Write(WaterDepthBiasMask); _with2.Write(TerrainTypeData.ToArray()); if (MapFileVersion <= 52) { _with2.Write(Convert.ToInt16(0)); } if (VersionMinor >= 60) { AdditionalSkyboxData.Save(_with2); } _with2.Write(Props.Count); for (int i = 0; i <= Props.Count - 1; i++) { Props[i].Save(_with2); } _with2.Close(); fs.Close(); fs.Dispose(); return(true); }
void DuplicateAction() { DuplicateData = new List <CopyDecalData>(); int count = DecalsControler.AllDecals.Count; List <GameObject> Objs = SelectionManager.GetAllSelectedGameobjects(false); Debug.Log("Copied " + Objs.Count + " decal"); int selectionCount = Objs.Count; for (int i = 0; i < count; i++) { for (int s = 0; s < selectionCount; s++) { if (Objs[s] == DecalsControler.AllDecals[i].Obj.gameObject) { DuplicateData.Add( new CopyDecalData(DecalsControler.AllDecals[i].Shared, DecalsControler.AllDecals[i].Obj.tr.localPosition, DecalsControler.AllDecals[i].Obj.tr.localRotation, DecalsControler.AllDecals[i].Obj.tr.localScale, DecalsControler.AllDecals[i].CutOffLOD, DecalsControler.AllDecals[i].NearCutOffLOD, DecalsControler.AllDecals[i].OwnerArmy) ); DuplicateCenterPoint += DecalsControler.AllDecals[i].Obj.tr.localPosition; break; } } } if (DuplicateData.Count > 0) { DuplicateCenterPoint /= DuplicateData.Count; } DecalsControler.Sort(); if (DuplicateData.Count > 0) { int PasteCount = DuplicateData.Count; isPasteAction = true; if (PasteCount > 0) { Undo.RegisterUndo(new UndoHistory.HistoryDecalsChange()); } PastedObjects.Clear(); //GoToSelection(); Vector3 PlaceOffset = new Vector3(0.5f, 0f, -0.5f); Decal.DecalSharedSettings storePrevousSettings = PlaceSharedSettings; PlacementManager.BeginPlacement(DecalSettingsUi.CreationPrefab, Place); for (int i = 0; i < PasteCount; i++) { if (DuplicateData[i].Shared == null) { continue; } PlaceSharedSettings = DuplicateData[i].Shared; paste_CutOffLOD = DuplicateData[i].CutOffLOD; paste_NearCutOffLOD = DuplicateData[i].NearCutOffLOD; paste_OwnerArmy = DuplicateData[i].OwnerArmy; PlacementManager.PlaceAtPosition(DuplicateData[i].Position + PlaceOffset, DuplicateData[i].Rotation, DuplicateData[i].Scale); } PlacementManager.Clear(); PlaceSharedSettings = storePrevousSettings; DecalsControler.Sort(); GoToSelection(); SelectionManager.Current.CleanSelection(); for (int i = 0; i < PastedObjects.Count; i++) { SelectionManager.Current.SelectObjectAdd(PastedObjects[i]); DecalsControler.MoveTop(PastedObjects[i].GetComponent <OzoneDecal>().Dec); } Debug.Log("Pasted " + PastedObjects.Count + " decals"); UpdateTotalCount(); //DecalsControler.Sort(); isPasteAction = false; } }
private void Awake() { Current = this; }
private void OnDestroy() { //if(CreationObject) DecalsControler.RemoveDecal(Dec); OnBecameInvisible(); }