Skip to content

Commit 138ef9c

Browse files
author
Unity Technologies
committed
Unity 2018.3.6f1 C# reference source code
1 parent fca55ae commit 138ef9c

18 files changed

Lines changed: 130 additions & 81 deletions

File tree

‎Editor/Mono/Inspector/ParticleSystemForceFieldInspector.cs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ internal class ParticleSystemForceFieldInspector : Editor
3535
private static PropertyInfo s_GravityFocusProperty = typeof(ParticleSystemForceField).GetProperty("gravityFocus");
3636
private static PropertyInfo s_LengthProperty = typeof(ParticleSystemForceField).GetProperty("length");
3737

38+
private static readonly string s_UndoString = L10n.Tr("Modify {0}");
39+
3840
private SerializedProperty m_Shape;
3941
private SerializedProperty m_StartRange;
4042
private SerializedProperty m_EndRange;
@@ -273,7 +275,7 @@ private static void DrawSphere(PropertyInfo radiusProp, ParticleSystemForceField
273275
s_SphereBoundsHandle.DrawHandle();
274276
if (EditorGUI.EndChangeCheck())
275277
{
276-
Undo.RecordObject(target, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));
278+
Undo.RecordObject(target, string.Format(s_UndoString, ObjectNames.NicifyVariableName(target.GetType().Name)));
277279
radiusProp.SetValue(target, s_SphereBoundsHandle.radius / multiplyByRadius, null);
278280
}
279281
}
@@ -286,7 +288,7 @@ private static void DrawHemisphere(PropertyInfo radiusProp, ParticleSystemForceF
286288
float newRadius = Handles.DoSimpleRadiusHandle(Quaternion.Euler(-90, 0, 0), Vector3.zero, oldRadius, true);
287289
if (EditorGUI.EndChangeCheck())
288290
{
289-
Undo.RecordObject(target, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));
291+
Undo.RecordObject(target, string.Format(s_UndoString, ObjectNames.NicifyVariableName(target.GetType().Name)));
290292
radiusProp.SetValue(target, newRadius / multiplyByRadius, null);
291293
}
292294
}
@@ -306,7 +308,7 @@ private static void DrawCylinder(PropertyInfo radiusProp, PropertyInfo lengthPro
306308
s_SphereBoundsHandle.DrawHandle();
307309
if (EditorGUI.EndChangeCheck())
308310
{
309-
Undo.RecordObject(target, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));
311+
Undo.RecordObject(target, string.Format(s_UndoString, ObjectNames.NicifyVariableName(target.GetType().Name)));
310312
radiusProp.SetValue(target, s_SphereBoundsHandle.radius / multiplyByRadius, null);
311313
}
312314
}
@@ -317,7 +319,7 @@ private static void DrawCylinder(PropertyInfo radiusProp, PropertyInfo lengthPro
317319
lengthHalf = Handles.SizeSlider(Vector3.zero, -Vector3.up, lengthHalf);
318320
if (EditorGUI.EndChangeCheck())
319321
{
320-
Undo.RecordObject(target, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));
322+
Undo.RecordObject(target, string.Format(s_UndoString, ObjectNames.NicifyVariableName(target.GetType().Name)));
321323
lengthProp.SetValue(target, Mathf.Max(0.0f, lengthHalf * 2.0f), null);
322324
}
323325

@@ -339,7 +341,7 @@ private static void DrawBox(PropertyInfo extentProp, ParticleSystemForceField ta
339341
s_BoxBoundsHandle.DrawHandle();
340342
if (EditorGUI.EndChangeCheck())
341343
{
342-
Undo.RecordObject(target, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));
344+
Undo.RecordObject(target, string.Format(s_UndoString, ObjectNames.NicifyVariableName(target.GetType().Name)));
343345
extentProp.SetValue(target, s_BoxBoundsHandle.radius / multiplyByRadius, null);
344346
}
345347
}

‎Editor/Mono/Inspector/StandardParticlesShaderGUI.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ private static class Styles
8787
public static GUIContent streamTangentText = EditorGUIUtility.TrTextContent("Tangent (TANGENT.xyzw)");
8888

8989
public static GUIContent streamApplyToAllSystemsText = EditorGUIUtility.TrTextContent("Apply to Systems", "Apply the vertex stream layout to all Particle Systems using this material");
90+
91+
public static string undoApplyCustomVertexStreams = L10n.Tr("Apply custom vertex streams from material");
9092
}
9193

9294
MaterialProperty blendMode = null;
@@ -477,7 +479,7 @@ void DoVertexStreamsArea(Material material)
477479
// Display list of streams required to make this shader work
478480
bool useLighting = (material.GetFloat("_LightingEnabled") > 0.0f);
479481
bool useFlipbookBlending = (material.GetFloat("_FlipbookMode") > 0.0f);
480-
bool useTangents = material.GetTexture("_BumpMap") && useLighting;
482+
bool useTangents = useLighting && material.GetTexture("_BumpMap");
481483

482484
bool useGPUInstancing = ShaderUtil.HasProceduralInstancing(material.shader);
483485
if (useGPUInstancing && m_RenderersUsingThisMaterial.Count > 0)
@@ -535,6 +537,8 @@ void DoVertexStreamsArea(Material material)
535537
// Set the streams on all systems using this material
536538
if (GUILayout.Button(Styles.streamApplyToAllSystemsText, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
537539
{
540+
Undo.RecordObjects(m_RenderersUsingThisMaterial.Where(r => r != null).ToArray(), Styles.undoApplyCustomVertexStreams);
541+
538542
foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial)
539543
{
540544
if (renderer != null)
@@ -717,7 +721,7 @@ void SetMaterialKeywords(Material material)
717721
// (MaterialProperty value might come from renderer material property block)
718722
bool useDistortion = !hasZWrite && (material.GetFloat("_DistortionEnabled") > 0.0f);
719723
SetKeyword(material, "_NORMALMAP", (useLighting || useDistortion) && material.GetTexture("_BumpMap"));
720-
SetKeyword(material, "_METALLICGLOSSMAP", useLighting && (material.GetTexture("_MetallicGlossMap") != null));
724+
SetKeyword(material, "_METALLICGLOSSMAP", useLighting && material.GetTexture("_MetallicGlossMap"));
721725

722726
material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None;
723727
SetKeyword(material, "_EMISSION", material.GetFloat("_EmissionEnabled") > 0.0f);

‎Editor/Mono/ParticleSystemEditor/ParticleSystemModules/CollisionModuleUI.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ enum PlaneVizType { Grid, Solid };
4646
static Transform s_SelectedTransform; // static so to ensure only one selected Transform across multiple particle systems
4747
internal static PrefColor s_CollisionBoundsColor = new PrefColor("Particle System/Collision Bounds", 0.0f, 1.0f, 0.0f, 1.0f);
4848

49+
static readonly string s_UndoCollisionPlaneString = L10n.Tr("Modified Collision Plane Transform");
50+
4951
class Texts
5052
{
5153
public GUIContent lifetimeLoss = EditorGUIUtility.TrTextContent("Lifetime Loss", "When particle collides, it will lose this fraction of its Start Lifetime");
@@ -494,7 +496,7 @@ private void CollisionPlanesSceneGUI()
494496
}
495497
if (EditorGUI.EndChangeCheck())
496498
{
497-
Undo.RecordObject(transform, "Modified Collision Plane Transform");
499+
Undo.RecordObject(transform, s_UndoCollisionPlaneString);
498500
transform.position = newPosition;
499501
transform.rotation = newRotation;
500502
ParticleSystemEditorUtils.PerformCompleteResimulation();

‎Editor/Mono/ParticleSystemEditor/ParticleSystemModules/ExternalForcesModuleUI.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Texts
2626
public GUIContent[] influenceFilters = new GUIContent[]
2727
{
2828
EditorGUIUtility.TrTextContent("Layer Mask"),
29-
EditorGUIUtility.TrTextContent("List")
29+
EditorGUIUtility.TrTextContent("List"),
30+
EditorGUIUtility.TrTextContent("Layer Mask and List")
3031
};
3132
}
3233
static Texts s_Texts;
@@ -67,9 +68,9 @@ override public void OnInspectorGUI(InitialModuleUI initial)
6768
}
6869
else
6970
{
70-
if (filter == ParticleSystemGameObjectFilter.LayerMask)
71+
if (filter != ParticleSystemGameObjectFilter.List)
7172
GUILayerMask(s_Texts.influenceMask, m_InfluenceMask);
72-
else
73+
if (filter != ParticleSystemGameObjectFilter.LayerMask)
7374
m_InfluenceListView.DoLayoutList();
7475
}
7576
}

‎Editor/Mono/ParticleSystemEditor/ParticleSystemModules/RendererModuleUI.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ override public void OnInspectorGUI(InitialModuleUI initial)
316316
{
317317
GUIPopup(s_Texts.space, m_RenderAlignment, s_Texts.spaces);
318318
}
319-
320-
if (renderMode == RenderMode.Billboard)
321-
GUIVector3Field(s_Texts.flip, m_Flip);
322-
else
323-
GUIVector3Field(s_Texts.flipMeshes, m_Flip);
324319
}
325320

321+
if (renderMode == RenderMode.Mesh)
322+
GUIVector3Field(s_Texts.flipMeshes, m_Flip);
323+
else
324+
GUIVector3Field(s_Texts.flip, m_Flip);
325+
326326
if (renderMode == RenderMode.Billboard)
327327
GUIToggle(s_Texts.allowRoll, m_AllowRoll);
328328

‎Editor/Mono/ParticleSystemEditor/ParticleSystemModules/ShapeModuleUI.cs‎

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ class Texts
157157
public GUIContent rotation = EditorGUIUtility.TrTextContent("Rotation", "Rotate the emission shape.");
158158
public GUIContent scale = EditorGUIUtility.TrTextContent("Scale", "Scale the emission shape.");
159159

160+
public readonly string undoSphereThickness = L10n.Tr("Sphere Thickness Handle Change");
161+
public readonly string undoSphere = L10n.Tr("Sphere Handle Change");
162+
public readonly string undoCircleThickness = L10n.Tr("Circle Thickness Handle Change");
163+
public readonly string undoCircle = L10n.Tr("Circle Handle Change");
164+
public readonly string undoHemisphereThickness = L10n.Tr("Hemisphere Thickness Handle Change");
165+
public readonly string undoHemisphere = L10n.Tr("Hemisphere Handle Change");
166+
public readonly string undoConeThickness = L10n.Tr("Cone Thickness Handle Change");
167+
public readonly string undoCone = L10n.Tr("Cone Handle Change");
168+
public readonly string undoConeVolumeThickness = L10n.Tr("Cone Volume Thickness Handle Change");
169+
public readonly string undoConeVolume = L10n.Tr("Cone Volume Handle Change");
170+
public readonly string undoBox = L10n.Tr("Box Handle Change");
171+
public readonly string undoDonut = L10n.Tr("Donut Handle Change");
172+
public readonly string undoDonutRadiusThickness = L10n.Tr("Donut Radius Thickness Handle Change");
173+
public readonly string undoDonutRadius = L10n.Tr("Donut Radius Handle Change");
174+
public readonly string undoEdge = L10n.Tr("Edge Handle Change");
175+
public readonly string undoRectangle = L10n.Tr("Rectangle Handle Change");
176+
public readonly string undoTransform = L10n.Tr("Shape Transform Change");
177+
160178
public GUIContent[] shapeTypes = new GUIContent[]
161179
{
162180
EditorGUIUtility.TrTextContent("Sphere"),
@@ -579,17 +597,9 @@ override public void OnSceneViewGUI()
579597

580598
Matrix4x4 transformMatrix = new Matrix4x4();
581599
if (mainModule.scalingMode == ParticleSystemScalingMode.Local)
582-
{
583600
transformMatrix.SetTRS(ps.transform.position, ps.transform.rotation, ps.transform.localScale);
584-
}
585-
else if (mainModule.scalingMode == ParticleSystemScalingMode.Hierarchy)
586-
{
587-
transformMatrix = ps.transform.localToWorldMatrix;
588-
}
589601
else
590-
{
591-
transformMatrix.SetTRS(ps.transform.position, ps.transform.rotation, ps.transform.lossyScale);
592-
}
602+
transformMatrix = ps.transform.localToWorldMatrix;
593603

594604
bool isBox = (type == ParticleSystemShapeType.Box || type == ParticleSystemShapeType.BoxShell || type == ParticleSystemShapeType.BoxEdge || type == ParticleSystemShapeType.Rectangle);
595605

@@ -606,7 +616,7 @@ override public void OnSceneViewGUI()
606616
float radiusThickness = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false, shapeModule.arc);
607617
if (EditorGUI.EndChangeCheck())
608618
{
609-
Undo.RecordObject(ps, "Sphere Thickness Handle Change");
619+
Undo.RecordObject(ps, s_Texts.undoSphereThickness);
610620
shapeModule.radiusThickness = 1.0f - (radiusThickness / shapeModule.radius);
611621
}
612622

@@ -616,7 +626,7 @@ override public void OnSceneViewGUI()
616626
float radius = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shapeModule.radius, false, shapeModule.arc);
617627
if (EditorGUI.EndChangeCheck())
618628
{
619-
Undo.RecordObject(ps, "Sphere Handle Change");
629+
Undo.RecordObject(ps, s_Texts.undoSphere);
620630
shapeModule.radius = radius;
621631
}
622632

@@ -639,7 +649,7 @@ override public void OnSceneViewGUI()
639649

640650
if (EditorGUI.EndChangeCheck())
641651
{
642-
Undo.RecordObject(ps, "Circle Thickness Handle Change");
652+
Undo.RecordObject(ps, s_Texts.undoCircleThickness);
643653
shapeModule.radiusThickness = 1.0f - (m_ArcHandle.radius / shapeModule.radius);
644654
}
645655

@@ -654,7 +664,7 @@ override public void OnSceneViewGUI()
654664

655665
if (EditorGUI.EndChangeCheck())
656666
{
657-
Undo.RecordObject(ps, "Circle Handle Change");
667+
Undo.RecordObject(ps, s_Texts.undoCircle);
658668
shapeModule.radius = m_ArcHandle.radius;
659669
shapeModule.arc = m_ArcHandle.angle;
660670
}
@@ -671,7 +681,7 @@ override public void OnSceneViewGUI()
671681
float radiusThickness = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
672682
if (EditorGUI.EndChangeCheck())
673683
{
674-
Undo.RecordObject(ps, "Hemisphere Thickness Handle Change");
684+
Undo.RecordObject(ps, s_Texts.undoHemisphereThickness);
675685
shapeModule.radiusThickness = 1.0f - (radiusThickness / shapeModule.radius);
676686
}
677687

@@ -681,7 +691,7 @@ override public void OnSceneViewGUI()
681691
float radius = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shapeModule.radius, true, shapeModule.arc);
682692
if (EditorGUI.EndChangeCheck())
683693
{
684-
Undo.RecordObject(ps, "Hemisphere Handle Change");
694+
Undo.RecordObject(ps, s_Texts.undoHemisphere);
685695
shapeModule.radius = radius;
686696
}
687697

@@ -699,7 +709,7 @@ override public void OnSceneViewGUI()
699709
radiusThicknessAngleRange = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusThicknessAngleRange, Handles.ConeHandles.Radius);
700710
if (EditorGUI.EndChangeCheck())
701711
{
702-
Undo.RecordObject(ps, "Cone Thickness Handle Change");
712+
Undo.RecordObject(ps, s_Texts.undoConeThickness);
703713
shapeModule.radiusThickness = 1.0f - (radiusThicknessAngleRange.x / shapeModule.radius);
704714
}
705715

@@ -710,7 +720,7 @@ override public void OnSceneViewGUI()
710720
radiusAngleRange = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange);
711721
if (EditorGUI.EndChangeCheck())
712722
{
713-
Undo.RecordObject(ps, "Cone Handle Change");
723+
Undo.RecordObject(ps, s_Texts.undoCone);
714724
shapeModule.radius = radiusAngleRange.x;
715725
shapeModule.angle = radiusAngleRange.y;
716726
mainModule.startSpeedMultiplier = radiusAngleRange.z;
@@ -730,7 +740,7 @@ override public void OnSceneViewGUI()
730740
radiusThicknessAngleLength = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusThicknessAngleLength, Handles.ConeHandles.Radius);
731741
if (EditorGUI.EndChangeCheck())
732742
{
733-
Undo.RecordObject(ps, "Cone Volume Thickness Handle Change");
743+
Undo.RecordObject(ps, s_Texts.undoConeVolumeThickness);
734744
shapeModule.radiusThickness = 1.0f - (radiusThicknessAngleLength.x / shapeModule.radius);
735745
}
736746

@@ -741,7 +751,7 @@ override public void OnSceneViewGUI()
741751
radiusAngleLength = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleLength);
742752
if (EditorGUI.EndChangeCheck())
743753
{
744-
Undo.RecordObject(ps, "Cone Volume Handle Change");
754+
Undo.RecordObject(ps, s_Texts.undoConeVolume);
745755
shapeModule.radius = radiusAngleLength.x;
746756
shapeModule.angle = radiusAngleLength.y;
747757
shapeModule.length = radiusAngleLength.z;
@@ -761,7 +771,7 @@ override public void OnSceneViewGUI()
761771

762772
if (EditorGUI.EndChangeCheck())
763773
{
764-
Undo.RecordObject(ps, "Box Handle Change");
774+
Undo.RecordObject(ps, s_Texts.undoBox);
765775
shapeModule.scale = m_BoxBoundsHandle.size;
766776
}
767777

@@ -783,7 +793,7 @@ override public void OnSceneViewGUI()
783793

784794
if (EditorGUI.EndChangeCheck())
785795
{
786-
Undo.RecordObject(ps, "Donut Handle Change");
796+
Undo.RecordObject(ps, s_Texts.undoDonut);
787797
shapeModule.radius = m_ArcHandle.radius;
788798
shapeModule.arc = m_ArcHandle.angle;
789799
}
@@ -824,7 +834,7 @@ override public void OnSceneViewGUI()
824834
m_SphereBoundsHandle.DrawHandle();
825835
if (EditorGUI.EndChangeCheck())
826836
{
827-
Undo.RecordObject(ps, "Donut Radius Thickness Handle Change");
837+
Undo.RecordObject(ps, s_Texts.undoDonutRadiusThickness);
828838
shapeModule.radiusThickness = 1.0f - (m_SphereBoundsHandle.radius / shapeModule.donutRadius);
829839
}
830840
}
@@ -840,7 +850,7 @@ override public void OnSceneViewGUI()
840850
m_SphereBoundsHandle.DrawHandle();
841851
if (EditorGUI.EndChangeCheck())
842852
{
843-
Undo.RecordObject(ps, "Donut Radius Handle Change");
853+
Undo.RecordObject(ps, s_Texts.undoDonutRadius);
844854
shapeModule.donutRadius = m_SphereBoundsHandle.radius;
845855
}
846856
}
@@ -855,7 +865,7 @@ override public void OnSceneViewGUI()
855865
float radius = Handles.DoSimpleEdgeHandle(Quaternion.identity, Vector3.zero, shapeModule.radius);
856866
if (EditorGUI.EndChangeCheck())
857867
{
858-
Undo.RecordObject(ps, "Edge Handle Change");
868+
Undo.RecordObject(ps, s_Texts.undoEdge);
859869
shapeModule.radius = radius;
860870
}
861871
}
@@ -883,7 +893,7 @@ override public void OnSceneViewGUI()
883893

884894
if (EditorGUI.EndChangeCheck())
885895
{
886-
Undo.RecordObject(ps, "Rectangle Handle Change");
896+
Undo.RecordObject(ps, s_Texts.undoRectangle);
887897
shapeModule.scale = new Vector3(m_BoxBoundsHandle.size.x, m_BoxBoundsHandle.size.y, 0.0f);
888898
}
889899

0 commit comments

Comments
 (0)