Ejemplo n.º 1
0
        /// <summary>
        /// Handles rendering a variable that is considered a 'built-in' supported
        /// type
        /// </summary>
        /// <param name="serializedVar">The serialized representation of the variable</param>
        /// <param name="rect">The rect to render in</param>
        /// <param name="index">The index of the item in the list</param>
        /// <param name="isActive">True if the element is active, false if not</param>
        /// <param name="isSelected">True if the element is selected, false if not</param>
        private void RenderBuiltInVariable(SerializedSceneVariable serializedVar,
                                           Rect rect, int index, bool isSelected)
        {
            SerializedObject serializedValue = serializedVar.GetSerializedValue();

            SerializedProperty activeValueProp = serializedValue.FindProperty("DefaultValue");

            if (EditorApplication.isPlaying)
            {
                activeValueProp = serializedValue.FindProperty("currentValue");
            }

            Rect nameRect = new Rect(rect);

            nameRect.width = EditorGUIUtility.labelWidth;

            RenderVariableName(nameRect, serializedVar.NameProp, index, isSelected);

            Rect refreshToggleRect = new Rect(rect);

            refreshToggleRect.xMin  = nameRect.xMax + 2f;
            refreshToggleRect.width = 20f;

            RenderRefreshToggle(refreshToggleRect, serializedVar);

            Rect valueRect = new Rect(rect);

            valueRect.xMin = refreshToggleRect.xMax + 2f;

            EditorGUI.BeginChangeCheck();

            EditorGUI.PropertyField(valueRect, activeValueProp, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                serializedValue.ApplyModifiedProperties();
            }
        }