Ejemplo n.º 1
0
        protected override void WindowGUI(int windowID)
        {
            MechJebModuleCustomWindowEditor ed = core.GetComputerModule <MechJebModuleCustomWindowEditor>();
            bool alt = Input.GetKey(KeyCode.LeftAlt);

            if (GUI.Button(new Rect(windowPos.width - 48, 0, 13, 20), "?", GuiUtils.yellowOnHover))
            {
                var help = core.GetComputerModule <MechJebModuleWaypointHelpWindow>();
                help.selTopic = ((IList)help.topics).IndexOf("Controller");
                help.enabled  = help.selTopic > -1 || help.enabled;
            }

            ed.registry.Find(i => i.id == "Toggle:RoverController.ControlHeading").DrawItem();
            ed.registry.Find(i => i.id == "Editable:RoverController.heading").DrawItem();
            ed.registry.Find(i => i.id == "Value:RoverController.headingErr").DrawItem();
            ed.registry.Find(i => i.id == "Toggle:RoverController.ControlSpeed").DrawItem();
            ed.registry.Find(i => i.id == "Editable:RoverController.speed").DrawItem();
            ed.registry.Find(i => i.id == "Value:RoverController.speedErr").DrawItem();
            ed.registry.Find(i => i.id == "Toggle:RoverController.StabilityControl").DrawItem();

            if (!core.GetComputerModule <MechJebModuleSettings>().hideBrakeOnEject)
            {
                ed.registry.Find(i => i.id == "Toggle:RoverController.BrakeOnEject").DrawItem();
            }

            ed.registry.Find(i => i.id == "Toggle:RoverController.BrakeOnEnergyDepletion").DrawItem();
            if (autopilot.BrakeOnEnergyDepletion)
            {
                ed.registry.Find(i => i.id == "Toggle:RoverController.WarpToDaylight").DrawItem();
            }

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Target Speed", GUILayout.ExpandWidth(true));
            GUILayout.Label(autopilot.tgtSpeed.ToString("F1"), GUILayout.ExpandWidth(false));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Waypoints", GUILayout.ExpandWidth(true));
            GUILayout.Label("Index " + (autopilot.WaypointIndex + 1).ToString() + " of " + autopilot.Waypoints.Count.ToString(), GUILayout.ExpandWidth(false));
            GUILayout.EndHorizontal();

//			GUILayout.Label("Debug1: " + autopilot.debug1.ToString("F3"));

            GUILayout.BeginHorizontal();
            if (core.target != null && core.target.Target != null)             // && (core.target.targetBody == orbit.referenceBody || (core.target.Orbit != null ? core.target.Orbit.referenceBody == orbit.referenceBody : false))) {
            {
                var vssl = core.target.Target.GetVessel();

                if (GUILayout.Button("To Target"))
                {
                    core.GetComputerModule <MechJebModuleWaypointWindow>().selIndex = -1;
                    autopilot.WaypointIndex = 0;
                    autopilot.Waypoints.Clear();
                    if (vssl != null)
                    {
                        autopilot.Waypoints.Add(new MechJebWaypoint(vssl, 25f));
                    }
                    else
                    {
                        autopilot.Waypoints.Add(new MechJebWaypoint(core.target.GetPositionTargetPosition()));
                    }
                    autopilot.ControlHeading = autopilot.ControlSpeed = true;
                    vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, false);
                    autopilot.LoopWaypoints = alt;
                }

                if (GUILayout.Button("Add Target"))
                {
                    if (vssl != null)
                    {
                        autopilot.Waypoints.Add(new MechJebWaypoint(vssl, 25f));
                    }
                    else
                    {
                        autopilot.Waypoints.Add(new MechJebWaypoint(core.target.GetPositionTargetPosition()));
                    }
//					if (autopilot.WaypointIndex < 0) { autopilot.WaypointIndex = autopilot.Waypoints.Count - 1; }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (autopilot.WaypointIndex == -1)
            {
                if (autopilot.Waypoints.Count > 0)
                {
                    if (GUILayout.Button("Follow"))
                    {
                        autopilot.WaypointIndex  = 0;
                        autopilot.ControlHeading = autopilot.ControlSpeed = true;
                        autopilot.LoopWaypoints  = alt;
                    }
                }
                else
                {
//					if (GUILayout.Button("No Waypoints")) {
//					}
                }
            }
            else
            {
                if (GUILayout.Button("Stop"))
                {
                    autopilot.WaypointIndex  = -1;
                    autopilot.ControlHeading = autopilot.ControlSpeed = autopilot.LoopWaypoints = false;
                }
            }
            if (GUILayout.Button("Waypoints"))
            {
                var waypoints = core.GetComputerModule <MechJebModuleWaypointWindow>();
                waypoints.enabled = !waypoints.enabled;
                if (waypoints.enabled)
                {
                    waypoints.Mode = MechJebModuleWaypointWindow.WaypointMode.Rover;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Ejemplo n.º 2
0
        void DrawCustomToneCurve()
        {
            EditorGUILayout.Space();

            // Reserve GUI space
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(EditorGUI.indentLevel * 15f);
                m_CustomToneCurveRect = GUILayoutUtility.GetRect(128, 80);
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            // Prepare curve data
            float toeStrength      = m_ToneCurveToeStrength.value.floatValue;
            float toeLength        = m_ToneCurveToeLength.value.floatValue;
            float shoulderStrength = m_ToneCurveShoulderStrength.value.floatValue;
            float shoulderLength   = m_ToneCurveShoulderLength.value.floatValue;
            float shoulderAngle    = m_ToneCurveShoulderAngle.value.floatValue;
            float gamma            = m_ToneCurveGamma.value.floatValue;

            m_HableCurve.Init(
                toeStrength,
                toeLength,
                shoulderStrength,
                shoulderLength,
                shoulderAngle,
                gamma
                );

            float endPoint = m_HableCurve.whitePoint;

            // Background
            m_RectVertices[0] = PointInRect(0f, 0f, endPoint);
            m_RectVertices[1] = PointInRect(endPoint, 0f, endPoint);
            m_RectVertices[2] = PointInRect(endPoint, k_CustomToneCurveRangeY, endPoint);
            m_RectVertices[3] = PointInRect(0f, k_CustomToneCurveRangeY, endPoint);
            Handles.DrawSolidRectangleWithOutline(m_RectVertices, Color.white * 0.1f, Color.white * 0.4f);

            // Vertical guides
            if (endPoint < m_CustomToneCurveRect.width / 3)
            {
                int steps = Mathf.CeilToInt(endPoint);
                for (var i = 1; i < steps; i++)
                {
                    DrawLine(i, 0, i, k_CustomToneCurveRangeY, 0.4f, endPoint);
                }
            }

            // Label
            Handles.Label(m_CustomToneCurveRect.position + Vector2.right, "Custom Tone Curve", EditorStyles.miniLabel);

            // Draw the acual curve
            var vcount = 0;

            while (vcount < k_CustomToneCurveResolution)
            {
                float x = endPoint * vcount / (k_CustomToneCurveResolution - 1);
                float y = m_HableCurve.Eval(x);

                if (y < k_CustomToneCurveRangeY)
                {
                    m_CurveVertices[vcount++] = PointInRect(x, y, endPoint);
                }
                else
                {
                    if (vcount > 1)
                    {
                        // Extend the last segment to the top edge of the rect.
                        var v1   = m_CurveVertices[vcount - 2];
                        var v2   = m_CurveVertices[vcount - 1];
                        var clip = (m_CustomToneCurveRect.y - v1.y) / (v2.y - v1.y);
                        m_CurveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
                    }
                    break;
                }
            }

            if (vcount > 1)
            {
                Handles.color = Color.white * 0.9f;
                Handles.DrawAAPolyLine(2f, vcount, m_CurveVertices);
            }
        }
Ejemplo n.º 3
0
        void DoCurvesGUI(bool hdr)
        {
            EditorGUILayout.Space();
            ResetVisibleCurves();

            using (new EditorGUI.DisabledGroupScope(serializedObject.isEditingMultipleObjects))
            {
                int curveEditingId = 0;
                SerializedProperty currentCurveRawProp = null;

                // Top toolbar
                using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    curveEditingId = DoCurveSelectionPopup(GlobalSettings.currentCurve, hdr);
                    curveEditingId = Mathf.Clamp(curveEditingId, hdr ? 4 : 0, 7);

                    EditorGUILayout.Space();

                    switch (curveEditingId)
                    {
                    case 0:
                        CurveOverrideToggle(m_MasterCurve.overrideState);
                        SetCurveVisible(m_RawMasterCurve, m_MasterCurve.overrideState);
                        currentCurveRawProp = m_RawMasterCurve;
                        break;

                    case 1:
                        CurveOverrideToggle(m_RedCurve.overrideState);
                        SetCurveVisible(m_RawRedCurve, m_RedCurve.overrideState);
                        currentCurveRawProp = m_RawRedCurve;
                        break;

                    case 2:
                        CurveOverrideToggle(m_GreenCurve.overrideState);
                        SetCurveVisible(m_RawGreenCurve, m_GreenCurve.overrideState);
                        currentCurveRawProp = m_RawGreenCurve;
                        break;

                    case 3:
                        CurveOverrideToggle(m_BlueCurve.overrideState);
                        SetCurveVisible(m_RawBlueCurve, m_BlueCurve.overrideState);
                        currentCurveRawProp = m_RawBlueCurve;
                        break;

                    case 4:
                        CurveOverrideToggle(m_HueVsHueCurve.overrideState);
                        SetCurveVisible(m_RawHueVsHueCurve, m_HueVsHueCurve.overrideState);
                        currentCurveRawProp = m_RawHueVsHueCurve;
                        break;

                    case 5:
                        CurveOverrideToggle(m_HueVsSatCurve.overrideState);
                        SetCurveVisible(m_RawHueVsSatCurve, m_HueVsSatCurve.overrideState);
                        currentCurveRawProp = m_RawHueVsSatCurve;
                        break;

                    case 6:
                        CurveOverrideToggle(m_SatVsSatCurve.overrideState);
                        SetCurveVisible(m_RawSatVsSatCurve, m_SatVsSatCurve.overrideState);
                        currentCurveRawProp = m_RawSatVsSatCurve;
                        break;

                    case 7:
                        CurveOverrideToggle(m_LumVsSatCurve.overrideState);
                        SetCurveVisible(m_RawLumVsSatCurve, m_LumVsSatCurve.overrideState);
                        currentCurveRawProp = m_RawLumVsSatCurve;
                        break;
                    }

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
                    {
                        switch (curveEditingId)
                        {
                        case 0: m_RawMasterCurve.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
                            break;

                        case 1: m_RawRedCurve.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
                            break;

                        case 2: m_RawGreenCurve.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
                            break;

                        case 3: m_RawBlueCurve.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
                            break;

                        case 4: m_RawHueVsHueCurve.animationCurveValue = new AnimationCurve();
                            break;

                        case 5: m_RawHueVsSatCurve.animationCurveValue = new AnimationCurve();
                            break;

                        case 6: m_RawSatVsSatCurve.animationCurveValue = new AnimationCurve();
                            break;

                        case 7: m_RawLumVsSatCurve.animationCurveValue = new AnimationCurve();
                            break;
                        }
                    }

                    GlobalSettings.currentCurve = curveEditingId;
                }

                // Curve area
                var settings  = m_CurveEditor.settings;
                var rect      = GUILayoutUtility.GetAspectRect(2f);
                var innerRect = settings.padding.Remove(rect);

                if (Event.current.type == EventType.Repaint)
                {
                    // Background
                    EditorGUI.DrawRect(rect, new Color(0.15f, 0.15f, 0.15f, 1f));

                    if (curveEditingId == 4 || curveEditingId == 5)
                    {
                        DrawBackgroundTexture(innerRect, 0);
                    }
                    else if (curveEditingId == 6 || curveEditingId == 7)
                    {
                        DrawBackgroundTexture(innerRect, 1);
                    }

                    // Bounds
                    Handles.color = Color.white * (GUI.enabled ? 1f : 0.5f);
                    Handles.DrawSolidRectangleWithOutline(innerRect, Color.clear, new Color(0.8f, 0.8f, 0.8f, 0.5f));

                    // Grid setup
                    Handles.color = new Color(1f, 1f, 1f, 0.05f);
                    int hLines = (int)Mathf.Sqrt(innerRect.width);
                    int vLines = (int)(hLines / (innerRect.width / innerRect.height));

                    // Vertical grid
                    int gridOffset  = Mathf.FloorToInt(innerRect.width / hLines);
                    int gridPadding = ((int)(innerRect.width) % hLines) / 2;

                    for (int i = 1; i < hLines; i++)
                    {
                        var offset = i * Vector2.right * gridOffset;
                        offset.x += gridPadding;
                        Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.x, innerRect.yMax - 1) + offset);
                    }

                    // Horizontal grid
                    gridOffset  = Mathf.FloorToInt(innerRect.height / vLines);
                    gridPadding = ((int)(innerRect.height) % vLines) / 2;

                    for (int i = 1; i < vLines; i++)
                    {
                        var offset = i * Vector2.up * gridOffset;
                        offset.y += gridPadding;
                        Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.xMax - 1, innerRect.y) + offset);
                    }
                }

                // Curve editor
                if (m_CurveEditor.OnGUI(rect))
                {
                    Repaint();
                    GUI.changed = true;
                }

                if (Event.current.type == EventType.Repaint)
                {
                    // Borders
                    Handles.color = Color.black;
                    Handles.DrawLine(new Vector2(rect.x, rect.y - 18f), new Vector2(rect.xMax, rect.y - 18f));
                    Handles.DrawLine(new Vector2(rect.x, rect.y - 19f), new Vector2(rect.x, rect.yMax));
                    Handles.DrawLine(new Vector2(rect.x, rect.yMax), new Vector2(rect.xMax, rect.yMax));
                    Handles.DrawLine(new Vector2(rect.xMax, rect.yMax), new Vector2(rect.xMax, rect.y - 18f));

                    bool   editable       = m_CurveEditor.GetCurveState(currentCurveRawProp).editable;
                    string editableString = editable ? string.Empty : "(Not Overriding)\n";

                    // Selection info
                    var selection = m_CurveEditor.GetSelection();
                    var infoRect  = innerRect;
                    infoRect.x     += 5f;
                    infoRect.width  = 100f;
                    infoRect.height = 30f;

                    if (selection.curve != null && selection.keyframeIndex > -1)
                    {
                        var key = selection.keyframe.Value;
                        GUI.Label(infoRect, string.Format("{0}\n{1}", key.time.ToString("F3"), key.value.ToString("F3")), Styling.preLabel);
                    }
                    else
                    {
                        GUI.Label(infoRect, editableString, Styling.preLabel);
                    }
                }
            }
        }
		void ShowImportHeightmapGUI()
		{
			// Heightmap Mode
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField(Styles.HeightmapMode);
			ToggleHightmapMode();
			EditorGUILayout.EndHorizontal();
			
			// Heightmap selector			
			if (m_Settings.HeightmapMode == Heightmap.Mode.Global)
			{
				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField(Styles.SelectGlobalHeightmap);
				EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
				EditorGUILayout.LabelField(m_Settings.GlobalHeightmapPath);
				EditorGUI.BeginChangeCheck();
				if (GUILayout.Button("...", GUILayout.Width(25.0f)))
				{
					m_Settings.GlobalHeightmapPath = EditorUtility.OpenFilePanelWithFilters("Select raw image file...", "Assets", new string[] { "Raw Image File", "raw" });
				}
				if (EditorGUI.EndChangeCheck())
				{
					UpdateHeightmapInformation(m_Settings.GlobalHeightmapPath);				
				}				
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.EndHorizontal();
			}
			else if (m_Settings.HeightmapMode == Heightmap.Mode.Tiles)
			{
				int fileIndex = 0;
				int numFiles = m_Settings.TilesX * m_Settings.TilesZ;
				for (int i = 0; i < numFiles; i++)
				{
					m_Settings.TileHeightmapPaths.Add(string.Empty);
				}

				for (int x = 0; x < m_Settings.TilesZ; x++)
				{
					for (int y = 0; y < m_Settings.TilesX; y++)
					{
						EditorGUILayout.BeginHorizontal();
						string tileIndex = "X-" + x + " | " + "Y-" + y;
						EditorGUILayout.LabelField(tileIndex);

						EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
						EditorGUILayout.LabelField(m_Settings.TileHeightmapPaths[fileIndex]);
						EditorGUI.BeginChangeCheck();
						if (GUILayout.Button("...", GUILayout.Width(25.0f)))
						{
							m_Settings.TileHeightmapPaths[fileIndex] = EditorUtility.OpenFilePanelWithFilters("Select raw image file...", "Assets", new string[] { "Raw Image File", "raw" });
						}
						if (EditorGUI.EndChangeCheck())
						{
							UpdateHeightmapInformation(m_Settings.TileHeightmapPaths[fileIndex]);
						}
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.EndHorizontal();

						fileIndex++;
					}
				}
			}
			else if (m_Settings.HeightmapMode == Heightmap.Mode.Batch)
			{
				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField(Styles.SelectBatchHeightmapFolder);
				EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
				EditorGUILayout.LabelField(m_Settings.BatchHeightmapFolder);
				EditorGUI.BeginChangeCheck();
				if (GUILayout.Button("...", GUILayout.Width(25.0f)))
				{
					m_Settings.BatchHeightmapFolder = EditorUtility.OpenFolderPanel("Select heightmaps folder...", "", "");					
				}
				if (EditorGUI.EndChangeCheck() && Directory.Exists(m_Settings.BatchHeightmapFolder))
				{
					List<string> heightFiles = Directory.GetFiles(m_Settings.BatchHeightmapFolder, "*.raw").ToList();					
					m_Settings.TileHeightmapPaths = SortBatchHeightmapFiles(heightFiles);
					UpdateHeightmapInformation(m_Settings.TileHeightmapPaths[0]);
				}
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.EndHorizontal();
			}
			// Heightmap settings
			string infoMsg = "Heightmap(s) must use a single channel and be either 8 or 16 bit in RAW format. Resolution must be a power of two. \n";
			string sizeMsg = string.Format("Resolution: {0} x {1} \n", m_Settings.HeightmapWidth, m_Settings.HeightmapHeight);
			string tileMsg = string.Format("Number of Tiles: {0} x {1} \n", m_Settings.TilesX, m_Settings.TilesZ);
			string depthMsg = string.Format("Bit depth: {0}", ToolboxHelper.GetBitDepth(m_Settings.HeightmapDepth));
			string msg = infoMsg + sizeMsg + tileMsg + depthMsg;
			EditorGUILayout.HelpBox(msg, MessageType.Info);
			m_Settings.HeightmapResolution = EditorGUILayout.IntPopup("Tile Height Resolution", m_Settings.HeightmapResolution, HeightmapSizeNames, HeightmapSize);
			EditorGUILayout.BeginHorizontal();			
			EditorGUILayout.MinMaxSlider(Styles.HeightmapRemap, ref m_Settings.HeightmapRemapMin, ref m_Settings.HeightmapRemapMax, 0f, (float)m_Settings.TerrainHeight);
			EditorGUILayout.LabelField(Styles.HeightmapRemapMin, GUILayout.Width(40.0f));			
			m_Settings.HeightmapRemapMin = EditorGUILayout.FloatField(m_Settings.HeightmapRemapMin, GUILayout.Width(75.0f));
			EditorGUILayout.LabelField(Styles.HeightmapRemapMax, GUILayout.Width(40.0f));
			m_Settings.HeightmapRemapMax = EditorGUILayout.FloatField(m_Settings.HeightmapRemapMax, GUILayout.Width(75.0f));
			EditorGUILayout.EndHorizontal();
			m_Settings.FlipMode = (Heightmap.Flip)EditorGUILayout.EnumPopup(Styles.FlipAxis, m_Settings.FlipMode);
		}
Ejemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            if (sceneComponentGroup == null)
            {
                return;
            }

            if (MyGUI.Button("更新场景组件到最新的预制体"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateToPrefab(), 9999);
            }

            if (MyGUI.Button("更新组件排序"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateRendererShader(), 9999);
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateSortRenderer(), 9999);
            }

            if (GUILayout.Button("给所有渲染节点添加阴影"))
            {
                List <Renderer> renderers = sceneComponentGroup.gameObject.GetComponentList <Renderer>();
                foreach (var renderer in renderers)
                {
                    Light.ShadowRenderer shadowRenderer = renderer.gameObject.AddComponentUnique <Light.ShadowRenderer>();
                    //if (renderer.sharedMaterial.mainTexture != null)
                    //{
                    //    string texturePath = AssetDatabase.GetAssetPath(renderer.sharedMaterial.mainTexture);
                    //    string normalPath = texturePath.Insert(texturePath.LastIndexOf('.'), "_normal");
                    //    Debug.Log("texturePath =" + texturePath);
                    //    Debug.Log("normalPath =" + normalPath);
                    //    Texture2D normalTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(normalPath);
                    //    if (normalTexture != null)
                    //    {
                    //        shadowRenderer.ShadowTexture = normalTexture;
                    //    }
                    //}
                }
            }

            if (GUILayout.Button("保存所有场景预制体"))
            {
                List <SceneController> sceneControllers = sceneComponentGroup.gameObject.GetComponentList <SceneController>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_ApplySceneController(), 9999);
            }

            if (GUILayout.Button("更新组件到最新->保存场景"))
            {
                List <SceneController> sceneControllers = sceneComponentGroup.gameObject.GetComponentList <SceneController>();
                foreach (var sceneController in sceneControllers)
                {
                    List <SceneComponent> sceneComponentList = sceneController.gameObject.GetComponentList <SceneComponent>();
                    EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateToPrefab(), 9999);
                }

                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_InitSceneObjectControllers(), 9999);
                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_ApplySceneController(), 9999);
            }

            if (MyGUI.Button("设置场景地形组件的SortRenderer"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();

                sceneComponentList.Editor_UpdateSideWallRendererSort();
                //Editor_UpdatePlacementsRendererSort
            }
        }
        void GrabUpdate()
        {
            GUI.Label(steptitlerect, "STEP " + (currentPage + 1) + " - INTERACTIONS", "steptitle");

            GUI.Label(boldlabelrect, "Does the participant pick up anything?", "boldlabel");

            if (GUI.Button(new Rect(100, 150, 100, 30), "NO", UseGrabbableObjects == 0 ? "button_blueoutline" : "button_disabledtext"))
            {
                UseGrabbableObjects = 0;
                EditorPrefs.SetInt("useGrabbable", UseGrabbableObjects);
                UpdateActiveAssessments();
            }
            if (UseGrabbableObjects != 0)
            {
                GUI.Box(new Rect(100, 150, 100, 30), "", "box_sharp_alpha");
            }
            if (GUI.Button(new Rect(300, 150, 100, 30), "YES", UseGrabbableObjects == 1 ? "button_blueoutline" : "button_disabledtext"))
            {
                UseGrabbableObjects = 1;
                EditorPrefs.SetInt("useGrabbable", UseGrabbableObjects);
                UpdateActiveAssessments();
                RefreshGrabbables(true);
            }
            if (UseGrabbableObjects != 1)
            {
                GUI.Box(new Rect(300, 150, 100, 30), "", "box_sharp_alpha");
            }

            if (UseGrabbableObjects == 0)
            {
                GUI.Label(new Rect(30, 200, 440, 440), "The participant will not see any instructions about picking up objects", "normallabel");
            }
            if (UseGrabbableObjects == 1)
            {
                RefreshGrabbables();

                GUI.Label(new Rect(30, 200, 440, 440), "There will be a test asking the participant to pickup and examine a small cube", "normallabel");

                if (Grabbables.Count > 0)
                {
                    GUI.Label(new Rect(30, 260, 440, 440), "<b>Step 6:</b> These gameobject must to be configured to use your grabbing interaction:", "normallabel_actionable");

                    Rect innerScrollSize = new Rect(30, 0, 420, Grabbables.Count * 30);
                    dynamicScrollPosition = GUI.BeginScrollView(new Rect(30, 330, 440, 100), dynamicScrollPosition, innerScrollSize, false, true);

                    for (int i = 0; i < Grabbables.Count; i++)
                    {
                        if (Grabbables[i] == null) { continue; }
                        string background = (i % 2 == 0) ? "dynamicentry_even" : "dynamicentry_odd";
                        if (GUILayout.Button(Grabbables[i].gameObject.name, background))
                        {
                            Selection.activeGameObject = Grabbables[i].gameObject;
                        }
                    }

                    GUI.EndScrollView();

                    GUI.Box(new Rect(30, 330, 425, 100), "", "box_sharp_alpha");

                    if (GUI.Button(new Rect(180, 440, 140, 35), "Select All", "button"))
                    {
                        List<GameObject> grabGameObjects = new List<GameObject>();
                        for (int i = 0; i < Grabbables.Count; i++)
                        {
                            grabGameObjects.Add(Grabbables[i].gameObject);
                        }

                        Selection.objects = grabGameObjects.ToArray();
                        EditorGUIUtility.PingObject(grabGameObjects[0]);
                    }
                }
            }
        }
Ejemplo n.º 7
0
	public static bool ShaderKeywordRadio(string header, string[] keywords, GUIContent[] labels, List<string> list, ref bool update)
	{
		var index = 0;
		for(var i = 1; i < keywords.Length; i++)
		{
			if(list.Contains(keywords[i]))
			{
				index = i;
				break;
			}
		}
		
		EditorGUI.BeginChangeCheck();
		
		//Header and rect calculations
		var hasHeader = (!string.IsNullOrEmpty(header));
		var headerRect = GUILayoutUtility.GetRect(120f, 16f, GUILayout.ExpandWidth(false));
		var r = headerRect;
		if(hasHeader)
		{
			var helpRect = headerRect;
			helpRect.width = 16;
			headerRect.width -= 16;
			headerRect.x += 16;
			var helpTopic = header.ToLowerInvariant();
			helpTopic = char.ToUpperInvariant(helpTopic[0]) + helpTopic.Substring(1);
			TCP2_GUI.HelpButton(helpRect, helpTopic);
			GUI.Label(headerRect, header, index > 0 ? EditorStyles.boldLabel : EditorStyles.label);
			r.width = ScreenWidthRetina - headerRect.width - 34f;
			r.x += headerRect.width;
		}
		else
		{
			r.width = ScreenWidthRetina - 34f;
		}
		
		for(var i = 0; i < keywords.Length; i++)
		{
			var rI = r;
			rI.width /= keywords.Length;
			rI.x += i * rI.width;
			if(GUI.Toggle(rI, index == i,labels[i], (i == 0) ? EditorStyles.miniButtonLeft : (i == keywords.Length-1) ? EditorStyles.miniButtonRight : EditorStyles.miniButtonMid))
			{
				index = i;
			}
		}
		
		if(EditorGUI.EndChangeCheck())
		{
			//Remove all other keywords and add selected
			for(var i = 0; i < keywords.Length; i++)
			{
				if(list.Contains(keywords[i]))
					list.Remove(keywords[i]);
			}
			
			if(index > 0)
			{
				list.Add(keywords[index]);
			}
			
			update = true;
		}
		
		return (index > 0);
	}
Ejemplo n.º 8
0
    private void OnGUI()
    {
        GUILayout.Label("Nom de l'objet");
        nameObject = EditorGUILayout.TextArea(nameObject);
        if (nameObject == "")
        {
            nameObject = "J'ai laissé un nom vide , shame on me";
        }

        GUILayout.Label("Vitesse du bandeau (multiplicateur)");
        vitesseBandeauMultipler = Mathf.Max(0.001f,EditorGUILayout.FloatField("", vitesseBandeauMultipler));

        GUILayout.Label("Texte de victoire");
        textVictory = EditorGUILayout.TextArea(textVictory);

        GUILayout.Label("Texte de defaite");
        textDefeat= EditorGUILayout.TextArea(textDefeat);

        GUILayout.Label("Taille de police (Victoire)");
        textSizeVictory = Mathf.Max(10, EditorGUILayout.IntField(textSizeVictory));

        GUILayout.Label("Taille de police (Defaite)");
        textSizeDefeat = Mathf.Max(10, EditorGUILayout.IntField(textSizeDefeat));

        GUILayout.Label("Delai du bandeau (temps en secondes)");
        delaiBandeau = Mathf.Max(0.001f, EditorGUILayout.FloatField("", delaiBandeau));


        GUILayout.Label("Vitesse de transition (multiplicateur) ");
        vitesseInsertion = Mathf.Max(0.001f, EditorGUILayout.FloatField("", vitesseInsertion));

        GUILayout.Label("Quel animation ?");
        anim = (animHero)EditorGUILayout.EnumPopup(anim);

        sprt = (Sprite)EditorGUILayout.ObjectField("Quel sprite de fond ? ", sprt, typeof(Sprite), true);

        GUILayout.Label("IMPORTANT SINON CA MARCHE PAS ");
        model = (GameObject)EditorGUILayout.ObjectField("Modele de base", model, typeof(GameObject), true);

        GUILayout.Label("Code ? (une seule lettre et en majuscule)");
        code = GUILayout.TextField(code);

        GUILayout.Label("Position x ");
        x = EditorGUILayout.FloatField(x);

        GUILayout.Label("Position y");
        y = EditorGUILayout.FloatField(y);

        if (GUILayout.Button("Ajouter la frappe dans la liste actuelle"))
        {
            if (sequence >= sequences.Count)
            {
                sequences.Add(new SequenceInput());
            }

            KeyCode c = KeyCode.A;
            for(int i = 97; i <= 122; i++)
            {
                if (((KeyCode)i).ToString() == code.ToUpper())
                {
                    c = (KeyCode)i;
                }
            }

            DataInput sI = new DataInput(c, new Vector2(x, y));
            sequences[sequence].dI.Add(sI);
        }

        if (GUILayout.Button("Supprimer la derniere frappe de la liste actuelle"))
        {
            if (sequences[sequence].dI.Count > 0)
            {
                sequences[sequence].dI.RemoveAt(sequences[sequence].dI.Count - 1);
            }
        }

        if (GUILayout.Button("Liste de frappe suivante"))
        {
            sequence++;
            if (sequence >= sequences.Count)
            {
                sequences.Add(new SequenceInput());
            }
        }

        if (GUILayout.Button("Liste de frappe precedente"))
        {
            sequence = Mathf.Max(0, sequence - 1);
        }

        EditorGUILayout.LabelField("Index : " + sequence.ToString());
        foreach(SequenceInput sI in sequences)
        {
            foreach(string s in sI.ToStringAlt())
            {
                EditorGUILayout.LabelField(s);
            }
        }

        GUILayout.Label("Sons Optionnels (en prendra un par defaut si aucun n'est choisi)");
        clpFail = (AudioClip)EditorGUILayout.ObjectField("Mauvaise touche ", clpFail, typeof(AudioClip), true);
        clpSuccess = (AudioClip)EditorGUILayout.ObjectField("Bonne touche ", clpSuccess, typeof(AudioClip), true);
        clpSuccessScenette = (AudioClip)EditorGUILayout.ObjectField("Fin scenette positive ", clpSuccessScenette, typeof(AudioClip), true);


        if (GUILayout.Button("Créer"))
        {
            GameObject instance;
            instance = Instantiate(model);
            instance.name = nameObject;
            Scenette scn = instance.GetComponent<Scenette>();
            scn.sequencesToDo = new List<SequenceInput>(sequences);
            scn.speedBandeauMultipler = vitesseBandeauMultipler;
            scn.timeBeforeNext = delaiBandeau;
            scn.mutliplerSpeedEnter = vitesseInsertion;
            scn.failClic = clpFail;
            scn.successClic = clpSuccess;
            scn.successScenette = clpSuccessScenette;
            scn.animPourHero = anim;
            scn.backgroundSprite = sprt;
            scn.textSizeDefeat = textSizeDefeat;
            scn.textSizeVictory = textSizeVictory;
            scn.textVictory = textVictory;
            scn.textDefeat = textDefeat;
            scn.init();

            sequences = new List<SequenceInput>();
        }
    }
 /// <summary>
 /// Ends the column.
 /// </summary>
 public void EndColumn()
 {
     GUILayout.Space(this.spaceAfter);
     GUILayout.EndArea();
 }
Ejemplo n.º 10
0
        private void DisplayAboutGUI()
        {
            EditorGUILayout.Space();
            ShowCustomBillboardFoldout = GUILayoutHelper.Foldout(ShowCustomBillboardFoldout, new GUIContent("Custom"), () =>
            {
                var propCustomArchive = Prop("customArchive");
                var propCustomRecord  = Prop("customRecord");
                GUILayoutHelper.Indent(() =>
                {
                    propCustomArchive.intValue = EditorGUILayout.IntField(new GUIContent("Archive", "Set texture archive index (e.g. TEXTURE.210 is 210)"), propCustomArchive.intValue);
                    propCustomRecord.intValue  = EditorGUILayout.IntField(new GUIContent("Record", "Set texture record index (between 0-n)"), propCustomRecord.intValue);
                    if (GUILayout.Button("Set Billboard Texture"))
                    {
                        try
                        {
                            dfBillboard.SetMaterial(propCustomArchive.intValue, propCustomRecord.intValue);
                        }
                        catch (Exception ex)
                        {
                            Debug.Log("Failed to set custom billboard texture. Exception: " + ex.Message);
                        }
                    }
                    if (GUILayout.Button("Align To Surface"))
                    {
                        GameObjectHelper.AlignBillboardToGround(dfBillboard.gameObject, dfBillboard.Summary.Size, 4);
                    }
                });
            });

            EditorGUILayout.Space();
            ShowAboutBillboardFoldout = GUILayoutHelper.Foldout(ShowAboutBillboardFoldout, new GUIContent("About"), () =>
            {
                GUILayoutHelper.Indent(() =>
                {
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("File", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(TextureFile.IndexToFileName(dfBillboard.Summary.Archive), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("Index", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(dfBillboard.Summary.Record.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                    //GUILayoutHelper.Horizontal(() =>
                    //{
                    //    EditorGUILayout.LabelField("In Dungeon", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                    //    EditorGUILayout.SelectableLabel(dfBillboard.Summary.InDungeon.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    //});
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("Is Mobile", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(dfBillboard.Summary.IsMobile.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                    if (dfBillboard.Summary.IsMobile)
                    {
                        GUILayoutHelper.Horizontal(() =>
                        {
                            EditorGUILayout.LabelField("Flags", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                            EditorGUILayout.SelectableLabel(dfBillboard.Summary.Flags.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                        });
                        GUILayoutHelper.Horizontal(() =>
                        {
                            EditorGUILayout.LabelField("Type", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                            EditorGUILayout.SelectableLabel(dfBillboard.Summary.FixedEnemyType.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                        });
                    }
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("Is Atlased", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(dfBillboard.Summary.AtlasedMaterial.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("Is Animated", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(dfBillboard.Summary.AnimatedMaterial.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField("Current Frame", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                        EditorGUILayout.SelectableLabel(dfBillboard.Summary.CurrentFrame.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    });
                });
            });
        }
Ejemplo n.º 11
0
 // Draw
 public override void Draw()
 {
     GUILayout.Label("You can fly if you hold W, jump once and at the peak hold Shift in the air and look a bit upwards.");
 }
        void _drawGUI(int id)
        {
            UpArrow   = ResonantOrbitCalculator.Instance.upContent;
            DownArrow = ResonantOrbitCalculator.Instance.downContent;

            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));
            GUILayout.BeginVertical(GUILayout.Width(GRAPH_WIDTH + 10));
            // draw graph box
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[0]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[1]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Box(graph_texture);
            GUILayout.EndVertical();


            // draw side text
            GUILayout.BeginVertical(GUILayout.Width(wnd_width - GRAPH_WIDTH - 30));
            bool draw = false;

            if (firstTime)
            {
                firstTime = false;
                draw      = true;
            }
            // if (!PlanetSelection.isActive)
            {
                if (GUILayout.Button("Select Planet"))
                {
                    if (!PlanetSelection.isActive)
                    {
                        planetSelection = new GameObject().AddComponent <PlanetSelection>();
                    }
                    else
                    {
                        planetSelection.DestroyThis();
                    }
                }
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Number of satellites:", "Total number of satellites to arrange"));

            var newsNumSats = GUILayout.TextField(sNumSats);

            int butW = 19;

            if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
            {
                numSats++;
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
            {
                if (numSats > 1)
                {
                    numSats--;
                }
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (sNumSats != newsNumSats)
            {
                bValidNumSats = int.TryParse(newsNumSats, out iTmp);
                if (!bValidNumSats)
                {
                    sNumSats = numSats.ToString();
                }
                else
                {
                    numSats  = iTmp;
                    sNumSats = newsNumSats;
                    draw     = true;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Altitude:", "Orbital altitude"));
            GUI.SetNextControlName("altitude");
            string newsOrbitAltitude = GUILayout.TextField(sOrbitAltitude);

            if (newsOrbitAltitude != sOrbitAltitude)
            {
                bValidOrbitAltitude = double.TryParse(newsOrbitAltitude, out dTmp);
                if (bValidOrbitAltitude)
                {
                    selectedOrbit = SelectedOrbit.None;
                    orbitAltitude = dTmp;
                }
                sOrbitAltitude = orbitAltitude.ToString("F0");
                draw           = true;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.FlexibleSpace();

            GUI.SetNextControlName("periodHour");
            string h = GUILayout.TextField(OrbitCalc.periodHour, bh ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("h ");
            GUI.SetNextControlName("periodMin");
            string m = GUILayout.TextField(OrbitCalc.periodMin, bm ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("m ");
            GUI.SetNextControlName("periodSec");
            string s = GUILayout.TextField(OrbitCalc.periodSec, bs ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("s");
            OrbitCalc.periodEntry = GUI.GetNameOfFocusedControl() == "periodHour" ||
                                    GUI.GetNameOfFocusedControl() == "periodMin" ||
                                    GUI.GetNameOfFocusedControl() == "periodSec";


            bh = Double.TryParse(h, out dh);
            bm = Double.TryParse(m, out dm);
            bs = Double.TryParse(s, out ds);
            if (h != OrbitCalc.periodHour || m != OrbitCalc.periodMin || s != OrbitCalc.periodSec)
            {
                if (bh && bm && bs)
                {
                    double T = dh * 3600 + dm * 60 + ds;

                    orbitAltitude  = OrbitCalc.satelliteorbit.a(T);
                    sOrbitAltitude = orbitAltitude.ToString("F0");
                    draw           = true;
                }
                OrbitCalc.periodHour = h;
                OrbitCalc.periodMin  = m;
                OrbitCalc.periodSec  = s;
            }

            GUILayout.EndHorizontal();


            if (OrbitCalc.synchrorbit == "" || OrbitCalc.synchrorbit == "n/a")
            {
                GUI.enabled = false;
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(synchronousOrbit, new GUIContent("Synchronous orbit (" + OrbitCalc.synchrorbit + ")", "Set the altitude to have the satellites be in a geosynchronous orbit")))
            {
                selectedOrbit = SelectedOrbit.Synchronous;

                orbitAltitude         = OrbitCalc.body.geoAlt;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            if (OrbitCalc.losorbit == "" || OrbitCalc.losorbit == "n/a")
            {
                GUI.enabled = false;
            }

            if (GUILayout.Toggle(minLOSorbit, new GUIContent("Minimum LOS orbit (" + OrbitCalc.losorbit + ")", "Set the altitude to the minimum altitude possible to maintain a Line of Sight"),
                                 OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : toggleMinLOSNormal))
            {
                selectedOrbit         = SelectedOrbit.MinLOS;
                orbitAltitude         = OrbitCalc.minLOS;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            if (HighLogic.LoadedSceneIsFlight)
            {
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                bool warning = false;
                warning = (FlightGlobals.activeTarget.orbit.ApA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);

                if (GUILayout.Toggle(currentAp, new GUIContent("Current Ap (" + FlightGlobals.activeTarget.orbit.ApA.ToString("N0") + ")", "Set the altitude to the current vessel's Ap"),
                                     warning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Ap;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.ApA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                warning = (FlightGlobals.activeTarget.orbit.PeA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);
                if (FlightGlobals.activeTarget.orbit.PeA < 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Toggle(currentPe, new GUIContent("Current Pe (" + FlightGlobals.activeTarget.orbit.PeA.ToString("N0") + ")", "Set the altitude to the current vessel's Pe"),
                                     OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Pe;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.PeA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            bool newshowLOSlines = GUILayout.Toggle(showLOSlines, new GUIContent("Show LOS lines", "Show the Line Of Sight lines"));

            if (newshowLOSlines != showLOSlines)
            {
                draw         = true;
                showLOSlines = newshowLOSlines;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            bool newocclusionModifiers = GUILayout.Toggle(occlusionModifiers, new GUIContent("Occlusion modifiers", "Enable occlusion modifiers for vacuum and atmospheres"));

            GUILayout.EndHorizontal();
            if (occlusionModifiers)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Atm:", "Occlusion atmospheric modifier"));
                var newsAtmOcclusion = GUILayout.TextField(sAtmOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion < 1.1)
                    {
                        atmOcclusion += 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion > 0)
                    {
                        atmOcclusion -= 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (newsAtmOcclusion != sAtmOcclusion)
                {
                    bValidAtmOcclusion = double.TryParse(newsAtmOcclusion, out dTmp);
                    if (!bValidAtmOcclusion)
                    {
                        sAtmOcclusion = atmOcclusion.ToString("F2");
                    }
                    else
                    {
                        atmOcclusion  = dTmp;
                        sAtmOcclusion = newsAtmOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Vac:", "Occlusion vacuum modifier"));
                var newsVacOcclusion = GUILayout.TextField(sVacOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion < 1.1)
                    {
                        vacOcclusion += 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion > 0)
                    {
                        vacOcclusion -= 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (newsVacOcclusion != sVacOcclusion)
                {
                    bValidVacOcclusion = Double.TryParse(newsVacOcclusion, out dTmp);
                    if (!bValidVacOcclusion)
                    {
                        sVacOcclusion = vacOcclusion.ToString("F2");
                    }
                    else
                    {
                        vacOcclusion  = dTmp;
                        sVacOcclusion = newsVacOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
            }
            if (occlusionModifiers != newocclusionModifiers)
            {
                draw = true;
            }
            occlusionModifiers = newocclusionModifiers;

            GUILayout.Space(15);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Resonant Orbit", labelResonantOrbit);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            bool newflipOrbit = GUILayout.Toggle(flipOrbit, new GUIContent("Dive orbit", "Set Carrier orbit to be lower than target orbit"));

            if (newflipOrbit != flipOrbit)
            {
                draw      = true;
                flipOrbit = newflipOrbit;
            }
            GUILayout.EndHorizontal();

            if (draw)
            {
                UpdateGraph();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.Label(OrbitCalc.carrierT);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Apoapsis: ");
            GUILayout.Label(OrbitCalc.carrierAp);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Periapsis: ");

            if (OrbitCalc.carrierPe != "")
            {
                GUILayout.Label(OrbitCalc.carrierPe, OrbitCalc.carrierPeWarning ? warningLabel : normalLabel);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Injection Δv: ");
            GUILayout.Label(OrbitCalc.burnDV);
            GUILayout.EndHorizontal();

            Log.Info("LoadedSceneIsFlight: " + HighLogic.LoadedSceneIsFlight + ",    patchedConicsUnlocked: " + FlightGlobals.ActiveVessel.patchedConicsUnlocked());
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel.patchedConicsUnlocked())
            {
                GUILayout.FlexibleSpace();
                Log.Info("selectedOrbit: " + selectedOrbit);
                if (selectedOrbit == SelectedOrbit.Ap)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Ap", "Creates a maneuver node to put the current vessel into the resonant orbit")))
                    {
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtAP(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToAp;
                        var o = FlightGlobals.ActiveVessel.orbit;
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                if (selectedOrbit == SelectedOrbit.Pe)
                {
                    if (OrbitCalc.carrierPeWarning)
                    {
                        buttonStyle = buttonRed;
                    }
                    else
                    {
                        buttonStyle = GUI.skin.button;
                    }
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Pe", "Creates a maneuver node to put the current vessel into the resonant orbit"), buttonStyle))
                    {
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToPe;
                        var      o             = FlightGlobals.ActiveVessel.orbit;
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtPE(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                Log.Info("FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count(): " + FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count());
                if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count() > 0)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Clear all nodes"))
                    {
                        for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0; i--)
                        {
                            FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (selectedOrbit == SelectedOrbit.Ap || selectedOrbit == SelectedOrbit.Pe)
                    {
                        if (KACWrapper.APIReady)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Add alarms to KAC"))
                            {
                                double timeToOrbit = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT;
                                double period      = OrbitCalc.satelliteorbit.T;
                                String aID;
                                if (!ResonantOrbitCalculator.Instance.mucore.Available)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Maneuver, "Orbital Maneuver", timeToOrbit - 60);
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Put carrier craft into resonant orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                }
                                timeToOrbit += period;
                                for (int i = 0; i < numSats; i++)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Detachment # " + (i + 1).ToString(), timeToOrbit - 60);

                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Detach satellite # " + (i + 1) + " and circularize it's orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                    timeToOrbit += period;
                                }
                            }
                            GUILayout.EndHorizontal();
                        }

                        if (ResonantOrbitCalculator.Instance.mucore.Available)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Execute maneuver"))
                            {
                                ResonantOrbitCalculator.Instance.mucore.ExecuteNode();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Save Window", "Saves an image of the window to the Screenshots directory")))
            {
                saveScreen = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.Repaint && GUI.tooltip != tooltip)
            {
                tooltip = GUI.tooltip;
            }

            GUI.DragWindow();
        }
Ejemplo n.º 13
0
	private void jumpingScenePanel()
	{
		GUILayout.BeginHorizontal(new GUILayoutOption[0]);
		if (GUILayout.Button("(<)", new GUILayoutOption[0]))
		{
			Int32 num = EventEngine.FindArrayIDFromEventID((Int32)this.FF9.fldMapNo);
			num--;
			if (num < 0)
			{
				num = EventEngine.testEventIDs.GetUpperBound(0);
			}
			this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num];
			this.shutdownField();
			SoundLib.StopAllSounds();
			SceneDirector.FF9Wipe_FadeIn();
			SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true);
		}
		this.stringToEdit = GUILayout.TextField(this.stringToEdit, new GUILayoutOption[]
		{
			GUILayout.Width(90f)
		});
		if (GUILayout.Button("(>)", new GUILayoutOption[0]))
		{
			Int32 num2 = EventEngine.FindArrayIDFromEventID((Int32)this.FF9.fldMapNo);
			num2++;
			if (num2 > EventEngine.testEventIDs.GetUpperBound(0))
			{
				num2 = 0;
			}
			this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num2];
			this.shutdownField();
			SoundLib.StopAllSounds();
			SceneDirector.FF9Wipe_FadeIn();
			SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true);
		}
		if (GUILayout.Button("Jump", new GUILayoutOption[0]))
		{
			Int32 num3;
			Int32.TryParse(this.stringToEdit, out num3);
			num3 = EventEngine.FindArrayIDFromEventID(num3);
			if (num3 == -1)
			{
				this.stringToEdit = this.FF9.fldMapNo.ToString();
				return;
			}
			EBin eBin = PersistenSingleton<EventEngine>.Instance.eBin;
			Int32 num4 = 0;
			if (Int32.TryParse(this.scString, out num4))
			{
				eBin.setVarManually(EBin.SC_COUNTER_SVR, num4);
			}
			Int32 num5;
			if (Int32.TryParse(this.mapIDString, out num5))
			{
				eBin.setVarManually(EBin.MAP_INDEX_SVR, num5);
			}
			if (num3 < 0 || num3 > EventEngine.testEventIDs.GetUpperBound(0))
			{
				num3 = 0;
			}
			this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num3];
			this.shutdownField();
			SoundLib.StopAllSounds();
			SceneDirector.FF9Wipe_FadeIn();
			SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true);
			global::Debug.Log(String.Concat(new Object[]
			{
				"----- Jump to : ",
				this.FF9.fldMapNo,
				"/",
				num4,
				"/",
				num5,
				" -----"
			}));
		}
		GUILayout.FlexibleSpace();
	}
        public override void UpdateGUI()
        {
            base.UpdateGUI();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Power", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.Label(PluginHelper.getFormattedPowerString(CurrentPower) + "/" + PluginHelper.getFormattedPowerString(PowerRequirements), _value_label, GUILayout.Width(valueWidth));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Ammona Consumption Rate", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.Label(_ammonia_consumption_rate * GameConstants.HOUR_SECONDS + " mT/hour", _value_label, GUILayout.Width(valueWidth));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Uranium Tetraflouride Consumption Rate", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.Label(_uranium_tetraflouride_consumption_rate * GameConstants.HOUR_SECONDS + " mT/hour", _value_label, GUILayout.Width(valueWidth));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Uranium Nitride Production Rate", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.Label(_uranium_nitride_production_rate * GameConstants.HOUR_SECONDS + " mT/hour", _value_label, GUILayout.Width(valueWidth));
            GUILayout.EndHorizontal();
        }
        public override void OnInspectorGUI()
        {
            if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject)
            {
                LoadEditorUserSettings();
            }

            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                            hasRequiredFields = false;
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                    osState = "Connecting...";
                else if (Provider.onlineState == OnlineState.Offline)
                    osState = "Disconnected";
                else if (EditorUserSettings.WorkOffline)
                    osState = "Work Offline";

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                    Provider.UpdateSettings();
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons);
                if (newOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                    DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabRegularEnvironment = scene;
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabUIEnvironment = scene;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;
            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
                LightmapVisualization.showResolution = showRes;

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn
                || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
        /// <summary>
        /// Begins the table.
        /// </summary>
        public void BeginTable(int rowCount)
        {
            marginFix = marginFix ?? new GUIStyle();
            this.currColIndex = 0;
            this.rows = this.rows ?? new TableRow[0];

            if (this.rowCount != rowCount)
            {
                this.isDirty = 3;
                this.rowCount = rowCount;
            }

            this.RowIndexFrom = Math.Min(this.rowCount, this.RowIndexFrom);
            this.RowIndexTo = Math.Min(this.rowCount, this.RowIndexTo);

            if (this.rows.Length != rowCount)
            {
                Array.Resize(ref this.rows, rowCount);
            }

            if (Event.current.type == EventType.Layout)
            {
                for (int i = this.RowIndexFrom; i < this.RowIndexTo; i++)
                {
                    var row = rows[i];
                    if (row.tmpRowHeight > 0)
                    {
                        if (row.rowHeight != row.tmpRowHeight)
                        {
                            this.isDirty = 3;
                            row.rowHeight = row.tmpRowHeight;
                        }

                        row.tmpRowHeight = 0;
                        this.rows[i] = row;
                    }
                }

                if (this.isDirty > 0)
                {
                    this.UpdateSpaceAllocation();
                    GUIHelper.RequestRepaint();
                }
            }

            if (Event.current.type == EventType.Repaint)
            {
                var p = GUIUtility.GUIToScreenPoint(this.OuterRect.position);
                if (this.outerVisibleRect != p)
                {
                    this.outerVisibleRect = p;
                    this.isDirty = 3;
                }
            }

            var outerRect = EditorGUILayout.BeginVertical(this.GetOuterRectLayoutOptions());

            if (Event.current.type != EventType.Layout && outerRect.height > 1 || Event.current.type == EventType.Repaint)
            {
                if (this.OuterRect != outerRect)
                {
                    this.isDirty = 3;
                    this.OuterRect = outerRect;
                }
            }

            Vector2 newScrollPos;
            if (this.DrawScrollBars())
            {
                newScrollPos = GUILayout.BeginScrollView(this.ScrollPos, false, false, this.GetScrollViewOptions(true));
            }
            else
            {
                this.ignoreScrollView = Event.current.rawType == EventType.ScrollWheel;
                if (this.ignoreScrollView) GUIHelper.PushEventType(EventType.Ignore);
                newScrollPos = GUILayout.BeginScrollView(this.ScrollPos, false, false, GUIStyle.none, GUIStyle.none, this.GetScrollViewOptions(false));
                if (this.ignoreScrollView)
                {
                    GUIHelper.PopEventType();
                    this.isDirty = 3;
                }
            }

            if (newScrollPos != this.ScrollPos)
            {
                this.nextScrollPos = newScrollPos;
                this.isDirty = 3;
            }

            var rect = GUILayoutUtility.GetRect(0, this.totalHeight);
            if (Event.current.type != EventType.Layout && rect.width > 1)
            {
                this.innerVisibleRect = GUIClipInfo.VisibleRect;

                if (this.DrawScrollView)
                {
                    var scrollDelta = this.nextScrollPos - this.ScrollPos;
                    this.innerVisibleRect.y += scrollDelta.y;

                    if (scrollDelta != Vector2.zero)
                    {
                        this.isDirty = 3;
                    }
                }

                if (rect != this.contentRect)
                {
                    this.isDirty = 3;
                }

                if (this.contentRect != rect)
                {
                    this.isDirty = 3;
                }

                this.contentRect = rect;
            }

            if (this.isDirty > 0)
            {
                GUIHelper.RequestRepaint();

                if (Event.current.type == EventType.Repaint)
                {
                    this.isDirty--;
                }
            }

        }
        private void DoCacheServerSettings()
        {
            GUILayout.Space(10);
            GUILayout.Label(Content.cacheServer, EditorStyles.boldLabel);

            var overrideAddress = CacheServerPreferences.GetCommandLineRemoteAddressOverride();
            if (overrideAddress != null)
            {
                EditorGUILayout.HelpBox("Cache Server remote address forced via command line argument. To use the cache server address specified here please restart Unity without the -CacheServerIPAddress command line argument.", MessageType.Info, true);
            }

            int index = Mathf.Clamp((int)m_CacheServerMode.intValue, 0, cacheServerModePopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, cacheServerModePopupList, index, SetCacheServerMode);

            if (index != (int)CacheServerMode.Disabled)
            {
                bool isCacheServerEnabled = true;

                if (index == (int)CacheServerMode.AsPreferences)
                {
                    if (CacheServerPreferences.IsCacheServerV2Enabled)
                    {
                        var cacheServerIP = CacheServerPreferences.CachesServerV2Address;
                        cacheServerIP = string.IsNullOrEmpty(cacheServerIP) ? "Not set in preferences" : cacheServerIP;
                        EditorGUILayout.HelpBox(cacheServerIP, MessageType.None, false);
                    }
                    else
                    {
                        isCacheServerEnabled = false;
                        EditorGUILayout.HelpBox("Disabled", MessageType.None, false);
                    }
                }

                if (isCacheServerEnabled)
                {
                    m_CacheServerList.DoLayoutList();

                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                            m_CacheServerConnectionState = CacheServerConnectionState.Success;
                        else
                            m_CacheServerConnectionState = CacheServerConnectionState.Failure;
                    }

                    GUILayout.Space(25);

                    switch (m_CacheServerConnectionState)
                    {
                        case CacheServerConnectionState.Success:
                            EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, true);
                            break;

                        case CacheServerConnectionState.Failure:
                            EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, true);
                            break;

                        case CacheServerConnectionState.Unknown:
                            GUILayout.Space(44);
                            break;
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Ejemplo n.º 18
0
        void AddQuailtyToDatabase()
        {
            selectedItem.Name = EditorGUILayout.TextField("Name:", selectedItem.Name);
            if (selectedItem.Icon)
            {
                selectedTexture = selectedItem.Icon.texture;
            }
            else
            {
                selectedTexture = null;
            }

            if (GUILayout.Button(selectedTexture, GUILayout.Width(SPRITE_BUTTON_SIZE), GUILayout.Height(SPRITE_BUTTON_SIZE)))
            {
                int controlorID = EditorGUIUtility.GetControlID(FocusType.Passive);
                EditorGUIUtility.ShowObjectPicker <Sprite>(null, true, null, controlorID);
            }

            string commandName = Event.current.commandName;

            if (commandName == "ObjectSelectorUpdated")
            {
                selectedItem.Icon = (Sprite)EditorGUIUtility.GetObjectPickerObject();
                Repaint();
            }

            if (GUILayout.Button("Save"))
            {
                if (selectedItem == null)
                {
                    return;
                }
                if (selectedItem.Name == "")
                {
                    return;
                }

                qualityDatabase.Add(selectedItem);


                selectedItem = new ISQuality();
            }
        }
Ejemplo n.º 19
0
 /// <inheritdoc cref="BrightEditorUtility.DrawButton"/>
 protected bool DrawButton(string text, float width = 60, float height = 20)
 => DrawButton(text, GUILayout.Width(width), GUILayout.Height(height));
Ejemplo n.º 20
0
 public static void HorzLine()
 {
     GUILayout.Box(GUIContent.none, horzLine, GUILayout.ExpandWidth(true), GUILayout.Height(1f));
 }
        public override void OnInspectorGUI()
        {
            bool GUIEnabledValue = GUI.enabled;

            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                GUI.enabled = false;
            }

            if (m_Edited)
            {
                UpdateOrder(m_Edited);
                m_Edited = null;
            }

            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            {
                GUILayout.Label(Content.helpText, EditorStyles.helpBox);

                EditorGUILayout.Space();

                // Vertical that contains box and the toolbar below it
                Rect listRect = EditorGUILayout.BeginVertical();
                {
                    int        dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect);
                    MonoScript dropped     = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript;
                    if (dropped)
                    {
                        AddScriptToCustomOrder(dropped);
                    }

                    // Vertical that is used as a border around the scrollview
                    EditorGUILayout.BeginVertical(Styles.boxBackground);
                    {
                        // The scrollview itself
                        m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll);
                        {
                            // List
                            Rect r       = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true));
                            int  changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement);
                            if (changed >= 0)
                            {
                                // Give dragged item value in between neighbors
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                                // Update neighbors if needed
                                UpdateOrder(m_CustomTimeScripts[changed]);
                                // Neighbors may have been moved so there's more space around dragged item,
                                // so set order again to get possible rounding benefits
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                            }
                        } EditorGUILayout.EndScrollView();
                    } EditorGUILayout.EndVertical();

                    // The toolbar below the box
                    GUILayout.BeginHorizontal(Styles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        Rect       r2;
                        GUIContent content = Content.iconToolbarPlus;
                        r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown);
                        if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown))
                        {
                            ShowScriptPopup(r2);
                        }
                    } GUILayout.EndHorizontal();
                } GUILayout.EndVertical();

                ApplyRevertGUI();
            } GUILayout.EndVertical();

            GUI.enabled = GUIEnabledValue;
            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning);
            }

            GUILayout.FlexibleSpace();
        }
Ejemplo n.º 22
0
 public static void CenterLabel(string text)
 {
     GUILayout.Label(text, centerLabel);
 }
		public void OnGUI()
		{
			// scroll view of settings
			EditorGUIUtility.hierarchyMode = true;
			TerrainToolboxUtilities.DrawSeperatorLine();
			m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);

			// General Settings
			ShowGeneralGUI();

			// Import Heightmap
			TerrainToolboxUtilities.DrawSeperatorLine();
			bool importHeightmapToggle = m_Settings.EnableHeightmapImport;
			m_Settings.ShowHeightmapSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.ImportHeightmap, m_Settings.ShowHeightmapSettings, ref importHeightmapToggle, 0f);
			++EditorGUI.indentLevel;
			if (m_Settings.ShowHeightmapSettings)
			{
				EditorGUI.BeginDisabledGroup(!m_Settings.EnableHeightmapImport);
				ShowImportHeightmapGUI();
				EditorGUI.EndDisabledGroup();
			}
			m_Settings.EnableHeightmapImport = importHeightmapToggle;

			// Presets
			ShowPresetGUI();

			// Gizmos
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField(Styles.Gizmo, EditorStyles.boldLabel);
			if (GUILayout.Button(Styles.ShowGizmo))
			{
				ToolboxHelper.ShowGizmo();
			}
			if (GUILayout.Button(Styles.HideGizmo))
			{
				ToolboxHelper.HideGizmo();
			}
			EditorGUILayout.EndHorizontal();
			EditorGUILayout.Space();
			EditorGUILayout.EndScrollView();

			// Options
			ShowOptionsGUI();

			// Terrain info box
			--EditorGUI.indentLevel;
			string sizeMsg = string.Format("Terrain Size: {0}m x {1}m		", m_Settings.TerrainWidth, m_Settings.TerrainLength);
			string tileMsg = string.Format("Number of Tiles: {0} x {1} \n", m_Settings.TilesX, m_Settings.TilesZ);
			string heightMsg = string.Format("Terrain Height: {0}m		", m_Settings.TerrainHeight);			
			string tileSizeMsg = string.Format("Tile Size: {0} x {1} ", (m_Settings.TerrainWidth / m_Settings.TilesX), (m_Settings.TerrainLength / m_Settings.TilesZ));
			m_TerrainMessage = sizeMsg + tileMsg + heightMsg + tileSizeMsg;
			EditorGUILayout.HelpBox(m_TerrainMessage, MessageType.Info);

			// Create			
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button(Styles.CreateBtn, GUILayout.Height(40)))
			{
				if (!RunCreateValidations())
				{
					EditorUtility.DisplayDialog("Error", "There are incompatible terrain creation settings that need to be resolved to continue. Please check Console for details.", "OK");
				}
				else
				{
					if (m_Settings.HeightmapMode == Heightmap.Mode.Global && File.Exists(m_Settings.GlobalHeightmapPath))
					{
						m_Settings.UseGlobalHeightmap = true;
					}
					else
					{
						m_Settings.UseGlobalHeightmap = false;
					}

					Create();
				}				
			}
			EditorGUILayout.EndHorizontal();
		}
Ejemplo n.º 24
0
        public override void OnGUI(string searchContext)
        {
            EditorGUILayout.Space();
            var contentWidth = GUILayoutUtility.GetLastRect().width * 0.5f;

            EditorGUIUtility.labelWidth = contentWidth;
            EditorGUIUtility.fieldWidth = contentWidth;
            GUILayout.BeginVertical(Styles.Group);
            GUILayout.Label("Enabled Readers", EditorStyles.boldLabel);
            GUILayout.Label("You can disable file formats you don't use here");
            EditorGUILayout.Space();
            var changed = false;

            foreach (var importerOption in _importerOptions)
            {
                var value    = importerOption.PluginImporter.GetCompatibleWithAnyPlatform();
                var newValue = EditorGUILayout.Toggle(importerOption, value);
                if (newValue != value)
                {
                    importerOption.PluginImporter.SetCompatibleWithAnyPlatform(newValue);
                    changed = true;
                }
            }
            if (changed)
            {
                string usings     = null;
                string extensions = null;
                string findReader = null;
                foreach (var importerOption in _importerOptions)
                {
                    if (importerOption.PluginImporter.GetCompatibleWithAnyPlatform())
                    {
                        extensions += $"\n\t\t\t\textensions.AddRange({importerOption.text}.GetExtensions());";
                        usings     += $"using {importerOption.Namespace};\n";
                        findReader += $"\n\t\t\tif (((IList) {importerOption.text}.GetExtensions()).Contains(extension))\n\t\t\t{{\n\t\t\t\treturn new {importerOption.text}();\n\t\t\t}}";
                    }
                }
                var text      = string.Format(ReadersFileTemplate, usings, extensions, findReader);
                var textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(_readersFilePath);
                File.WriteAllText(_readersFilePath, text);
                EditorUtility.SetDirty(textAsset);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
            EditorGUILayout.Space();
            GUILayout.Label("Material Mappers", EditorStyles.boldLabel);
            GUILayout.Label("Select the Material Mappers according your project rendering pipeline");
            EditorGUILayout.Space();
            foreach (var materialMapperName in MaterialMapper.RegisteredMappers)
            {
                var value    = TriLibSettings.GetBool(materialMapperName);
                var newValue = EditorGUILayout.Toggle(materialMapperName, value);
                if (newValue != value)
                {
                    TriLibSettings.SetBool(materialMapperName, newValue);
                }
            }
            CheckMappers.Initialize();
            EditorGUILayout.Space();
            GUILayout.Label("Misc Options", EditorStyles.boldLabel);
            GUILayout.Label("Advanced Options");
            EditorGUILayout.Space();
            ShowConditionalToggle("Enable GLTF Draco Decompression (Experimental)", "TRILIB_DRACO");
            ShowConditionalToggle("Force synchronous loading", "TRILIB_FORCE_SYNC");
            ShowConditionalToggle("Change Thread names (Debug purposes only)", "TRILIB_USE_THREAD_NAMES");
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Version Notes"))
            {
                TriLibVersionNotes.ShowWindow();
            }
            if (GUILayout.Button("API Reference"))
            {
                Application.OpenURL("https://ricardoreis.net/trilib/trilib2/docs/");
            }
            if (GUILayout.Button("Support"))
            {
                Application.OpenURL("mailto:[email protected]");
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            base.OnGUI(searchContext);
        }
Ejemplo n.º 25
0
        void DoStandardModeGUI(bool hdr)
        {
            if (!hdr)
            {
                PropertyField(m_LdrLut);

                var lut = (target as ColorGrading).ldrLut.value;
                CheckLutImportSettings(lut);
            }

            if (hdr)
            {
                EditorGUILayout.Space();
                EditorUtilities.DrawHeaderLabel("Tonemapping");
                PropertyField(m_Tonemapper);

                if (m_Tonemapper.value.intValue == (int)Tonemapper.Custom)
                {
                    DrawCustomToneCurve();
                    PropertyField(m_ToneCurveToeStrength);
                    PropertyField(m_ToneCurveToeLength);
                    PropertyField(m_ToneCurveShoulderStrength);
                    PropertyField(m_ToneCurveShoulderLength);
                    PropertyField(m_ToneCurveShoulderAngle);
                    PropertyField(m_ToneCurveGamma);
                }
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("White Balance");

            PropertyField(m_Temperature);
            PropertyField(m_Tint);

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Tone");

            if (hdr)
            {
                PropertyField(m_PostExposure);
            }

            PropertyField(m_ColorFilter);
            PropertyField(m_HueShift);
            PropertyField(m_Saturation);

            if (!hdr)
            {
                PropertyField(m_Brightness);
            }

            PropertyField(m_Contrast);

            EditorGUILayout.Space();
            int currentChannel = GlobalSettings.currentChannelMixer;

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.PrefixLabel("Channel Mixer", GUIStyle.none, Styling.labelHeader);

                EditorGUI.BeginChangeCheck();
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayoutUtility.GetRect(9f, 18f, GUILayout.ExpandWidth(false)); // Dirty hack to do proper right column alignement
                        if (GUILayout.Toggle(currentChannel == 0, EditorUtilities.GetContent("Red|Red output channel."), EditorStyles.miniButtonLeft))
                        {
                            currentChannel = 0;
                        }
                        if (GUILayout.Toggle(currentChannel == 1, EditorUtilities.GetContent("Green|Green output channel."), EditorStyles.miniButtonMid))
                        {
                            currentChannel = 1;
                        }
                        if (GUILayout.Toggle(currentChannel == 2, EditorUtilities.GetContent("Blue|Blue output channel."), EditorStyles.miniButtonRight))
                        {
                            currentChannel = 2;
                        }
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    GUI.FocusControl(null);
                }
            }

            GlobalSettings.currentChannelMixer = currentChannel;

            if (currentChannel == 0)
            {
                PropertyField(m_MixerRedOutRedIn);
                PropertyField(m_MixerRedOutGreenIn);
                PropertyField(m_MixerRedOutBlueIn);
            }
            else if (currentChannel == 1)
            {
                PropertyField(m_MixerGreenOutRedIn);
                PropertyField(m_MixerGreenOutGreenIn);
                PropertyField(m_MixerGreenOutBlueIn);
            }
            else
            {
                PropertyField(m_MixerBlueOutRedIn);
                PropertyField(m_MixerBlueOutGreenIn);
                PropertyField(m_MixerBlueOutBlueIn);
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Trackballs");

            using (new EditorGUILayout.HorizontalScope())
            {
                PropertyField(m_Lift);
                GUILayout.Space(4f);
                PropertyField(m_Gamma);
                GUILayout.Space(4f);
                PropertyField(m_Gain);
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Grading Curves");

            DoCurvesGUI(hdr);
        }
Ejemplo n.º 26
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // var serializedObject = property.serializedObject;

            var temp = (BindableObject)property.objectReferenceValue;
            if (temp == null) return;

            var tp = temp.GetType();
            var prop = tp.GetProperty("target", BindingFlags.Public | BindingFlags.Instance);
            if (prop != null)
            {
                if (prop.GetValue(temp) == null)
                    prop.SetValue(temp, temp.GetComponent(prop.PropertyType));
            }

            var rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(34));
            //selected
            bool isExpanded = property.isExpanded;

            var rect1 = rect;
            float w = rect.width;
            EditorGUI.HelpBox(rect, "", MessageType.None);
            rect1.height -= BindableObjectStyle.kExtraSpacing * 2;
            rect1.y += BindableObjectStyle.kExtraSpacing;

            rect1.x += BindableObjectStyle.kExtraSpacing;
            rect1.width = 24f;
            EditorGUI.LabelField(rect1, GetIndex(property.propertyPath)); //Debug.LogFormat("prop={0}", property.propertyPath);

            rect1.x += BindableObjectStyle.kExtraSpacing*2;
            rect1.width = 26f;
            isExpanded = EditorGUI.Toggle(rect1, isExpanded);
            property.isExpanded = isExpanded;
            rect1.x = rect1.xMax + BindableObjectStyle.kExtraSpacing;
            rect1.width = w * .35f;


            CustomBinder customer = null;
            if (temp is CustomBinder)
            {
                customer = (CustomBinder)temp;
                EditorGUI.ObjectField(rect1, customer.target, typeof(Component), false); //显示绑定对象
            }
            else
                EditorGUI.ObjectField(rect1, temp, typeof(BindableObject), false); //显示绑定对象

            rect1.x = rect1.xMax + BindableObjectStyle.kExtraSpacing;
            rect1.width = w * .35f;


            if (customer != null)
            {
                propertyName = BindalbeObjectUtilty.PopupComponentsProperty(rect1, customer.target, propertyName); //绑定属性
            }
            else
                propertyName = BindalbeObjectUtilty.PopupComponentsProperty(rect1, temp, propertyName); //绑定属性


            rect1.x = rect1.xMax + BindableObjectStyle.kExtraSpacing;
            rect1.width = w * .2f - BindableObjectStyle.kExtraSpacing * 4;
            if (GUI.Button(rect1, "add"))
            {
                if (string.Equals(propertyName, BindableObjectStyle.FIRST_PROPERTY_NAME))
                {
                    Debug.LogWarningFormat("please choose a property to binding");
                }
                else
                {
                    Binding expression = new Binding();
                    expression.propertyName = propertyName;
                    temp.AddBinding(expression);
                    property.isExpanded = true;
                }

            }
            EditorGUILayout.Separator();
            EditorGUILayout.EndHorizontal();

            if (isExpanded)
            {
                //显示列表
                if (temSerialziedObject == null || temSerialziedObject.targetObject != temp)
                    temSerialziedObject = new SerializedObject(temp);
                {
                    var bindings = temSerialziedObject.FindProperty("bindings");
                    // serializedObject.targetObject
                    if (bindings != null && bindings.isArray)
                    {
                        selectedList.Clear();
                        temSerialziedObject.Update();

                        var len = bindings.arraySize;
                        SerializedProperty bindingProperty;
                        for (int i = 0; i < len; i++)
                        {
                            bindingProperty = bindings.GetArrayElementAtIndex(i);
                            EditorGUILayout.PropertyField(bindingProperty, true);
                            if (bindingProperty.isExpanded)
                            {
                                selectedList.Add(i);
                            }
                        }


                        rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(20));
                        rect.y += BindableObjectStyle.kExtraSpacing;

                        float width;
                        //删除数据
                        if (selectedList.Count > 0)
                        {
                            width = 102;
                            rect.x = rect.xMax - width;
                            rect.width = width;
                            if (GUI.Button(rect, "del property " + selectedList.Count))
                            {
                                selectedList.Sort((int a, int b) =>
                                {
                                    if (a < b) return 1;
                                    else if (a == b) return 0;
                                    else
                                        return -1;
                                });

                                foreach (var i in selectedList)
                                {
                                    bindings.DeleteArrayElementAtIndex(i);
                                }
                            }
                            EditorGUILayout.Separator();
                        }
                        else
                        {
                            string DELETE_TIPS = BindableObjectStyle.PROPPERTY_CHOOSE_TIPS;
                            width = DELETE_TIPS.Length * BindableObjectStyle.kExtraSpacing;
                            rect.x = rect.xMax - width;
                            rect.width = width;
                            GUI.Box(rect, DELETE_TIPS);
                        }

                        temSerialziedObject.ApplyModifiedProperties();

                        EditorGUILayout.Separator();
                        EditorGUILayout.EndHorizontal();
                    }
                }

            }
            else
            {
                // GUILayout.Box("click checkbox  to see detail or delete!");
            }
        }
Ejemplo n.º 27
0
 void CurveOverrideToggle(SerializedProperty overrideProp)
 {
     overrideProp.boolValue = GUILayout.Toggle(overrideProp.boolValue, EditorUtilities.GetContent("Override"), EditorStyles.toolbarButton);
 }
Ejemplo n.º 28
0
 void OnGUI()
 {
     m_Position = GUILayout.BeginScrollView(m_Position);
     GUILayout.Label(m_InGameLog);
     GUILayout.EndScrollView();
 }
Ejemplo n.º 29
0
        void DrawBackgroundTexture(Rect rect, int pass)
        {
            if (s_MaterialGrid == null)
            {
                s_MaterialGrid = new Material(Shader.Find("Hidden/PostProcessing/Editor/CurveGrid"))
                {
                    hideFlags = HideFlags.HideAndDontSave
                }
            }
            ;

            float scale = EditorGUIUtility.pixelsPerPoint;

        #if UNITY_2018_1_OR_NEWER
            const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.sRGB;
        #else
            const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.Linear;
        #endif

            var oldRt = RenderTexture.active;
            var rt    = RenderTexture.GetTemporary(Mathf.CeilToInt(rect.width * scale), Mathf.CeilToInt(rect.height * scale), 0, RenderTextureFormat.ARGB32, kReadWrite);
            s_MaterialGrid.SetFloat("_DisabledState", GUI.enabled ? 1f : 0.5f);
            s_MaterialGrid.SetFloat("_PixelScaling", EditorGUIUtility.pixelsPerPoint);

            Graphics.Blit(null, rt, s_MaterialGrid, pass);
            RenderTexture.active = oldRt;

            GUI.DrawTexture(rect, rt);
            RenderTexture.ReleaseTemporary(rt);
        }

        int DoCurveSelectionPopup(int id, bool hdr)
        {
            GUILayout.Label(s_Curves[id], EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));

            var lastRect = GUILayoutUtility.GetLastRect();
            var e        = Event.current;

            if (e.type == EventType.MouseDown && e.button == 0 && lastRect.Contains(e.mousePosition))
            {
                var menu = new GenericMenu();

                for (int i = 0; i < s_Curves.Length; i++)
                {
                    if (i == 4)
                    {
                        menu.AddSeparator("");
                    }

                    if (hdr && i < 4)
                    {
                        menu.AddDisabledItem(s_Curves[i]);
                    }
                    else
                    {
                        int current = i; // Capture local for closure
                        menu.AddItem(s_Curves[i], current == id, () => GlobalSettings.currentCurve = current);
                    }
                }

                menu.DropDown(new Rect(lastRect.xMin, lastRect.yMax, 1f, 1f));
            }

            return(id);
        }
    }
Ejemplo n.º 30
0
 public override GUILayoutOption[] WindowOptions()
 {
     return(new GUILayoutOption[] { GUILayout.Width(200), GUILayout.Height(50) });
 }