Example #1
0
 public override void OnInspectorGUI()
 {
     EditorGUI.BeginDisabledGroup(true);
     EditorGUILayout.ObjectField(new GUIContent("Script"), MonoScript.FromMonoBehaviour((EventConditions)target), typeof(EventConditions), true);
     EditorGUI.EndDisabledGroup();
     serializedObject.Update();
     EditorGUILayout.PropertyField(constantCheck);
     if (GUI.changed && EditorApplication.isPlaying)
     {
         serializedObject.ApplyModifiedProperties();
         (serializedObject.targetObject as EventConditions).constantCheck = constantCheck.boolValue;
         GUI.changed = false;
     }
     EditorGUILayout.DelayedFloatField(checkRate);
     if (GUI.changed && EditorApplication.isPlaying)
     {
         serializedObject.ApplyModifiedProperties();
         (serializedObject.targetObject as EventConditions).checkRate = checkRate.floatValue;
         GUI.changed = false;
     }
     GUILayout.Space(2);
     conditionList.DoLayoutList();
     EditorTool.AddSpecialSpace(0);
     EditorGUILayout.PropertyField(satisfiedEvent);
     EditorGUILayout.PropertyField(unsatisfiedEvent);
     serializedObject.ApplyModifiedProperties();
 }
Example #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(_lockCursor, new GUIContent("Lock Cursor"));
        if (GUI.changed)
        {
            serializedTarget.lockCursor = _lockCursor.boolValue;
        }
        EditorGUILayout.PropertyField(lockToTransform);
        GUILayout.EndHorizontal();
        EditorTool.AddSpecialSpace(0);
        EditorGUILayout.LabelField("Movement Settings", new GUIStyle("BoldLabel"));
        EditorGUI.indentLevel++;
        EditorTool.MakeMinMaxSlider(minDistance, maxDistance, 0, 100, "Distance Clamp");
        EditorGUILayout.Slider(currentDistance, minDistance.floatValue, maxDistance.floatValue);
        EditorGUILayout.Slider(collisionMargin, -(maxDistance.floatValue - minDistance.floatValue) / 2, (maxDistance.floatValue - minDistance.floatValue) / 2);
        EditorGUILayout.PropertyField(collisionMask);
        EditorGUILayout.Slider(zoomSpeed, -25, 25);
        EditorGUILayout.Slider(movementSmoothness, 0f, 1, "Smoothness");
        EditorGUI.indentLevel--;
        EditorTool.AddSpecialSpace(0);
        EditorGUILayout.LabelField("Rotation Settings", new GUIStyle("BoldLabel"));
        Vector3 rotations = new Vector3(pitch.floatValue, yaw.floatValue, roll.floatValue);
        Rect buttonRect   = GUILayoutUtility.GetLastRect();

        buttonRect.x += EditorGUIUtility.labelWidth; buttonRect.width -= EditorGUIUtility.labelWidth;
        if (GUI.Button(buttonRect, "Calculate Initial Rotation"))
        {
            if (objective.objectReferenceValue != null)
            {
                var objectiveTransform = objective.objectReferenceValue as Transform;
                var rotation           = serializedTarget.transform.rotation;
                serializedTarget.transform.LookAt(objectiveTransform.position + objectiveOffset.vector3Value);
                rotations = serializedTarget.transform.rotation.eulerAngles;
                serializedTarget.transform.rotation = rotation;
                pitch.floatValue = rotations.x; yaw.floatValue = rotations.y; roll.floatValue = rotations.z;
            }
        }
        EditorGUI.indentLevel++;
        EditorTool.MakeMinMaxSlider(minPitch, maxPitch, -180, 180, "Pitch Clamp");
        rotationSpeed.vector3Value = EditorGUILayout.Vector3Field(rotationSpeed.displayName, rotationSpeed.vector3Value);
        rotations = EditorGUILayout.Vector3Field("Rotations", rotations);
        if (GUI.changed)
        {
            pitch.floatValue = rotations.x; yaw.floatValue = rotations.y; roll.floatValue = rotations.z;
        }
        EditorGUILayout.Slider(rotationSmoothness, 0f, 0.5f, "Smoothness");
        GUI.enabled = objective.objectReferenceValue;
        GUI.enabled = true;
        EditorGUI.indentLevel--;

        serializedObject.ApplyModifiedProperties();
    }