Exemplo n.º 1
0
        public static List <LevelEditorObject> GetEditorObjects()
        {
            /*
             * Creates Object... don't need it, use static instead
             * Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
             * GraphicObject g = (GraphicObject)asm.CreateInstance(objType.ToString(), false, BindingFlags.CreateInstance, null, new object[] { x , y },null,null);
             */
            List <LevelEditorObject> Res = new List <LevelEditorObject>();
            Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();

            foreach (Type t in asm.GetTypes())
            {
                Type       objType = Type.GetType(t.FullName);
                MethodInfo i       = objType.GetMethod("GetLEObject");
                if (i != null)
                {
                    LevelEditorObject LE = (LevelEditorObject)(i.Invoke(null, null));
                    LE.name = t.Name;
                    Res.Add(LE);
                }
            }

            //Type objType = Type.GetType("MarioObjects.");
            //MethodInfo i = objType.GetMethod("GetLEObject");
            //return (LevelEditorObject)(i.Invoke(null, null));
            return(Res);
        }
Exemplo n.º 2
0
        static void _CreateSingleton()
        {
            GameObject _prefab;
            GameObject _instance;

            GameObject parent = GameObject.Find("LOADED LEVEL");

            //_prefab = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Player/PlayerSpawner.prefab", typeof(GameObject)) as GameObject;
            LevelEditorObject spawnerData = Resources.Load <LevelEditorObject>("LevelEditorObjects/Special/PlayerSpawn");

            _prefab = spawnerData.Prefab;

            if (_prefab == null)
            {
                Debug.Log("PlayerSpawner PATH error!!!");
            }
            else
            {
                _instance      = Instantiate(_prefab, new Vector3(0, 2.5f, 0), Quaternion.identity);
                _instance.name = spawnerData.Path;
                _instance.transform.SetParent(parent.transform);
                OET_io.lib.ActiveGameObjects.Add(_instance);
                Undo.RegisterCreatedObjectUndo(_instance, "Init the level");
            };


            _CreateSingleton("Music Intensity Manager", parent, "Assets/Prefabs/General/Music Intensity Manager.prefab");
            _CreateSingleton("ServiceWrangler", parent, "Assets/Prefabs/General/ServiceWrangler.prefab");
            _CreateSingleton("SpawnManager", parent, "Assets/Prefabs/Enemies/SpawnManager.prefab");
            _CreateSingleton("NavMeshSurface", parent, "Assets/Prefabs/LevelEditor/Floor Tiles/NavMeshSurface.prefab");
        }
Exemplo n.º 3
0
    void Load()
    {
        string path = UnityEditor.EditorUtility.OpenFilePanel(
            "Open saved level",
            "Saves",
            "sav");

        if (path.Length != 0)
        {
            foreach (Transform child in root.transform)
            {
                Destroy(child.gameObject);
            }
            ArchiveData data = JsonUtility.FromJson <ArchiveData>(File.ReadAllText(path));
            foreach (ArchiveEntry item in data.objects)
            {
                GameObject        newObject = (GameObject)Instantiate(Resources.Load(item.path, typeof(GameObject)), new Vector2(item.x, item.y), Quaternion.Euler(0, 0, item.phi));
                LevelEditorObject leo       = newObject.AddComponent <LevelEditorObject>();
                leo.PrefabName             = item.path;
                leo.IsPlaced               = true;
                newObject.transform.parent = root.transform;
                //newObject.layer = layer;
            }
        }
    }
Exemplo n.º 4
0
    public void LevelObjectDatabaseTest_PlayModeSimplePasses()
    {
        LevelObjectDatabase database = new LevelObjectDatabase();
        LevelEditorObject   obj      = database.GetObject(0, 0);

        Assert.IsNotNull(obj);
    }
Exemplo n.º 5
0
        public void SetListIndexToObjects()
        {
            foreach (LevelEditorObject le in Objects)
            {
                LevelEditorObject tmp =
                    (LevelEditorObject)(list.Items.Find(le.name, false)[0].Tag);

                le.ListIndex = tmp.ListIndex;
            }
        }
Exemplo n.º 6
0
 private void list_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == (int)Keys.Space)
     {
         LevelEditorObject le = CheckPosition(OX, OY);
         if (le != null)
         {
             le.Checked = !le.Checked;
         }
     }
 }
Exemplo n.º 7
0
        public Bitmap ObjectTypeToImage(LevelEditorObject obj)
        {
            Bitmap    tmp = new Bitmap(obj.width, obj.height);
            Graphics  xGraph = Graphics.FromImage(tmp);
            Rectangle Src, Dest;

            Dest = new Rectangle(0, 0, obj.width, obj.height);
            Src  = new Rectangle(obj.width * obj.ImageIndex, 0, obj.width, obj.height);
            xGraph.DrawImage(ImageGenerator.GetImage(obj.OT), Dest, Src, GraphicsUnit.Pixel);
            xGraph.Dispose();
            return(tmp);
        }
Exemplo n.º 8
0
        public void PutBox(int x, int y, int ind, Boolean Check)
        {
            Graphics          xGraph = Graphics.FromImage(pictureLevel.Image);
            LevelEditorObject le     = (LevelEditorObject)list.Items[ind].Tag;
            int hOff = (le.height - 16);

            xGraph.DrawImage(images.Images[ind], new Rectangle(x, y - hOff, le.width, le.height), new Rectangle(0, 0, 32, 32), GraphicsUnit.Pixel);

            if (Check)
            {
                xGraph.DrawImage(pSelected.Image, new Rectangle(x, y - hOff, le.width, le.height), new Rectangle(0, 0, 12, 12), GraphicsUnit.Pixel);
            }
        }
Exemplo n.º 9
0
        public LevelEditorObject CheckPosition(int x, int y)
        {
            LevelEditorObject Res = null;

            for (int i = 0; i < Objects.Count; i++)
            {
                if (x == Objects[i].x && y == Objects[i].y)
                {
                    return(Objects[i]);
                }
            }

            return(Res);
        }
Exemplo n.º 10
0
        private void timerobject_Tick(object sender, EventArgs e)
        {
            Seconds++;

            if (Seconds >= 10)
            {
                LevelEditorObject le = CheckPosition(OX, OY);
                if (le != null)
                {
                    objectnamelabel.Text = le.name;
                    timerobject.Enabled  = false;
                }
            }
        }
Exemplo n.º 11
0
        public static GraphicObject SetEditorObject(LevelEditorObject le)
        {
            Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();

            Type          objType = Type.GetType("MarioObjects.Objects.GameObjects." + le.name);
            MethodInfo    i       = objType.GetMethod("SetLEObject");
            GraphicObject g       = null;

            if (i != null)
            {
                g = (GraphicObject)i.Invoke(null, new object[] { le });
            }

            return(g);
        }
Exemplo n.º 12
0
        public static GraphicObject SetEditorObject(LevelEditorObject le)
        {
            Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();

            Type objType = Type.GetType("MarioObjects.Objects.GameObjects." + le.name);
            MethodInfo i = objType.GetMethod("SetLEObject");
            GraphicObject g = null;

            if (i != null)
            {
                g = (GraphicObject)i.Invoke(null, new object[] { le });
            }

            return g;
        }
Exemplo n.º 13
0
        private void pictureLevel_MouseDown(object sender, MouseEventArgs e)
        {
            int Divx, Divy, Divyi;

            Divx = (e.X / 16);
            Divy = (e.Y / 16);

            LX = Divx * 16;
            LY = Divy * 16;
            //PutBox(LX, LY, CurrentImageIndex);

            Divyi = (MainImage.Height / 16) - (Divy + 1);

            if (e.Button == MouseButtons.Left)
            {
                LevelEditorObject le = CheckPosition(Divx, Divyi);
                if (le == null)
                {
                    le   = new LevelEditorObject((LevelEditorObject)list.Items[CurrentImageIndex].Tag);
                    le.x = Divx;
                    le.y = Divyi;
                    Objects.Add(le);
                }
                else
                {
                    if (le.ParamTypes != null)
                    {
                        FormParams PR = new FormParams(le);
                        PR.ShowDialog();
                        if (PR.Update)
                        {
                            le = PR.MainObject;
                        }
                        PR.Dispose();
                    }
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                LevelEditorObject le = CheckPosition(Divx, Divyi);
                if (le != null)
                {
                    Objects.Remove(le);
                    pictureLevel.Invalidate();
                }
            }
        }
Exemplo n.º 14
0
    public void SerializableLevelTest_EditModeSimplePasses()
    {
        // Load database
        LevelObjectDatabase database = new LevelObjectDatabase();

        // Create level
        GameObject[]      objects  = new GameObject[0];
        LevelEditorObject data     = database.GetObject(0, 0);
        GameObject        instance = MonoBehaviour.Instantiate(data.Prefab);

        instance.name = data.Path;

        instance.transform.position   = new Vector3(-1f, 5f, 3);
        instance.transform.rotation   = Quaternion.Euler(-45f, 90f, 15f);
        instance.transform.localScale = new Vector3(2f, 0.5f, 1.5f);
        objects[0] = instance;
    }
Exemplo n.º 15
0
        public static LevelEditorObject GetEditorObject(string name)
        {
            Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();

            Type       objType = Type.GetType("MarioObjects.Objects.GameObjects." + name);
            MethodInfo i       = objType.GetMethod("GetLEObject");

            if (i != null)
            {
                LevelEditorObject LE = (LevelEditorObject)(i.Invoke(null, null));
                LE.name = name;
                return(LE);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 16
0
    void PlaceRing()
    {
        Vector3    pos        = GetPos();
        float      deltaAngle = 360 / angularGridDensity;
        Quaternion rotator    = Quaternion.Euler(0, 0, deltaAngle);

        for (int i = 0; i < angularGridDensity; i++)
        {
            pos = rotator * pos;
            GameObject        newObject = (GameObject)Instantiate(Resources.Load("Editor/Block", typeof(GameObject)), pos, FaceAxis.GetRotator(pos));
            LevelEditorObject leo       = newObject.AddComponent <LevelEditorObject>();
            leo.PrefabName             = "Editor/Block";
            leo.IsPlaced               = true;
            newObject.transform.parent = root.transform;
            //newObject.layer = layer;
            //objects.Add(newObject);
        }
    }
Exemplo n.º 17
0
    void SpawnRing()
    {
        Vector3    pos        = GetPos();
        float      deltaAngle = 360 / angularGridDensity;
        Quaternion rotator    = Quaternion.Euler(0, 0, deltaAngle);

        for (int i = 0; i < angularGridDensity; i++)
        {
            pos = rotator * pos;
            GameObject        newGhost = (GameObject)Instantiate(Resources.Load("Editor/Block", typeof(GameObject)), pos, FaceAxis.GetRotator(pos));
            LevelEditorObject leo      = newGhost.AddComponent <LevelEditorObject>();
            leo.PrefabName = "Editor/Block";
            leo.IsPlaced   = false;
            foreach (Collider2D coll in newGhost.GetComponents <Collider2D>())
            {
                coll.enabled = false;
            }
            ghosts.Add(newGhost);
            //newObject.transform.parent = root.transform;
            //newObject.layer = layer;
            //objects.Add(newObject);
        }
    }
Exemplo n.º 18
0
        public FormParams(LevelEditorObject le)
        {
            InitializeComponent();

            MainObject = le;
        }
Exemplo n.º 19
0
 public static CoinBlock SetLEObject(LevelEditorObject le)
 {
     return(new CoinBlock(le.x, le.y, false));
 }
Exemplo n.º 20
0
 public static CoinBlock SetLEObject(LevelEditorObject le)
 {
     return new CoinBlock(le.x, le.y, false);
 }
Exemplo n.º 21
0
 public static BlockGrass SetLEObject(LevelEditorObject le)
 {
     return(new BlockGrass(le.x, le.y));
 }
Exemplo n.º 22
0
 public static BlockSolid SetLEObject(LevelEditorObject le)
 {
     return(new BlockSolid(le.x, le.y));
 }
Exemplo n.º 23
0
        //public static void renderGUI(int vpos, GameObject get_projectActiveSelection)
        public static void renderGUI(int vpos, LevelEditorObject get_projectActiveSelection)
        {
            if (!usingDB)
            {
                projectActiveSelection = get_projectActiveSelection;
            }

            int width   = Screen.width;
            int height  = Screen.height;
            int btWidth = width < 160 ? width - 20 : 160;

            GUIStyle styleInfoText = new GUIStyle(GUI.skin.box);

            styleInfoText.wordWrap         = true;
            styleInfoText.normal.textColor = GUI.skin.label.normal.textColor;
            styleInfoText.alignment        = TextAnchor.MiddleLeft;

            usingDB = GUI.Toggle(new Rect(10, vpos + 100, btWidth, 40), usingDB, "");
            GUI.Label(new Rect(30, vpos + 100, btWidth, 40), "Using Prefabs DataBase");

            if (projectActiveSelection == null)
            {
                OET_lib.ToolLib.alertBox("Prefab Placement", "Select a prefab in the project window to enable this tool.");
            }
            else
            {
                if (projectActiveSelection != null)
                {
                    if (clickToAddEnabled)
                    {
                        vpos += OET_lib.ToolLib.header("<b>Click to Add</b>\nClick anywhere in the scene to add " + projectActiveSelection.name, vpos, true);
                    }
                    else
                    {
                        vpos += OET_lib.ToolLib.header("<b>Click to Add</b>\nClick on the button below then click on the scene to add " + projectActiveSelection.name, vpos, true);
                    }
                }


                Texture2D projectPreview = UnityEditor.AssetPreview.GetAssetPreview(projectActiveSelection.Prefab);
                if (height > 310)
                {
                    Color saveBg = GUI.backgroundColor;

                    if (clickToAddEnabled)
                    {
                        GUI.backgroundColor = new Color(.5f, 0f, 0f, 1);
                    }

                    clickToAddEnabled = GUI.Toggle(new Rect(width / 2 - btWidth / 2, vpos, btWidth, 40), clickToAddEnabled, "Add to Scene", "button");
                    if (clickToAddEnabled)
                    {
                        GUI.backgroundColor = saveBg;
                    }
                    vpos += 50;

                    if (projectPreview != null)
                    {
                        GUI.Box(new Rect(width / 2 - 64, vpos, 128, 128), projectPreview);
                    }
                }
                else
                {
                    int bth = height - vpos - 30;
                    if (bth > 128)
                    {
                        bth = 128;
                    }

                    clickToAddEnabled = GUI.Toggle(new Rect((width - bth - 30) / 2 - btWidth / 2, vpos, btWidth, bth > 40 ? 40 : bth), clickToAddEnabled, "Add to Scene", "Button");
                    if (projectPreview != null)
                    {
                        GUI.Box(new Rect(width - bth - 10, vpos, bth, bth), projectPreview);
                    }
                }
            }


            if (usingDB)
            {
                RenderDB(vpos);
            }
        }
Exemplo n.º 24
0
 public static Character SetLEObject(LevelEditorObject le)
 {
     return(new Character(le.x, le.y));
 }
Exemplo n.º 25
0
 public static Mario SetLEObject(LevelEditorObject le)
 {
     return new Mario(le.x, le.y);
 }
Exemplo n.º 26
0
 public static BlockBrick SetLEObject(LevelEditorObject le)
 {
     return new BlockBrick(le.x, le.y);
 }
Exemplo n.º 27
0
 public static BlockPipeUp SetLEObject(LevelEditorObject le)
 {
     return(new BlockPipeUp(le.x, le.y, (MonsterPiranah.PiranahType)le.ParamInt[0]));
 }
Exemplo n.º 28
0
 public static Flag_Win SetLEObject(LevelEditorObject le)
 {
     return(new Flag_Win(le.x, le.y));
 }
Exemplo n.º 29
0
 public static MonsterKoopa SetLEObject(LevelEditorObject le)
 {
     return new MonsterKoopa(le.x, le.y);
 }
Exemplo n.º 30
0
 public static MonsterKoopa SetLEObject(LevelEditorObject le)
 {
     return(new MonsterKoopa(le.x, le.y));
 }
Exemplo n.º 31
0
 public static ExitBlock SetLEObject(LevelEditorObject le)
 {
     return new ExitBlock(le.x, le.y);
 }
Exemplo n.º 32
0
        public static void renderGUI(int vpos)
        {
            vpos += OET_lib.ToolLib.header("<b>Init / Save / Load</b>\nSave or Load the Scene with JSON.", vpos, false);

            int   width   = Screen.width;
            float btWidth = width < 160 ? width - 20 : 160;

            GUI.Label(new Rect(10, vpos, 150, 20), "+x");
            Num_x = EditorGUI.IntSlider(new Rect(90, vpos, width - 100, 20), Num_x, 1, 20);

            GUI.Label(new Rect(10, vpos + 50, 150, 20), "+z");
            Num_z = EditorGUI.IntSlider(new Rect(90, vpos + 50, width - 100, 20), Num_z, 1, 20);

            GUI.enabled = !OET_io.lib.LevelIsLoaded;


            // Init button
            if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 100, btWidth, 25), "Init") && initialized == false)
            {
                // This will force a database reload
                new LevelObjectDatabase();

                GameObject _platform = new GameObject("LOADED LEVEL");

                _CreateSingleton();

                Undo.RegisterCreatedObjectUndo(_platform, "Init the level");

                //GameObject _prefab = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Old/Environment/Hallway/Hallway_Floor.prefab", typeof(GameObject)) as GameObject;

                for (int i = -Num_x; i <= Num_x; i++)
                {
                    for (int j = -Num_z; j <= Num_z; j++)
                    {
                        GameObject _instance = Instantiate(tileObject.Prefab, new Vector3(i * OET_grid.lib.size_x, 0, j * OET_grid.lib.size_z), Quaternion.identity);
                        _instance.name = tileObject.Path;

                        //Edge + Wall
                        if (i == -Num_x || i == Num_x || j == -Num_z || j == Num_z)
                        {
                            _AddNavMeshModifier(_instance, OET_lib.NavMeshAreas.NotWalkable);

                            GameObject _wall = Instantiate(tileObject.Prefab, new Vector3(i * OET_grid.lib.size_x, OET_grid.lib.size_y, j * OET_grid.lib.size_z), Quaternion.identity);
                            _wall.transform.SetParent(_platform.transform);
                            Undo.RegisterCreatedObjectUndo(_wall, "Init the level");
                            OET_io.lib.ActiveGameObjects.Add(_wall);
                            _AddNavMeshModifier(_wall, OET_lib.NavMeshAreas.NotWalkable);
                        }
                        else if (_instance.GetComponent <LevelUnit>() == null)
                        {
                            LevelUnit LU = _instance.AddComponent <LevelUnit>() as LevelUnit;
                            LU.defaultState = LevelUnitStates.Floor;
                            _AddNavMeshModifier(_instance, OET_lib.NavMeshAreas.Walkable);
                        }

                        _instance.transform.SetParent(_platform.transform);
                        Undo.RegisterCreatedObjectUndo(_instance, "Init the level");
                        OET_io.lib.ActiveGameObjects.Add(_instance);
                    }
                }


                GameObject NavSurface = GameObject.Find("NavMeshSurface");

                if (NavSurface)
                {
                    NavSurface.GetComponent <NavMeshSurface>().BuildNavMesh();
                }


                OET_io.lib.SetDirty(true);
            }

            tileObject = EditorGUI.ObjectField(
                new Rect(width / 2 + btWidth / 2 + 8, vpos + 100, btWidth, 25),
                tileObject,
                typeof(LevelEditorObject)) as LevelEditorObject;

            GUI.enabled = OET_io.lib.LevelIsLoaded;

            // Save button
            if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 150, btWidth, 25), "Save"))
            {
                OET_io.lib.SaveCurrentLevel();
            }

            // Save As button
            if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 200, btWidth, 25), "Save As"))
            {
                string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level");
                if (savePath == "" || savePath == default(string))
                {
                    return;
                }
                OET_io.lib.SaveCurrentLevel(savePath);
            }

            // Close button
            if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 250, btWidth, 25), "Close"))
            {
                if (OET_io.lib.IsDirty)
                {
                    switch (EditorUtility.DisplayDialogComplex(
                                "Save Level", "Do you want to save your level?",
                                "Save", "Don't Save", "Cancel"))
                    {
                    case 0:     // Save
                        string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level");
                        if (savePath == "" || savePath == default(string))
                        {
                            return;
                        }
                        OET_io.lib.SaveCurrentLevel(savePath);
                        OET_io.lib.CloseLevel();
                        break;

                    case 1:     // Don't Save
                        OET_io.lib.CloseLevel();
                        break;

                    case 2:     // Cancel
                        break;
                    }
                }

                OET_io.lib.CloseLevel();
            }

            GUI.enabled = true;

            // Load button
            if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 300, btWidth, 25), "Load"))
            {
                if (OET_io.lib.LevelIsLoaded && OET_io.lib.IsDirty)
                {
                    switch (EditorUtility.DisplayDialogComplex(
                                "Save Level", "Do you want to save your level?",
                                "Save", "Don't Save", "Cancel"))
                    {
                    case 0:         // Save
                        string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level");
                        if (savePath == "" || savePath == default(string))
                        {
                            return;
                        }
                        OET_io.lib.SaveCurrentLevel(savePath);
                        OET_io.lib.CloseLevel();
                        break;

                    case 1:         // Don't Save
                        OET_io.lib.CloseLevel();
                        break;

                    case 2:         // Cancel
                        break;
                    }
                }

                string openPath = EditorUtility.OpenFilePanel("Open Level", Application.dataPath, "level");
                if (openPath == "" || openPath == default(string))
                {
                    return;
                }
                OET_io.lib.OpenLevel(openPath);
            }
        }
Exemplo n.º 33
0
 public static BlockQuestion SetLEObject(LevelEditorObject le)
 {
     return(new BlockQuestion(le.x, le.y, (ObjectType)le.ParamInt[0]));
 }
Exemplo n.º 34
0
 public static BlockMoving SetLEObject(LevelEditorObject le)
 {
     return(new BlockMoving(le.x, le.y, le.ParamInt[0], (MovingType)le.ParamInt[1], le.Parambool[0]));
 }
Exemplo n.º 35
0
 public static BlockGrass SetLEObject(LevelEditorObject le)
 {
     return new BlockGrass(le.x, le.y);
 }
Exemplo n.º 36
0
 public static BlockQuestion SetLEObject(LevelEditorObject le)
 {
     return new BlockQuestion(le.x, le.y, (ObjectType)le.ParamInt[0]);
 }
Exemplo n.º 37
0
        //public static void renderGUI(int vpos, GameObject[] sceneSelection, GameObject projectActiveSelection)
        public static void renderGUI(int vpos, GameObject[] sceneSelection, LevelEditorObject projectActiveSelection)
        {
            int  width   = Screen.width;
            int  height  = Screen.height;
            bool colMode = height < 350;

            if (sceneSelection != null)
            {
                if (projectActiveSelection != null)
                {
                    GUIStyle styleInfoText = new GUIStyle(GUI.skin.box);
                    styleInfoText.wordWrap         = true;
                    styleInfoText.fontSize         = 9;
                    styleInfoText.normal.textColor = GUI.skin.label.normal.textColor;
                    styleInfoText.alignment        = TextAnchor.MiddleLeft;

                    if (height > 220)
                    {
                        vpos += OET_lib.ToolLib.header("<b>Replacement</b>\nReplace the current selection in the scene with the latest selected prefab in the project window (previewed below).", vpos, false);
                    }
                    Texture2D projectPreview = UnityEditor.AssetPreview.GetAssetPreview(projectActiveSelection.Prefab);
                    if (projectPreview != null)
                    {
                        if (colMode)
                        {
                            int bxsize = vpos + 128 + 30 > height ? height - vpos - 30 : 128;
                            if (width < 330)
                            {
                                bxsize = width - 210;
                            }
                            if (vpos + bxsize + 30 > height)
                            {
                                bxsize = height - vpos - 30;
                            }
                            GUI.Box(new Rect(width - bxsize - 10, vpos, bxsize, bxsize), projectPreview);
                        }
                    }

                    GUI.Label(new Rect(10, vpos, 150, 20), "Preserve Orientation");
                    preserveOrientation = GUI.Toggle(new Rect(160, vpos, 50, 20), preserveOrientation, "");
                    vpos += 20;

                    GUI.Label(new Rect(10, vpos, 150, 20), "Preserve Scale");
                    preserveScale = GUI.Toggle(new Rect(160, vpos, 50, 20), preserveScale, "");
                    vpos         += 35;

                    int btWidth = width < 160 ? width - 20 : 160;
                    if (GUI.Button(new Rect(colMode ? width / 3 - btWidth / 2 : width / 2 - btWidth / 2, vpos, btWidth, 25), "Replace"))
                    {
                        var newSelection = new List <GameObject>();
                        foreach (GameObject obj in sceneSelection)
                        {
                            GameObject newObject = PrefabUtility.InstantiatePrefab(projectActiveSelection) as GameObject;
                            newObject.transform.parent   = obj.transform.parent;
                            newObject.transform.position = obj.transform.position;
                            if (preserveScale)
                            {
                                newObject.transform.localScale = obj.transform.localScale;
                            }
                            if (preserveOrientation)
                            {
                                newObject.transform.eulerAngles = obj.transform.eulerAngles;
                            }
                            newSelection.Add(newObject);
                            Undo.RegisterCreatedObjectUndo(newObject, "Objects replacement");
                            Undo.DestroyObjectImmediate(obj);
                        }
                        Selection.objects = newSelection.ToArray();
                    }
                    vpos += 30;
                    if (!colMode)
                    {
                        GUI.Box(new Rect(width / 2 - 64, vpos, 128, 128), projectPreview);
                    }
                }
                else
                {
                    OET_lib.ToolLib.alertBox("Objects Replacement", "Select a prefab in the project window to enable this tool.");
                }
            }
            else
            {
                OET_lib.ToolLib.alertBox("Objects Replacement", "Select objects in the hierarchy or in the scene view to enable this tool.");
            }
        }
Exemplo n.º 38
0
 public static BlockMoving SetLEObject(LevelEditorObject le)
 {
     return new BlockMoving(le.x, le.y, le.ParamInt[0], (MovingType)le.ParamInt[1], le.Parambool[0]);
 }
Exemplo n.º 39
0
 public static Mario SetLEObject(LevelEditorObject le)
 {
     return(new Mario(le.x, le.y));
 }