static public void Open(Planet planet, List <GameObject> prefabs, List <Texture2D> previews)
        {
            PlanetVegetationWindow win = EditorWindow.GetWindow <PlanetVegetationWindow> ();

            win.minSize            = new Vector2(300f, 600f);
            win.target             = planet;
            win.vegetationPrefabs  = prefabs;
            win.vegetationPreviews = previews;
            win.Initialize();
        }
示例#2
0
        static void PlanetEditorGUI(SceneView sceneView)
        {
            mousePos.x = Event.current.mousePosition.x / Screen.width;
            mousePos.y = (SceneView.lastActiveSceneView.camera.pixelHeight - Event.current.mousePosition.y) / SceneView.lastActiveSceneView.camera.pixelHeight;

            Handles.BeginGUI();
            if (PlanetEditor.PlanetSelected() != null)
            {
                GUILayout.Button(PlanetEditorLogo, GUILayout.Height(50f), GUILayout.Width(150f));
                if (!PlanetEditor.planetEditMode)
                {
                    if (GUILayout.Button("EDIT", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetEditor.selectedPlanet = PlanetEditor.PlanetSelected();
                        PlanetEditor.planetEditMode = true;
                        PlanetEditor.selectedPlanet.BuildColliders();
                        PlanetEditor.selectedBlock = 0;
                        PlanetCursor.SetMaterial(PlanetEditor.EraseMaterial);
                    }
                }
                else if (PlanetEditor.planetEditMode)
                {
                    if (GUILayout.Button("OVER", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetEditor.planetEditMode = false;
                        PlanetCursor.HideCursor();
                    }

                    GUILayout.Button("Cursor. i = " + PlanetCursor.posInPlanetSide.x + " | j = " + PlanetCursor.posInPlanetSide.y + " | h = " + PlanetCursor.posInPlanetSide.z, GUILayout.Height(30f), GUILayout.Width(250f));

                    scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(110f));
                    if (GUILayout.Button(PlanetEditor.PlanetEraseLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = 0.2f;
                        PlanetEditor.selectedBlock      = 0;
                        PlanetCursor.SetMaterial(PlanetEditor.EraseMaterial);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetDirtLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 1;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[0]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetRockLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 3;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[2]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetSandLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 4;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[3]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetDustLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 5;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[4]);
                    }

                    for (int i = 0; i < PrefabsVegetation.Count; i++)
                    {
                        if (GUILayout.Button(PrefabsVegetationLogo[i], GUILayout.Height(80f), GUILayout.Width(80f)))
                        {
                            PlanetEditor.mouseRayCorrection = -0.2f;
                            PlanetEditor.selectedBlock      = 100;
                            PlanetCursor.SetMaterial(VegetationMaterial);
                            selectedGameObject = PrefabsVegetation[i];
                        }
                    }
                    GUILayout.EndScrollView();

                    if (GUILayout.Button("Vegetation Wizard", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetVegetationWindow.Open(selectedPlanet, PrefabsVegetation, PrefabsVegetationLogo);
                    }

                    if (PrefabsVegetation.Count > 0)
                    {
                        if (PrefabsVegetation [0] == null)
                        {
                            Debug.Log("IsNull");
                        }
                    }

                    if (GUILayout.Button("Refresh Vegetation Pictures", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        prefabsVegetationLogo = null;
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                }
            }
            Handles.EndGUI();

            if (PlanetEditor.planetEditMode)
            {
                if (PlanetEditor.planetHit)
                {
                    selectedPlanet.SetCursorAt(PlanetEditor.selectedBlock, mouseRayImpact);
                }
                else
                {
                    PlanetCursor.HideCursor();
                }

                if (Event.current.type == EventType.MouseDown)
                {
                    if (Event.current.button == 0)
                    {
                        if (selectedBlock < 100)
                        {
                            PlanetEditor.selectedPlanet.AddBlockAt(PlanetEditor.mouseRayImpact, PlanetEditor.selectedBlock);
                        }
                        else
                        {
                            PlanetEditor.selectedPlanet.AddGameObjectAtCursor(selectedGameObject);
                        }
                    }
                }
            }
        }