Example #1
0
        public override void OnInspectorGUI()
        {
            sobject.Update();

            DrawPreInspectorGUI();

            if (drawOffset)
            {
                // Draw the transform offset editor
                GUILayout.Label("Offset", EditorStyles.boldLabel);
                if (targets != null && targets.Length > 1)
                {
                    // Multiple object editing not supported
                    EditorGUILayout.HelpBox("Multiple Objects selected", MessageType.Info);
                }
                else
                {
                    var node = target as PlaceableNode;
                    InspectorUtils.DrawMatrixProperty("Offset", ref node.offset);
                    GUILayout.Space(CATEGORY_SPACING);
                }
            }

            if (drawAttachments)
            {
                // Draw the attachment properties
                GUILayout.Label("Attachment", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(AttachmentProbability, new GUIContent("Probability"));
                EditorGUILayout.PropertyField(ConsumeOnAttach);
                GUILayout.Space(CATEGORY_SPACING);


                // Clamp the probability to [0..1]
                if (!AttachmentProbability.hasMultipleDifferentValues)
                {
                    AttachmentProbability.floatValue = Mathf.Clamp01(AttachmentProbability.floatValue);
                }
            }

            DrawPostInspectorGUI();

            sobject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                if (target is GraphNode)
                {
                    var node = target as GraphNode;
                    if (node.Graph != null)
                    {
                        node.Graph.NotifyStateChanged();
                    }
                }
            }
            base.OnInspectorGUI();
        }
Example #2
0
        protected override void HandleInspectorGUI()
        {
            DrawPreInspectorGUI();

            if (drawOffset)
            {
                // Draw the transform offset editor
                GUILayout.Label("Offset", EditorStyles.boldLabel);
                if (targets != null && targets.Length > 1)
                {
                    // Multiple object editing not supported
                    EditorGUILayout.HelpBox("Multiple Objects selected", MessageType.Info);
                }
                else
                {
                    var node = target as PlaceableNode;
                    InspectorUtils.DrawMatrixProperty("Offset", ref node.offset);
                    GUILayout.Space(CATEGORY_SPACING);
                }
            }

            if (drawAttachments)
            {
                // Draw the attachment properties
                GUILayout.Label("Attachment", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(AttachmentProbability, new GUIContent("Probability"));
                EditorGUILayout.PropertyField(ConsumeOnAttach);
                GUILayout.Space(CATEGORY_SPACING);


                // Clamp the probability to [0..1]
                if (!AttachmentProbability.hasMultipleDifferentValues)
                {
                    AttachmentProbability.floatValue = Mathf.Clamp01(AttachmentProbability.floatValue);
                }
            }

            DrawPostInspectorGUI();
        }