Пример #1
0
        public string GetListenerFunLine(BindCell target, int index)
        {
            int id = m_EventIds[index];

            if (m_Type == type.Button)
            {
                switch (id)
                {
                case 0:    //click
                    return(string.Format("    private void {0}()\n    {{\n\n    }}\n\n", GetFuncName(target, id)));

                case 1:    //Down
                case 2:    //Up
                case 3:    //BeginDrag
                case 4:    //Drag
                case 5:    //EndDrag
                    return(string.Format("    private void {0}(GameObject obj, PointerEventData eventData)\n    {{\n\n    }}\n\n", GetFuncName(target, id)));
                }
            }
            else if (m_Type == type.Slider)
            {
                return(string.Format("    private void {0}(float value)\n    {{\n\n    }}\n\n", GetFuncName(target, id)));
            }
            else if (m_Type == type.Toggle)
            {
                return(string.Format("    private void {0}(bool value)\n    {{\n\n    }}\n\n", GetFuncName(target, id)));
            }

            return(null);
        }
Пример #2
0
 private void RemoveBindCell(BindCell target)
 {
     if (!m_deleteCells.Contains(target))
     {
         m_deleteCells.Add(target);
     }
 }
Пример #3
0
        public string GetListenerLine(BindCell target, int index)
        {
            string[] componentEvents = ComponentEvents();

            int id = m_EventIds[index];

            if (m_Type == type.Button)
            {
                if (id == 0) //onclick
                {
                    return(string.Format("        m_{0}.{1}.AddListener({0}{1});\n", target.GetName(), componentEvents[id]));
                }
                else
                {
                    return(string.Format("        EventTriggerListener.Get(m_{0}.gameObject).{1} = {0}{1};\n", target.GetName(), componentEvents[id]));
                }
            }
            else if (m_Type == type.Slider)
            {
                return(string.Format("        m_{0}.{1}.AddListener({0}{1});\n", target.GetName(), componentEvents[id]));
            }
            else if (m_Type == type.Toggle)
            {
                return(string.Format("        m_{0}.{1}.AddListener({0}{1});\n", target.GetName(), componentEvents[id]));
            }

            return(null);
        }
Пример #4
0
    private void AddBindCell(object target, BindCell cell)
    {
        m_BindCells.Add(cell);
        if (target != null)
        {
            m_DualCells.Add(target, cell);
        }

        if (cell.m_Target != null)
        {
            if (!m_GoCells.ContainsKey(cell.m_Target))
            {
                m_GoCells.Add(cell.m_Target, new List <BindCell>());
            }

            m_GoCells[cell.m_Target].Add(cell);
        }
    }
Пример #5
0
    private void AddBindCell(object target)
    {
        BindCell cell = new BindCell();

        bool enabel = false;

        if (target is GameObject)
        {
            enabel = AddComponent((GameObject)target);
            cell.SetRoot((GameObject)target);
            cell.m_Type = BindCell.type.gameobject;
        }
        if (target is Transform)
        {
            enabel = AddComponent((Transform)target);
            cell.SetRoot(((Transform)target).gameObject);
            cell.m_Type = BindCell.type.transform;
        }
        if (target is MonoBehaviour)
        {
            enabel = AddComponent((MonoBehaviour)target);
            cell.SetRoot(((MonoBehaviour)target).gameObject);
            cell.m_Type = BindCell.type.behaviour;
            cell.SetBehaviour((MonoBehaviour)target);
            cell.m_Event.SetEventType(cell.m_Behaviour);

            if (s_EventDefault.Contains(cell.m_BehaviourType))
            {
                cell.m_Event.AddIndex(0);
            }
        }

        if (!enabel)
        {
            return;
        }

        cell.m_Path = GetTargetPath(cell.m_Target.transform, cell.m_Path);

        AddBindCell(target, cell);

        NewCurInfo(m_CurInfo.m_Target != null ? m_CurInfo.m_Target : null);
    }
Пример #6
0
    private void DeleteBindCell(BindCell target)
    {
        if (m_BindCells.Contains(target))
        {
            m_BindCells.Remove(target);
            m_UnabelCells.Remove(target);

            object bindBehaviour = target.GetComponent();
            if (bindBehaviour != null && m_DualCells.ContainsKey(bindBehaviour))
            {
                m_DualCells.Remove(bindBehaviour);
            }

            if (target.m_Target != null && m_GoCells.ContainsKey(target.m_Target))
            {
                m_GoCells[target.m_Target].Remove(target);
                if (m_GoCells[target.m_Target].Count == 0)
                {
                    m_GoCells.Remove(target.m_Target);
                }
            }

            if (bindBehaviour is GameObject)
            {
                RemoveComponent((GameObject)bindBehaviour);
            }

            if (bindBehaviour is Transform)
            {
                RemoveComponent((Transform)bindBehaviour);
            }

            if (bindBehaviour is MonoBehaviour)
            {
                RemoveComponent((MonoBehaviour)bindBehaviour);
            }
        }

        NewCurInfo(m_CurInfo.m_Target != null ? m_CurInfo.m_Target : null);
    }
Пример #7
0
    private void GetCode(string filePath)
    {
        string menberRegex = "(?<name>[\\w\\W]+) = m_Transform.Find\\(\"(?<path>[\\w\\W]+)\"\\)";
        Dictionary <string, BindCell> cells = new Dictionary <string, BindCell>();

        using (StreamReader reader = File.OpenText(filePath))
        {
            string line;
            int    state = 0;
            while ((line = reader.ReadLine()) != null)
            {
                if (line.Contains("Menber End") || line.Contains("Init End") || line.Contains("EventListener End"))
                {
                    state = 0;
                }

                if (state == 1)
                {
                    string[] content = line.Split(' ');
                    if (content.Length < 7)
                    {
                        continue;
                    }
                    BindCell cell = new BindCell();
                    cell.m_BehaviourType = content[5];
                    cell.m_Name          = content[6];
                    cells.Add(cell.m_Name, cell);
                }

                if (state == 2)
                {
                    Match match = Regex.Match(line, menberRegex);
                    if (match.Groups.Count > 1)
                    {
                        string name = match.Groups["name"].Value.Replace(" ", string.Empty);
                        if (!cells.ContainsKey(name))
                        {
                            continue;
                        }

                        BindCell cell = cells[name];
                        cell.m_Path = match.Groups["path"].Value;
                        cell.m_Name = cell.m_Name.Replace("m_", string.Empty).Replace(cell.m_BehaviourType, string.Empty);

                        Transform target = m_Root.transform.Find(cell.m_Path);
                        if (PrefabUtility.GetPrefabParent(target) == null)
                        {
                            target = null;
                        }

                        object component = null;

                        cell.m_Event.SetEventType(cell.m_BehaviourType);

                        if (cell.m_BehaviourType == "GameObject")
                        {
                            cell.m_Type          = BindCell.type.gameobject;
                            cell.m_BehaviourType = string.Empty;
                        }
                        else if (cell.m_BehaviourType == "Transform")
                        {
                            cell.m_Type          = BindCell.type.transform;
                            cell.m_BehaviourType = string.Empty;
                        }
                        else
                        {
                            cell.m_Type = BindCell.type.behaviour;
                        }

                        if (target != null)
                        {
                            cell.SetRoot(target.gameObject);

                            if (cell.m_Type == BindCell.type.gameobject)
                            {
                                component = cell.m_Target;
                                AddComponent(cell.m_Target);
                                cell.SetBehaviour(null);
                            }
                            else if (cell.m_Type == BindCell.type.transform)
                            {
                                component = cell.m_Target.transform;
                                AddComponent(cell.m_Target.transform);
                                cell.SetBehaviour(null);
                            }
                            else
                            {
                                component = cell.m_Target.GetComponent(cell.m_BehaviourType);
                                if (component != null)
                                {
                                    cell.SetBehaviour((MonoBehaviour)component);
                                    AddComponent(cell.m_Behaviour);
                                }
                            }
                        }

                        AddBindCell(component, cell);
                    }
                }

                if (state == 3)
                {
                    BindCell curCell;
                    for (var index = 0; index < m_BindCells.Count; index++)
                    {
                        curCell = m_BindCells[index];
                        if (curCell.m_Event.GetEventType() == EventCell.type.Other)
                        {
                            continue;
                        }

                        if (!line.Contains(curCell.GetName()))
                        {
                            continue;
                        }

                        int id = curCell.m_Event.GetComponentId(line);
                        if (id != -1)
                        {
                            curCell.m_Event.AddIndex(id);
                        }
                    }
                }

                if (line.Contains("Menber Start"))
                {
                    state = 1;
                }

                if (line.Contains("Init Start"))
                {
                    state = 2;
                }

                if (line.Contains("EventListener Start"))
                {
                    state = 3;
                }
            }
        }

        RefreshUnableBindCell();
    }
Пример #8
0
 public string GetFuncName(BindCell target, int id)
 {
     string[] componentEvents = ComponentEvents();
     return(target.GetName() + componentEvents[id]);
 }