Exemplo n.º 1
0
        /// <summary>
        /// Updates the settings of a custom editor.
        /// </summary>
        /// <param name="_TargetType">The new target type of the custom editor.</param>
        /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor.</param>
        /// <param name="_DefaultOptions">The default options to use for the custom editor.</param>
        public void Update(Type _TargetType, MultipleEditorsManager.CreateEditorDelegate _CreateEditorMethod, CustomEditorExtensionOptions _DefaultOptions)
        {
            TargetType = _TargetType;
            if (m_Order == m_DefaultOptions.defaultOrder)
            {
                m_Order = _DefaultOptions.defaultOrder;
            }
            m_DefaultOptions = _DefaultOptions;

            CreateEditorMethod = _CreateEditorMethod;
        }
 /// <summary>
 /// Registers this custom editor with the manager to make it available for multiple editors system.
 /// </summary>
 /// <param name="_CreateEditorMethod">The method to use for creating an instance of this custom editor extension. For example if
 /// your custom editor class name is "TestEditorExtension", you can use:
 /// RegisterCustomEditor(() => { return new TestEditorExtension(); });</param>
 /// <param name="_Options">The options and default values to use for the CustomEditorExtension instance.</param>
 protected static void RegisterCustomEditor(MultipleEditorsManager.CreateEditorDelegate _CreateEditorMethod, CustomEditorExtensionOptions _Options)
 {
     MultipleEditorsManager.RegisterCustomEditor <TTarget>(_CreateEditorMethod, _Options);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an instance of CustomEditorExtensionSettings.
        /// </summary>
        /// <param name="_TargetType">The target type of the custom editor.</param>
        /// <param name="_CustomEditorType">The custom editor type.</param>
        /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor.</param>
        /// <param name="_DefaultOptions">The default options to use for the custom editor.</param>
        public CustomEditorExtensionSettings(Type _TargetType, Type _CustomEditorType, MultipleEditorsManager.CreateEditorDelegate _CreateEditorMethod, CustomEditorExtensionOptions _DefaultOptions)
        {
            CustomEditorType          = _CustomEditorType;
            m_Order                   = _DefaultOptions.defaultOrder;
            m_RequiresConstantRepaint = _DefaultOptions.requiresConstantRepaint;

            Update(_TargetType, _CreateEditorMethod, _DefaultOptions);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Registers a CustomEditorExtension that customizes the inspector of the given target type.
 /// </summary>
 /// <typeparam name="TTarget">The type of the decorated Object.</typeparam>
 /// <param name="_CustomEditorCreator">The method to use to instantiate a CustomObectEditor.</param>
 /// <param name="_Options">The options and default values to use for the CustomEditorExtension.</param>
 /// <returns>Returns true if the CustomEditorExtension has successfully been registered, otherwise false.</returns>
 public static bool RegisterCustomEditor <TTarget>(CreateEditorDelegate _CustomEditorCreator, CustomEditorExtensionOptions _Options)
     where TTarget : Object
 {
     Instance.AddOrUpdateCustomEditorSettings <TTarget>(_CustomEditorCreator, _Options);
     return(true);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a new settings entry in the list, or update an existing one.
        /// </summary>
        /// <param name="_TargetType">The target type of the custom editor.</param>
        /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor extension.</param>
        /// <param name="_DefaultOptions">The default options to use for the custom editor extension.</param>
        /// <returns>Returns the created settings.</returns>
        private CustomEditorExtensionSettings AddOrUpdateCustomEditorSettings(CreateEditorDelegate _CreateEditorMethod, Type _TargetType, CustomEditorExtensionOptions _DefaultOptions)
        {
            Type customEditorType = _CreateEditorMethod.Invoke().GetType();

            // Gets the existing settings for the custom inspector.
            CustomEditorExtensionSettings settings = m_CustomEditorSettings.Find(currentSettings => { return(currentSettings.CustomEditorType == customEditorType); });

            // Update the existing settings if it exists
            if (settings != null)
            {
                settings.Update(_TargetType, _CreateEditorMethod, _DefaultOptions);
            }
            // If no matching settings has been found, create a new one using the given params, and add it to the list
            else
            {
                settings = new CustomEditorExtensionSettings(_TargetType, customEditorType, _CreateEditorMethod, _DefaultOptions);
                m_CustomEditorSettings.Add(settings);
            }

            m_CustomEditorSettings.Sort();
            return(settings);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a new settings entry in the list, or update an existing one.
 /// </summary>
 /// <typeparam name="TTarget">The target type of the custom editor.</typeparam>
 /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor extension.</param>
 /// <param name="_DefaultOptions">The default options to use for the custom editor extension.</param>
 /// <returns>Returns the created settings.</returns>
 private CustomEditorExtensionSettings AddOrUpdateCustomEditorSettings <TTarget>(CreateEditorDelegate _CreateEditorMethod, CustomEditorExtensionOptions _DefaultOptions)
     where TTarget : Object
 {
     return(AddOrUpdateCustomEditorSettings(_CreateEditorMethod, typeof(TTarget), _DefaultOptions));
 }