예제 #1
0
 public void UnhideAll()
 {
     foreach (Decal.DecalSharedSettings Shared in Decal.AllDecalsShared)
     {
         Shared.Hidden = false;
     }
     DecalsControler.Sort();
     DecalsList.UpdateSelection();
 }
        public void PasteAction()
        {
            if (CopyData == null)
            {
                return;
            }

            int PasteCount = CopyData.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 (CopyData[i].Shared == null)
                {
                    continue;
                }

                PlaceSharedSettings = CopyData[i].Shared;
                paste_CutOffLOD     = CopyData[i].CutOffLOD;
                paste_NearCutOffLOD = CopyData[i].NearCutOffLOD;
                paste_OwnerArmy     = CopyData[i].OwnerArmy;

                PlacementManager.PlaceAtPosition(CopyData[i].Position + PlaceOffset, CopyData[i].Rotation, CopyData[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;
        }
예제 #3
0
 public void ToggleHideOther(Decal.DecalSharedSettings Connected)
 {
     foreach (Decal.DecalSharedSettings Shared in Decal.AllDecalsShared)
     {
         if (Shared == Connected)
         {
             continue;
         }
         Shared.Hidden = !Shared.Hidden;
     }
     DecalsControler.Sort();
     DecalsList.UpdateSelection();
 }
예제 #4
0
        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 MoveDown()
        {
            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.MoveDown(Odec.Dec);
            }
            DecalsControler.Sort();
        }
예제 #6
0
    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();
            }
        }
    }
예제 #7
0
        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();
        }
예제 #9
0
        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;
        }
        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;
            }
        }