void FooterDraw(Rect fRect)
    {
        fRect.x      += EditorGUI.indentLevel + 1;
        fRect.y      -= 3;
        fRect.height += 4;
        GUI.enabled   = canRemove;
        GUI.Box(new Rect(fRect.x + 2, fRect.y, 38F, fRect.height), GUIContent.none, EditorStyles.toolbarButton);

        //Point Count
        EditorGUI.BeginChangeCheck();
        int value = EditorGUI.DelayedIntField(new Rect(fRect.x + 2, fRect.y, 38F, fRect.height), controlPointList.count);

        if (EditorGUI.EndChangeCheck())
        {
            value = Mathf.Max(value, 4);
            if (controlPointList.count > value)
            {
                while (controlPointList.count > value)
                {
                    controlPointList.serializedProperty.DeleteArrayElementAtIndex(controlPointList.count - 1);
                }
            }
            else if (controlPointList.count < value)
            {
                while (controlPointList.count < value)
                {
                    controlPointList.serializedProperty.InsertArrayElementAtIndex(controlPointList.count);
                }
            }
        }
        GUI.enabled = true;
        if (clipboardPoint == null)
        {
            GUI.enabled = false;
        }
        if (GUI.Button(new Rect(fRect.x + 40F, fRect.y, fRect.width - 100F, fRect.height), new GUIContent("Paste as new", ((clipboardPoint != null) ? "Paste " + clipboardPoint.ToString() : "Clipboard empty")), EditorStyles.toolbarButton))
        {
            if (clipboardPoint != null)
            {
                int i = controlPointList.count;
                controlPointList.serializedProperty.InsertArrayElementAtIndex(i);
                controlPointList.serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative("position").vector3Value = clipboardPoint.GetValueOrDefault();
            }
        }
        GUI.enabled = true;
        if (GUI.Button(new Rect(fRect.x + fRect.width - 64F, fRect.y, 30F, fRect.height), EditorGUIUtility.IconContent("Toolbar Plus", "Add to list"), EditorStyles.toolbarButton))
        {
            ReorderableList.defaultBehaviours.DoAddButton(controlPointList);
        }
        GUI.enabled = canRemove;
        if (GUI.Button(new Rect(fRect.x + fRect.width - 34F, fRect.y, 30F, fRect.height), EditorGUIUtility.IconContent("Toolbar Minus", "Remove element from list"), EditorStyles.toolbarButton))
        {
            ReorderableList.defaultBehaviours.DoRemoveButton(controlPointList);
        }
        GUI.enabled = true;
    }
Exemple #2
0
        public static void DrawItemInList(Rect rect, SerializedCompositionLayer serialized, RenderTexture thumbnail, float aspectRatio, bool isAlphaEnbaled)
        {
            bool isCameraStack = serialized.outTarget.intValue == (int)CompositorLayer.OutputTarget.CameraStack;

            // Compute the desired indentation
            {
                const float listBorder = 2.0f;
                rect.x      = isCameraStack ? rect.x + CompositorStyle.k_ListItemStackPading + listBorder : rect.x + listBorder;
                rect.width  = isCameraStack ? rect.width - CompositorStyle.k_ListItemStackPading - listBorder : rect.width - listBorder;
                rect.y     += CompositorStyle.k_ListItemPading;
                rect.height = EditorGUIUtility.singleLineHeight;
            }

            if (thumbnail)
            {
                Rect newRect = rect;
                newRect.width = EditorGUIUtility.singleLineHeight;
                EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none);
                rect.x += CompositorStyle.k_CheckboxSpacing;
                Rect previewRect = rect;
                previewRect.width  = CompositorStyle.k_ThumbnailSize * aspectRatio;
                previewRect.height = CompositorStyle.k_ThumbnailSize;
                EditorGUI.DrawPreviewTexture(previewRect, thumbnail);
                previewRect.x += previewRect.width + CompositorStyle.k_ThumbnailDivider;
                rect.x        += previewRect.width + CompositorStyle.k_ThumbnailSpacing;
                rect.width    -= previewRect.width + CompositorStyle.k_ThumbnailSpacing;

                if (isAlphaEnbaled &&
                    (thumbnail.format == RenderTextureFormat.ARGBHalf ||
                     thumbnail.format == RenderTextureFormat.ARGBFloat ||
                     thumbnail.format == RenderTextureFormat.ARGB64))
                {
                    EditorGUI.DrawTextureAlpha(previewRect, thumbnail);
                    rect.x     += previewRect.width + CompositorStyle.k_ThumbnailSpacing;
                    rect.width -= previewRect.width + CompositorStyle.k_ThumbnailSpacing;
                }

                rect.y += CompositorStyle.k_LabelVerticalOffset;
                EditorGUI.LabelField(rect, serialized.layerName.stringValue);
            }
            else
            {
                Rect newRect = rect;
                newRect.width = EditorGUIUtility.singleLineHeight;
                EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none);
                newRect.x += CompositorStyle.k_CheckboxSpacing;
                if (isCameraStack)
                {
                    Rect iconRect = newRect;
                    iconRect.width  = CompositorStyle.k_IconSize;
                    iconRect.height = CompositorStyle.k_IconSize;
                    iconRect.y     -= CompositorStyle.k_IconVerticalOffset;
                    switch (serialized.inputLayerType.enumValueIndex)
                    {
                    case (int)CompositorLayer.LayerType.Camera:
                        GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(Camera)).image);
                        break;

                    case (int)CompositorLayer.LayerType.Video:
                        GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(UnityEngine.Video.VideoClip)).image);
                        break;

                    case (int)CompositorLayer.LayerType.Image:
                        GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(Texture)).image);
                        break;

                    default:
                        // This will happen if someone adds a new layer type and does not update this switch statement
                        Debug.Log("Unknown layer type: Please add code here to draw this type of layer.");
                        break;
                    }
                    newRect.x += CompositorStyle.k_IconSize + CompositorStyle.k_IconSpacing;
                }

                newRect.width = rect.width - newRect.x;
                EditorGUI.LabelField(newRect, serialized.layerName.stringValue);
            }
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            serializedObject.Update();

            var bs = NavMesh.GetSettingsByID(m_AgentTypeID.intValue);

            if (bs.agentTypeID != -1)
            {
                // Draw image
                const float diagramHeight    = 80.0f;
                Rect        agentDiagramRect = EditorGUILayout.GetControlRect(false, diagramHeight);
                NavMeshEditorHelpers.DrawAgentDiagram(agentDiagramRect, bs.agentRadius, bs.agentHeight, bs.agentClimb, bs.agentSlope);
            }
            NavMeshComponentsGUIUtility.AgentTypePopup("Agent Type", m_AgentTypeID);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_CollectObjects);
            if ((CollectObjects)m_CollectObjects.enumValueIndex == CollectObjects.Volume)
            {
                EditorGUI.indentLevel++;

                EditMode.DoEditModeInspectorModeButton(EditMode.SceneViewEditMode.Collider, "Edit Volume",
                                                       EditorGUIUtility.IconContent("EditCollider"), GetBounds, this);
                EditorGUILayout.PropertyField(m_Size);
                EditorGUILayout.PropertyField(m_Center);

                EditorGUI.indentLevel--;
            }
            else
            {
                if (editingCollider)
                {
                    EditMode.QuitEditMode();
                }
            }

            EditorGUILayout.PropertyField(m_LayerMask, s_Styles.m_LayerMask);
            EditorGUILayout.PropertyField(m_UseGeometry);

            EditorGUILayout.Space();

            EditorGUILayout.Space();

            m_OverrideVoxelSize.isExpanded = EditorGUILayout.Foldout(m_OverrideVoxelSize.isExpanded, "Advanced");
            if (m_OverrideVoxelSize.isExpanded)
            {
                EditorGUI.indentLevel++;

                NavMeshComponentsGUIUtility.AreaPopup("Default Area", m_DefaultArea);

                // Override voxel size.
                EditorGUILayout.PropertyField(m_OverrideVoxelSize);

                using (new EditorGUI.DisabledScope(!m_OverrideVoxelSize.boolValue || m_OverrideVoxelSize.hasMultipleDifferentValues)) {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(m_VoxelSize);

                    if (!m_OverrideVoxelSize.hasMultipleDifferentValues)
                    {
                        if (!m_AgentTypeID.hasMultipleDifferentValues)
                        {
                            float voxelsPerRadius = m_VoxelSize.floatValue > 0.0f ? (bs.agentRadius / m_VoxelSize.floatValue) : 0.0f;
                            EditorGUILayout.LabelField(" ", voxelsPerRadius.ToString("0.00") + " voxels per agent radius", EditorStyles.miniLabel);
                        }
                        if (m_OverrideVoxelSize.boolValue)
                        {
                            EditorGUILayout.HelpBox("Voxel size controls how accurately the navigation mesh is generated from the level geometry. A good voxel size is 2-4 voxels per agent radius. Making voxel size smaller will increase build time.", MessageType.None);
                        }
                    }
                    EditorGUI.indentLevel--;
                }

                // Override tile size
                EditorGUILayout.PropertyField(m_OverrideTileSize);

                using (new EditorGUI.DisabledScope(!m_OverrideTileSize.boolValue || m_OverrideTileSize.hasMultipleDifferentValues)) {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(m_TileSize);

                    if (!m_TileSize.hasMultipleDifferentValues && !m_VoxelSize.hasMultipleDifferentValues)
                    {
                        float tileWorldSize = m_TileSize.intValue * m_VoxelSize.floatValue;
                        EditorGUILayout.LabelField(" ", tileWorldSize.ToString("0.00") + " world units", EditorStyles.miniLabel);
                    }

                    if (!m_OverrideTileSize.hasMultipleDifferentValues)
                    {
                        if (m_OverrideTileSize.boolValue)
                        {
                            EditorGUILayout.HelpBox("Tile size controls the how local the changes to the world are (rebuild or carve). Small tile size allows more local changes, while potentially generating more data in overal.", MessageType.None);
                        }
                    }
                    EditorGUI.indentLevel--;
                }

                // Height mesh
                using (new EditorGUI.DisabledScope(true)) {
                    EditorGUILayout.PropertyField(m_BuildHeightMesh);
                }

                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();

            var hadError        = false;
            var multipleTargets = targets.Length > 1;

            foreach (NavMeshSurface navSurface in targets)
            {
                var settings = navSurface.GetBuildSettings();
                // Calculating bounds is potentially expensive when unbounded - so here we just use the center/size.
                // It means the validation is not checking vertical voxel limit correctly when the surface is set to something else than "in volume".
                var bounds = new Bounds(Vector3.zero, Vector3.zero);
                if (navSurface.collectObjects == CollectObjects.Volume)
                {
                    bounds = new Bounds(navSurface.center, navSurface.size);
                }

                var errors = settings.ValidationReport(bounds);
                if (errors.Length > 0)
                {
                    if (multipleTargets)
                    {
                        EditorGUILayout.LabelField(navSurface.name);
                    }
                    foreach (var err in errors)
                    {
                        EditorGUILayout.HelpBox(err, MessageType.Warning);
                    }
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(EditorGUIUtility.labelWidth);
                    if (GUILayout.Button("Open Agent Settings...", EditorStyles.miniButton))
                    {
                        NavMeshEditorHelpers.OpenAgentSettings(navSurface.agentTypeID);
                    }
                    GUILayout.EndHorizontal();
                    hadError = true;
                }
            }

            if (hadError)
            {
                EditorGUILayout.Space();
            }

            if (!Application.isPlaying)
            {
                using (new EditorGUI.DisabledScope(m_AgentTypeID.intValue == -1)) {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(EditorGUIUtility.labelWidth);
                    if (GUILayout.Button("Clear"))
                    {
                        foreach (NavMeshSurface s in targets)
                        {
                            ClearSurface(s);
                        }
                        SceneView.RepaintAll();
                    }

                    if (GUILayout.Button("Bake"))
                    {
                        // Remove first to avoid double registration of the callback
                        EditorApplication.update -= UpdateAsyncBuildOperations;
                        EditorApplication.update += UpdateAsyncBuildOperations;

                        foreach (NavMeshSurface surf in targets)
                        {
                            var oper = new AsyncBakeOperation();

                            oper.bakeData      = InitializeBakeData(surf);
                            oper.bakeOperation = surf.UpdateNavMesh(oper.bakeData);
                            oper.surface       = surf;

                            s_BakeOperations.Add(oper);
                        }
                    }

                    GUILayout.EndHorizontal();
                }
            }

            // Show progress for the selected targets
            for (int i = s_BakeOperations.Count - 1; i >= 0; --i)
            {
                if (!targets.Contains(s_BakeOperations[i].surface))
                {
                    continue;
                }

                var oper = s_BakeOperations[i].bakeOperation;
                if (oper == null)
                {
                    continue;
                }

                var p = oper.progress;
                if (oper.isDone)
                {
                    SceneView.RepaintAll();
                    continue;
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Cancel", EditorStyles.miniButton))
                {
                    var bakeData = s_BakeOperations[i].bakeData;
                    UnityEngine.AI.NavMeshBuilder.Cancel(bakeData);
                    s_BakeOperations.RemoveAt(i);
                }

                EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(), p, "Baking: " + (int)(100 * p) + "%");
                if (p <= 1)
                {
                    Repaint();
                }

                GUILayout.EndHorizontal();
            }
        }
Exemple #4
0
 public static GUIStyle GetEditorStyle(string style)
 {
     return(EditorGUIUtility.GetBuiltinSkin(EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector).GetStyle(style));
 }
 private static Texture2D LoadPlatformIcon(string iconId)
 {
     return(EditorGUIUtility.IconContent(string.Format("BuildSettings.{0}.Small", iconId)).image as Texture2D);
 }
	// Override the OnInspectorGUI and present these EditorGUI gadgets instead of the default ones
    public override void OnInspectorGUI() {
		// Update the serialized object
		myTarget.Update();		
		
		// Present inspector GUI gadgets/objects and modify AsteroidField.cs instances with configured values
		maxAsteroids.intValue = EditorGUILayout.IntSlider("Number of Asteroids", maxAsteroids.intValue, _displayMinAsteroidCount, _displayMaxAsteroidCount);
		if (maxAsteroids.intValue > _warningHighAsteroidCount) {
			EditorGUILayout.LabelField("Warning! Many asteroids may impact performance! Consider smaller range and fewer asteroids instead.", EditorStyles.wordWrappedMiniLabel);
		}
		range.floatValue = EditorGUILayout.Slider("Range", range.floatValue, _displayMinRange, _displayMaxRange);	
		if (range.floatValue > Camera.main.farClipPlane) {
			EditorGUILayout.LabelField("Warning! Main camera clipping plane is closer than asteroid range.", EditorStyles.wordWrappedMiniLabel);
		}
		EditorGUILayout.LabelField("Range is distance from the center to the edge of the asteroid field. If the transform of the AsteroidField moves, asteroids " +
			"that become out of range will respawn to a new location at spawn distance of range.", EditorStyles.wordWrappedMiniLabel);		
		respawnIfOutOfRange.boolValue = EditorGUILayout.Toggle("Respawn if Out of Range", respawnIfOutOfRange.boolValue);
		EditorGUILayout.LabelField("Note: Respawn if out of range must be enabled for endless/infinite asteroid fields", EditorStyles.wordWrappedMiniLabel);
		respawnDestroyedAsteroids.boolValue = EditorGUILayout.Toggle("Respawn if Destroyed", respawnDestroyedAsteroids.boolValue);
		EditorGUILayout.Separator();
		distanceSpawn.floatValue = EditorGUILayout.Slider("Spawn at % of Range", distanceSpawn.floatValue, 0.0f, 1.0f);		
		EditorGUILayout.Separator();
		
		EditorGUILayout.LabelField("Asteroid Scale (Min/Max Range)", EditorStyles.boldLabel);
		_minScale = minAsteroidScale.floatValue;
		_maxScale = maxAsteroidScale.floatValue;
		GUIContent _scaleContent = new GUIContent( string.Format( "Min:{0:F1}, Max:{1:F1}", _minScale , _maxScale ) );
		EditorGUILayout.MinMaxSlider(_scaleContent, ref _minScale, ref _maxScale, 0.1f, 1.0f);
		minAsteroidScale.floatValue = _minScale;
		maxAsteroidScale.floatValue = _maxScale;
		scaleMultiplier.floatValue = EditorGUILayout.FloatField( "Scale Multiplier", scaleMultiplier.floatValue);		
		EditorGUILayout.Separator();
		
		// Rigidbody or non-rigidbody Asteroids
		isRigidbody.boolValue = EditorGUILayout.Toggle("Is Rigidbody", isRigidbody.boolValue);		
		if (isRigidbody.boolValue) {
			mass.floatValue = EditorGUILayout.FloatField("Mass (scales with size)", mass.floatValue);
			EditorGUILayout.LabelField("Asteroid Angular Velocity (Min/Max Range)", EditorStyles.boldLabel);		
			_minAngularVelocity = minAsteroidAngularVelocity.floatValue;
			_maxAngularVelocity = maxAsteroidAngularVelocity.floatValue;
			GUIContent _rotationContent = new GUIContent( string.Format( "Min:{0:F1}, Max:{1:F1}", _minAngularVelocity , _maxAngularVelocity ) );
			EditorGUILayout.MinMaxSlider(_rotationContent, ref _minAngularVelocity, ref _maxAngularVelocity, 0.0f, 1.0f);
			minAsteroidAngularVelocity.floatValue = _minAngularVelocity;
			maxAsteroidAngularVelocity.floatValue = _maxAngularVelocity;		
			angularVelocityMultiplier.floatValue = EditorGUILayout.FloatField( "Rotation Speed Multiplier", angularVelocityMultiplier.floatValue);
			
			EditorGUILayout.LabelField("Asteroid Velocity (Min/Max Range)", EditorStyles.boldLabel);			
			_minVelocity = minAsteroidVelocity.floatValue;
			_maxVelocity = maxAsteroidVelocity.floatValue;
			GUIContent _driftContent = new GUIContent( string.Format( "Min:{0:F1}, Max:{1:F1}", _minVelocity , _maxVelocity ) );
			EditorGUILayout.MinMaxSlider(_driftContent, ref _minVelocity, ref _maxVelocity, 0.0f, 1.0f);
			minAsteroidVelocity.floatValue = _minVelocity;
			maxAsteroidVelocity.floatValue = _maxVelocity;
			velocityMultiplier.floatValue = EditorGUILayout.FloatField( "Drift Speed Multiplier", velocityMultiplier.floatValue);			
		} else {
			EditorGUILayout.LabelField("Asteroid Rotation Speed (Min/Max Range)", EditorStyles.boldLabel);		
			_minRotationSpeed = minAsteroidRotationSpeed.floatValue;
			_maxRotationSpeed = maxAsteroidRotationSpeed.floatValue;
			GUIContent _rotationContent = new GUIContent( string.Format( "Min:{0:F1}, Max:{1:F1}", _minRotationSpeed , _maxRotationSpeed ) );
			EditorGUILayout.MinMaxSlider(_rotationContent, ref _minRotationSpeed, ref _maxRotationSpeed, 0.0f, 1.0f);
			minAsteroidRotationSpeed.floatValue = _minRotationSpeed;
			maxAsteroidRotationSpeed.floatValue = _maxRotationSpeed;		
			rotationSpeedMultiplier.floatValue = EditorGUILayout.FloatField( "Rotation Speed Multiplier", rotationSpeedMultiplier.floatValue);
			
			EditorGUILayout.LabelField("Asteroid Drift Speed (Min/Max Range)", EditorStyles.boldLabel);
			_minDriftSpeed = minAsteroidDriftSpeed.floatValue;
			_maxDriftSpeed = maxAsteroidDriftSpeed.floatValue;
			GUIContent _driftContent = new GUIContent( string.Format( "Min:{0:F1}, Max:{1:F1}", _minDriftSpeed , _maxDriftSpeed ) );
			EditorGUILayout.MinMaxSlider(_driftContent, ref _minDriftSpeed, ref _maxDriftSpeed, 0.0f, 1.0f);
			minAsteroidDriftSpeed.floatValue = _minDriftSpeed;
			maxAsteroidDriftSpeed.floatValue = _maxDriftSpeed;
			driftSpeedMultiplier.floatValue = EditorGUILayout.FloatField( "Drift Speed Multiplier", driftSpeedMultiplier.floatValue);
		}		
		EditorGUILayout.Separator();
		
		// Visual Settings
		EditorGUILayout.LabelField("Visual Settings", EditorStyles.boldLabel);
		fadeAsteroids.boolValue = EditorGUILayout.Toggle("Fade Asteroids", fadeAsteroids.boolValue);		
		if (fadeAsteroids.boolValue) {
			distanceFade.floatValue = EditorGUILayout.Slider("Fade from % of Spawn", distanceFade.floatValue, 0.0f, 1.0f);
			EditorGUILayout.LabelField("Alpha is 1.0 at distanceFade*distanceSpawn*range and " +
			"gradually fades out to 0.0 at distanceSpawn*range.", EditorStyles.wordWrappedMiniLabel);			
		}				
		EditorGUILayout.Separator();
		
		// Asteroid Mesh Quality
		EditorGUILayout.LabelField("Asteroid Mesh Quality", EditorStyles.boldLabel);
		EditorGUILayout.PropertyField( polyCount);
		EditorGUILayout.PropertyField( polyCountCollider);
		if (polyCountCollider.enumValueIndex != (int) SU_Asteroid.PolyCount.LOW) {
			EditorGUILayout.LabelField("Warning! Using detailed collider meshes may heavily impact performance or raise errors if the mesh is too detailed.", EditorStyles.wordWrappedMiniLabel);	
		}
		
		// Asteroid Prefab (array of asteroid shapes the asteroid field should randomly consist of) 
		EditorGUILayout.LabelField("Asteroid Prefabs", EditorStyles.boldLabel);		
		_showPrefabs = EditorGUILayout.Foldout(_showPrefabs, "Prefabs");
		EditorGUIUtility.LookLikeInspector();
		if (_showPrefabs) {
			ArrayGUI(myTarget, "prefabAsteroids");				
		}		
		EditorGUIUtility.LookLikeControls();		
		EditorGUILayout.Separator();
		
		// Asteroid Materials (array of asteroid materials the asteroid field should randomly consist of)
		// The random selection is weighted between common and rare materials.
		EditorGUILayout.LabelField("Asteroid Materials", EditorStyles.boldLabel);
		_showMaterials = EditorGUILayout.Foldout(_showMaterials, "Materials");
		EditorGUIUtility.LookLikeInspector();
		if (_showMaterials) {
			EditorGUILayout.LabelField("Very Common Materials (50%)", EditorStyles.boldLabel);
			ArrayGUI(myTarget, "materialVeryCommon");				
			EditorGUILayout.LabelField("Common Materials (30%)", EditorStyles.boldLabel);
			ArrayGUI(myTarget, "materialCommon");				
			EditorGUILayout.LabelField("Rare Materials (15%)", EditorStyles.boldLabel);
			ArrayGUI(myTarget, "materialRare");
			EditorGUILayout.LabelField("Very Rare Materials (5%)", EditorStyles.boldLabel);
			ArrayGUI(myTarget, "materialVeryRare");			
		}
		EditorGUIUtility.LookLikeControls();
		
		// Apply the modified properties
		myTarget.ApplyModifiedProperties();
	}
Exemple #7
0
		public override void Draw( DrawInfo drawInfo )
		{
			base.Draw( drawInfo ):

			if ( !m_isVisible )
				return:

			if ( m_isEditingFields && m_currentParameterType != PropertyType.Global )
			{
				bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant:
				Matrix4x4 value = currMode ? m_materialValue : m_defaultValue:

				EditorGUI.BeginChangeCheck():
				for ( int row = 0: row < 4: row++ )
				{
					for ( int column = 0: column < 4: column++ )
					{
						m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ):
						value[ row, column ] = EditorGUIFloatField( m_propertyDrawPos, string.Empty, value[ row, column ], UIUtils.MainSkin.textField ):
					}
				}

				if ( currMode )
				{
					m_materialValue = value:
				}
				else
				{
					m_defaultValue = value:
				}

				if ( EditorGUI.EndChangeCheck() )
				{
					m_requireMaterialUpdate = m_materialMode:
					BeginDelayedDirtyProperty():
				}
			}
			else if ( drawInfo.CurrentEventType == EventType.Repaint )
			{
				bool guiEnabled = GUI.enabled:
				GUI.enabled = m_currentParameterType != PropertyType.Global:

				bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant:
				Matrix4x4 value = currMode ? m_materialValue : m_defaultValue:
				for ( int row = 0: row < 4: row++ )
				{
					for ( int column = 0: column < 4: column++ )
					{
						Rect fakeField = m_propertyDrawPos:
						fakeField.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ):
						if( GUI.enabled )
							EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ):

						if ( m_previousValue[ row, column ] != value[ row, column ] )
						{
							m_previousValue[ row, column ] = value[ row, column ]:
							m_fieldText[ row, column ] = value[ row, column ].ToString():
						}

						GUI.Label( fakeField, m_fieldText[ row, column ], UIUtils.MainSkin.textField ):
					}
				}
				GUI.enabled = guiEnabled:
			}
		}
        private void DrawEnvironmentInspector(BuildEnvironment environment,
                                              WorkerBuildConfiguration configurationForWorker)
        {
            var environmentName = environment.ToString();

            var environmentConfiguration =
                configurationForWorker.GetEnvironmentConfig(environment);

            var hash         = configurationForWorker.WorkerType.GetHashCode() ^ environment.GetHashCode() ^ typeof(FoldoutState).GetHashCode();
            var foldoutState = GetStateObject <FoldoutState>(hash);

            if (foldoutState.Content == null || invalidateCachedContent > 0)
            {
                var builtTargets = string.Join(",",
                                               environmentConfiguration.BuildTargets.Where(t => t.Enabled).Select(t => t.Label));

                foldoutState.Content = new GUIContent($"{environmentName} Build Options ({builtTargets})");

                if (environmentConfiguration.BuildTargets.Any(IsBuildTargetError))
                {
                    foldoutState.Icon =
                        new GUIContent(EditorGUIUtility.IconContent(BuildConfigEditorStyle.BuiltInErrorIcon))
                    {
                        tooltip = "Missing build support for one or more build targets."
                    };
                }
                else if (environmentConfiguration.BuildTargets.Any(IsBuildTargetWarning))
                {
                    foldoutState.Icon =
                        new GUIContent(EditorGUIUtility.IconContent(BuildConfigEditorStyle.BuiltInWarningIcon))
                    {
                        tooltip = "Missing build support for one or more build targets."
                    };
                }
                else
                {
                    foldoutState.Icon = null;
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                foldoutState.Expanded =
                    EditorGUILayout.Foldout(foldoutState.Expanded, foldoutState.Content, true);

                GUILayout.FlexibleSpace();
                if (foldoutState.Icon != null)
                {
                    GUILayout.Label(foldoutState.Icon);
                    GUILayout.Space(28);
                }
            }

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldoutState.Expanded)
                {
                    DrawBuildTargets(environmentConfiguration, hash);
                }

                if (check.changed)
                {
                    // Re-evaluate heading.
                    foldoutState.Content = null;
                }
            }
        }
 private static DefaultPluginImporterExtension.Property[] GetProperties() =>
 new DefaultPluginImporterExtension.Property[]
 {
     m_frameworks, new DefaultPluginImporterExtension.Property(EditorGUIUtility.TextContent("Compile flags"), Plugin.compileFlagsKey, "", "tvOS")
 };
        private bool DrawWorkerConfiguration(WorkerBuildConfiguration configurationForWorker)
        {
            var workerType = configurationForWorker.WorkerType;

            var foldoutState = GetStateObject <FoldoutState>(configurationForWorker.WorkerType.GetHashCode());

            using (new EditorGUILayout.HorizontalScope())
            {
                if (foldoutState.Content == null || invalidateCachedContent > 0)
                {
                    var buildStateIcon = GetBuildConfigurationStateIcon(configurationForWorker);
                    if (buildStateIcon != null)
                    {
                        foldoutState.Icon =
                            new GUIContent(EditorGUIUtility.IconContent(buildStateIcon))
                        {
                            tooltip = "Missing build support for one or more build targets."
                        };
                    }
                    else if (configurationForWorker.CloudBuildConfig.BuildTargets.Any(NeedsAndroidSdk) ||
                             configurationForWorker.LocalBuildConfig.BuildTargets.Any(NeedsAndroidSdk))
                    {
                        foldoutState.Icon =
                            new GUIContent(EditorGUIUtility.IconContent(BuildConfigEditorStyle.BuiltInErrorIcon))
                        {
                            tooltip = "Missing Android SDK installation. Go to Preferences > External Tools to set it up."
                        };
                    }
                    else
                    {
                        foldoutState.Icon = null;
                    }

                    foldoutState.Content = new GUIContent(workerType);
                }

                foldoutState.Expanded = EditorGUILayout.Foldout(foldoutState.Expanded, foldoutState.Content, true);

                GUILayout.FlexibleSpace();
                using (new EditorGUIUtility.IconSizeScope(SmallIconSize))
                {
                    if (foldoutState.Icon != null)
                    {
                        using (new EditorGUIUtility.IconSizeScope(Vector2.zero))
                        {
                            GUILayout.Label(foldoutState.Icon);
                        }
                    }

                    if (GUILayout.Button(style.RemoveWorkerTypeButtonContents, EditorStyles.miniButton))
                    {
                        return(false);
                    }
                }
            }

            using (var check = new EditorGUI.ChangeCheckScope())
                using (new EditorGUI.IndentLevelScope())
                {
                    if (foldoutState.Expanded)
                    {
                        DrawScenesInspectorForWorker(configurationForWorker);
                        EditorGUILayout.Space();
                        DrawEnvironmentInspectorForWorker(configurationForWorker);
                    }

                    if (check.changed)
                    {
                        // Re-evaluate heading.
                        foldoutState.Content = null;
                    }
                }

            return(true);
        }
        private void DrawScenesInspectorForWorker(WorkerBuildConfiguration configurationForWorker)
        {
            DragAndDropInfo dragState;
            var             currentEventType = Event.current.type;

            using (new EditorGUIUtility.IconSizeScope(SmallIconSize))
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Scenes to include (in order)");
                    var workerControlId = configurationForWorker.WorkerType.GetHashCode() ^ typeof(DragAndDrop).GetHashCode();
                    dragState = GetStateObject <DragAndDropInfo>(workerControlId);

                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(style.AddSceneButtonContents, EditorStyles.miniButton))
                    {
                        EditorGUIUtility.ShowObjectPicker <SceneAsset>(null, false, "t:Scene",
                                                                       workerControlId);
                    }

                    HandleObjectSelectorUpdated(configurationForWorker, workerControlId);
                }

            if (configurationForWorker.ScenesForWorker.Count == 0)
            {
                DrawEmptySceneBox(configurationForWorker, currentEventType);
            }
            else
            {
                int?indexToRemove   = null;
                int?targetItemIndex = null;

                if (currentEventType == EventType.Repaint)
                {
                    dragState.AllItemsRect = Rect.zero;
                    dragState.ItemHeight   = 0;
                }

                for (var i = 0; i < configurationForWorker.ScenesForWorker.Count; i++)
                {
                    var item = configurationForWorker.ScenesForWorker[i];

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Space(EditorGUI.indentLevel * 16.0f);
                        indexToRemove = DrawSceneItem(i, dragState, item, currentEventType, indexToRemove);

                        var hitRect = new Rect(dragState.AllItemsRect.xMin,
                                               dragState.AllItemsRect.yMin + i * (dragState.ItemHeight +
                                                                                  EditorGUIUtility.standardVerticalSpacing) -
                                               EditorGUIUtility.standardVerticalSpacing / 2.0f, dragState.AllItemsRect.width,
                                               dragState.ItemHeight + EditorGUIUtility.standardVerticalSpacing / 2.0f);

                        if (hitRect.Contains(Event.current.mousePosition))
                        {
                            if (i != dragState.SourceItemIndex)
                            {
                                targetItemIndex = Event.current.mousePosition.y >
                                                  hitRect.yMin + hitRect.height / 2
                                        ? i + 1
                                        : i;
                            }

                            TrackDragDrop(configurationForWorker, currentEventType, item, dragState, i);
                        }
                    }
                }

                List <SceneAsset> list = null;

                if (indexToRemove.HasValue)
                {
                    list = configurationForWorker.ScenesForWorker.ToList();
                    list.RemoveAt(indexToRemove.Value);
                }
                else if (targetItemIndex.HasValue)
                {
                    list = configurationForWorker.ScenesForWorker.ToList();

                    switch (currentEventType)
                    {
                    case EventType.DragPerform:

                        // The drag event is coming from outside of this list, for example:
                        // The asset browser or another worker's scene list.
                        // If the incoming drag contains a duplicate of the item, it's already been rejected in the hit detection code,
                        // so there's no need to validate it again here.
                        if (dragState.SourceItemIndex == -1)
                        {
                            if (targetItemIndex >= list.Count)
                            {
                                list.AddRange(DragAndDrop.objectReferences.OfType <SceneAsset>());
                            }
                            else
                            {
                                list.InsertRange(targetItemIndex.Value,
                                                 DragAndDrop.objectReferences.OfType <SceneAsset>());
                            }
                        }
                        else
                        {
                            var movingItem = list[dragState.SourceItemIndex];

                            if (targetItemIndex >= list.Count)
                            {
                                list.RemoveAt(dragState.SourceItemIndex);
                                list.Add(movingItem);
                            }
                            else
                            {
                                list.RemoveAt(dragState.SourceItemIndex);
                                if (targetItemIndex >= dragState.SourceItemIndex)
                                {
                                    list.Insert(targetItemIndex.Value - 1, movingItem);
                                }
                                else
                                {
                                    list.Insert(targetItemIndex.Value, movingItem);
                                }
                            }
                        }

                        break;

                    case EventType.Repaint:
                        if (DragAndDrop.visualMode == DragAndDropVisualMode.Copy)
                        {
                            var newRect = new Rect(dragState.AllItemsRect.xMin,
                                                   dragState.AllItemsRect.yMin + targetItemIndex.Value *
                                                   dragState.AllItemsRect.height / list.Count,
                                                   dragState.AllItemsRect.width, 2);
                            EditorGUI.DrawRect(newRect, new Color(0.4f, 0.4f, 0.4f, 1));
                        }
                        else if (DragAndDrop.visualMode == DragAndDropVisualMode.Rejected)
                        {
                            var newRect = new Rect(dragState.AllItemsRect);
                            EditorGUI.DrawRect(newRect, new Color(0.8f, 0.0f, 0.0f, 0.25f));
                        }

                        break;
                    }
                }

                if (list != null)
                {
                    RecordUndo("Configure scenes for worker");

                    configurationForWorker.ScenesForWorker = list;
                }
            }
        }
    public override void OnInspectorGUI()
    {
        gcScript = target as GunController;

        GUILayout.Space(10);

        if (gcScript.firePos == null)
        {
            GUILayout.Box("IMPORTANT! Assign a fire position before continuing!");
        }
        gcScript.firePos = (Transform)EditorGUILayout.ObjectField("Fire Position:", gcScript.firePos, typeof(Transform), true);
        if (gcScript.firePos == null)
        {
            return;
        }

        gcScript.leftHandTransform = (Transform)EditorGUILayout.ObjectField("Left Hand:", gcScript.leftHandTransform, typeof(Transform), true);

        GUILayout.Space(5);

        if (GUILayout.Button("Convert To Pickup"))
        {
            PrefabUtility.DisconnectPrefabInstance(gcScript.gameObject);

            GunVisuals gv = gcScript.GetComponent <GunVisuals>();
            if (gv)
            {
                foreach (GameObject go in gv.activateOnUse)
                {
                    DestroyImmediate(go);
                }
                foreach (GameObject go in gv.deactivateOnUse)
                {
                    go.SetActive(true);
                }
                DestroyImmediate(gcScript.firePos.gameObject);
                DestroyImmediate(gv);
            }

            PistolAnim pa = gcScript.GetComponent <PistolAnim>();
            if (pa)
            {
                DestroyImmediate(pa);
            }

            gcScript.gameObject.AddComponent <Rigidbody>().mass = 3f;
            UsableObject uo = gcScript.gameObject.AddComponent <UsableObject>();
            uo.weaponPickup            = new UsableObject.WeaponPickup();
            uo.weaponPickup.enabled    = true;
            uo.weaponPickup.ammoAmount = gcScript.currentAmmo;
            uo.objectName             = gcScript.gunName;
            uo.weaponPickup.weaponID  = gcScript.weaponID;
            gcScript.transform.parent = null;
            gcScript.transform.name  += " (Pickup)";

            AntiClipVariables acv = gcScript.GetComponent <AntiClipVariables>();
            if (acv)
            {
                DestroyImmediate(acv);
            }

            DestroyImmediate(gcScript);

            return;
        }

        if (GUILayout.Button("Reset IDs"))
        {
            WeaponDatabase.RefreshIDs();
            return;
        }

        DarkRef.GUISeparator();

        if (GUILayout.Button("Set First Person Info"))
        {
            GunController toSetFirst = WeaponDatabase.GetWeaponByID(gcScript.weaponID);
            toSetFirst.firstPersonPosition = gcScript.transform.localPosition;
            toSetFirst.firstPersonRotation = gcScript.transform.localRotation;

            gcScript.firstPersonPosition = gcScript.transform.localPosition;
            gcScript.firstPersonRotation = gcScript.transform.localRotation;
        }
        GUILayout.Label("First Person Info:", EditorStyles.boldLabel);
        GUILayout.Label("    Position: " + DarkRef.PreciseStringVector3(gcScript.firstPersonPosition));
        GUILayout.Label("    Rotation: " + gcScript.firstPersonRotation.eulerAngles);


        DarkRef.GUISeparator();

        if (GUILayout.Button("Set Third Person Info"))
        {
            GunController toSetThird = WeaponDatabase.GetWeaponByID(gcScript.weaponID);
            toSetThird.thirdPersonPosition = gcScript.transform.localPosition;
            toSetThird.thirdPersonRotation = gcScript.transform.localRotation;

            gcScript.thirdPersonPosition = gcScript.transform.localPosition;
            gcScript.thirdPersonRotation = gcScript.transform.localRotation;
        }

        if ((gcScript.transform.parent != null && gcScript.transform.parent.name == "WeaponsParent") && GUILayout.Button("Pose Transform"))
        {
            gcScript.transform.localPosition = gcScript.thirdPersonPosition;
            gcScript.transform.localRotation = gcScript.thirdPersonRotation;
        }

        GUILayout.Label("Third Person Info:", EditorStyles.boldLabel);
        GUILayout.Label("    Position: " + DarkRef.PreciseStringVector3(gcScript.thirdPersonPosition));
        GUILayout.Label("    Rotation: " + gcScript.thirdPersonRotation.eulerAngles);

        DarkRef.GUISeparator();

        GUILayout.Label("GUI Properties", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();
        gcScript.iconTexture = (Texture2D)EditorGUILayout.ObjectField("Icon:", gcScript.iconTexture, typeof(Texture2D));
        gcScript.iconScale   = EditorGUILayout.Vector2Field("Icon Scale:", gcScript.iconScale);
        gcScript.iconOffset  = EditorGUILayout.Vector2Field("Icon Offset:", gcScript.iconOffset);
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(10);
        gcScript.gunName    = EditorGUILayout.TextField("Weapon Name:", gcScript.gunName);
        gcScript.weaponSlot = (WeaponSlot)EditorGUILayout.EnumPopup("Weapon Slot:", gcScript.weaponSlot);
        GUILayout.Space(5);

        GUILayout.Label("Fire Mode Settings", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();
        gcScript.firstMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #1:", gcScript.firstMode);
        if (gcScript.firstMode != GunController.FireMode.None)
        {
            gcScript.firstRPM = EditorGUILayout.FloatField("    Fire Rate (RPM):", gcScript.firstRPM);
        }
        gcScript.secondMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #2:", gcScript.secondMode);
        if (gcScript.secondMode != GunController.FireMode.None)
        {
            gcScript.secondRPM = EditorGUILayout.FloatField("    Fire Rate (RPM):", gcScript.secondRPM);
            GUI.enabled        = false;
        }
        if (gcScript.secondMode == GunController.FireMode.None)
        {
            GUI.enabled        = false;
            gcScript.thirdMode = GunController.FireMode.None;
        }
        else
        {
            GUI.enabled = true;
        }

        gcScript.thirdMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #3:", gcScript.thirdMode);
        if (gcScript.thirdMode != GunController.FireMode.None && gcScript.secondMode != GunController.FireMode.None)
        {
            gcScript.thirdRPM = EditorGUILayout.FloatField("    Fire Rate (RPM):", gcScript.thirdRPM);
        }
        GUI.enabled = true;
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        BulletInfo.BulletType bulletType = gcScript.bulletInfo.bulletType;
        GUILayout.Label((bulletType == BulletInfo.BulletType.Bullet) ? "Bullet Properties" : "Projectile Properties", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();
        PoolingList poolList = (PoolingList)Resources.Load("Static Prefabs/PoolingList", typeof(PoolingList));

        gcScript.bulletInfo.bulletType = (BulletInfo.BulletType)EditorGUILayout.EnumPopup("Bullet Type:", gcScript.bulletInfo.bulletType);

        GUI.color = new Color(1f, 0.8f, 0.8f);
        EditorGUILayout.ObjectField((bulletType == BulletInfo.BulletType.Bullet) ? "Bullet Prefab:" : "Projectile Prefab:", poolList.poolPrefabs[Mathf.Clamp(gcScript.bulletInfo.poolIndex, 0, poolList.poolPrefabs.Length - 1)], typeof(GameObject), true);
        GUI.color = Color.white;

        EditorGUI.indentLevel        += 1;
        gcScript.bulletInfo.poolIndex = EditorGUILayout.IntField("Pool Index:", Mathf.Clamp(gcScript.bulletInfo.poolIndex, 0, poolList.poolPrefabs.Length - 1));
        EditorGUI.indentLevel        -= 1;
        GUILayout.Space(8f);

        gcScript.bulletInfo.damage = EditorGUILayout.IntField((bulletType == BulletInfo.BulletType.Rocket) ? "Explosion Damage" : "Damage:", gcScript.bulletInfo.damage);

        if (bulletType == BulletInfo.BulletType.Rocket)
        {
            gcScript.bulletInfo.explosionRadius = EditorGUILayout.FloatField("Explosion Radius:", gcScript.bulletInfo.explosionRadius);
        }
        else
        {
            gcScript.bulletInfo.force = EditorGUILayout.FloatField("Impact Force:", gcScript.bulletInfo.force);
        }

        gcScript.bulletInfo.muzzleVelocity = EditorGUILayout.FloatField("Base Velocity (m/s):", gcScript.bulletInfo.muzzleVelocity);
        gcScript.bulletInfo.gravityFactor  = EditorGUILayout.Slider("Gravity (" + (-Physics.gravity.y * gcScript.bulletInfo.gravityFactor).ToString("F2") + " m/s)", gcScript.bulletInfo.gravityFactor, 0f, 5f);

        gcScript.bulletInfo.damageFalloff = EditorGUILayout.CurveField("Damage Falloff:", gcScript.bulletInfo.damageFalloff);
        for (int i = 0; i < gcScript.bulletInfo.damageFalloff.length; i++)
        {
            Keyframe modKey = gcScript.bulletInfo.damageFalloff.keys[i];
            modKey.time  = Mathf.RoundToInt(Mathf.Max(0f, modKey.time));
            modKey.value = Mathf.Round(Mathf.Clamp(modKey.value, 0f, 1f) * 100f) / 100f;
            gcScript.bulletInfo.damageFalloff.MoveKey(i, modKey);
        }

        //        if(gcScript.bulletInfo.penetrationDistance <= 0f) {
        gcScript.bulletInfo.ricochetLength   = EditorGUILayout.IntField("Ricochet Amount:", Mathf.Max(gcScript.bulletInfo.ricochetLength, 0));
        gcScript.bulletInfo.ricochetMaxAngle = EditorGUILayout.FloatField("Ricochet Max Angle:", Mathf.Clamp(gcScript.bulletInfo.ricochetMaxAngle, 0f, 90f));

        /*
         * }
         * else {
         *  EditorGUILayout.HelpBox("You must disable penetration to enable ricochet", MessageType.Info);
         * }
         *
         * gcScript.bulletInfo.penetrationDistance = EditorGUILayout.FloatField("Penetration Distance: ", Mathf.Clamp(gcScript.bulletInfo.penetrationDistance, 0f, 10000f));
         * gcScript.bulletInfo.penetrationDamageReduction = EditorGUILayout.FloatField("Penetration Damage Reduction: ", Mathf.Clamp(gcScript.bulletInfo.penetrationDamageReduction, 0f, 100f));
         * gcScript.bulletInfo.penetrationSpeedReduction = EditorGUILayout.FloatField("Penetration Speed Reduction: ", Mathf.Clamp(gcScript.bulletInfo.penetrationSpeedReduction, 0f, 100f));
         */

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.Label("Sound Settings", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();
        gcScript.fireSound  = (AudioClip)EditorGUILayout.ObjectField("Fire Sound:", gcScript.fireSound, typeof(AudioClip), true);
        gcScript.emptySound = (AudioClip)EditorGUILayout.ObjectField("Empty Sound:", gcScript.emptySound, typeof(AudioClip), true);

        string reloadLabel = (gcScript.reloadMethod == GunController.ReloadMethod.Magazine) ? "Reload Sound:" : "Reload Sound (Loop):";

        gcScript.reloadSound = (AudioClip)EditorGUILayout.ObjectField(reloadLabel, gcScript.reloadSound, typeof(AudioClip), true);
        if (gcScript.reloadMethod == GunController.ReloadMethod.Singular)
        {
            gcScript.reloadEnd = (AudioClip)EditorGUILayout.ObjectField("Reload End:", gcScript.reloadEnd, typeof(AudioClip), true);
        }
        else if (gcScript.reloadMethod == GunController.ReloadMethod.Magazine)
        {
            gcScript.reloadSoundEmpty = (AudioClip)EditorGUILayout.ObjectField("Reload Sound (empty):", gcScript.reloadSoundEmpty, typeof(AudioClip), true);
        }

        gcScript.switchSound = (AudioClip)EditorGUILayout.ObjectField("Switch Fire Mode:", gcScript.switchSound, typeof(AudioClip), true);
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.Label("Shoot Settings", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();

        gcScript.bulletsPerShot    = EditorGUILayout.IntSlider("Bullets Per Shot:", gcScript.bulletsPerShot, 1, 50);
        gcScript.countsAsOneBullet = EditorGUILayout.Toggle("Subtract 1 Bullet:", gcScript.countsAsOneBullet);
        if (gcScript.firstMode == GunController.FireMode.BurstFire || gcScript.secondMode == GunController.FireMode.BurstFire || gcScript.thirdMode == GunController.FireMode.BurstFire)
        {
            gcScript.bulletsPerBurst = EditorGUILayout.IntSlider("Rounds Per Burst:", gcScript.bulletsPerBurst, 2, Mathf.Max(3, gcScript.clipSize));
            gcScript.burstInterval   = EditorGUILayout.Slider("Burst Interval:", gcScript.burstInterval, 0.01f, 1f);
            gcScript.burstCooldown   = EditorGUILayout.Slider("Burst Cooldown:", gcScript.burstCooldown, 0.01f, 1f);
        }
        GUILayout.Space(10);
        gcScript.muzzleProbability  = EditorGUILayout.Slider("Muzzle Probability:", gcScript.muzzleProbability, 0f, 1f);
        gcScript.muzzleFlash        = (ParticleEmitter)EditorGUILayout.ObjectField("Muzzle Flash:", gcScript.muzzleFlash, typeof(ParticleEmitter), true);
        gcScript.muzzleLight        = (Light)EditorGUILayout.ObjectField("Muzzle Light:", gcScript.muzzleLight, typeof(Light), true);
        EditorGUI.indentLevel      += 1;
        EditorGUIUtility.labelWidth = 140f;
        gcScript.muzzleSpeed        = EditorGUILayout.FloatField("Light Fade Speed:", Mathf.Max(5f, gcScript.muzzleSpeed));
        EditorGUIUtility.LookLikeControls();
        EditorGUI.indentLevel -= 1;

        GUILayout.Space(5f);

        gcScript.shootParticle = (ParticleEmitter)EditorGUILayout.ObjectField("Shoot Smoke:", gcScript.shootParticle, typeof(ParticleEmitter), true);

        GUILayout.Space(10);
        gcScript.ejectionEnabled = EditorGUILayout.Toggle("Shell Ejection:", gcScript.ejectionEnabled);
        if (gcScript.ejectionEnabled)
        {
            gcScript.ejectionPos      = (Transform)EditorGUILayout.ObjectField("    Ejection Position:", gcScript.ejectionPos, typeof(Transform), true);
            gcScript.bulletShellIndex = EditorGUILayout.IntField("    Bullet Shell Index:", gcScript.bulletShellIndex);
            gcScript.ejectionDelay    = EditorGUILayout.FloatField("    Ejection Delay:", gcScript.ejectionDelay);
            gcScript.ejectionMinForce = EditorGUILayout.Vector3Field("    Minimum Force:", gcScript.ejectionMinForce);
            gcScript.ejectionMaxForce = EditorGUILayout.Vector3Field("    Maximum Force:", gcScript.ejectionMaxForce);
            gcScript.ejectionRotation = EditorGUILayout.FloatField("    Rotation Force:", gcScript.ejectionRotation);
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.Label("Ammo Settings", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.BeginVertical();
        gcScript.currentAmmo = EditorGUILayout.IntSlider("Current Ammo:", gcScript.currentAmmo, 0, gcScript.clipSize);
        gcScript.clipSize    = EditorGUILayout.IntField("    Magazine Size:", gcScript.clipSize);

        GUILayout.Space(5f);

        gcScript.ammoLeft    = EditorGUILayout.IntSlider("Reserve Ammo:", gcScript.ammoLeft, 0, gcScript.ammoLeftCap);
        gcScript.ammoLeftCap = EditorGUILayout.IntField("    Reserve Limit:", gcScript.ammoLeftCap);

        DarkRef.GUISeparator(7f);

        gcScript.reloadMethod = (GunController.ReloadMethod)EditorGUILayout.EnumPopup("Reload Method:", gcScript.reloadMethod);

        EditorGUI.indentLevel      += 1;
        EditorGUIUtility.labelWidth = 140f;
        gcScript.reloadOnMouseClick = EditorGUILayout.Toggle("Reload On Click:", gcScript.reloadOnMouseClick);
        EditorGUIUtility.LookLikeControls();
        if (gcScript.reloadMethod == GunController.ReloadMethod.Magazine)
        {
            EditorGUIUtility.labelWidth = 140f;
            gcScript.reloadLength       = EditorGUILayout.FloatField("Reload Duration:", Mathf.Clamp(gcScript.reloadLength, 0f, 30f));
            if (gcScript.reloadSoundEmpty != null)
            {
                gcScript.reloadLengthEmpty = EditorGUILayout.FloatField("   Empty Duration:", Mathf.Clamp(gcScript.reloadLengthEmpty, 0f, 30f));
            }
            gcScript.includeChamberRound = EditorGUILayout.Toggle("Chamber Round:", gcScript.includeChamberRound);
            EditorGUIUtility.LookLikeControls();
        }
        else if (gcScript.reloadMethod == GunController.ReloadMethod.Singular)
        {
            EditorGUIUtility.labelWidth = 135f;
            gcScript.reloadDelay        = EditorGUILayout.FloatField("Reload Delay:", Mathf.Clamp(gcScript.reloadDelay, 0f, 5f));
            gcScript.reloadInterval     = EditorGUILayout.FloatField("Reload Interval:", Mathf.Clamp(gcScript.reloadInterval, 0f, 5f));
            gcScript.reloadAmount       = EditorGUILayout.IntField("Reload Amount:", Mathf.Clamp(gcScript.reloadAmount, 1, gcScript.clipSize));
            GUILayout.Box("Reload sound will now loop, make sure that the sound can loop seamlessly.");
            EditorGUIUtility.LookLikeControls();
        }
        EditorGUI.indentLevel -= 1;
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        EditorGUIUtility.labelWidth = 165f;

        GUILayout.Space(5);

        GUILayout.Label("Aim Settings", EditorStyles.boldLabel);
        gcScript.sniperAimEffect     = EditorGUILayout.Toggle("    Sniper Aim Effect:", gcScript.sniperAimEffect);
        gcScript.playerSpeedAim      = EditorGUILayout.Slider("    Player Speed Aim:", gcScript.playerSpeedAim, 0.1f, 1f);
        gcScript.mouseSensitivityAim = EditorGUILayout.Slider("    Mouse Sensitivity Aim:", gcScript.mouseSensitivityAim, 0.01f, 1.0f);
        gcScript.aimPos         = EditorGUILayout.Vector3Field("    Aim Position:", gcScript.aimPos);
        gcScript.aimSpeedFactor = EditorGUILayout.FloatField("    Aim Speed Factor:", gcScript.aimSpeedFactor);
        gcScript.addZoomFOV     = EditorGUILayout.FloatField("    Additional Zoom (FOV):", Mathf.Clamp(gcScript.addZoomFOV, -15f, 75f));
        gcScript.aimSwayFactor  = EditorGUILayout.Slider("    Sniper Sway Factor:", gcScript.aimSwayFactor, 0f, 5f);

        GUILayout.Space(5);

        GUILayout.Label("Crosshair Settings", EditorStyles.boldLabel);
        gcScript.crosshairsEnabled = EditorGUILayout.Toggle("    Enabled:", gcScript.crosshairsEnabled);

        GUILayout.Space(5);

        GUILayout.Label("Accuracy and Recoil Settings", EditorStyles.boldLabel);

        gcScript.baseSpreadAmount     = EditorGUILayout.FloatField("    Base Bullet Spread:", gcScript.baseSpreadAmount);
        gcScript.spreadSpeed          = EditorGUILayout.FloatField("    Bullet Spread Speed:", gcScript.spreadSpeed);
        gcScript.spreadAimFactor      = EditorGUILayout.Slider("        Spread Aim Factor:", gcScript.spreadAimFactor, 0f, 1f);
        gcScript.recoverSpeed         = EditorGUILayout.FloatField("    Recover Spread Speed:", gcScript.recoverSpeed);
        gcScript.movementSpreadAmount = EditorGUILayout.FloatField("    Movement Spread Amount:", gcScript.movementSpreadAmount);
        gcScript.maxSpreadAmount      = EditorGUILayout.FloatField("    Max Bullet Spread:", gcScript.maxSpreadAmount);
        gcScript.aimSpreadModifier    = EditorGUILayout.Slider("    Aim Spread Mod:", gcScript.aimSpreadModifier, 0f, 1f);
        gcScript.crouchWalkModifier   = EditorGUILayout.Slider("    Crouch/Walk Mod:", gcScript.crouchWalkModifier, 0f, 1f);
        GUILayout.Space(10);
        gcScript.recoilAmount = EditorGUILayout.FloatField("    Offset Recoil:", gcScript.recoilAmount);

        GUILayout.Space(6);

        gcScript.upKickAmount = EditorGUILayout.FloatField("    Up-kick Amount:", gcScript.upKickAmount);
        gcScript.autoReturn   = EditorGUILayout.FloatField("        Auto Return:", gcScript.autoReturn);

        GUILayout.Space(5f);

        gcScript.sideKickAmount       = EditorGUILayout.FloatField("    Side-kick Amount:", gcScript.sideKickAmount);
        gcScript.aimUpkickModifier    = EditorGUILayout.Slider("        Aim Kick Modifier:", gcScript.aimUpkickModifier, 0f, 1f);
        gcScript.crouchUpkickModifier = EditorGUILayout.Slider("        Crouch Kick Modifier:", gcScript.crouchUpkickModifier, 0f, 1f);

        gcScript.kickInfluence = EditorGUILayout.Vector2Field("    Kick Influence", gcScript.kickInfluence);
        GUILayout.Space(5);

        EditorGUIUtility.LookLikeControls(200f);
        gcScript.extraRecoilThreshold = EditorGUILayout.IntField("    Extra Recoil Threshold:", gcScript.extraRecoilThreshold);
        gcScript.extraRecoilAmount    = EditorGUILayout.FloatField("    Extra Recoil Amount (" + (gcScript.extraRecoilAmount * 100f).ToString() + "%):", Mathf.Max(0f, gcScript.extraRecoilAmount));
        gcScript.maxExtraRecoil       = EditorGUILayout.FloatField("    Extra Recoil Limit (+" + (gcScript.maxExtraRecoil * 100f).ToString() + "%):", Mathf.Max(0f, gcScript.maxExtraRecoil));
        EditorGUIUtility.LookLikeControls(150f);

        GUILayout.Space(10f);

        gcScript.kickCameraTilt = EditorGUILayout.FloatField("    Camera Recoil Tilt:", gcScript.kickCameraTilt);
        gcScript.kickGunTilt    = EditorGUILayout.FloatField("    Gun Recoil Tilt:", gcScript.kickGunTilt);
        gcScript.camShakeAnim   = EditorGUILayout.FloatField("    Camera Animation:", gcScript.camShakeAnim);

        GUILayout.Space(5f);

        gcScript.kickBackAmount    = EditorGUILayout.FloatField("    Kickback Amount:", gcScript.kickBackAmount);
        gcScript.kickSpeedFactor   = EditorGUILayout.FloatField("    Kickback Speed:", gcScript.kickSpeedFactor);
        gcScript.kickbackAimFactor = EditorGUILayout.Slider("    Kickback Aim Factor:", gcScript.kickbackAimFactor, 0f, 1f);

        GUILayout.Space(5);

        GUILayout.Label("Animation Settings", EditorStyles.boldLabel);
        gcScript.reloadAnim = EditorGUILayout.TextField("    Reload Name:", gcScript.reloadAnim);

        GUILayout.Space(5);

        GUILayout.Label("Miscellaneous Settings", EditorStyles.boldLabel);
        gcScript.flashlight      = (Light)EditorGUILayout.ObjectField("    Flashlight:", gcScript.flashlight, typeof(Light), true);
        gcScript.flashlightClick = (AudioClip)EditorGUILayout.ObjectField("    Flashlight Click:", gcScript.flashlightClick, typeof(AudioClip), true);
        GUILayout.Space(10f);
        gcScript.weaponWeight = EditorGUILayout.FloatField("    Weapon Weight (kg):", Mathf.Clamp(gcScript.weaponWeight, 0f, 100f));
        gcScript.aimBobFactor = EditorGUILayout.Slider("    Aim Bob Factor:", gcScript.aimBobFactor, 0.01f, 1f);

        GUILayout.Space(10f);
        GUILayout.Label("    DoF Settings");
        gcScript.dofBlurAmount    = EditorGUILayout.FloatField("        Blur Amount:", Mathf.Clamp(gcScript.dofBlurAmount, 0f, 50f));
        gcScript.dofBlurDistance  = EditorGUILayout.FloatField("        Blur Distance:", Mathf.Clamp(gcScript.dofBlurDistance, 0f, 25f));
        gcScript.dofBlurAperture  = EditorGUILayout.FloatField("        Blur Aperture:", Mathf.Clamp(gcScript.dofBlurAperture, 0f, 40f));
        gcScript.dofBlurFocalSize = EditorGUILayout.FloatField("        Focal Size:", Mathf.Clamp(gcScript.dofBlurFocalSize, 0f, 10f));
        gcScript.dofBlendBlur     = EditorGUILayout.FloatField("        Blend Blur:", Mathf.Clamp(gcScript.dofBlendBlur, 0f, 50f));

        GUILayout.Space(10);

        gcScript.weaponID = EditorGUILayout.IntField("Weapon ID", Mathf.Clamp(gcScript.weaponID, -1, 2000));

        if (GUI.changed)
        {
            EditorUtility.SetDirty(gcScript);
        }
    }
Exemple #13
0
        protected virtual bool DrawWardrobeSlotsFields(Type TargetType, bool ShowHelp = false)
        {
            #region Setup
            bool doUpdate = false;
            //Field Infos
            FieldInfo ReplacesField             = TargetType.GetField("replaces", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo CompatibleRacesField      = TargetType.GetField("compatibleRaces", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo WardrobeSlotField         = TargetType.GetField("wardrobeSlot", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo SuppressWardrobeSlotField = TargetType.GetField("suppressWardrobeSlots", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo HidesField        = TargetType.GetField("Hides", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo DisplayValueField = TargetType.GetField("DisplayValue", BindingFlags.Public | BindingFlags.Instance);
            FieldInfo UserField         = TargetType.GetField("UserField", BindingFlags.Public | BindingFlags.Instance);

            // ************************************
            // field values
            // ************************************
            string replaces = "";
            if (ReplacesField != null)
            {
                object o = ReplacesField.GetValue(target);
                if (o != null)
                {
                    replaces = (string)ReplacesField.GetValue(target);
                }
            }

            List <string> compatibleRaces      = (List <string>)CompatibleRacesField.GetValue(target);
            string        wardrobeSlot         = (string)WardrobeSlotField.GetValue(target);
            List <string> suppressWardrobeSlot = (List <string>)SuppressWardrobeSlotField.GetValue(target);
            List <string> hides          = (List <string>)HidesField.GetValue(target);
            string        displayValue   = (string)DisplayValueField.GetValue(target);
            string        userFieldValue = (string)UserField.GetValue(target);
            #endregion

            #region Display Value UI
            //displayValue UI
            string PreviousValue = displayValue;
            displayValue = EditorGUILayout.DelayedTextField("Display Value", displayValue);
            if (displayValue != PreviousValue)
            {
                DisplayValueField.SetValue(target, displayValue);
                doUpdate = true;
            }
            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("Display Value can be used to store a user-friendly name for this item. It's not used for constructing the character, but it can be used in UI design by accessing the .DisplayValue field on the recipe.", MessageType.Info);
            }
            PreviousValue  = userFieldValue;
            userFieldValue = EditorGUILayout.DelayedTextField("User Field", userFieldValue);
            if (userFieldValue != PreviousValue)
            {
                UserField.SetValue(target, userFieldValue);
                doUpdate = true;
            }
            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("User Field is ignored by the system. You can use this to store data that can later be used by your application to provide filtering or categorizing, etc.", MessageType.Info);
            }

            #endregion

            #region Wardrobe Slot UI
            //wardrobeSlot UI
            int           selectedWardrobeSlotIndex = GenerateWardrobeSlotsEnum(wardrobeSlot, compatibleRaces, false);
            string        newWardrobeSlot;
            int           newSuppressFlags        = 0;
            List <string> newSuppressWardrobeSlot = new List <string>();
            if (selectedWardrobeSlotIndex == -1)
            {
                EditorGUILayout.LabelField("No Compatible Races set. You need to select a compatible race in order to set a wardrobe slot");
                newWardrobeSlot = "None";
            }
            else if (selectedWardrobeSlotIndex == -2)
            {
                EditorGUILayout.LabelField("Not all compatible races found. Do you have the all correct Race(s) available Locally?");
                newWardrobeSlot = "None";
            }
            else
            {
                int newSelectedWardrobeSlotIndex = EditorGUILayout.Popup("Wardrobe Slot", selectedWardrobeSlotIndex, generatedWardrobeSlotOptionsLabels.ToArray());
                if (newSelectedWardrobeSlotIndex != selectedWardrobeSlotIndex)
                {
                    WardrobeSlotField.SetValue(target, generatedWardrobeSlotOptions[newSelectedWardrobeSlotIndex]);
                    doUpdate = true;
                }
                newWardrobeSlot = generatedWardrobeSlotOptions.Count > 0 ? generatedWardrobeSlotOptions[selectedWardrobeSlotIndex] : "None";
            }
            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("Wardrobe Slot: This assigns the recipe to a Wardrobe Slot. The wardrobe slots are defined on the race. Characters can have only one recipe per Wardrobe Slot at a time, so for example, adding a 'beard' recipe to a character will replace the existing 'beard' if there is one", MessageType.Info);
            }
            #endregion

            #region Suppress UI
            //SuppressedSlots UI
            int suppressFlags = 0;
            for (int i = 0; i < generatedWardrobeSlotOptions.Count; i++)
            {
                if (suppressWardrobeSlot.Contains(generatedWardrobeSlotOptions[i]))
                {
                    suppressFlags |= 0x1 << i;
                }
            }
            newSuppressFlags = EditorGUILayout.MaskField("Suppress Wardrobe Slot(s)", suppressFlags, generatedWardrobeSlotOptionsLabels.ToArray());
            for (int i = 0; i < generatedWardrobeSlotOptions.Count; i++)
            {
                if ((newSuppressFlags & (1 << i)) == (1 << i))
                {
                    newSuppressWardrobeSlot.Add(generatedWardrobeSlotOptions[i]);
                }
            }
            if (newSuppressWardrobeSlot.Count > 1)
            {
                GUI.enabled = false;
                string swsl2Result = String.Join(", ", newSuppressWardrobeSlot.ToArray());
                EditorGUILayout.TextField(swsl2Result);
                GUI.enabled = true;
            }
            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("Suppress: This will stop a different wardrobe slot from displaying. For example, if you have a full-length robe assigned to a 'chest' wardrobe slot, you would want to suppress whatever is assigned to the 'legs' wardrobe slot, so they don't poke through. This is typically used for dresses, robes, and other items that cover multiple body areas.", MessageType.Info);
            }
            #endregion

            #region Hides UI
            //Hides UI
            EditorGUILayout.BeginHorizontal();
            GenerateBaseSlotsEnum(compatibleRaces, false, hides);
            int           hiddenBaseFlags = 0;
            List <string> newHides        = new List <string>();
            for (int i = 0; i < generatedBaseSlotOptions.Count; i++)
            {
                if (hides.Contains(generatedBaseSlotOptions[i]))
                {
                    hiddenBaseFlags |= 0x1 << i;
                }
            }

            if (generatedBaseSlotOptionsLabels.Count > 0)
            {
                int newHiddenBaseFlags = 0;

                newHiddenBaseFlags = EditorGUILayout.MaskField("Hides Base Slot(s)", hiddenBaseFlags, generatedBaseSlotOptionsLabels.ToArray());
                for (int i = 0; i < generatedBaseSlotOptionsLabels.Count; i++)
                {
                    if ((newHiddenBaseFlags & (1 << i)) == (1 << i))
                    {
                        newHides.Add(generatedBaseSlotOptions[i]);
                    }
                }
            }
            else
            {
                EditorGUILayout.Popup("Hides Base Slots(s)", 0, new string[1] {
                    "Nothing"
                });
            }

            GUILayout.Space(8);
            if (GUILayout.Button("Select", GUILayout.MaxWidth(64), GUILayout.MaxHeight(16)))
            {
                slotHidePickerID = EditorGUIUtility.GetControlID(FocusType.Passive) + 101;
                EditorGUIUtility.ShowObjectPicker <SlotDataAsset>(null, false, "", slotHidePickerID);
            }
            if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == slotHidePickerID)
            {
                SlotDataAsset sda = EditorGUIUtility.GetObjectPickerObject() as SlotDataAsset;
                newHides.Add(sda.slotName);
                Event.current.Use();
                GenerateBaseSlotsEnum(compatibleRaces, true, hides);
            }

            EditorGUILayout.EndHorizontal();
            if (newHides.Count > 1)
            {
                GUI.enabled = false;
                string newHidesResult = String.Join(", ", newHides.ToArray());
                EditorGUILayout.TextField(newHidesResult);
                GUI.enabled = true;
            }

            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("Hides: This is used to hide parts of the base recipe. For example, if you create gloves, you may want to hide the 'hands', so you don't get poke-through", MessageType.Info);
            }
            #endregion

            #region Replaces UI
            if (ReplacesField != null)
            {
                List <string> ReplacesSlots = new List <string>(generatedBaseSlotOptions);
                ReplacesSlots.Insert(0, "Nothing");
                int selectedIndex = ReplacesSlots.IndexOf(replaces);
                if (selectedIndex < 0)
                {
                    selectedIndex = 0;                                    // not found, point at "nothing"
                }
                selectedIndex = EditorGUILayout.Popup("Replaces", selectedIndex, ReplacesSlots.ToArray());

                ReplacesField.SetValue(target, ReplacesSlots[selectedIndex]);
            }

            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("Replaces: This is used to replace part of the base recipe while keeping it's overlays. For example, if you want to replace the head from the base race recipe with a High Poly head, you would 'replace' the head, not hide it. Only one slot can be replaced, and the recipe should only contain one slot.", MessageType.Info);
            }
            #endregion

            #region MeshHideArray
            //EditorGUIUtility.LookLikeInspector();
            SerializedProperty meshHides = serializedObject.FindProperty("MeshHideAssets");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+", GUILayout.MaxWidth(30)))
            {
                meshHideAssetPickerID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
                EditorGUIUtility.ShowObjectPicker <MeshHideAsset>(null, false, "", meshHideAssetPickerID);
            }
            GUILayout.Space(10);
            if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == meshHideAssetPickerID)
            {
                meshHides.InsertArrayElementAtIndex(0);
                SerializedProperty element = meshHides.GetArrayElementAtIndex(0);
                element.objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
                meshHideAssetPickerID        = -1;
            }
            EditorGUILayout.PropertyField(meshHides, true);
            EditorGUILayout.EndHorizontal();
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            //EditorGUIUtility.LookLikeControls();
            if (ShowHelp)
            {
                EditorGUILayout.HelpBox("MeshHideAssets: This is a list of advanced mesh hiding assets to hide their corresponding slot meshes on a per triangle basis.", MessageType.Info);
            }
            #endregion

            #region Update
            //Update the values
            if (newWardrobeSlot != wardrobeSlot)
            {
                WardrobeSlotField.SetValue(target, newWardrobeSlot);
                doUpdate = true;
            }
            if (!AreListsEqual <string>(newSuppressWardrobeSlot, suppressWardrobeSlot))
            {
                SuppressWardrobeSlotField.SetValue(target, newSuppressWardrobeSlot);
                doUpdate = true;
            }
            if (!AreListsEqual <string>(newHides, hides))
            {
                HidesField.SetValue(target, newHides);
                doUpdate = true;
            }
            #endregion

            return(doUpdate);
        }
        private static void DrawTypeSelectionControl(Rect position, SerializedProperty property, GUIContent label, SystemTypeAttribute filter)
        {
            try
            {
                Color restoreColor          = GUI.color;
                bool  restoreShowMixedValue = EditorGUI.showMixedValue;
                bool  typeResolved          = string.IsNullOrEmpty(property.stringValue) || ResolveType(property.stringValue) != null;
                EditorGUI.showMixedValue = property.hasMultipleDifferentValues;

                GUI.color = enabledColor;

                if (typeResolved)
                {
                    property.stringValue = DrawTypeSelectionControl(position, label, property.stringValue, filter, true);
                }
                else
                {
                    if (SelectRepairedTypeWindow.WindowOpen)
                    {
                        GUI.color = disabledColor;
                        DrawTypeSelectionControl(position, label, property.stringValue, filter, false);
                    }
                    else
                    {
                        var errorContent = EditorGUIUtility.IconContent("d_console.erroricon.sml");
                        GUI.Label(new Rect(position.width, position.y, position.width, position.height), errorContent);

                        Rect dropdownPosition = new Rect(position.x, position.y, position.width - 90, position.height);
                        Rect buttonPosition   = new Rect(position.x + position.width - 75, position.y, 75, position.height);

                        property.stringValue = DrawTypeSelectionControl(dropdownPosition, label, property.stringValue, filter, false);

                        if (GUI.Button(buttonPosition, "Try Repair", EditorStyles.miniButton))
                        {
                            string typeNameWithoutAssembly  = property.stringValue.Split(new string[] { "," }, StringSplitOptions.None)[0];
                            string typeNameWithoutNamespace = System.Text.RegularExpressions.Regex.Replace(typeNameWithoutAssembly, @"[.\w]+\.(\w+)", "$1");

                            Type[] repairedTypeOptions = FindTypesByName(typeNameWithoutNamespace, filter);
                            if (repairedTypeOptions.Length > 1)
                            {
                                SelectRepairedTypeWindow.Display(repairedTypeOptions, property);
                            }
                            else if (repairedTypeOptions.Length > 0)
                            {
                                property.stringValue = SystemType.GetReference(repairedTypeOptions[0]);
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("No types found", "No types with the name '" + typeNameWithoutNamespace + "' were found.", "OK");
                            }
                        }
                    }
                }

                GUI.color = restoreColor;
                EditorGUI.showMixedValue = restoreShowMixedValue;
            }
            finally
            {
                ExcludedTypeCollectionGetter = null;
            }
        }
Exemple #15
0
    void OnGUI()
    {
        RenderLeftSide();

        GUI.enabled = !Selected;

        // Basic Settings
        GUILayout.BeginArea(new Rect(300, 0, 600, 200), "Basic Settings", EditorStyles.helpBox);
        GUILayout.Space(10);

        element.Name = EditorGUILayout.TextField("Name", element.Name);

        if (GUI.Button(new Rect(0, 40, 400, 20), "Select Picture"))
        {
            EditorGUIUtility.ShowObjectPicker <Sprite>(null, false, null, 1);
        }

        AddObject();

        if (element.Icon != null)
        {
            GUI.DrawTextureWithTexCoords(new Rect(400, 40, element.Icon.textureRect.width, element.Icon.textureRect.height), element.Icon.texture, Constant.GetTextureCoordinate(element.Icon));
        }

        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(300, 200, 600, 200), "Curves", EditorStyles.helpBox);
        GUILayout.Space(10);

        CurveUI(ref element.Data.XP, Color.white);
        CurveUI(ref element.Data.MaxHP, Color.red);
        CurveUI(ref element.Data.MaxMP, Color.blue);
        CurveUI(ref element.Data.Attack, Color.magenta);
        CurveUI(ref element.Data.Defense, Color.grey);
        CurveUI(ref element.Data.MagicAttack, Color.cyan);
        CurveUI(ref element.Data.MagicDefense, Color.grey);
        CurveUI(ref element.Data.Agility, Color.green);
        CurveUI(ref element.Data.Luck, Color.yellow);

        GUILayout.EndArea();

        // Skills
        GUILayout.BeginArea(new Rect(300, 400, 600, 180), "Skills", EditorStyles.helpBox);
        GUILayout.Space(10);

        ScrollPosition = GUILayout.BeginScrollView(ScrollPosition);
        ReorderableListGUI.ListField(element.Data.Abilities, DrawAbilityUI, ReorderableListFlags.DisableReordering);
        GUILayout.EndScrollView();
        GUILayout.EndArea();

        if (Selected)
        {
            GUI.enabled  = !Creating;
            SelectButton = GUI.Button(new Rect(300, position.height - 20, 100, 20), "Select");
            GUI.enabled  = true;
        }
        else
        {
            SaveButton   = GUI.Button(new Rect(300, 580, 100, 20), "Save");
            GUI.enabled  = !Creating;
            DeleteButton = GUI.Button(new Rect(400, 580, 100, 20), "Delete");
            GUI.enabled  = true;
        }
    }
Exemple #16
0
        private void DrawEnvironmentDetails(float currentY)
        {
            var envIdLabelLength   = 120;
            var envIdValueLength   = 260;
            var envIsDefaultLength = 50;
            var isDefaultIcon      = m_Controller.environmentIsDefault ? EditorGUIUtility.FindTexture("CollabNew") : EditorGUIUtility.FindTexture("Grid.BoxTool");

            GUI.Label(new Rect(0, currentY, envIdLabelLength, k_LineHeight), m_EnvironmentsIdContent);
            var envIdRect = new Rect(envIdLabelLength, currentY, envIdValueLength, k_LineHeight);

            EditorGUI.SelectableLabel(envIdRect, m_Controller.environmentId);
            GUI.Label(new Rect(envIdLabelLength + envIdValueLength, currentY + 1, envIsDefaultLength, 18), m_EnvironmentsIsDefaultContent);
            GUI.DrawTexture(new Rect(envIdLabelLength + envIdValueLength + envIsDefaultLength, currentY + 4, 12, 12), isDefaultIcon);
        }
        public override void OnInspectorGUI()
        {
            this.Repaint();

#if !URP
            EditorGUILayout.HelpBox("The Universal Render Pipeline v" + AssetInfo.MIN_URP_VERSION + " is not installed", MessageType.Error);
#else
            serializedObject.Update();
            windParams = Shader.GetGlobalVector("_GlobalWindParams");

            EditorGUI.BeginChangeCheck();

            StylizedGrassGUI.ParameterGroup.DrawHeader(new GUIContent("Settings"));

            using (new EditorGUILayout.VerticalScope(StylizedGrassGUI.ParameterGroup.Section))
            {
                EditorGUILayout.PropertyField(renderExtends);
                EditorGUILayout.HelpBox("Resolution: " + StylizedGrassRenderer.CalculateResolution(renderExtends.floatValue).ToString() + "px (" + StylizedGrassRenderer.TexelsPerMeter + " texels/m)", MessageType.None);
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PropertyField(maskEdges);
                    if (!Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox("Only takes effect in Play mode", MessageType.None);
                    }
                }
                EditorGUILayout.PropertyField(followSceneCamera);
                EditorGUILayout.PropertyField(followTarget);
                EditorGUILayout.Space();

                //renderLayer.intValue = EditorGUILayout.Popup("Render layer", renderLayer.intValue, layerStr);
                EditorGUILayout.PropertyField(colorMap);
                EditorGUILayout.PropertyField(listenToWindZone);
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (listenToWindZone.boolValue)
                    {
                        EditorGUILayout.PropertyField(windZone);

                        if (!windZone.objectReferenceValue)
                        {
                            if (GUILayout.Button("Create", GUILayout.MaxWidth(75f)))
                            {
                                GameObject obj = new GameObject();
                                obj.name = "Wind Zone";
                                WindZone wz = obj.AddComponent <WindZone>();

                                windZone.objectReferenceValue = wz;
                            }
                        }
                    }
                }
            }

            EditorGUILayout.Space();

            StylizedGrassGUI.ParameterGroup.DrawHeader(new GUIContent("Grass benders (" + StylizedGrassRenderer.benderCount + ")"));

            benderScrollPos = EditorGUILayout.BeginScrollView(benderScrollPos, StylizedGrassGUI.ParameterGroup.Section, GUILayout.MaxHeight(150f));
            {
                var prevColor   = GUI.color;
                var prevBgColor = GUI.backgroundColor;
                //var rect = EditorGUILayout.BeginHorizontal();

                int i = 0;

                foreach (KeyValuePair <int, List <GrassBender> > layer in StylizedGrassRenderer.GrassBenders)
                {
                    if (StylizedGrassRenderer.GrassBenders.Count > 1)
                    {
                        EditorGUILayout.LabelField("Layer " + layer.Key, EditorStyles.boldLabel);
                    }
                    foreach (GrassBender bender in layer.Value)
                    {
                        var rect = EditorGUILayout.BeginHorizontal();
                        GUI.color = i % 2 == 0 ? Color.white * 0.66f : Color.grey * (EditorGUIUtility.isProSkin ? 1.1f : 1.5f);

                        if (rect.Contains(Event.current.mousePosition))
                        {
                            GUI.color = Color.white * 0.75f;
                        }
                        if (Selection.activeGameObject == bender.gameObject)
                        {
                            GUI.color = Color.white * 0.8f;
                        }

                        EditorGUI.DrawRect(rect, GUI.color);

                        //GUILayout.Space(5);
                        GUI.color           = prevColor;
                        GUI.backgroundColor = prevBgColor;

                        if (bender.benderType == GrassBenderBase.BenderType.Mesh)
                        {
                            benderIcon = EditorGUIUtility.IconContent("MeshRenderer Icon").image;
                        }
                        if (bender.benderType == GrassBenderBase.BenderType.Trail)
                        {
                            benderIcon = EditorGUIUtility.IconContent("TrailRenderer Icon").image;
                        }
                        if (bender.benderType == GrassBenderBase.BenderType.ParticleSystem)
                        {
                            benderIcon = EditorGUIUtility.IconContent("ParticleSystem Icon").image;
                        }

                        if (GUILayout.Button(new GUIContent(" " + bender.name, benderIcon), EditorStyles.miniLabel, GUILayout.MaxHeight(20f)))
                        {
                            Selection.activeGameObject = bender.gameObject;
                        }

                        EditorGUILayout.EndHorizontal();

                        i++;
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (colorMap.objectReferenceValue)
                {
                    script.colorMap.SetActive();
                }
            }

            EditorGUILayout.LabelField("- Staggart Creations -", EditorStyles.centeredGreyMiniLabel);
#endif
        }
Exemple #18
0
        void Update()
        {
            if (m_HasError)
            {
                return;
            }

            if (PlayerSettings.colorSpace != m_ColorSpace)
            {
                graphEditorView = null;
                m_ColorSpace    = PlayerSettings.colorSpace;
            }

            if (GraphicsSettings.renderPipelineAsset != m_RenderPipelineAsset)
            {
                graphEditorView       = null;
                m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;
            }

            if (EditorGUIUtility.isProSkin != m_ProTheme)
            {
                if (graphObject != null && graphObject.graph != null)
                {
                    Texture2D icon = GetThemeIcon(graphObject.graph);

                    // This is adding the icon at the front of the tab
                    titleContent = EditorGUIUtility.TrTextContentWithIcon(assetName, icon);
                    m_ProTheme   = EditorGUIUtility.isProSkin;
                }
            }

            try
            {
                if (graphObject == null && selectedGuid != null)
                {
                    var guid = selectedGuid;
                    selectedGuid = null;
                    Initialize(guid);
                }

                if (graphObject == null)
                {
                    Close();
                    return;
                }

                var materialGraph = graphObject.graph as GraphData;
                if (materialGraph == null)
                {
                    return;
                }

                if (graphEditorView == null)
                {
                    messageManager.ClearAll();
                    materialGraph.messageManager = messageManager;
                    var asset = AssetDatabase.LoadAssetAtPath <Object>(AssetDatabase.GUIDToAssetPath(selectedGuid));
                    graphEditorView = new GraphEditorView(this, materialGraph, messageManager)
                    {
                        viewDataKey = selectedGuid,
                        assetName   = asset.name.Split('/').Last()
                    };
                    m_ColorSpace          = PlayerSettings.colorSpace;
                    m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;
                    graphObject.Validate();
                }

                if (m_ChangedFileDependencies.Count > 0 && graphObject != null && graphObject.graph != null)
                {
                    var subGraphNodes = graphObject.graph.GetNodes <SubGraphNode>();
                    foreach (var subGraphNode in subGraphNodes)
                    {
                        subGraphNode.Reload(m_ChangedFileDependencies);
                    }
                    if (subGraphNodes.Count() > 0)
                    {
                        // Keywords always need to be updated to test against variant limit
                        // No Keywords may indicate removal and this may have now made the Graph valid again
                        // Need to validate Graph to clear errors in this case
                        materialGraph.OnKeywordChanged();
                    }
                    foreach (var customFunctionNode in graphObject.graph.GetNodes <CustomFunctionNode>())
                    {
                        customFunctionNode.Reload(m_ChangedFileDependencies);
                    }

                    m_ChangedFileDependencies.Clear();
                }

                if (graphObject.wasUndoRedoPerformed)
                {
                    graphEditorView.HandleGraphChanges();
                    graphObject.graph.ClearChanges();
                    graphObject.HandleUndoRedo();
                }

                graphEditorView.HandleGraphChanges();
                graphObject.graph.ClearChanges();
            }
            catch (Exception e)
            {
                m_HasError        = true;
                m_GraphEditorView = null;
                graphObject       = null;
                Debug.LogException(e);
                throw;
            }
        }
 /// <summary>
 /// Draw the Haptic Events foldout.
 /// </summary>
 /// <seealso cref="DrawHapticEventsNested"/>
 protected virtual void DrawHapticEvents()
 {
     m_PlayHapticsOnSelectEntered.isExpanded = EditorGUILayout.Foldout(m_PlayHapticsOnSelectEntered.isExpanded, EditorGUIUtility.TrTempContent("Haptic Events"), true);
     if (m_PlayHapticsOnSelectEntered.isExpanded)
     {
         using (new EditorGUI.IndentLevelScope())
         {
             DrawHapticEventsNested();
         }
     }
 }
Exemple #20
0
        public void Initialize(string assetGuid)
        {
            try
            {
                m_ColorSpace          = PlayerSettings.colorSpace;
                m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;

                var asset = AssetDatabase.LoadAssetAtPath <Object>(AssetDatabase.GUIDToAssetPath(assetGuid));
                if (asset == null)
                {
                    return;
                }

                if (!EditorUtility.IsPersistent(asset))
                {
                    return;
                }

                if (selectedGuid == assetGuid)
                {
                    return;
                }

                var path      = AssetDatabase.GetAssetPath(asset);
                var extension = Path.GetExtension(path);
                if (extension == null)
                {
                    return;
                }
                // Path.GetExtension returns the extension prefixed with ".", so we remove it. We force lower case such that
                // the comparison will be case-insensitive.
                extension = extension.Substring(1).ToLowerInvariant();
                bool isSubGraph;
                switch (extension)
                {
                case ShaderGraphImporter.Extension:
                    isSubGraph = false;
                    break;

                case ShaderSubGraphImporter.Extension:
                    isSubGraph = true;
                    break;

                default:
                    return;
                }

                selectedGuid = assetGuid;

                var textGraph = File.ReadAllText(path, Encoding.UTF8);
                graphObject                      = CreateInstance <GraphObject>();
                graphObject.hideFlags            = HideFlags.HideAndDontSave;
                graphObject.graph                = JsonUtility.FromJson <GraphData>(textGraph);
                graphObject.graph.assetGuid      = assetGuid;
                graphObject.graph.isSubGraph     = isSubGraph;
                graphObject.graph.messageManager = messageManager;
                graphObject.graph.OnEnable();
                graphObject.graph.ValidateGraph();

                graphEditorView = new GraphEditorView(this, m_GraphObject.graph, messageManager)
                {
                    viewDataKey = selectedGuid,
                    assetName   = asset.name.Split('/').Last()
                };

                Texture2D icon = GetThemeIcon(graphObject.graph);

                // This is adding the icon at the front of the tab
                titleContent = EditorGUIUtility.TrTextContentWithIcon(asset.name.Split('/').Last(), icon);

                Repaint();
            }
            catch (Exception)
            {
                m_HasError        = true;
                m_GraphEditorView = null;
                graphObject       = null;
                throw;
            }
        }
Exemple #21
0
 protected override Rect DrawBoldLabel(Rect position, SerializedProperty property, GUIContent label) =>
 MightyGUIUtilities.MultiFieldPrefixLabel(position, label ?? EditorGUIUtility.TrTextContent(property.displayName), Columns,
                                          EditorStyles.boldLabel);
 public static bool IsResourceReady()
 {
     return(EditorGUIUtility.Load(StylePath));
 }
 public override GUIContent GetPreviewTitle() => EditorGUIUtility.TrTextContent("Planar Reflection");
Exemple #24
0
        protected override void HandleEditShapeEvents(Rect sceneRect)
        {
            if (!SceneDragToolManager.IsDraggingObjectInScene &&
                Event.current.type == EventType.Repaint)
            {
                if (visualSnappedEdges != null)
                {
                    PaintUtility.DrawLines(visualSnappedEdges.ToArray(), ToolConstants.oldThickLineScale, ColorSettings.SnappedEdges);
                }

                if (visualSnappedGrid != null)
                {
                    var _origMatrix = Handles.matrix;
                    Handles.matrix = MathConstants.identityMatrix;
                    PaintUtility.DrawDottedLines(visualSnappedGrid.ToArray(), ColorSettings.SnappedEdges);
                    Handles.matrix = _origMatrix;
                }

                if (visualSnappedBrush != null)
                {
                    var brush_cache = InternalCSGModelManager.GetBrushCache(visualSnappedBrush);
                    if (brush_cache != null &&
                        brush_cache.compareTransformation != null &&
                        brush_cache.childData != null &&
                        brush_cache.childData.ModelTransform != null &&
                        brush_cache.childData.ModelTransform)
                    {
                        var brush_translation = brush_cache.compareTransformation.modelLocalPosition + brush_cache.childData.ModelTransform.position;
                        CSGRenderer.DrawOutlines(visualSnappedBrush.brushID, brush_translation, ColorSettings.SelectedOutlines, ColorSettings.SelectedOutlines, ColorSettings.SelectedOutlines, ColorSettings.SelectedOutlines);
                    }
                }

                var origMatrix = Handles.matrix;
                Handles.matrix = MathConstants.identityMatrix;

                /*
                 * bool isValid;
                 * var realVertices		= settings.GetVertices(buildPlane, worldPosition, gridTangent, gridBinormal, out isValid);
                 * if (editMode == EditMode.EditShape)
                 *      shapeIsValid = isValid;
                 *
                 * if (realVertices.Length > 0)*/
                {
                    PaintSquare();
                    PaintRadiusMessage();
                }

                Handles.matrix = origMatrix;
            }

            HandleHeightHandles(sceneRect, false);
            for (int i = 1; i < settings.vertices.Length; i++)
            {
                var id         = settings.vertexIDs[i];
                var point_type = Event.current.GetTypeForControl(id);
                switch (point_type)
                {
                case EventType.Repaint:
                {
                    if (SceneDragToolManager.IsDraggingObjectInScene)
                    {
                        break;
                    }

                    bool isSelected = id == GUIUtility.keyboardControl;
                    var  temp       = Handles.color;
                    var  origMatrix = Handles.matrix;

                    Handles.matrix = MathConstants.identityMatrix;
                    var rotation = Camera.current.transform.rotation;


                    if (isSelected)
                    {
                        Handles.color = ColorSettings.PointInnerStateColor[3];
                    }
                    else
                    if (HandleUtility.nearestControl == id)
                    {
                        Handles.color = ColorSettings.PointInnerStateColor[1];
                    }
                    else
                    {
                        Handles.color = ColorSettings.PointInnerStateColor[0];
                    }

                    float handleSize       = CSG_HandleUtility.GetHandleSize(settings.vertices[i]);
                    float scaledHandleSize = handleSize * ToolConstants.handleScale;
                    PaintUtility.SquareDotCap(id, settings.vertices[i], rotation, scaledHandleSize);

                    Handles.matrix = origMatrix;
                    Handles.color  = temp;
                    break;
                }

                case EventType.Layout:
                {
                    if ((Tools.viewTool != ViewTool.None && Tools.viewTool != ViewTool.Pan))
                    {
                        break;
                    }

                    var origMatrix = Handles.matrix;
                    Handles.matrix = MathConstants.identityMatrix;
                    float handleSize       = CSG_HandleUtility.GetHandleSize(settings.vertices[i]);
                    float scaledHandleSize = handleSize * ToolConstants.handleScale;
                    HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(settings.vertices[i], scaledHandleSize));
                    Handles.matrix = origMatrix;

                    break;
                }

                case EventType.ValidateCommand:
                case EventType.KeyDown:
                {
                    if (GUIUtility.hotControl == id)
                    {
                        if (Keys.CancelActionKey.IsKeyPressed())
                        {
                            Event.current.Use();
                            break;
                        }
                    }
                    break;
                }

                case EventType.KeyUp:
                {
                    if (GUIUtility.hotControl == id)
                    {
                        if (Keys.CancelActionKey.IsKeyPressed())
                        {
                            GUIUtility.hotControl             = 0;
                            GUIUtility.keyboardControl        = 0;
                            EditorGUIUtility.editingTextField = false;
                            Event.current.Use();
                            break;
                        }
                    }
                    break;
                }

                case EventType.MouseDown:
                {
                    if (!sceneRect.Contains(Event.current.mousePosition))
                    {
                        break;
                    }
                    if (Tools.viewTool != ViewTool.None && Tools.viewTool != ViewTool.Pan)
                    {
                        break;
                    }
                    if (GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id && Event.current.button == 0)
                    {
                        GUIUtility.hotControl             = id;
                        GUIUtility.keyboardControl        = id;
                        EditorGUIUtility.editingTextField = false;
                        EditorGUIUtility.SetWantsMouseJumping(1);
                        Event.current.Use();
                        break;
                    }
                    break;
                }

                case EventType.MouseDrag:
                {
                    if (Tools.viewTool != ViewTool.None && Tools.viewTool != ViewTool.Pan)
                    {
                        break;
                    }
                    if (GUIUtility.hotControl == id && Event.current.button == 0)
                    {
                        Undo.RecordObject(this, "Modify shape");

                        var mouseRay      = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                        var alignedPlane  = new CSGPlane(RealtimeCSG.CSGGrid.CurrentWorkGridPlane.normal, settings.vertices[0]);
                        var worldPosition = buildPlane.Project(alignedPlane.Intersection(mouseRay));
                        if (float.IsInfinity(worldPosition.x) || float.IsNaN(worldPosition.x) ||
                            float.IsInfinity(worldPosition.y) || float.IsNaN(worldPosition.y) ||
                            float.IsInfinity(worldPosition.z) || float.IsNaN(worldPosition.z))
                        {
                            worldPosition = settings.vertices[i];
                        }

                        ResetVisuals();
                        if (snapFunction != null)
                        {
                            CSGBrush snappedOnBrush;
                            worldPosition = snapFunction(worldPosition, buildPlane, ref base.visualSnappedEdges, out snappedOnBrush, generatedBrushes);
                        }

                        base.visualSnappedGrid = RealtimeCSG.CSGGrid.FindAllGridEdgesThatTouchPoint(worldPosition);

                        settings.vertices[i] = worldPosition;
                        if (editMode == EditMode.ExtrudeShape)
                        {
                            StartExtrudeMode();
                        }
                        UpdateBaseShape();
                        UpdateExtrudedShape();

                        GUI.changed = true;
                        Event.current.Use();
                        break;
                    }
                    break;
                }

                case EventType.MouseUp:
                {
                    if (GUIUtility.hotControl != id)
                    {
                        break;
                    }
                    if (Tools.viewTool != ViewTool.None && Tools.viewTool != ViewTool.Pan)
                    {
                        break;
                    }
                    if (Event.current.button == 0)
                    {
                        GUIUtility.hotControl             = 0;
                        GUIUtility.keyboardControl        = 0;
                        EditorGUIUtility.editingTextField = false;
                        EditorGUIUtility.SetWantsMouseJumping(0);
                        Event.current.Use();

                        ResetVisuals();
                        if (RadiusA == 0)
                        {
                            Cancel();
                        }
                        break;
                    }
                    break;
                }
                }
            }
        }
Exemple #25
0
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>

    public override void OnInspectorGUI()
    {
        UIPanel panel = target as UIPanel;
        BetterList <UIDrawCall> drawcalls = panel.drawCalls;

        EditorGUIUtility.LookLikeControls(80f);

        //NGUIEditorTools.DrawSeparator();
        EditorGUILayout.Space();

        float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f);

        if (alpha != panel.alpha)
        {
            NGUIEditorTools.RegisterUndo("Panel Alpha", panel);
            panel.alpha = alpha;
        }

        if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool))
        {
            panel.showInPanelTool = !panel.showInPanelTool;
            EditorUtility.SetDirty(panel);
            EditorWindow.FocusWindowIfItsOpen <UIPanelTool>();
        }

        GUILayout.BeginHorizontal();
        bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f));

        GUILayout.Label("Needed for lit shaders");
        GUILayout.EndHorizontal();

        if (panel.generateNormals != norms)
        {
            panel.generateNormals = norms;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        GUILayout.BeginHorizontal();
        bool depth = EditorGUILayout.Toggle("Depth Pass", panel.depthPass, GUILayout.Width(100f));

        GUILayout.Label("Doubles draw calls, saves fillrate");
        GUILayout.EndHorizontal();

        if (panel.depthPass != depth)
        {
            panel.depthPass = depth;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        if (depth)
        {
            UICamera cam = UICamera.FindCameraForLayer(panel.gameObject.layer);

            if (cam == null || cam.GetComponent <Camera>().orthographic)
            {
                EditorGUILayout.HelpBox("Please note that depth pass will only save fillrate when used with 3D UIs, and only UIs drawn by the game camera. If you are using a separate camera for the UI, you will not see any benefit!", MessageType.Warning);
            }
        }

        GUILayout.BeginHorizontal();
        bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f));

        GUILayout.Label("Check if widgets won't move");
        GUILayout.EndHorizontal();

        if (panel.widgetsAreStatic != stat)
        {
            panel.widgetsAreStatic = stat;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString());
        EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString());

        UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo);

        if (panel.debugInfo != di)
        {
            panel.debugInfo = di;
            EditorUtility.SetDirty(panel);
        }

        UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping);

        if (panel.clipping != clipping)
        {
            panel.clipping = clipping;
            EditorUtility.SetDirty(panel);
        }

        if (panel.clipping != UIDrawCall.Clipping.None)
        {
            Vector4 range = panel.clipRange;

            GUILayout.BeginHorizontal();
            GUILayout.Space(80f);
            Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(80f);
            Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w));
            GUILayout.EndHorizontal();

            if (size.x < 0f)
            {
                size.x = 0f;
            }
            if (size.y < 0f)
            {
                size.y = 0f;
            }

            range.x = pos.x;
            range.y = pos.y;
            range.z = size.x;
            range.w = size.y;

            if (panel.clipRange != range)
            {
                NGUIEditorTools.RegisterUndo("Clipping Change", panel);
                panel.clipRange = range;
                EditorUtility.SetDirty(panel);
            }

            if (panel.clipping == UIDrawCall.Clipping.SoftClip)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(80f);
                Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness);
                GUILayout.EndHorizontal();

                if (soft.x < 1f)
                {
                    soft.x = 1f;
                }
                if (soft.y < 1f)
                {
                    soft.y = 1f;
                }

                if (panel.clipSoftness != soft)
                {
                    NGUIEditorTools.RegisterUndo("Clipping Change", panel);
                    panel.clipSoftness = soft;
                    EditorUtility.SetDirty(panel);
                }
            }

#if UNITY_ANDROID || UNITY_IPHONE
            if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x)
            {
                EditorGUILayout.HelpBox("Clipping requires shader support!\n\nOpen File -> Build Settings -> Player Settings -> Other Settings, then set:\n\n- Graphics Level: OpenGL ES 2.0.", MessageType.Error);
            }
#endif
        }

        if (clipping == UIDrawCall.Clipping.HardClip)
        {
            EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning);
        }

        if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale))
        {
            EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);

            if (GUILayout.Button("Auto-fix"))
            {
                NGUIEditorTools.FixUniform(panel.gameObject);
            }
        }

        foreach (UIDrawCall dc in drawcalls)
        {
            NGUIEditorTools.DrawSeparator();
            EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false);
            EditorGUILayout.LabelField("Triangles", dc.triangles.ToString());

            if (clipping != UIDrawCall.Clipping.None && !dc.isClipped)
            {
                EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.",
                                        MessageType.Warning);
            }
        }
    }
Exemple #26
0
 public override Texture LoadImage()
 {
     return((Texture)EditorGUIUtility.LoadRequired("MegaFiers\\twist_help.png"));
 }
Exemple #27
0
    public void DropAreaGUI(int i)
    {
        if (sprites == null)
        {
            return;                          //Failsafe
        }
        Event  evt            = Event.current;
        Rect   dropRect       = GUILayoutUtility.GetRect(spriteSize, spriteSize, GUILayout.ExpandWidth(false));
        Sprite selectedSprite = sprites[i];

        if (selectedSprite == null)
        {
            Debug.LogError("Missing TileTool2D editor texture... aborting Tile2D Wizard");
            return;             //Failsafe
        }
        if (tile && toggleView)
        {
            Sprite[] arr = (Sprite[])tile.GetType().GetField("tile" + SpriteNumberToName(i)).GetValue(tile);
            if (arr != null && arr.Length > 0)
            {
                selectedSprite = arr[0];
            }
        }
        if (selectedSprite != null)
        {
            Rect texCoords = new Rect(selectedSprite.textureRect.x / selectedSprite.texture.width,
                                      selectedSprite.textureRect.y / selectedSprite.texture.height,
                                      selectedSprite.textureRect.width / selectedSprite.texture.width,
                                      selectedSprite.textureRect.height / selectedSprite.texture.height);
            GUI.DrawTextureWithTexCoords(dropRect, selectedSprite.texture, texCoords);
        }
        switch (evt.type)
        {
        case EventType.MouseDown:
        case EventType.DragUpdated:
        case EventType.DragPerform:
            if (!dropRect.Contains(evt.mousePosition))
            {
                return;
            }
            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            if (evt.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();
                Undo.RegisterCompleteObjectUndo(tile.gameObject, "TileTool 2D Wizard");
                int l = 0;
                preCurrentSprite = i;
                currentSprite    = -1;
                foreach (UnityEngine.Object dragged_object in DragAndDrop.objectReferences)
                {
                    if (dragged_object.GetType() == typeof(Sprite))
                    {
                        l++;
                    }
                }
                if (l == 0)
                {
                    return;
                }
                Sprite[] arr = (Sprite[])tile.GetType().GetField("tile" + SpriteNumberToName(i)).GetValue(tile);
                NewArray("tile" + SpriteNumberToName(i), l, tile);
                arr = (Sprite[])tile.GetType().GetField("tile" + SpriteNumberToName(i)).GetValue(tile);

                int n = 0;
                foreach (UnityEngine.Object dragged_object in DragAndDrop.objectReferences)
                {
                    if (dragged_object.GetType() == typeof(Sprite))
                    {
                        //toggleView = true;
                        arr[n] = (Sprite)dragged_object;
                        ReplaceDefaultSprite();
                        n++;
                    }
                }
                EditorUtility.SetDirty(tile);
            }
            if (evt.type == EventType.MouseDown)
            {
                if (dropRect.Contains(evt.mousePosition))
                {
                    Sprite[] arrr = (Sprite[])tile.GetType().GetField("tile" + SpriteNumberToName(i)).GetValue(tile);
                    if (arrr != null && arrr.Length > 0 && i == currentSprite)
                    {
                        EditorGUIUtility.PingObject(arrr[0]);
                    }
                    preCurrentSprite = i;
                    Repaint();
                }
            }
            break;
        }
    }
Exemple #28
0
	void DrawAssetList(Rect position, BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
	{

		if (list != null)
		{
			if (_searchResults != null && _searchResults.Length == 0)
			{
				DrawCentralMessage(position, "No search results");
				return;
			}

			BuildReportTool.SizePart[] assetListToUse;

			var hasSearchResults = _searchResults != null;

			if (hasSearchResults && _searchResults.Length > 0)
			{
				assetListToUse = _searchResults;
			}
			else
			{
				assetListToUse = list.GetListToDisplay(filter);
			}

			if (assetListToUse != null)
			{
				if (assetListToUse.Length == 0)
				{
					GUILayout.BeginHorizontal();
					GUILayout.Space(10);
					GUILayout.Label(Labels.NO_FILES_FOR_THIS_CATEGORY_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME);
					GUILayout.EndHorizontal();
				}
				else
				{
					EditorGUIUtility.SetIconSize(Vector2.one * ICON_DISPLAY_SIZE);
					bool useAlt = false;

					int viewOffset = list.GetViewOffsetForDisplayedList(filter);

					// if somehow view offset was out of bounds of the SizePart[] array
					// reset it to zero
					if (viewOffset >= assetListToUse.Length)
					{
						list.SetViewOffsetForDisplayedList(filter, 0);
						viewOffset = 0;
					}

					int len = Mathf.Min(viewOffset + length, assetListToUse.Length);




					GUILayout.BeginHorizontal();

					
					// --------------------------------------------------------------------------------------------------------
					// column: asset path and name
					GUILayout.BeginVertical();
						useAlt = false;

						//GUILayout.Box("", BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME, GUILayout.Height(LIST_HEIGHT), GUILayout.Width(position.width));

						GUILayout.BeginHorizontal();


						string sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
						if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFullPath)
						{
							if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
							{
								sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
							}
							else
							{
								sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
							}
						}
						if ( GUILayout.Button("Asset Path", sortTypeAssetFullPathStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults )
						{
							list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFullPath);
						}


						string sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
						if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFilename)
						{
							if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
							{
								sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
							}
							else
							{
								sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
							}
						}
						if (GUILayout.Button("Asset Filename", sortTypeAssetFilenameStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults)
						{
							list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFilename);
						}
						GUILayout.EndHorizontal();


						// --------------------------------------------------------------------------------------------------------

						_assetListScrollPos = GUILayout.BeginScrollView(_assetListScrollPos, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME);

						for (int n = viewOffset; n < len; ++n)
						{
							BuildReportTool.SizePart b = assetListToUse[n];

							string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_SMALL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_SMALL_STYLE_NAME;
							bool inSumSelect = list.InSumSelection(b);
							if (inSumSelect)
							{
								styleToUse = BuildReportTool.Window.Settings.LIST_SMALL_SELECTED_NAME;
							}

							GUILayout.BeginHorizontal();

								if (b.Name.StartsWith("Assets/"))
								{
									if (GUILayout.Button("Ping", GUILayout.Width(37)))
									{
										Utility.PingAssetInProject(b.Name);
									}
								}
								else
								{
									GUILayout.Space(37);
								}
								

								// the asset name
								Texture icon = AssetDatabase.GetCachedIcon(b.Name);

								string prettyName = string.Empty;

								prettyName = string.Format(" {0}. <color=#{1}>{2}{3}</color><b>{4}</b>", (n+1), GetPathColor(inSumSelect), BuildReportTool.Util.GetAssetPath(b.Name), BuildReportTool.Util.GetAssetPathToNameSeparator(b.Name), BuildReportTool.Util.GetAssetFilename(b.Name));




								GUIStyle styleObjToUse = GUI.skin.GetStyle(styleToUse);
								Color temp = styleObjToUse.normal.textColor;
								int origLeft = styleObjToUse.padding.left;
								int origRight = styleObjToUse.padding.right;

								styleObjToUse.normal.textColor = styleObjToUse.onNormal.textColor;
								styleObjToUse.padding.right = 0;

								if (icon == null)
								{
									//GUILayout.BeginHorizontal(styleObjToUse);
									GUILayout.Space(24);
									//GUILayout.EndHorizontal();
								}

								styleObjToUse.normal.textColor = temp;
								styleObjToUse.padding.left = 2;
								if (GUILayout.Button(new GUIContent(prettyName, icon), styleObjToUse, GUILayout.Height(LIST_HEIGHT)))
								{
									if (Event.current.control)
									{
										if (!inSumSelect)
										{
											list.AddToSumSelection(b);
											_lastClickedEntryIdx = n;
										}
										else
										{
											list.ToggleSumSelection(b);
											_lastClickedEntryIdx = -1;
										}
									}
									else if (Event.current.shift)
									{
										if (_lastClickedEntryIdx != -1)
										{
											// select all from last clicked to here
											if (_lastClickedEntryIdx < n)
											{
												for (int addToSelectIdx = _lastClickedEntryIdx; addToSelectIdx <= n; ++addToSelectIdx)
												{
													list.AddToSumSelection(assetListToUse[addToSelectIdx]);
												}
											}
											else if (_lastClickedEntryIdx > n)
											{
												for (int addToSelectIdx = n; addToSelectIdx <= _lastClickedEntryIdx; ++addToSelectIdx)
												{
													list.AddToSumSelection(assetListToUse[addToSelectIdx]);
												}
											}
										}
										else
										{
											list.AddToSumSelection(b);
										}

										_lastClickedEntryIdx = n;
									}
									else
									{
										list.ClearSelection();
										list.AddToSumSelection(b);
										_lastClickedEntryIdx = n;
									}
									
								}
								styleObjToUse.padding.right = origRight;
								styleObjToUse.padding.left = origLeft;


							GUILayout.EndHorizontal();

							useAlt = !useAlt;
						}

						
						GUILayout.Space(SCROLLBAR_BOTTOM_PADDING);

						GUILayout.EndScrollView();
						
					GUILayout.EndVertical();
					



					bool pressedRawSizeSortBtn = false;
					bool pressedImpSizeSortBtn = false;
					
					bool pressedSizeBeforeBuildSortBtn = false;

					// --------------------------------------------------------------------------------------------------------
					// column: raw file size

					
					if (IsShowingUsedAssets && (assetListToUse[0].SizeInAssetsFolderBytes != -1))
					{
						pressedSizeBeforeBuildSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.SizeBeforeBuild, "Size Before Build   ", !hasSearchResults, false,
							list, assetListToUse, (b) => b.SizeInAssetsFolder, ref _assetListScrollPos);
					}

					if (IsShowingUsedAssets && BuildReportTool.Options.ShowImportedSizeForUsedAssets)
					{
						pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSizeOrRawSize, "Size In Build", !hasSearchResults, false,
							list, assetListToUse, (b) =>
							{
								// assets in the "StreamingAssets" folder do not have an imported size
								// in those cases, the raw size is the same as the imported size
								// so just use the raw size
								if (b.ImportedSize == "N/A")
								{
									return b.RawSize;
								}

								return b.ImportedSize;
							}, ref _assetListScrollPos);
					}
					
					if (IsShowingUnusedAssets || (IsShowingUsedAssets && !BuildReportTool.Options.ShowImportedSizeForUsedAssets))
					{
						pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.RawSize, (IsShowingUnusedAssets ? "Raw Size" : "Size In Build"), !hasSearchResults, false,
							list, assetListToUse, (b) => b.RawSize, ref _assetListScrollPos);
					}


					bool showScrollbarForImportedSize = IsShowingUnusedAssets;
					

					// --------------------------------------------------------------------------------------------------------
					// column: imported file size


					if (IsShowingUnusedAssets)
					{
						pressedImpSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSize, "Imported Size   ", !hasSearchResults, showScrollbarForImportedSize,
							list, assetListToUse, (b) => b.ImportedSize, ref _assetListScrollPos);
					}

					
					// --------------------------------------------------------------------------------------------------------
					// column: percentage to total size
					
					bool pressedPercentSortBtn = false;

					if (IsShowingUsedAssets)
					{
						pressedPercentSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.PercentSize, "Percent   ", !hasSearchResults, true,
							list, assetListToUse, (b) => {

								string text = b.Percentage + "%";
								if (b.Percentage < 0)
								{
									text = Labels.NON_APPLICABLE_PERCENTAGE_LABEL;
								}
								return text;

							}, ref _assetListScrollPos);
					}
					
					// --------------------------------------------------------------------------------------------------------

					if (!hasSearchResults)
					{
						if (pressedRawSizeSortBtn)
						{
							var sortType = BuildReportTool.AssetList.SortType.RawSize;
							if (IsShowingUsedAssets && BuildReportTool.Options.ShowImportedSizeForUsedAssets)
							{
								sortType = BuildReportTool.AssetList.SortType.ImportedSizeOrRawSize;
							}
							list.ToggleSort(sortType);
						}
						else if (pressedSizeBeforeBuildSortBtn)
						{
							list.ToggleSort(BuildReportTool.AssetList.SortType.SizeBeforeBuild);
						}
						else if (pressedImpSizeSortBtn)
						{
							list.ToggleSort(BuildReportTool.AssetList.SortType.ImportedSize);
						}
						else if (pressedPercentSortBtn)
						{
							list.ToggleSort(BuildReportTool.AssetList.SortType.PercentSize);
						}
					}


					GUILayout.EndHorizontal();
				}
			}
		}
	}
Exemple #29
0
    static void GUI_Inlcudes()
    {
        if (currentBundle.includeGUIDs.Count > 0)
        {
#if !(UNITY_4_2 || UNITY_4_1 || UNITY_4_0)
            m_FoldoutIncludes = EditorGUILayout.Foldout(m_FoldoutIncludes, "INCLUDE", BMGUIStyles.GetStyle("CFoldout"));
#else
            m_FoldoutIncludes = EditorGUILayout.Foldout(m_FoldoutIncludes, "INCLUDE");
#endif
        }
        else
        {
            GUILayout.Label("INCLUDE", BMGUIStyles.GetStyle("UnfoldableTitle"));
        }

        if (!m_FoldoutIncludes)
        {
            return;
        }

        EditorGUILayout.BeginVertical();
        {
            foreach (var guid in currentBundle.includeGUIDs)
            {
                string         assetPath           = AssetDatabase.GUIDToAssetPath(guid);
                bool           isCurrentPathSelect = m_CurSelectAsset == guid && !m_IsMetaListSelect;
                AssetItemState itemState           = GUI_AssetItem(assetPath, isCurrentPathSelect, GetSharedIconOfInlucde(guid));
                if (itemState != AssetItemState.None)
                {
                    if (!isCurrentPathSelect)
                    {
                        m_IsMetaListSelect = false;
                        m_CurSelectAsset   = guid;
                    }
                    else if (itemState != AssetItemState.RClicked)                    // Only left click can disable selection
                    {
                        if (EditorApplication.timeSinceStartup - m_LastClickTime < 2f)
                        {
                            // Double clicked
                            EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)));
                        }
                        else
                        {
                            m_CurSelectAsset = "";
                        }
                    }

                    m_LastClickTime = EditorApplication.timeSinceStartup;
                    Refresh();

                    // Right click
                    if (itemState == AssetItemState.RClicked)
                    {
                        GenericMenu rightClickMenu = new GenericMenu();
                        rightClickMenu.AddItem(new GUIContent("Delete"), false, GUI_DeleteMenuCallback);
                        rightClickMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
                    }
                }
            }
        } EditorGUILayout.EndVertical();
    }
        private void SinglePassStereoGUI(BuildTargetGroup targetGroup, SerializedProperty stereoRenderingPath)
        {
            if (!PlayerSettings.virtualRealitySupported)
                return;

            bool supportsMultiPass = IsStereoRenderingModeSupported(targetGroup, StereoRenderingPath.MultiPass);
            bool supportsSinglePass = IsStereoRenderingModeSupported(targetGroup, StereoRenderingPath.SinglePass);
            bool supportsSinglePassInstanced = IsStereoRenderingModeSupported(targetGroup, StereoRenderingPath.Instancing);

            // populate the dropdown with the valid options based on target platform.
            int multiPassAndSinglePass = 2;
            int validStereoRenderingOptionsCount = multiPassAndSinglePass + (supportsSinglePassInstanced ? 1 : 0);
            var validStereoRenderingPaths = new GUIContent[validStereoRenderingOptionsCount];
            var validStereoRenderingValues = new int[validStereoRenderingOptionsCount];

            GUIContent[] stereoRenderingPaths = GetStereoRenderingPaths(targetGroup);

            int addedStereoRenderingOptionsCount = 0;
            validStereoRenderingPaths[addedStereoRenderingOptionsCount] = stereoRenderingPaths[(int)StereoRenderingPath.MultiPass];
            validStereoRenderingValues[addedStereoRenderingOptionsCount++] = (int)StereoRenderingPath.MultiPass;

            validStereoRenderingPaths[addedStereoRenderingOptionsCount] = stereoRenderingPaths[(int)StereoRenderingPath.SinglePass];
            validStereoRenderingValues[addedStereoRenderingOptionsCount++] = (int)StereoRenderingPath.SinglePass;

            if (supportsSinglePassInstanced)
            {
                validStereoRenderingPaths[addedStereoRenderingOptionsCount] = stereoRenderingPaths[(int)StereoRenderingPath.Instancing];
                validStereoRenderingValues[addedStereoRenderingOptionsCount++] = (int)StereoRenderingPath.Instancing;
            }

            // setup fallbacks
            if (!supportsMultiPass && (stereoRenderingPath.intValue == (int)StereoRenderingPath.MultiPass))
            {
                stereoRenderingPath.intValue = (int)StereoRenderingPath.SinglePass;
                m_ShowMultiPassSRPInfoBox = true;
            }

            if (!supportsSinglePassInstanced && (stereoRenderingPath.intValue == (int)StereoRenderingPath.Instancing))
                stereoRenderingPath.intValue = (int)StereoRenderingPath.SinglePass;

            if (!supportsSinglePass && (stereoRenderingPath.intValue == (int)StereoRenderingPath.SinglePass))
                stereoRenderingPath.intValue = (int)StereoRenderingPath.MultiPass;

            if (m_ShowMultiPassSRPInfoBox)
                EditorGUILayout.HelpBox(Styles.multiPassNotSupportedWithSRP.text, MessageType.Info);

            var rect = EditorGUILayout.GetControlRect();
            EditorGUI.BeginProperty(rect, EditorGUIUtility.TrTextContent("Stereo Rendering Mode*"), stereoRenderingPath);
            rect = EditorGUI.PrefixLabel(rect, EditorGUIUtility.TrTextContent("Stereo Rendering Mode*"));

            int index = Math.Max(0, Array.IndexOf(validStereoRenderingValues, stereoRenderingPath.intValue));
            if (EditorGUI.DropdownButton(rect, validStereoRenderingPaths[index], FocusType.Passive))
            {
                var menu = new GenericMenu();
                for (int i = 0; i < validStereoRenderingValues.Length; i++)
                {
                    int value = validStereoRenderingValues[i];
                    bool selected = (value == stereoRenderingPath.intValue);

                    if (!IsStereoRenderingModeSupported(targetGroup, (StereoRenderingPath)value))
                        menu.AddDisabledItem(validStereoRenderingPaths[i], selected);
                    else
                        menu.AddItem(validStereoRenderingPaths[i], selected, (object userData) => { OnStereoModeSelected(stereoRenderingPath, userData); }, value);
                }
                menu.DropDown(rect);
            }
            EditorGUI.EndProperty();

            if ((stereoRenderingPath.intValue == (int)StereoRenderingPath.SinglePass) && (targetGroup == BuildTargetGroup.Android))
            {
                var apisAndroid = PlayerSettings.GetGraphicsAPIs(BuildTarget.Android);
                if ((apisAndroid.Length > 0) && (apisAndroid[0] == GraphicsDeviceType.OpenGLES3))
                {
                    if (supportsMultiPass)
                    {
                        EditorGUILayout.HelpBox(Styles.singlepassAndroidWarning2.text, MessageType.Info);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(Styles.singlepassAndroidWarning3.text, MessageType.Info);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox(Styles.singlepassAndroidWarning.text, MessageType.Warning);
                }
            }
            else if ((stereoRenderingPath.intValue == (int)StereoRenderingPath.Instancing) && (targetGroup == BuildTargetGroup.Standalone))
            {
                EditorGUILayout.HelpBox(Styles.singlePassInstancedWarning.text, MessageType.Warning);
            }

            m_Settings.serializedObject.ApplyModifiedProperties();
        }