protected virtual void CreateTempComponent(z_EditableObject target, z_BrushSettings settings)
		{
			if(!z_Util.IsValid(target))
				return;

			tempComponent = target.gameObject.AddComponent<z_ZoomOverride>();
			tempComponent.hideFlags = HideFlags.HideAndDontSave;
			tempComponent.SetWeights(null, 0f);
		}
Beispiel #2
0
        protected virtual void CreateTempComponent(z_EditableObject target, z_BrushSettings settings)
        {
            if(!z_Util.IsValid(target))
                return;

            tempComponent = target.gameObject.AddComponent<z_ZoomOverride>();
            tempComponent.hideFlags = HideFlags.HideAndDontSave;
            tempComponent.SetWeights(null, 0f);
        }
        Bounds OnGetFrameBounds()
        {
            z_ZoomOverride ren = (z_ZoomOverride)target;

            Mesh m = ren.mesh;

            Vector3[] vertices = m.vertices;
            float[]   weights  = ren.GetWeights();

            Bounds bounds         = new Bounds(Vector3.zero, Vector3.zero);
            int    appliedWeights = 0;

            Transform transform = ((z_ZoomOverride)target).transform;

            for (int i = 0; i < m.vertexCount; i++)
            {
                if (weights[i] > 0.0001f)
                {
                    if (appliedWeights > 0)
                    {
                        bounds.Encapsulate(transform.TransformPoint(vertices[i]));
                    }
                    else
                    {
                        bounds.center = transform.TransformPoint(vertices[i]);
                    }

                    appliedWeights++;
                }
            }

            if (appliedWeights < 1)
            {
                bounds = ren.transform.GetComponent <MeshRenderer>().bounds;
            }
            else if (appliedWeights == 1 || bounds.size.magnitude < .1f)
            {
                bounds.size = Vector3.one * .5f;
            }

            return(bounds);
        }
        bool HasFrameBounds()
        {
            z_ZoomOverride ren = (z_ZoomOverride)target;

            return(ren.mesh != null && ren.GetWeights().Length == ren.mesh.vertexCount);
        }