Ejemplo n.º 1
0
 static EditorToolAttribute GetEditorToolAttribute(EditorTool tool)
 {
     if (tool == null)
     {
         return(null);
     }
     return(GetEditorToolAttribute(tool.GetType()));
 }
Ejemplo n.º 2
0
        static bool CustomEditorToolIsMatch(Editor editor, Type toolType, EditorTool tool)
        {
            if (editor == null || toolType != tool.GetType())
            {
                return(false);
            }

            // if it's an EditModeTool we need to be stricter about ownership for backwards compatibility.
            var editModeTool = tool as EditModeTool;

            if (editModeTool != null)
            {
                return(editModeTool.owner == (IToolModeOwner)editor || editModeTool.target == editor.target);
            }

            // otherwise just check if it's a valid type
            return(true);
        }
Ejemplo n.º 3
0
            public bool IsEqual(EditorTool other)
            {
                if (editorToolType != (other == null ? null : other.GetType()))
                {
                    return(false);
                }

                if (ReferenceEquals(targetObjects, other.m_Targets))
                {
                    return(true);
                }

                if (targetObjects == null || other.m_Targets == null)
                {
                    return(false);
                }

                return(targetObjects.SequenceEqual(other.m_Targets));
            }
Ejemplo n.º 4
0
            public CustomEditorToolContext(EditorTool tool)
            {
                if (tool != null)
                {
                    editorToolType    = tool.GetType();
                    targetObject      = tool.target;
                    targetObjects     = tool.targets.ToArray();
                    m_EditorToolState = EditorJsonUtility.ToJson(tool);
                }
                else
                {
                    editorToolType    = null;
                    targetObject      = null;
                    targetObjects     = null;
                    m_EditorToolState = null;
                }

                m_EditorToolType = null;
            }
Ejemplo n.º 5
0
            public ComponentToolCache(EditorToolContext context, EditorTool tool)
            {
                bool customTool    = IsCustomEditorTool(tool);
                bool customContext = IsCustomToolContext(context);

                if (customTool || customContext)
                {
                    toolType      = customTool ? tool.GetType() : null;
                    contextType   = customContext ? context.GetType() : null;
                    targetObject  = tool.target;
                    targetObjects = tool.targets.ToArray();
                }
                else
                {
                    toolType      = null;
                    contextType   = null;
                    targetObject  = null;
                    targetObjects = null;
                }

                m_ToolType    = null;
                m_ContextType = null;
            }
Ejemplo n.º 6
0
 static bool IsCustomEditorTool(EditorTool tool)
 {
     return(EditorToolUtility.IsCustomEditorTool(tool != null ? tool.GetType() : null));
 }
Ejemplo n.º 7
0
 internal static string GetToolMenuPath(EditorTool tool)
 {
     return(GetToolMenuPath(tool != null ? tool.GetType() : typeof(EditorTool)));
 }