@@ -78,6 +78,41 @@ public static Texture2D[] autoTransforms
78
78
}
79
79
}
80
80
81
+ private static class Styles
82
+ {
83
+ public static readonly GUIContent defaultSprite = EditorGUIUtility . TrTextContent ( "Default Sprite"
84
+ , "The default Sprite set when creating a new Rule." ) ;
85
+ public static readonly GUIContent defaultGameObject = EditorGUIUtility . TrTextContent ( "Default GameObject"
86
+ , "The default GameObject set when creating a new Rule." ) ;
87
+ public static readonly GUIContent defaultCollider = EditorGUIUtility . TrTextContent ( "Default Collider"
88
+ , "The default Collider Type set when creating a new Rule." ) ;
89
+
90
+ public static readonly GUIContent extendNeighbor = EditorGUIUtility . TrTextContent ( "Extend Neighbor"
91
+ , "Enabling this allows you to increase the range of neighbors beyond the 3x3 box." ) ;
92
+
93
+ public static readonly GUIContent tilingRules = EditorGUIUtility . TrTextContent ( "Tiling Rules" ) ;
94
+ public static readonly GUIContent tilingRulesGameObject = EditorGUIUtility . TrTextContent ( "GameObject"
95
+ , "The GameObject for the Tile which fits this Rule." ) ;
96
+ public static readonly GUIContent tilingRulesCollider = EditorGUIUtility . TrTextContent ( "Collider"
97
+ , "The Collider Type for the Tile which fits this Rule" ) ;
98
+ public static readonly GUIContent tilingRulesOutput = EditorGUIUtility . TrTextContent ( "Output"
99
+ , "The Output for the Tile which fits this Rule. Each Output type has its own properties." ) ;
100
+
101
+ public static readonly GUIContent tilingRulesNoise = EditorGUIUtility . TrTextContent ( "Noise"
102
+ , "The Perlin noise factor when placing the Tile." ) ;
103
+ public static readonly GUIContent tilingRulesShuffle = EditorGUIUtility . TrTextContent ( "Shuffle"
104
+ , "The randomized transform given to the Tile when placing it." ) ;
105
+ public static readonly GUIContent tilingRulesRandomSize = EditorGUIUtility . TrTextContent ( "Size"
106
+ , "The number of Sprites to randomize from." ) ;
107
+
108
+ public static readonly GUIContent tilingRulesMinSpeed = EditorGUIUtility . TrTextContent ( "Min Speed"
109
+ , "The minimum speed at which the animation is played." ) ;
110
+ public static readonly GUIContent tilingRulesMaxSpeed = EditorGUIUtility . TrTextContent ( "Max Speed"
111
+ , "The maximum speed at which the animation is played." ) ;
112
+ public static readonly GUIContent tilingRulesAnimationSize = EditorGUIUtility . TrTextContent ( "Size"
113
+ , "The number of Sprites in the animation." ) ;
114
+ }
115
+
81
116
/// <summary>
82
117
/// The RuleTile being edited
83
118
/// </summary>
@@ -115,11 +150,11 @@ public static Texture2D[] autoTransforms
115
150
/// <summary>
116
151
/// Padding between Rule Elements
117
152
/// </summary>
118
- public const float k_PaddingBetweenRules = 26f ;
153
+ public const float k_PaddingBetweenRules = 8f ;
119
154
/// <summary>
120
155
/// Single line height
121
156
/// </summary>
122
- public const float k_SingleLineHeight = 16f ;
157
+ public const float k_SingleLineHeight = 18f ;
123
158
/// <summary>
124
159
/// Width for labels
125
160
/// </summary>
@@ -216,10 +251,8 @@ public float GetElementHeight(RuleTile.TilingRuleOutput rule)
216
251
switch ( rule . m_Output )
217
252
{
218
253
case RuleTile . TilingRule . OutputSprite . Random :
219
- inspectorHeight = k_DefaultElementHeight + k_SingleLineHeight * ( rule . m_Sprites . Length + 3 ) + k_PaddingBetweenRules ;
220
- break ;
221
254
case RuleTile . TilingRule . OutputSprite . Animation :
222
- inspectorHeight = k_DefaultElementHeight + k_SingleLineHeight * ( rule . m_Sprites . Length + 2 ) + k_PaddingBetweenRules ;
255
+ inspectorHeight = k_DefaultElementHeight + k_SingleLineHeight * ( rule . m_Sprites . Length + 3 ) + k_PaddingBetweenRules ;
223
256
break ;
224
257
}
225
258
@@ -359,14 +392,14 @@ public static List<RuleOverrideTile> FindAffectedOverrideTiles(RuleTile target)
359
392
/// <param name="rect">GUI Rect to draw the header at</param>
360
393
public void OnDrawHeader ( Rect rect )
361
394
{
362
- GUI . Label ( rect , "Tiling Rules" ) ;
395
+ GUI . Label ( rect , Styles . tilingRules ) ;
363
396
364
397
Rect toggleRect = new Rect ( rect . xMax - rect . height , rect . y , rect . height , rect . height ) ;
365
398
Rect toggleLabelRect = new Rect ( rect . x , rect . y , rect . width - toggleRect . width - 5f , rect . height ) ;
366
399
367
400
EditorGUI . BeginChangeCheck ( ) ;
368
401
extendNeighbor = EditorGUI . Toggle ( toggleRect , extendNeighbor ) ;
369
- EditorGUI . LabelField ( toggleLabelRect , "Extend Neighbor" , new GUIStyle ( )
402
+ EditorGUI . LabelField ( toggleLabelRect , Styles . extendNeighbor , new GUIStyle ( )
370
403
{
371
404
alignment = TextAnchor . MiddleRight ,
372
405
fontStyle = FontStyle . Bold ,
@@ -392,9 +425,9 @@ public override void OnInspectorGUI()
392
425
{
393
426
EditorGUI . BeginChangeCheck ( ) ;
394
427
395
- tile . m_DefaultSprite = EditorGUILayout . ObjectField ( "Default Sprite" , tile . m_DefaultSprite , typeof ( Sprite ) , false ) as Sprite ;
396
- tile . m_DefaultGameObject = EditorGUILayout . ObjectField ( "Default GameObject" , tile . m_DefaultGameObject , typeof ( GameObject ) , false ) as GameObject ;
397
- tile . m_DefaultColliderType = ( Tile . ColliderType ) EditorGUILayout . EnumPopup ( "Default Collider" , tile . m_DefaultColliderType ) ;
428
+ tile . m_DefaultSprite = EditorGUILayout . ObjectField ( Styles . defaultSprite , tile . m_DefaultSprite , typeof ( Sprite ) , false ) as Sprite ;
429
+ tile . m_DefaultGameObject = EditorGUILayout . ObjectField ( Styles . defaultGameObject , tile . m_DefaultGameObject , typeof ( GameObject ) , false ) as GameObject ;
430
+ tile . m_DefaultColliderType = ( Tile . ColliderType ) EditorGUILayout . EnumPopup ( Styles . defaultCollider , tile . m_DefaultColliderType ) ;
398
431
399
432
DrawCustomFields ( false ) ;
400
433
@@ -701,39 +734,40 @@ public virtual void SpriteOnGUI(Rect rect, RuleTile.TilingRuleOutput tilingRule)
701
734
public void RuleInspectorOnGUI ( Rect rect , RuleTile . TilingRuleOutput tilingRule )
702
735
{
703
736
float y = rect . yMin ;
704
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "GameObject" ) ;
737
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesGameObject ) ;
705
738
tilingRule . m_GameObject = ( GameObject ) EditorGUI . ObjectField ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , "" , tilingRule . m_GameObject , typeof ( GameObject ) , false ) ;
706
739
y += k_SingleLineHeight ;
707
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Collider" ) ;
740
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesCollider ) ;
708
741
tilingRule . m_ColliderType = ( Tile . ColliderType ) EditorGUI . EnumPopup ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_ColliderType ) ;
709
742
y += k_SingleLineHeight ;
710
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Output" ) ;
743
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesOutput ) ;
711
744
tilingRule . m_Output = ( RuleTile . TilingRule . OutputSprite ) EditorGUI . EnumPopup ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_Output ) ;
712
745
y += k_SingleLineHeight ;
713
746
714
747
if ( tilingRule . m_Output == RuleTile . TilingRule . OutputSprite . Animation )
715
748
{
716
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Min Speed" ) ;
749
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesMinSpeed ) ;
717
750
tilingRule . m_MinAnimationSpeed = EditorGUI . FloatField ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_MinAnimationSpeed ) ;
718
751
y += k_SingleLineHeight ;
719
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Max Speed" ) ;
752
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesMaxSpeed ) ;
720
753
tilingRule . m_MaxAnimationSpeed = EditorGUI . FloatField ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_MaxAnimationSpeed ) ;
721
754
y += k_SingleLineHeight ;
722
755
}
723
756
if ( tilingRule . m_Output == RuleTile . TilingRule . OutputSprite . Random )
724
757
{
725
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Noise" ) ;
758
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesNoise ) ;
726
759
tilingRule . m_PerlinScale = EditorGUI . Slider ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_PerlinScale , 0.001f , 0.999f ) ;
727
760
y += k_SingleLineHeight ;
728
761
729
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Shuffle" ) ;
762
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , Styles . tilingRulesShuffle ) ;
730
763
tilingRule . m_RandomTransform = ( RuleTile . TilingRule . Transform ) EditorGUI . EnumPopup ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_RandomTransform ) ;
731
764
y += k_SingleLineHeight ;
732
765
}
733
766
734
767
if ( tilingRule . m_Output != RuleTile . TilingRule . OutputSprite . Single )
735
768
{
736
- GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight ) , "Size" ) ;
769
+ GUI . Label ( new Rect ( rect . xMin , y , k_LabelWidth , k_SingleLineHeight )
770
+ , tilingRule . m_Output == RuleTile . TilingRuleOutput . OutputSprite . Animation ? Styles . tilingRulesAnimationSize : Styles . tilingRulesRandomSize ) ;
737
771
EditorGUI . BeginChangeCheck ( ) ;
738
772
int newLength = EditorGUI . DelayedIntField ( new Rect ( rect . xMin + k_LabelWidth , y , rect . width - k_LabelWidth , k_SingleLineHeight ) , tilingRule . m_Sprites . Length ) ;
739
773
if ( EditorGUI . EndChangeCheck ( ) )
0 commit comments