示例#1
0
    void UpdateCanvas()
    {
        if (null == m_brush)
        {
            return;
        }
        if (m_dots.Count < 2)
        {
            return;
        }
        var path = DrawerUtility.GetNodesPath(m_dots[m_dots.Count - 2], m_dots[m_dots.Count - 1], m_fixedz, m_threshold);

        if (m_pathNodes.Count < 1)
        {
            m_pathNodes.Add(path[0]);
        }
        m_pathNodes.Add(path[path.Count - 1]);
        for (int i = 0; i < m_brushInstance.Count; i++)
        {
            m_brushInstance[i].SetActive(false);
        }
        for (var i = 0; i < path.Count; i++)
        {
            if (i > m_brushInstance.Count - 1)
            {
                m_brushInstance.Add(Instantiate(m_brush));
            }
            m_brushInstance[i].SetActive(true);
            m_brushInstance[i].transform.position = path[i];
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (!Input.GetMouseButton(0))
        {
            m_lastPos = Vector3.zero;
            return;
        }
        int i, j;

        if ((Input.mousePosition - m_lastPos).magnitude < m_scale)
        {
            return;
        }
        if (m_lastPos == Vector3.zero)
        {
            DrawerUtility.ScreenToCanvas(Input.mousePosition, m_fixedPosz, m_startx, m_starty, m_scale, out i, out j, m_range);
            m_canvas[i][j].SetActive(false);
        }
        else
        {
            var list = DrawerUtility.GetNodesPath(m_lastPos, Input.mousePosition, m_fixedPosz, m_startx, m_starty, m_scale, m_range);
            foreach (var item in list)
            {
                m_canvas[item.i][item.j].SetActive(false);
            }
        }
        m_lastPos = Input.mousePosition;
    }
示例#3
0
 protected virtual void OnEnd()
 {
     Compose(ref m_pathNodes);
     DrawerUtility.OptimizedGenerateShape(m_meshFilter.sharedMesh, m_pathNodes);
     m_pathNodes.Clear();
     m_bstart = false;
 }
        public override bool IsVisible()
        {
            VisibleIfAttribute attr = GetAttr <VisibleIfAttribute>();

            if (!string.IsNullOrEmpty(attr.MemberName))
            {
                return(DrawerUtility.GetMemberValue <bool>(attr.MemberName, Property.Target));
            }
            return(false);
        }
示例#5
0
        public override bool IsValid()
        {
            CompareVerificationAttribute attr = GetAttr <CompareVerificationAttribute>();

            object value = attr.Value;

            if (!string.IsNullOrEmpty(attr.MemberName))
            {
                value = DrawerUtility.GetMemberValue(attr.MemberName, Property.Target);
            }
            return(DrawerUtility.Compare(Property.Value, value, attr.Symbol));
        }
示例#6
0
        protected override void OnDrawProperty(string label)
        {
            FloatSliderAttribute attr = GetAttr <FloatSliderAttribute>();

            float leftValue  = attr.LeftValue;
            float rightValue = attr.RightValue;

            if (!string.IsNullOrEmpty(attr.LeftValueMemberName))
            {
                leftValue = DrawerUtility.GetMemberValue <float>(attr.LeftValueMemberName, Property.Target);
            }

            if (!string.IsNullOrEmpty(attr.RightValueMemberName))
            {
                rightValue = DrawerUtility.GetMemberValue <float>(attr.RightValueMemberName, Property.Target);
            }

            label = label ?? "";

            float value = Property.GetValue <float>();

            if (value < leftValue)
            {
                value          = leftValue;
                Property.Value = value;
            }
            if (value > rightValue)
            {
                value          = rightValue;
                Property.Value = value;
            }

            EditorGUI.BeginChangeCheck();
            {
                value = EditorGUILayout.Slider(label, value, leftValue, rightValue);
            }
            if (EditorGUI.EndChangeCheck())
            {
                Property.Value = value;
            }
        }
示例#7
0
        protected override void OnDrawProperty(string label)
        {
            var attr = GetAttr <StringPopupAttribute>();

            string[] options = attr.Options;
            if (!string.IsNullOrEmpty(attr.MemberName))
            {
                options = DrawerUtility.GetMemberValue <string[]>(attr.MemberName, Property.Target);
            }

            var value      = Property.GetValue <string>();
            var valueIndex = Array.IndexOf(options, value);

            if (valueIndex < 0 && options != null && options.Length > 0)
            {
                valueIndex = 0;
                value      = options[0];

                Property.Value = value;
            }

            label = label ?? "";

            if (attr.IsSearchable)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PrefixLabel(label);
                    Rect btnRect = GUILayoutUtility.GetRect(new GUIContent(value), "dropdownbutton");

                    if (EditorGUI.DropdownButton(btnRect, new GUIContent(value), FocusType.Keyboard))
                    {
                        try
                        {
                            SearchablePopup.Show(btnRect, new Vector2(200, 400), valueIndex, options, (selected) =>
                            {
                                Property.Value = options[selected];
                            });
                        }
                        catch (ExitGUIException)
                        {
                            lastSearchableWindow = EditorWindow.focusedWindow;
                            throw;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (lastSearchableWindow && lastSearchableWindow != EditorWindow.mouseOverWindow)
                {
                    if (Event.current.type == EventType.ScrollWheel)
                    {
                        Event.current.Use();
                    }
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                {
                    value = EGUILayout.DrawPopup <string>(label, options, options, value);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    Property.Value = value;
                }
            }
        }
示例#8
0
        protected override void OnDrawProperty(string label)
        {
            if (IsNeedRefresh)
            {
                InitList();
            }

            if (list == null)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PrefixLabel(label);
                    if (GUILayout.Button("Create"))
                    {
                        Property.Value = DrawerUtility.CreateInstance(Property.ValueType);

                        IsNeedRefresh = true;
                    }
                }
                EditorGUILayout.EndHorizontal();
                return;
            }
            else
            {
                EditorGUILayout.BeginVertical(EGUIStyles.BoxStyle);
                {
                    EditorGUILayout.LabelField(GUIContent.none, EditorStyles.toolbar, GUILayout.ExpandWidth(true));

                    Rect lastRect = GUILayoutUtility.GetLastRect();
                    EditorGUI.LabelField(lastRect, label, EGUIStyles.BoldLabelStyle);

                    Rect clearBtnRect = new Rect(lastRect.x + lastRect.width - 40, lastRect.y, 40, lastRect.height);
                    if (GUI.Button(clearBtnRect, "C", EditorStyles.toolbarButton))
                    {
                        Property.ClearArrayElement();
                        IsNeedRefresh = true;
                    }

                    for (int i = 0; i < list.Count; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                elementProperties[i].OnGUILayout();
                            }
                            EditorGUILayout.EndVertical();
                            EditorGUILayout.BeginVertical(GUILayout.Width(20));
                            {
                                if (GUILayout.Button("-"))
                                {
                                    Property.RemoveArrayElementAtIndex(i);
                                    IsNeedRefresh = true;
                                }
                            }
                            EditorGUILayout.EndVertical();
                        }
                        EditorGUILayout.EndHorizontal();

                        EGUILayout.DrawHorizontalLine();
                    }
                    Rect addBtnRect = GUILayoutUtility.GetRect(lastRect.width, 20);
                    addBtnRect.x    += addBtnRect.width - 40;
                    addBtnRect.width = 40;
                    if (GUI.Button(addBtnRect, "+"))
                    {
                        Property.AddArrayElement();
                        IsNeedRefresh = true;
                    }
                }
                EditorGUILayout.EndVertical();
            }
        }
示例#9
0
 void OnEnd()
 {
     m_start = false;
     DrawerUtility.OptimizedGenerateShape(m_mesh, m_verts);
 }