Skip to content

Commit

Permalink
fix #27; OnSceneGUI has errors in Unity 2018.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 23, 2018
1 parent 7c114bb commit 0fbc369
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
35 changes: 26 additions & 9 deletions Editor/UIParticleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ void OnSceneGUI ()

EditorGUI.BeginChangeCheck ();

foreach (UIParticle current in _particles)
foreach (UIParticle uip in _particles)
{
ParticleSystem ps = current.GetComponent<ParticleSystem> ();
ParticleSystem ps = uip.cachedParticleSystem;
if (!ps)
{
continue;
Expand Down Expand Up @@ -174,13 +174,13 @@ void OnSceneGUI ()
transformMatrix *= emitterMatrix;
Handles.matrix = transformMatrix;

if(current.canvas.renderMode == RenderMode.ScreenSpaceOverlay || ps.main.scalingMode == ParticleSystemScalingMode.Hierarchy)
if(uip.canvas.renderMode == RenderMode.ScreenSpaceOverlay || ps.main.scalingMode == ParticleSystemScalingMode.Hierarchy)
{
Handles.matrix = Handles.matrix * Matrix4x4.Scale (Vector3.one * current.scale);
Handles.matrix = Handles.matrix * Matrix4x4.Scale (Vector3.one * uip.scale);
}
else
{
Handles.matrix = Handles.matrix * Matrix4x4.Scale (current.canvas.rootCanvas.transform.localScale * current.scale);
Handles.matrix = Handles.matrix * Matrix4x4.Scale (uip.canvas.rootCanvas.transform.localScale * uip.scale);
}

if (type == ParticleSystemShapeType.Sphere)
Expand All @@ -189,7 +189,7 @@ void OnSceneGUI ()
Handles.color *= s_ShapeGizmoThicknessTint;
EditorGUI.BeginChangeCheck ();
//float radiusThickness = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false, shapeModule.arc);
float radiusThickness = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false, shapeModule.arc);
float radiusThickness = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false);
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Sphere Thickness Handle Change");
Expand All @@ -200,7 +200,7 @@ void OnSceneGUI ()
Handles.color = s_GizmoColor;
EditorGUI.BeginChangeCheck ();
//float radius = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, false, shapeModule.arc);
float radius = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius, false, shapeModule.arc);
float radius = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, false);
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Sphere Handle Change");
Expand Down Expand Up @@ -256,7 +256,8 @@ void OnSceneGUI ()
Handles.color *= s_ShapeGizmoThicknessTint;
EditorGUI.BeginChangeCheck ();
//float radiusThickness = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
float radiusThickness = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
//float radiusThickness = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
float radiusThickness = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true);
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Hemisphere Thickness Handle Change");
Expand All @@ -267,7 +268,7 @@ void OnSceneGUI ()
Handles.color = s_GizmoColor;
EditorGUI.BeginChangeCheck ();
//float radius = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, true, shapeModule.arc);
float radius = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius, true, shapeModule.arc);
float radius = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, true);
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Hemisphere Handle Change");
Expand All @@ -286,7 +287,11 @@ void OnSceneGUI ()
float angleThickness = Mathf.Lerp (shapeModule.angle, 0.0f, shapeModule.radiusThickness);
Vector3 radiusThicknessAngleRange = new Vector3 (shapeModule.radius * (1.0f - shapeModule.radiusThickness), angleThickness, mainModule.startSpeedMultiplier);
//radiusThicknessAngleRange = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusThicknessAngleRange, Handles.ConeHandles.Radius);
#if UNITY_2018_3_OR_NEWER
radiusThicknessAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleRange, 1);
#else
radiusThicknessAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleRange);
#endif
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Cone Thickness Handle Change");
Expand All @@ -298,7 +303,11 @@ void OnSceneGUI ()
EditorGUI.BeginChangeCheck ();
Vector3 radiusAngleRange = new Vector3 (shapeModule.radius, shapeModule.angle, mainModule.startSpeedMultiplier);
//radiusAngleRange = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusAngleRange);
#if UNITY_2018_3_OR_NEWER
radiusAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleRange, 7);
#else
radiusAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleRange);
#endif
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Cone Handle Change");
Expand All @@ -319,7 +328,11 @@ void OnSceneGUI ()
float angleThickness = Mathf.Lerp (shapeModule.angle, 0.0f, shapeModule.radiusThickness);
Vector3 radiusThicknessAngleLength = new Vector3 (shapeModule.radius * (1.0f - shapeModule.radiusThickness), angleThickness, shapeModule.length);
//radiusThicknessAngleLength = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusThicknessAngleLength, Handles.ConeHandles.Radius);
#if UNITY_2018_3_OR_NEWER
radiusThicknessAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleLength, 1);
#else
radiusThicknessAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleLength);
#endif
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Cone Volume Thickness Handle Change");
Expand All @@ -331,7 +344,11 @@ void OnSceneGUI ()
EditorGUI.BeginChangeCheck ();
Vector3 radiusAngleLength = new Vector3 (shapeModule.radius, shapeModule.angle, shapeModule.length);
//radiusAngleLength = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusAngleLength);
#if UNITY_2018_3_OR_NEWER
radiusAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleLength, 7);
#else
radiusAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleLength);
#endif
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject (ps, "Cone Volume Handle Change");
Expand Down
8 changes: 4 additions & 4 deletions UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public override Texture mainTexture
get
{
Texture tex = null;
if (!m_IsTrail && particleSystem)
if (!m_IsTrail && cachedParticleSystem)
{
Profiler.BeginSample ("Check TextureSheetAnimation module");
var textureSheet = particleSystem.textureSheetAnimation;
var textureSheet = cachedParticleSystem.textureSheetAnimation;
if (textureSheet.enabled && textureSheet.mode == ParticleSystemAnimationMode.Sprites && 0 < textureSheet.spriteCount)
{
tex = textureSheet.GetSprite (0).texture;
Expand Down Expand Up @@ -110,7 +110,7 @@ public bool isRoot
/// <summary>
/// ParticleSystem.
/// </summary>
new public ParticleSystem particleSystem { get { return m_ParticleSystem ? m_ParticleSystem : (m_ParticleSystem = GetComponent<ParticleSystem> ()); } }
public ParticleSystem cachedParticleSystem { get { return m_ParticleSystem ? m_ParticleSystem : (m_ParticleSystem = GetComponent<ParticleSystem> ()); } }

/// <summary>
/// Perform material modification in this function.
Expand Down Expand Up @@ -142,7 +142,7 @@ protected override void OnEnable ()
}
s_TempRelatables.Clear ();

_renderer = particleSystem ? particleSystem.GetComponent<ParticleSystemRenderer> () : null;
_renderer = cachedParticleSystem ? cachedParticleSystem.GetComponent<ParticleSystemRenderer> () : null;

// Create objects.
_mesh = new Mesh ();
Expand Down

0 comments on commit 0fbc369

Please sign in to comment.