Ejemplo n.º 1
0
        public override void OnModuleSceneDebugGUI()
        {
            CGVMesh vmesh = Target.InData.GetData <CGVMesh>();

            if (vmesh)
            {
                Handles.matrix = Target.Generator.transform.localToWorldMatrix;
                if (Target.ShowVertices)
                {
                    CGEditorUtility.SceneGUIPlot(vmesh.Vertex, 0.1f, Color.gray);
                }

                if (Target.ShowVertexID)
                {
                    var labels = Enumerable.Range(0, vmesh.Count).Select(i => i.ToString()).ToArray <string>();
                    CGEditorUtility.SceneGUILabels(vmesh.Vertex, labels, Color.black, Vector2.zero);
                }
                if (Target.ShowUV && vmesh.HasUV)
                {
                    var labels = Enumerable.Range(0, vmesh.UV.Length - 1).Select(i => string.Format("({0:0.##},{1:0.##})", vmesh.UV[i].x, vmesh.UV[i].y)).ToArray <string>();
                    CGEditorUtility.SceneGUILabels(vmesh.Vertex, labels, Color.black, Vector2.zero);
                }
                Handles.matrix = Matrix4x4.identity;
            }
        }
Ejemplo n.º 2
0
        public override void OnModuleSceneDebugGUI()
        {
            base.OnModuleSceneDebugGUI();
            var data = Target.OutPath.GetData <CGPath>();

            if (data)
            {
                Handles.matrix = Target.Generator.transform.localToWorldMatrix;
                CGEditorUtility.SceneGUIPlot(data.Position, 0.1f, Color.white);
                Handles.matrix = Matrix4x4.identity;
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            CGDataReferenceSelectorAttribute attrib = (CGDataReferenceSelectorAttribute)attribute;

            CurrentProp = property;
            var field = GetPropertySourceField <CGDataReference>(property);

            EditorGUI.PrefixLabel(position, label);

            position.x     += EditorGUIUtility.labelWidth;
            position.width -= EditorGUIUtility.labelWidth;

            Rect r = new Rect(position);

            if (field.Module != null)
            {
                r.width -= 30;
            }

            string btnLabel = (field.Module) ? string.Format("{0}.{1}", field.Module.ModuleName, field.SlotName) : "None";
            string btnTT    = (field.Module && field.Module.Generator) ? string.Format("{0}.{1}.{2}", field.Module.Generator.name, field.Module.ModuleName, field.SlotName) : "Click to choose";

            if (GUI.Button(r, new GUIContent(btnLabel, btnTT)))
            {
                CGEditorUtility.ShowOutputSlotsMenu(OnMenu, attrib.DataType);
            }
            if (field.Module != null)
            {
                r.width = 30;
                r.x     = position.xMax - 30;
                if (GUI.Button(r, new GUIContent(CurvyStyles.SelectTexture, "Select")))
                {
                    EditorGUIUtility.PingObject(field.Module);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Missing source", MessageType.Error);
            }
        }
Ejemplo n.º 4
0
        public override void OnModuleSceneDebugGUI()
        {
            base.OnModuleSceneDebugGUI();
            CGVolume vol = Target.InData.GetData <CGVolume>();

            if (vol)
            {
                Handles.matrix = Target.Generator.transform.localToWorldMatrix;

                if (Target.ShowPathSamples)
                {
                    CGEditorUtility.SceneGUIPlot(vol.Position, 0.1f, Target.PathColor);
                    if (Target.ShowIndex)
                    {
                        var labels = Enumerable.Range(0, vol.Count).Select(i => i.ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(vol.Position, labels, Color.black, Vector2.zero);
                    }
                }
                if (Target.ShowCrossSamples)
                {
                    int vtLo = Target.LimitCross.From * vol.CrossSize;
                    int vtHi = vtLo + vol.CrossSize;
                    if (!Target.LimitCross.SimpleValue)
                    {
                        vtLo = Target.LimitCross.Low * vol.CrossSize;
                        vtHi = (Target.LimitCross.High + 1) * vol.CrossSize;
                    }

                    vtLo = Mathf.Clamp(vtLo, 0, vol.VertexCount);
                    vtHi = Mathf.Clamp(vtHi, vtLo, vol.VertexCount);
                    var range = vol.Vertex.SubArray <Vector3>(vtLo, vtHi - vtLo);
                    CGEditorUtility.SceneGUIPlot(range, 0.1f, Color.white);

                    if (Target.ShowIndex)
                    {
                        var labels = Enumerable.Range(vtLo, vtHi).Select(i => i.ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(range, labels, Color.black, Vector2.zero);
                    }

                    if (Target.ShowMap)
                    {
                        var labels = Enumerable.Range(vtLo, vtHi).Select(i => DTMath.SnapPrecision(vol.CrossMap[i], 3).ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(range, labels, new Color(1, 0, 1), new Vector2(10, 20));
                    }

                    if (Target.ShowNormals)
                    {
                        DTHandles.PushHandlesColor(Target.NormalColor);

                        for (int i = vtLo; i < vtHi; i++)
                        {
                            Handles.DrawLine(vol.Vertex[i], vol.Vertex[i] + vol.VertexNormal[i] * 2);
                        }

                        DTHandles.PopHandlesColor();
                    }
                }
                if (Target.Interpolate)
                {
                    Vector3 pos;
                    Vector3 tan;
                    Vector3 up;
                    vol.InterpolateVolume(Target.InterpolatePathF, Target.InterpolateCrossF, out pos, out tan, out up);
                    Handles.ConeCap(0, pos, Quaternion.LookRotation(up, tan), 1f);
                }
                Handles.matrix = Matrix4x4.identity;
            }
        }