示例#1
0
        static void RemoveUnusedPrevious <THandler, TEvent, TData>(ResolumeOscMap map,
                                                                   GameObject go, List <THandler> components)
            where TEvent : UnityEvent <TData>, new()
            where THandler : OscEventHandler <TEvent, TData>
        {
            go.GetComponents(components);
            foreach (var component in components)
            {
                var found = false;
                foreach (var shortcut in map.Shortcuts)
                {
                    if (shortcut != component.Shortcut)
                    {
                        continue;
                    }

                    found = true;
                    break;
                }

                // only destroy events not found in the current map that have 0 event listeners
                if (!found && component.Event.GetPersistentEventCount() == 0)
                {
                    Destroy(component);
                }
            }
        }
示例#2
0
 public void OnEnable()
 {
     m_Map                     = (ResolumeOscMap)target;
     m_FoldoutStates           = new bool[m_Map.Shortcuts.Count];
     m_ColorGroupFoldoutStates = new bool[m_Map.ColorGroups.Count];
     m_Vec2FoldoutStates       = new bool[m_Map.Vector2Groups.Count];
     m_Vec3FoldoutStates       = new bool[m_Map.Vector3Groups.Count];
     m_AnyGroupsInMap          = AnyGroupsInMap();
     GenerateLabels();
 }
示例#3
0
        public ResolumeOscMap ParseFile(string filePath, bool createAsset = true)
        {
            Profiler.BeginSample("Resolink Parse Osc Map");

            m_Shortcuts.Clear();
            k_ColorGroups.Clear();
            k_Vector2Groups.Clear();
            k_Vector3Groups.Clear();

            m_Reader = XmlReader.Create(filePath, m_XmlSettings);
            m_Reader.MoveToContent();

            while (m_Reader.Read())
            {
                switch (m_Reader.NodeType)
                {
                case XmlNodeType.Element:
                    HandleNodeByName();
                    break;

                case XmlNodeType.EndElement:
                    HandleEndElementByName();
                    break;
                }
            }

            if (m_Shortcuts.Count == 0)
            {
                Profiler.EndSample();
                return(null);
            }

            foreach (var shortcut in m_Shortcuts)
            {
                var inPath = shortcut.Input.Path;
                if (!m_RegexToTypeMapper.Process(inPath, out var typeForShortcut))
                {
                    if (inPath.EndsWith("/color"))
                    {
                        Debug.LogWarning($"The color control at path '{inPath}' is only supported by enabling all of " +
                                         "its RGBA components.\nEnable those (if they aren't already) and remove this one!");
                    }
                    else if (ResolinkEditorSettings.Instance.WarnOnUnknownType)
                    {
                        Debug.LogWarning($"data type for input path '{inPath}' is unknown! This can be fixed by adding " +
                                         "a ResolumeEventMetaData entry with a regular expression that matches this path.");
                    }
                    continue;
                }

                shortcut.TypeName = typeForShortcut.Name;
            }

            GroupSubTargets(ref m_Shortcuts);

            // sort by output path label
            m_Shortcuts.Sort();

            // find all groupings of primitive controls that make up a more complex control
            FindColorGroups();
            // find vec3 groups before vec2 so we don't mistake a vec3 for a vec2
            FindVector3Groups();
            FindVector2Groups();

            m_Map         = CreateInstance <ResolumeOscMap>();
            m_Map.Version = m_Version;

            m_Map.Shortcuts.Clear();
            foreach (var shortcut in m_Shortcuts)
            {
                m_Map.Shortcuts.Add(shortcut);
            }

            m_Map.ColorGroups   = k_ColorGroups.ToList();   // copy the list in case we mutate the original
            m_Map.Vector2Groups = k_Vector2Groups.ToList();
            m_Map.Vector3Groups = k_Vector3Groups.ToList();

            Profiler.EndSample();
            if (createAsset)
            {
                CreateAsset();
            }

            return(m_Map);
        }