public void Init(RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI)
        {
            Selection.selectionChanged += OnSelectionChanged;

            this.ivyParametersGUI = ivyParametersGUI;
            this.realIvyProWindow = realIvyProWindow;
        }
Ejemplo n.º 2
0
        public static void Initialize(bool createNewIvy)
        {
            Undo.ClearAll();

            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            ivyParametersGUI = ScriptableObject.CreateInstance <IvyParametersGUI>();
            controller       = ScriptableObject.CreateInstance <RealIvyProWindowController>();
            controller.Init(instance, ivyParametersGUI);

            windowSkin        = (GUISkin)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("b0545e8c97ca8684182a76c2fb22c7ff"), typeof(GUISkin));
            downArrowTex      = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("8ee6aee77df7d3e4485148aa889f9b6b"), typeof(Texture2D));
            materialTex       = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("eb3b714e29c31744888e1bc4bcfe23d6"), typeof(Texture2D));
            leaveTex          = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("14bbaf6e0a8b00f4ea30434e5eeeaf8c"), typeof(Texture2D));
            dropdownShadowTex = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9cd9a16c9e229684983f50ff07427219"), typeof(Texture2D));
            presetTex         = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9dd821bf05e345d4a8a501a8768c7144"), typeof(Texture2D));
            infoTex           = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("d73d5146604f9594996de4e08eec4bdf"), typeof(Texture2D));

            Undo.undoRedoPerformed += MyUndoCallback;

            IvyPreset defaultPresset = GetDefaultPreset();


            if (realIvyProToolsWindow != null)
            {
                realIvyProToolsWindow.QuitWindow();
            }
            CreateTools();

            if (createNewIvy)
            {
                controller.CreateNewIvy(defaultPresset);
                ivyParametersGUI.CopyFrom(controller.infoPool.ivyParameters);
            }
        }
Ejemplo n.º 3
0
        public void CopyFrom(IvyParametersGUI copyFrom)
        {
            this.stepSize             = copyFrom.stepSize;
            this.branchProvability    = copyFrom.branchProvability;
            this.maxBranchs           = copyFrom.maxBranchs;
            this.layerMask            = copyFrom.layerMask;
            this.minDistanceToSurface = copyFrom.minDistanceToSurface;
            this.maxDistanceToSurface = copyFrom.maxDistanceToSurface;
            this.DTSFrequency         = copyFrom.DTSFrequency;
            this.DTSRandomness        = copyFrom.DTSRandomness;
            this.directionFrequency   = copyFrom.directionFrequency;
            this.directionAmplitude   = copyFrom.directionAmplitude;
            this.directionRandomness  = copyFrom.directionRandomness;
            this.gravity = new Vector3(copyFrom.gravityX, copyFrom.gravityY, copyFrom.gravityZ);
            this.grabProvabilityOnFall = copyFrom.grabProvabilityOnFall;
            this.stiffness             = copyFrom.stiffness;
            this.optAngleBias          = copyFrom.optAngleBias;
            this.leaveEvery            = copyFrom.leaveEvery;
            this.randomLeaveEvery      = copyFrom.randomLeaveEvery;

            this.buffer32Bits      = copyFrom.buffer32Bits;
            this.halfgeom          = copyFrom.halfgeom;
            this.sides             = copyFrom.sides;
            this.minRadius         = copyFrom.minRadius;
            this.maxRadius         = copyFrom.maxRadius;
            this.radiusVarFreq     = copyFrom.radiusVarFreq;
            this.radiusVarOffset   = copyFrom.radiusVarOffset;
            this.tipInfluence      = copyFrom.tipInfluence;
            this.uvScale           = new Vector2(copyFrom.uvScaleX, copyFrom.uvScaleY);
            this.uvOffset          = new Vector2(copyFrom.uvOffsetX, copyFrom.uvOffsetY);
            this.minScale          = copyFrom.minScale;
            this.maxScale          = copyFrom.maxScale;
            this.globalOrientation = copyFrom.globalOrientation;
            this.globalRotation    = new Vector3(copyFrom.globalRotationX, copyFrom.globalRotationY, copyFrom.globalRotationZ);
            this.rotation          = new Vector3(copyFrom.rotationX, copyFrom.rotationY, copyFrom.rotationZ);
            this.randomRotation    = new Vector3(copyFrom.randomRotationX, copyFrom.randomRotationY, copyFrom.randomRotationZ);
            this.offset            = new Vector3(copyFrom.offsetX, copyFrom.offsetY, copyFrom.offsetZ);
            this.LMUVPadding       = copyFrom.LMUVPadding;

            this.generateBranches    = copyFrom.generateBranches;
            this.generateLeaves      = copyFrom.generateLeaves;
            this.generateLightmapUVs = copyFrom.generateLightmapUVs;

            this.branchesMaterial = copyFrom.branchesMaterial;


            this.leavesPrefabs = new GameObject[copyFrom.leavesPrefabs.Count];
            for (int i = 0; i < copyFrom.leavesPrefabs.Count; i++)
            {
                this.leavesPrefabs[i] = copyFrom.leavesPrefabs[i];
            }

            this.leavesProb = new float[copyFrom.leavesProb.Count];
            for (int i = 0; i < copyFrom.leavesProb.Count; i++)
            {
                this.leavesProb[i] = copyFrom.leavesProb[i];
            }
        }
Ejemplo n.º 4
0
        private void RemoveLeavePrefab(IvyParametersGUI ivyParametersGUI, int index)
        {
            ivyParametersGUI.leavesPrefabs.RemoveAt(index);
            ivyParametersGUI.leavesProb.RemoveAt(index);
            realIvyProWindow.SaveParameters();

            realIvyProWindow.parametersChanged = true;
            realIvyProWindow.presetsChanged.Add(realIvyProWindow.presetSelected);

            for (int b = 0; b < RealIvyWindow.controller.infoPool.ivyContainer.branches.Count; b++)
            {
                for (int l = 0; l < RealIvyWindow.controller.infoPool.ivyContainer.branches[b].GetNumLeaves(); l++)
                {
                    if (RealIvyWindow.controller.infoPool.ivyContainer.branches[b].leaves[l].chosenLeave == index)
                    {
                        RealIvyWindow.controller.infoPool.ivyContainer.branches[b].leaves[l].chosenLeave = 0;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void DrawZone(string sectionName, float areaMaxHeight, RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                                      GUISkin windowSkin, RealIvyProWindowController controller,
                                      ref float YSpace, ref float presetDropDownYSpace, ref float areaYSpace, Rect generalArea,
                                      Color bgColor, AnimationCurve animationCurve)
        {
            base.DrawZone(sectionName, areaMaxHeight, realIvyProWindow, ivyParametersGUI,
                          windowSkin, controller, ref YSpace, ref presetDropDownYSpace,
                          ref areaYSpace, generalArea, bgColor, animationCurve);

            this.animationCurve = animationCurve;

            GUILayout.BeginArea(areaRect);

            EditorGUI.DrawRect(new Rect(0f, areaYSpace, generalArea.width, 50f), bgColor);
            GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Orientation", windowSkin.label);
            realIvyProWindow.OrientationToggle(100f, areaYSpace);
            UIUtils.CustomIntFloatField(ivyParametersGUI.leaveEvery, 0.01f, "Leaves Interval", 50f, areaYSpace, 250f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.randomLeaveEvery, 0.01f, "Random", 50f, areaYSpace, 330f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 45f;

            if (controller.infoPool.ivyParameters.globalOrientation)
            {
                GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Global Rotation", windowSkin.label);
                UIUtils.CustomIntFloatField(ivyParametersGUI.globalRotationX, 0.01f, "X", 50f, areaYSpace + 40f, 15f, windowSkin, realIvyProWindow.OnUpdatingParameter);
                UIUtils.CustomIntFloatField(ivyParametersGUI.globalRotationY, 0.01f, "Y", 50f, areaYSpace + 40f, 70f, windowSkin, realIvyProWindow.OnUpdatingParameter);
                UIUtils.CustomIntFloatField(ivyParametersGUI.globalRotationZ, 0.01f, "Z", 50f, areaYSpace + 40f, 125f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            }
            else
            {
                GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Local Rotation", windowSkin.label);
                UIUtils.CustomIntFloatField(ivyParametersGUI.rotationX, 0.01f, "X", 50f, areaYSpace + 40f, 15f, windowSkin, realIvyProWindow.OnUpdatingParameter);
                UIUtils.CustomIntFloatField(ivyParametersGUI.rotationY, 0.01f, "Y", 50f, areaYSpace + 40f, 70f, windowSkin, realIvyProWindow.OnUpdatingParameter);
                UIUtils.CustomIntFloatField(ivyParametersGUI.rotationZ, 0.01f, "Z", 50f, areaYSpace + 40f, 125f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            }

            //EditorGUI.DrawRect(new Rect(0f, leavesAreaYSpace - 5f, generalAreaWidth, 80f), bckgColor2);
            GUI.Label(new Rect(15f + 200f, areaYSpace + 15f, 100f, 25f), "Randomness", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.randomRotationX, 0.01f, "X", 50f, areaYSpace + 40f, 215f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.randomRotationY, 0.01f, "Y", 50f, areaYSpace + 40f, 270f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.randomRotationZ, 0.01f, "Z", 50f, areaYSpace + 40f, 325f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 80f;

            EditorGUI.DrawRect(new Rect(0f, areaYSpace + 15f, generalArea.width, 80f), bgColor);
            GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Position", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.offsetX, 0.001f, "X", 50f, areaYSpace + 40f, 15f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.offsetY, 0.001f, "Y", 50f, areaYSpace + 40f, 70f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.offsetZ, 0.001f, "Z", 50f, areaYSpace + 40f, 125f, windowSkin, realIvyProWindow.OnUpdatingParameter);

            GUI.Label(new Rect(215f, areaYSpace + 15f, 100f, 25f), "Scale", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.minScale, 0.01f, "Min", 50f, areaYSpace + 40f, 215f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.maxScale, 0.01f, "Max", 50f, areaYSpace + 40f, 270f, windowSkin, realIvyProWindow.OnUpdatingParameter);


            areaYSpace += 100f;

            GUILayout.EndArea();

            YSpace += areaRect.height;
            realIvyProWindow.Repaint();
        }
        public override void DrawZone(string sectionName, float areaMaxHeight, RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                                      GUISkin windowSkin, RealIvyProWindowController controller,
                                      ref float YSpace, ref float presetDropDownYSpace, ref float areaYSpace, Rect generalArea,
                                      Color bgColor, AnimationCurve animationCurve)
        {
            base.DrawZone(sectionName, areaMaxHeight, realIvyProWindow, ivyParametersGUI, windowSkin,
                          controller, ref YSpace, ref presetDropDownYSpace,
                          ref areaYSpace, generalArea, bgColor, animationCurve);


            GUILayout.BeginArea(areaRect);

            this.animationCurve = animationCurve;

            EditorGUI.DrawRect(new Rect(0f, areaYSpace, generalArea.width, 55f), bgColor);
            GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Radius", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.minRadius, 0.001f, "Min", 50f, areaYSpace, 100f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.maxRadius, 0.001f, "Max", 50f, areaYSpace, 155f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.radiusVarFreq, 0.01f, "Freq.", 50f, areaYSpace, 215f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.radiusVarOffset, 0.01f, "Offset", 50f, areaYSpace, 275f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.tipInfluence, 0.01f, "Tip", 50f, areaYSpace, 335f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 60f;

            GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "UVs", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.uvScaleX, 0.01f, "X Scale", 50f, areaYSpace, 100f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.uvScaleY, 0.01f, "Y Scale", 50f, areaYSpace, 155f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.uvOffsetX, 0.01f, "X Offset", 50f, areaYSpace, 215f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.uvOffsetY, 0.01f, "Y Offset", 50f, areaYSpace, 270f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 60f;

            EditorGUI.DrawRect(new Rect(0f, areaYSpace - 5f, generalArea.width, 60f), bgColor);
            GUI.Label(new Rect(15f, areaYSpace + 15f, 100f, 25f), "Others", windowSkin.label);

            UIUtils.CustomIntFloatField(ivyParametersGUI.sides, 0.01f, "Sides", 50f, areaYSpace, 100f, windowSkin, realIvyProWindow.OnUpdatingParameter);

            ivyParametersGUI.halfgeom = GUI.Toggle(new Rect(230f, areaYSpace + 16f, 133f, 20f), ivyParametersGUI.halfgeom, "Half Section", windowSkin.toggle);

            areaYSpace += 60f;

            GUILayout.EndArea();

            YSpace += areaRect.height;
            realIvyProWindow.Repaint();
        }
Ejemplo n.º 7
0
        public override void DrawZone(string sectionName, float areaMaxHeight, RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                                      GUISkin windowSkin, RealIvyProWindowController controller,
                                      ref float YSpace, ref float presetDropDownYSpace, ref float areaYSpace, Rect generalArea,
                                      Color bgColor, AnimationCurve animationCurve)
        {
            base.DrawZone(sectionName, areaMaxHeight, realIvyProWindow, ivyParametersGUI,
                          windowSkin, controller, ref YSpace, ref presetDropDownYSpace,
                          ref areaYSpace, generalArea, bgColor, animationCurve);

            GUILayout.BeginArea(areaRect);

            EditorGUI.DrawRect(new Rect(0f, areaYSpace, generalArea.width, 58f), bgColor);
            UIUtils.CustomIntFloatField(ivyParametersGUI.stepSize, 0.01f, "Step Size", 50f, areaYSpace, 20f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.directionFrequency, 0.01f, "Dir. Frequency", 50f, areaYSpace, 120f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.directionAmplitude, 0.01f, "Dir. Amplitude", 50f, areaYSpace, 225f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.directionRandomness, 0.01f, "Dir. Random", 50f, areaYSpace, 320f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 58f;

            GUI.Label(new Rect(15f, areaYSpace, 100f, 25f), "Gravity", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.gravityX, 0.01f, "X", 50f, areaYSpace + 25f, 15f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.gravityY, 0.01f, "Y", 50f, areaYSpace + 25f, 70f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.gravityZ, 0.01f, "Z", 50f, areaYSpace + 25f, 125f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.stiffness, 0.01f, "Stiffness", 50f, areaYSpace + 25f, 225f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.grabProvabilityOnFall, 0.01f, "Grab prob. on falling", 50f, areaYSpace + 25f, 320f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 86f;

            EditorGUI.DrawRect(new Rect(0f, areaYSpace - 5f, generalArea.width, 60f), bgColor);
            GUI.Label(new Rect(15f, areaYSpace + 15f, 150f, 25f), "Distance to surface", windowSkin.label);
            UIUtils.CustomIntFloatField(ivyParametersGUI.maxDistanceToSurface, 0.001f, "Max", 50f, areaYSpace, 165f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.minDistanceToSurface, 0.001f, "Min", 50f, areaYSpace, 225f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.DTSFrequency, 0.01f, "Freq.", 50f, areaYSpace, 285f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.DTSRandomness, 0.01f, "Random", 50f, areaYSpace, 345f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 60f;

            UIUtils.CustomIntFloatField(ivyParametersGUI.maxBranchs, 0.1f, "Max. Branches", 50f, areaYSpace, 20f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            UIUtils.CustomIntFloatField(ivyParametersGUI.branchProvability, 0.001f, "Branch probability", 50f, areaYSpace, 120f, windowSkin, realIvyProWindow.OnUpdatingParameter);
            areaYSpace += 55f;

            GUILayout.EndArea();

            YSpace += areaRect.height;
            realIvyProWindow.Repaint();
        }
Ejemplo n.º 8
0
 public void CopyFrom(IvyParametersGUI copyFrom)
 {
     ivyParameters.CopyFrom(copyFrom);
 }
Ejemplo n.º 9
0
        public virtual void DrawZone(string sectionName, float areaMaxHeight, RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                                     GUISkin windowSkin, RealIvyProWindowController controller,
                                     ref float YSpace, ref float presetDropDownYSpace, ref float areaYSpace, Rect generalArea,
                                     Color bgColor, AnimationCurve animationCurve)
        {
            this.realIvyProWindow = realIvyProWindow;

            dropDownButton.Draw(sectionName, windowSkin, RealIvyWindow.downArrowTex,
                                generalArea, ref areaHeight, ref YSpace, areaMaxHeight, animationCurve, this);

            areaRect = new Rect(10f, YSpace, generalArea.width, areaHeight);
        }
Ejemplo n.º 10
0
        public void DrawZone(RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                             GUISkin windowSkin, RealIvyProWindowController controller,
                             ref float YSpace, Rect generalArea, Color bgColor)
        {
            this.controller       = controller;
            this.realIvyProWindow = realIvyProWindow;
            this.ivyParametersGUI = ivyParametersGUI;
            this.windowSkin       = windowSkin;


            currentArea = new Rect(10f, 10f, generalArea.width, 520f);
            string gameObjectName = "None";

            if (controller.currentIvyInfo != null)
            {
                gameObjectName = controller.ivyGO.name;
            }

            string boxText = "Editing object: " + gameObjectName;

            GUI.Box(new Rect(0f, YSpace, generalArea.width + 20f, 40f), boxText, windowSkin.GetStyle("title"));
            YSpace += 45f;
            GUILayout.BeginArea(currentArea);
            GUIStyle placeButtonStyle = windowSkin.button;

            GUI.Label(new Rect(170f, YSpace - 15f, 100f, 40f), "Main Controls", windowSkin.label);
            YSpace += 25f;

            string placeButtonText = "Place Seed";

            if (realIvyProWindow.placingSeed)
            {
                placeButtonStyle = windowSkin.GetStyle("buttonorange");
                placeButtonText  = "Stop Placing";
            }

            GUIStyle startStopButtonStyle = windowSkin.button;
            string   startStopButtonText  = "Start Growth";

            if (controller.infoPool.growth.growing)
            {
                startStopButtonStyle = windowSkin.GetStyle("buttonorange");
                startStopButtonText  = "Stop Growth";
            }
            if (GUI.Button(new Rect(20f, YSpace, 100f, 25f), placeButtonText, placeButtonStyle))
            {
                realIvyProWindow.placingSeed = !realIvyProWindow.placingSeed;
            }


            if (GUI.Button(new Rect(140f, YSpace, 100f, 25f), "Randomize", windowSkin.button))
            {
                CheckRestrictions(Randomize);
            }
            if (GUI.Button(new Rect(20f, YSpace + 40f, 100f, 25f), startStopButtonText, startStopButtonStyle))
            {
                CheckIvySelectedBeforeAction(StartStopGrowth);
            }
            if (GUI.Button(new Rect(140f, YSpace + 40f, 100f, 25f), "Reset", windowSkin.button))
            {
                CheckIvySelectedBeforeAction(Reset);
            }

            if (GUI.Button(new Rect(275f, YSpace + 5f, 100f, 25f), "Optimize", windowSkin.button))
            {
                CheckRestrictions(Optimize);
            }

            Rect optimizeAngleLabel = new Rect(330f, YSpace + 35f, 50f, 20f);

            GUI.Label(optimizeAngleLabel, "Angle", windowSkin.label);
            if (EditorGUI.DropdownButton(optimizeAngleLabel, GUIContent.none, FocusType.Keyboard, windowSkin.GetStyle("transparent")))
            {
                realIvyProWindow.updatingParameter       = ivyParametersGUI.optAngleBias;
                realIvyProWindow.updatingValue           = true;
                realIvyProWindow.updatingValueMultiplier = 0.1f;
                realIvyProWindow.originalUpdatingValue   = ivyParametersGUI.optAngleBias;
                realIvyProWindow.mouseStartPoint         = GUIUtility.GUIToScreenPoint(Event.current.mousePosition).x;
            }
            if (optimizeAngleLabel.Contains(Event.current.mousePosition))
            {
                EditorGUIUtility.AddCursorRect(new Rect(Event.current.mousePosition, Vector2.one * 20f), MouseCursor.SlideArrow);
            }
            ivyParametersGUI.optAngleBias.value = EditorGUI.FloatField(new Rect(275, YSpace + 35f, 50f, 20f), "",
                                                                       ivyParametersGUI.optAngleBias, windowSkin.GetStyle("textfield"));

            YSpace += 65f;

            YSpace += 15f;
            EditorGUI.DrawRect(new Rect(0f, YSpace, generalArea.width, 2f), bgColor);
            YSpace += 20f;

            GUI.Label(new Rect(80f, YSpace - 20f, 200f, 40f), "Save ivy", windowSkin.label);
            if (GUI.Button(new Rect(10f, YSpace + 20f, 90f, 40f), "Save into Scene", windowSkin.button))
            {
                CheckRestrictions(SaveCurrentIvyIntoScene);
            }
            if (GUI.Button(new Rect(110f, YSpace + 20f, 90f, 40f), "Save as prefab", windowSkin.button))
            {
                CheckRestrictions(SaveAsPrefab);
            }

            EditorGUI.DrawRect(new Rect(209f, YSpace - 5f, 2f, 75f), bgColor);

            GUI.Label(new Rect(245f, YSpace - 20f, 200f, 40f), "Convert to runtime Ivy", windowSkin.label);
            if (GUI.Button(new Rect(220f, YSpace + 20f, 90f, 40f), "Runtime Procedural", windowSkin.button))
            {
                CheckRestrictions(PrepareRuntimeProcedural);
            }

            if (GUI.Button(new Rect(320f, YSpace + 20f, 90f, 40f), "Runtime Baked", windowSkin.button))
            {
                CheckRestrictions(PrepareRuntimeBaked);
            }
            YSpace += 90f;

            GUILayout.EndArea();
        }
Ejemplo n.º 11
0
        public override void DrawZone(string sectionName, float areaMaxHeight, RealIvyWindow realIvyProWindow, IvyParametersGUI ivyParametersGUI,
                                      GUISkin windowSkin, RealIvyProWindowController controller,
                                      ref float YSpace, ref float presetDropDownYSpace, ref float areaYSpace, Rect generalArea,
                                      Color bgColor, AnimationCurve animationCurve)
        {
            base.DrawZone(sectionName, areaMaxHeight, realIvyProWindow, ivyParametersGUI,
                          windowSkin, controller, ref YSpace, ref presetDropDownYSpace,
                          ref areaYSpace, generalArea, bgColor, animationCurve);

            GUILayout.BeginArea(areaRect);
            //EditorGUI.DrawRect(new Rect(0f, areaYSpace, generalArea.width, 58f), bgColor);

            //currentArea = new Rect(10f, 10f, generalArea.width, 520f);

            /*GUI.Box(new Rect(0f, areaYSpace, generalArea.width + 20f, 40f), "General Settings", windowSkin.GetStyle("sectionbutton"));*/
            //areaYSpace += 40f;

            //GUILayout.BeginArea(currentArea);
            GUI.Label(new Rect(5f, areaYSpace, 100f, 20f), "Preset:", windowSkin.label);

            areaYSpace += 20f;


            UIUtils.CustomObjectField <IvyPreset>(new Rect(0f, areaYSpace, areaRect.width / 2f, 25f),
                                                  controller.selectedPreset, windowSkin, realIvyProWindow.oldSkin, RealIvyWindow.presetTex, 489136168, string.Empty,
                                                  OnPresetChanged, controller.AreThereUnsavedChanges());


            //bool unsavedChanges = !controller.infoPool.ivyParameters.IsEqualTo(controller.selectedPreset);
            UIUtils.ButtonChangesAlert(new Rect(areaRect.width / 2f + 10f, areaYSpace, 60f, 25f), "Save", "Save *",
                                       windowSkin.button, windowSkin.GetStyle("bold"), false, SavePreset);

            /*if (GUI.Button(new Rect(currentArea.width / 2f + 10f, YSpace, 60f, 25f), "Save*", windowSkin.GetStyle("bold")))
             * {
             *      SavePreset();
             * }*/
            if (GUI.Button(new Rect(areaRect.width / 2f + 70f + 10f, areaYSpace, 130f, 25f), "Save preset as...", windowSkin.button))
            {
                SavePresetAs();
            }


            areaYSpace += 40f;
            GUI.Label(new Rect(5f, areaYSpace, 100f, 20f), "Generate...", windowSkin.label);
            areaYSpace += 20f;

            ivyParametersGUI.generateBranches    = GUI.Toggle(new Rect(0f, areaYSpace, 133f, 20f), ivyParametersGUI.generateBranches, "Vines", windowSkin.toggle);
            ivyParametersGUI.generateLeaves      = GUI.Toggle(new Rect(generalArea.width / 3f + 10f, areaYSpace, 133f, 20f), ivyParametersGUI.generateLeaves, "Leaves", windowSkin.toggle);
            ivyParametersGUI.generateLightmapUVs = GUI.Toggle(new Rect(generalArea.width / 3f * 2f + 10f, areaYSpace, 133f, 20f), ivyParametersGUI.generateLightmapUVs, "Lightmap UVs", windowSkin.toggle);
            areaYSpace += 20f;

            areaYSpace += 10f;
            GUI.Label(new Rect(5f, areaYSpace, generalArea.width / 3f - 5f, 20f), "Vines material:", windowSkin.label);
            GUI.Label(new Rect(generalArea.width / 3f + 10f, areaYSpace, generalArea.width / 3f - 5f, 20f), "Leaves prefabs:", windowSkin.label);
            areaYSpace += 20f;

            ivyParametersGUI.branchesMaterial = UIUtils.CustomObjectField <Material>(new Rect(0f, areaYSpace, generalArea.width / 3f - 5f, 25f),
                                                                                     ivyParametersGUI.branchesMaterial, windowSkin, realIvyProWindow.oldSkin, RealIvyWindow.materialTex, 489136169, string.Empty, OnVinesMaterialChanged, false);

            GUI.Label(new Rect(5f, areaYSpace + 35f, generalArea.width / 3f - 5f, 20f), "Layer Mask:", windowSkin.label);
            ivyParametersGUI.layerMask = EditorGUI.MaskField(new Rect(0f, areaYSpace + 55f, generalArea.width / 3f - 5f, 25f),
                                                             InternalEditorUtility.LayerMaskToConcatenatedLayersMask(ivyParametersGUI.layerMask),
                                                             InternalEditorUtility.layers,
                                                             windowSkin.GetStyle("dropdown"));
            GUI.DrawTexture(new Rect(generalArea.width / 3f - 30f, areaYSpace + 55f, 25f, 25f), RealIvyWindow.downArrowTex);
            ivyParametersGUI.layerMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(ivyParametersGUI.layerMask);

            ivyParametersGUI.buffer32Bits = GUI.Toggle(new Rect(0f, areaYSpace + 100f, 133f, 20f), ivyParametersGUI.buffer32Bits, "32 bits mesh buffer", windowSkin.toggle);

            GUI.Box(new Rect(generalArea.width / 3f + 5f, areaYSpace, (generalArea.width / 3f - 5f) * 2f, 120f), "", windowSkin.GetStyle("list"));

            float leaveButtonsMargin;

            if (ivyParametersGUI.leavesPrefabs.Count > 3)
            {
                leaveButtonsMargin = 50f;
            }
            else
            {
                leaveButtonsMargin = 35f;
            }

            realIvyProWindow.leavesPrefabsScrollView = GUI.BeginScrollView(new Rect(generalArea.width / 3f + 5f, areaYSpace, (generalArea.width / 3f - 5f) * 2f, 100f), realIvyProWindow.leavesPrefabsScrollView, new Rect(0f, 0f, (generalArea.width / 3f - 21f) * 2f, (ivyParametersGUI.leavesPrefabs.Count + 1) * 25f));

            for (int i = 0; i < ivyParametersGUI.leavesPrefabs.Count + 1; i++)
            {
                if (i < ivyParametersGUI.leavesPrefabs.Count)
                {
                    if (ivyParametersGUI.leavesPrefabs[i] != null)
                    {
                        if (GUI.Button(new Rect(0f, i * 25f, (generalArea.width / 3f - leaveButtonsMargin) * 2f, 25f), ivyParametersGUI.leavesPrefabs[i].name, windowSkin.GetStyle("listelement")))
                        {
                            EditorGUIUtility.PingObject(ivyParametersGUI.leavesPrefabs[i]);
                        }

                        GUI.DrawTexture(new Rect(0f, i * 25f, 25f, 25f), RealIvyWindow.leaveTex);

                        ivyParametersGUI.leavesProb[i] = EditorGUI.FloatField(new Rect(generalArea.width / 3f * 2f - leaveButtonsMargin * 2f + 10, i * 25f + 2, 25f, 20f), ivyParametersGUI.leavesProb[i], windowSkin.textArea);
                        GUI.Label(new Rect(generalArea.width / 3f * 2f - leaveButtonsMargin * 2f - 8f, i * 25f + 2, 25f, 20f), "%", windowSkin.GetStyle("whitelabel"));

                        if (GUI.Button(new Rect(generalArea.width / 3f * 2f - leaveButtonsMargin, i * 25f, 25f, 25f), "", windowSkin.GetStyle("removeelement")))
                        {
                            RemoveLeavePrefab(ivyParametersGUI, i);
                        }
                    }
                    else
                    {
                        RemoveLeavePrefab(ivyParametersGUI, i);
                    }
                }
                else
                {
                    GUI.Label(new Rect(0f, i * 25f, (generalArea.width / 3f - 5f) * 2, 25f), "Drag & Drop here to add", windowSkin.GetStyle("tooltip"));
                    UIUtils.DragAndDropArea(new Rect(0f, i * 25f, (generalArea.width / 3f - 5f) * 2f, 25f), OnObjectDragged, realIvyProWindow.SaveParameters);
                }
            }

            GUI.EndScrollView();


            GUILayout.EndArea();
            YSpace += areaRect.height;
            realIvyProWindow.Repaint();
        }