예제 #1
0
 public void uMyGUI_TreeBrowser_InitNode(object p_data)
 {
     if (m_text != null && m_image != null)
     {
         if (p_data is SendMessageInitData)
         {
             SendMessageInitData data = (SendMessageInitData)p_data;
             // image
             Texture2D iconTex = (Texture2D)Resources.Load(data.m_object.IconPath);
             if (iconTex != null)
             {
                 m_image.texture = iconTex;
             }
             else
             {
                 Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: object '" + data.m_object.name + "'" +
                                " has an invalid icon resource path! Path: '" + data.m_object.IconPath + "'");
             }
             // name
             m_text.text = UtilityStrings.InsertSpacesIntoCamelCase(data.m_object.name);
             // resize text due to indent
             Vector2 offsetMax = m_text.rectTransform.offsetMax;
             offsetMax.x -= data.m_indentLevel * 10f;
             m_text.rectTransform.offsetMax = offsetMax;
         }
         else if (p_data is LE_ObjectCategoryNode.SendMessageInitData)
         {
             LE_ObjectCategoryNode.SendMessageInitData data = (LE_ObjectCategoryNode.SendMessageInitData)p_data;
             Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: the category '" + data.m_categoryName + "' is empty and will not be shown correctly!");
             m_image.gameObject.SetActive(false);
             m_text.text = LE_ObjectCategoryNode.GetCleanCategoryName(data.m_categoryName);
         }
         else
         {
             Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a LE_ObjectPrefabNode.SendMessageInitData! p_data: " + p_data);
         }
     }
     else
     {
         Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: m_text or m_image were not set via inspector!");
     }
 }
예제 #2
0
        private uMyGUI_TreeBrowser.Node[] SetObjectsRecursive(LE_ObjectMap p_objectMap, int p_indentLevel)
        {
            List <uMyGUI_TreeBrowser.Node> nodes = new List <uMyGUI_TreeBrowser.Node>();

            // inner nodes
            for (int i = 0; i < p_objectMap.SubObjectMaps.Length; i++)
            {
                if (p_objectMap.SubObjectMaps[i] != null)
                {
                    LE_ObjectCategoryNode.SendMessageInitData data = new LE_ObjectCategoryNode.SendMessageInitData(p_objectMap.SubObjectMaps[i].name, p_indentLevel);
                    nodes.Add(new uMyGUI_TreeBrowser.Node(data, SetObjectsRecursive(p_objectMap.SubObjectMaps[i], p_indentLevel + 1)));
                }
                else
                {
                    Debug.LogError("LE_GUIInterface_uGUIimplDungeon: SetObjectsRecursive: sub object map from map '" + p_objectMap.name + "'" +
                                   " at index '" + i + "' is null!");
                }
            }
            // leafs
            for (int i = 0; i < p_objectMap.ObjectPrefabs.Length; i++)
            {
                if (p_objectMap.ObjectPrefabs[i] != null)
                {
                    LE_ObjectPrefabNode.SendMessageInitData data = new LE_ObjectPrefabNode.SendMessageInitData(p_objectMap.ObjectPrefabs[i], p_indentLevel);
                    uMyGUI_TreeBrowser.Node node = new uMyGUI_TreeBrowser.Node(data, null);
                    nodes.Add(node);
                    m_nodeToObject.Add(node, p_objectMap.ObjectPrefabs[i]);
                    m_nodeToResourcePath.Add(node, p_objectMap.ObjectPrefabResourcePaths[i]);
                }
                else
                {
                    Debug.LogError("LE_GUIInterface_uGUIimplDungeon: SetObjectsRecursive: object from map '" + p_objectMap.name + "'" +
                                   " at index '" + i + "' is null!");
                }
            }
            return(nodes.ToArray());
        }