public override void DoLayoutList()
        {
            base.DoLayoutList();
            var rect = ActionGUIUtil.GetDragRect();

            if (Event.current.type == EventType.DragUpdated && rect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".prefab", dragedGameObject);
            }
            else if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragedGameObject)
                {
                    if (!ActionEditorUtility.HaveElement(property, "prefab", item))
                    {
                        var prop       = property.AddItem();
                        var prefabProp = prop.FindPropertyRelative("prefab");
                        var _name_prop = prop.FindPropertyRelative("_name");
                        _name_prop.stringValue          = item.name;
                        prefabProp.objectReferenceValue = item;
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("警告", "预制体重复,无法添加:" + item.name, "ok");
                    }
                }
            }
        }
        public override void DoLayoutList()
        {
            base.DoLayoutList();
            var rect = ActionGUIUtil.GetDragRect();

            if (Event.current.type == EventType.DragUpdated && rect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".prefab", dragedGameObject);
            }
            else if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragedGameObject)
                {
                    if (!ActionEditorUtility.HaveElement(property, "prefab", item))
                    {
                        var prop = ActionEditorUtility.AddItem(property);
                        OnAddItem(prop, item);
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("警告", "预制体重复,无法添加:" + item.name, "ok");
                    }
                }
            }
        }
示例#3
0
        public override void DoLayoutList()
        {
            base.DoLayoutList();
            var rect = GUILayoutUtility.GetRect(ActionGUIUtil.currentViewWidth, EditorGUIUtility.singleLineHeight);

            if (Event.current.type == EventType.DragUpdated && rect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".asset", dragedCommands);
            }
            else if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragedCommands)
                {
                    if (!HaveCommand(item))
                    {
                        property.InsertArrayElementAtIndex(property.arraySize);
                        var prop = property.GetArrayElementAtIndex(property.arraySize - 1);
                        prop.FindPropertyRelative("command").objectReferenceValue = item;
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("警告", "步骤重复,无法添加:" + (item as ActionCommand).StepName, "ok");
                    }
                }
            }
        }
        protected override void DrawDragField(Rect objRect, SerializedProperty prop)
        {
            if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects <ActionHook>(".asset", dragHooks);
            }

            else if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragHooks)
                {
                    prop.objectReferenceValue = item;
                    break;
                }
            }
        }
 protected override void DrawDragField(Rect rect)
 {
     if (Event.current.type == EventType.DragUpdated && rect.Contains(Event.current.mousePosition))
     {
         ActionGUIUtil.UpdateDragedObjects(".asset", dragBindings);
     }
     else if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition))
     {
         foreach (var item in dragBindings)
         {
             property.InsertArrayElementAtIndex(property.arraySize);
             var prop = property.GetArrayElementAtIndex(property.arraySize - 1);
             prop.objectReferenceValue = item;
         }
     }
 }
示例#6
0
        protected override void DrawDragField(Rect objRect)
        {
            if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".asset", dragBindings);
            }

            else if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragBindings)
                {
                    var prop = property.AddItem();
                    prop.objectReferenceValue = item;
                    break;
                }
            }
        }
        public override void DoLayoutList()
        {
            base.DoLayoutList();
            var rect = ActionGUIUtil.GetDragRect();

            if (Event.current.type == EventType.DragUpdated && rect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".prefab", dragedObjects);
            }
            else if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragedObjects)
                {
                    var path = AssetDatabase.GetAssetPath(item);
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }
                    var guid = AssetDatabase.AssetPathToGUID(path);
                    if (!ActionEditorUtility.HaveElement(property, "guid", guid))
                    {
                        var prop               = property.AddItem();
                        var guidProp           = prop.FindPropertyRelative("guid");
                        var enviromentNameProp = prop.FindPropertyRelative("enviromentName");
                        var coordinateProp     = prop.FindPropertyRelative("coordinate");

                        guidProp.stringValue           = guid;
                        enviromentNameProp.stringValue = item.name;
                        ActionEditorUtility.SaveCoordinatesInfo(coordinateProp, (item as GameObject).transform);
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("警告", "预制体重复,无法添加:" + item.name, "ok");
                    }
                }
            }
        }
        protected override void DrawElementCallBack(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect = ActionGUIUtil.DrawBoxRect(rect, index.ToString());
            var prop = property.GetArrayElementAtIndex(index);

            EditorGUI.PropertyField(rect, prop, true);

            var objRect = new Rect(rect.x + rect.width - ActionGUIUtil.bigButtonWidth, rect.y, ActionGUIUtil.bigButtonWidth, rect.height);

            if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition))
            {
                ActionGUIUtil.UpdateDragedObjects(".prefab", dragedGameObject);
            }
            else if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition))
            {
                foreach (var item in dragedGameObject)
                {
                    if (!AddOneElement(item))
                    {
                        EditorUtility.DisplayDialog("警告", "预制体重复,无法添加:" + item.name, "ok");
                    }
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            elementNameProp    = property.FindPropertyRelative("enviromentName");
            guidProp           = property.FindPropertyRelative("guid");
            instenceIDProp     = property.FindPropertyRelative("instenceID");
            enviromentNameProp = property.FindPropertyRelative("enviromentName");
            coordinateProp     = property.FindPropertyRelative("coordinate");


            var btnRect = new Rect(position.x, position.y, position.width - ActionGUIUtil.middleButtonWidth, EditorGUIUtility.singleLineHeight);

            if (instenceIDProp.intValue != 0 && EditorUtility.InstanceIDToObject(instenceIDProp.intValue) == null)
            {
                instenceIDProp.intValue = 0;
                property.isExpanded     = false;
            }
            if (!string.IsNullOrEmpty(guidProp.stringValue) && string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(guidProp.stringValue)))
            {
                guidProp.stringValue = null;
            }

            if (GUI.Button(btnRect, elementNameProp.stringValue, EditorStyles.toolbarDropDown))
            {
                property.isExpanded = !property.isExpanded;
                if (property.isExpanded)
                {
                    ActionEditorUtility.LoadPrefab(guidProp.stringValue, instenceIDProp, coordinateProp);
                }
                else
                {
                    ActionEditorUtility.SavePrefab(instenceIDProp, coordinateProp);
                }
            }

            var objRect = new Rect(position.x + position.width - ActionGUIUtil.middleButtonWidth, position.y, ActionGUIUtil.middleButtonWidth, EditorGUIUtility.singleLineHeight);

            if (!string.IsNullOrEmpty(guidProp.stringValue))
            {
                if (GUI.Button(objRect, "", EditorStyles.objectFieldMiniThumb))
                {
                    GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(guidProp.stringValue));
                    EditorGUIUtility.PingObject(prefab);
                }

                if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition))
                {
                    ActionGUIUtil.UpdateDragedObjects <GameObject>(".prefab", dragedGameObjs);
                }

                else if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition))
                {
                    foreach (var item in dragedGameObjs)
                    {
                        RecordPrefab(item);
                        break;
                    }
                }
            }
            else
            {
                var obj = EditorGUI.ObjectField(objRect, null, typeof(GameObject), false);
                if (obj != null)
                {
                    RecordPrefab(obj);
                }
            }

            if (instenceIDProp.intValue != 0)
            {
                DrawInfo(position);
            }

            if (property.isExpanded)
            {
                position.y += EditorGUIUtility.singleLineHeight + 2f;
                EditorGUI.BeginChangeCheck();
                ActionGUIUtil.DrawChildInContent(property, position, null, "ignore", -1);
                if (EditorGUI.EndChangeCheck())
                {
                    if (instenceTranform)
                    {
                        ActionEditorUtility.LoadCoordinatePropInfo(coordinateProp, instenceTranform);
                    }
                }
                else
                {
                    if (instenceTranform)
                    {
                        ActionEditorUtility.SaveCoordinatesInfo(coordinateProp, instenceTranform);
                    }
                }
            }
        }
示例#10
0
        protected override void DrawElementCallBack(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect = ActionGUIUtil.DrawBoxRect(rect, index.ToString());

            var prop            = property.GetArrayElementAtIndex(index);
            var commandProp     = prop.FindPropertyRelative("command");
            var ignoreProp      = prop.FindPropertyRelative("ignore");
            var commandNameProp = prop.FindPropertyRelative("commandName");

            if (commandProp.objectReferenceValue != null)
            {
                commandNameProp.stringValue = (commandProp.objectReferenceValue as ActionCommand).StepName;
            }

            var btnRect = new Rect(rect.x, rect.y, rect.width - ActionGUIUtil.middleButtonWidth - ActionGUIUtil.smallButtonWidth, EditorGUIUtility.singleLineHeight);

            GUI.contentColor = ignoreProp.boolValue ? ActionGUIUtil.IgnoreColor : ActionGUIUtil.NormalColor;
            if (!string.IsNullOrEmpty(ActionGUIUtil.searchWord))
            {
                GUI.contentColor = commandNameProp.stringValue.ToLower().Contains(ActionGUIUtil.searchWord.ToLower()) ? ActionGUIUtil.MatchColor : GUI.contentColor;
            }
            if (GUI.Button(btnRect, commandNameProp.stringValue, EditorStyles.toolbarDropDown))
            {
                prop.isExpanded = !prop.isExpanded;
            }
            GUI.contentColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;

            var openGraphRect = new Rect(btnRect.x + btnRect.width + 5, btnRect.y, ActionGUIUtil.smallButtonWidth, btnRect.height);

            if (GUI.Button(openGraphRect, "o", EditorStyles.miniButtonRight) && commandProp.objectReferenceValue != null)
            {
                NodeGraph.NodeGraphWindow.OnOpenAsset(commandProp.objectReferenceInstanceIDValue, 0);
            }

            var objRect = new Rect(rect.x + rect.width - ActionGUIUtil.smallButtonWidth - 10, rect.y + 2, ActionGUIUtil.smallButtonWidth, EditorGUIUtility.singleLineHeight);

            if (commandProp.objectReferenceValue == null)
            {
                commandProp.objectReferenceValue = EditorGUI.ObjectField(objRect, commandProp.objectReferenceValue, typeof(ActionCommand), false);
            }
            else
            {
                if (GUI.Button(objRect, commandContent, EditorStyles.label))
                {
                    EditorGUIUtility.PingObject(commandProp.objectReferenceInstanceIDValue);
                }

                if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition))
                {
                    ActionGUIUtil.UpdateDragedObjects(".asset", dragedCommands);
                }

                if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition))
                {
                    foreach (var item in dragedCommands)
                    {
                        if (!HaveCommand(item as ActionCommand))
                        {
                            commandProp.objectReferenceValue = item;
                        }
                        else
                        {
                            EditorUtility.DisplayDialog("警告", "步骤重复,无法添加:" + (item as ActionCommand).StepName, "ok");
                        }
                    }
                }
            }
            if (prop.isExpanded)
            {
                var ignoreRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight);
                ignoreProp.boolValue = EditorGUI.ToggleLeft(ignoreRect, "[ignore]", ignoreProp.boolValue);
            }

            if (isActive)
            {
                if (commandProp.objectReferenceValue)
                {
                    DrawCommandItem(commandProp.objectReferenceValue as ActionCommand);
                }
            }
        }