public override void OnInspectorGUI() { //base.OnInspectorGUI(); bool useStrokeShader = shapeRenderer.StrokeMaterial ? VectorShapesUtils.IsStrokeShader(shapeRenderer.StrokeMaterial.shader) : false; if (!useStrokeShader) { EditorGUILayout.PropertyField(serializedObject.FindProperty("cam")); } ///if( shapeRenderer.FillMaterial ) MaterialField("fillMaterial", ref fillMaterialEditor); //if (shapeRenderer.StrokeMaterial) MaterialField("strokeMaterial", ref strokeMaterialEditor); if (fillMaterialEditor) { fillMaterialEditor.DrawHeader(); fillMaterialEditor.OnInspectorGUI(); } if (strokeMaterialEditor) { strokeMaterialEditor.DrawHeader(); strokeMaterialEditor.OnInspectorGUI(); } if (!useStrokeShader) { EditorGUILayout.HelpBox("Shader doesn't support stroke rendering, falling back to CPU mode (slow, only supports one camera).", MessageType.Warning); } }
void RefreshMesh() { if (Camera == null) { Camera = Camera.main; } if (strokeMaterial == null) { useShader = false; checkedShader = null; } else if (checkedShader == null || checkedShader != strokeMaterial.shader) { useShader = strokeMaterial && VectorShapesUtils.IsStrokeShader(strokeMaterial.shader); checkedShader = strokeMaterial ? strokeMaterial.shader : null; } // init mesh cache if necessary while (shapeMeshCaches.Count < shapes.Count) { shapeMeshCaches.Add(new ShapeMeshCache()); } while (shapeMeshCaches.Count > shapes.Count) { shapeMeshCaches [shapeMeshCaches.Count - 1].Release(); shapeMeshCaches.RemoveAt(shapeMeshCaches.Count - 1); } bool strokeMaterialHasChanged = false; var strokeKeywords = strokeMaterial ? strokeMaterial.shaderKeywords : null; if (lastStrokeKeywords == null || (strokeKeywords != null ? strokeKeywords.Length : 0) != lastStrokeKeywords.Length) { strokeMaterialHasChanged = true; } else { for (int i = 0; i < strokeKeywords.Length; i++) { if (strokeKeywords[i] != lastStrokeKeywords[i]) { strokeMaterialHasChanged = true; break; } } } lastStrokeKeywords = strokeKeywords; // update data if necessary for (int i = 0; i < shapeMeshCaches.Count; i++) { shapeMeshCaches[i].shape = shapes[i].ShapeData; shapeMeshCaches[i].transform = shapes[i].transform; shapeMeshCaches[i].camera = Camera; shapeMeshCaches[i].useShader = useShader; shapeMeshCaches[i].CreatePolyCollider = shapes[i].CreatePolyCollider; shapeMeshCaches[i].sourceFillMaterial = fillMaterial; if (strokeMaterialHasChanged) { shapeMeshCaches[i].sourceStrokeMaterial = null; } shapeMeshCaches[i].sourceStrokeMaterial = strokeMaterial; shapeMeshCaches[i].Refresh(); } }