@@ -519,14 +519,40 @@ public static SettingsProvider CreatePreferencesGUI()
519
519
keywords = new System . Collections . Generic . HashSet < string > ( ) { "Bezier" , "Spline" , "Point" , "Normals" , "Color" , "Size" }
520
520
} ;
521
521
}
522
+ #endif
522
523
523
524
[ MenuItem ( "CONTEXT/BezierSpline/Open Settings" ) ]
524
525
[ MenuItem ( "CONTEXT/BezierPoint/Open Settings" ) ]
525
526
private static void OpenPreferencesWindow ( MenuCommand command )
526
527
{
527
- SettingsService . OpenProjectSettings ( "yasirkula/Bezier Solution" ) ;
528
- }
528
+ #if UNITY_2018_3_OR_NEWER
529
+ SettingsService . OpenProjectSettings ( "Project/yasirkula/Bezier Solution" ) ;
530
+ #else
531
+ System . Type preferencesWindowType = typeof ( EditorWindow ) . Assembly . GetType ( "UnityEditor.PreferencesWindow" ) ;
532
+ preferencesWindowType . GetMethod ( "ShowPreferencesWindow" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) . Invoke ( null , null ) ;
533
+
534
+ EditorWindow preferencesWindow = EditorWindow . GetWindow ( preferencesWindowType ) ;
535
+ if ( ( bool ) preferencesWindowType . GetField ( "m_RefreshCustomPreferences" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( preferencesWindow ) )
536
+ {
537
+ preferencesWindowType . GetMethod ( "AddCustomSections" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . Invoke ( preferencesWindow , null ) ;
538
+ preferencesWindowType . GetField ( "m_RefreshCustomPreferences" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . SetValue ( preferencesWindow , false ) ;
539
+ }
540
+
541
+ int targetSectionIndex = - 1 ;
542
+ System . Collections . IList sections = ( System . Collections . IList ) preferencesWindowType . GetField ( "m_Sections" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( preferencesWindow ) ;
543
+ for ( int i = 0 ; i < sections . Count ; i ++ )
544
+ {
545
+ if ( ( ( GUIContent ) sections [ i ] . GetType ( ) . GetField ( "content" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( sections [ i ] ) ) . text == "Bezier Solution" )
546
+ {
547
+ targetSectionIndex = i ;
548
+ break ;
549
+ }
550
+ }
551
+
552
+ if ( targetSectionIndex >= 0 )
553
+ preferencesWindowType . GetProperty ( "selectedSectionIndex" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . SetValue ( preferencesWindow , targetSectionIndex , null ) ;
529
554
#endif
555
+ }
530
556
531
557
#if ! UNITY_2018_3_OR_NEWER
532
558
[ PreferenceItem ( "Bezier Solution" ) ]
0 commit comments