コード例 #1
0
 private void GuiButtons()
 {
     GUILayout.Space(8);
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("Add"))
     {
         LodUtil.Add <LodNode>(ref odData.nodes, new LodNode("role"));
     }
     if (GUILayout.Button("Save"))
     {
         odData.Save();
     }
     GUILayout.EndHorizontal();
 }
コード例 #2
0
        public bool AddorUpdate(string prefab, float[] levels)
        {
            bool find = false;

            if (nodes != null)
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    if (nodes[i].prefab == prefab)
                    {
                        find            = true;
                        nodes[i].levels = levels;
                        break;
                    }
                }
            }
            if (!find)
            {
                LodUtil.Add <LodNode>(ref nodes, new LodNode(prefab, levels));
            }
            return(find);
        }
コード例 #3
0
        public LodOP GUI()
        {
            LodOP lodOP = LodOP.NONE;

            EditorGUILayout.BeginHorizontal();
            folder = EditorGUILayout.Foldout(folder, desc);
            if (GUILayout.Button("X", GUILayout.MaxWidth(36)))
            {
                lodOP = LodOP.DELETE;
            }
            EditorGUILayout.EndHorizontal();
            if (folder)
            {
                obj = EditorGUILayout.ObjectField("fbx", obj, typeof(GameObject), false);
                if (obj == null)
                {
                    var path = dir + "/" + prefab + "_LOD0.fbx";
                    obj = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                }
                else
                {
                    var path = AssetDatabase.GetAssetPath(obj);
                    int idx  = path.LastIndexOf("/");
                    dir = path.Substring(0, idx);
                    int idx2 = path.LastIndexOf("_LOD");
                    if (idx2 > 0)
                    {
                        prefab = path.Substring(idx + 1, idx2 - idx - 1);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("fbx's name is not match lod rule", MessageType.Error);
                    }
                }
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(prefab);
                if (GUILayout.Button("Add", GUILayout.MaxWidth(80)))
                {
                    LodUtil.Add <float>(ref levels, levels[levels.Length - 1] / 2.0f);
                    LodUtil.Add <ExMesh>(ref format, ExMesh.UV1);
                }
                if (GUILayout.Button("Detail", GUILayout.MaxWidth(80)))
                {
                    lodOP = LodOP.DETAIL;
                }
                EditorGUILayout.EndHorizontal();
                comment = EditorGUILayout.TextField("备注: ", comment);
                bool sort = true;
                for (int i = 0; i < levels.Length; i++)
                {
                    bool del = false;
                    EditorGUILayout.BeginHorizontal();
                    levels[i] = EditorGUILayout.FloatField(" - lod" + i, levels[i]);
                    if (format == null || format.Length <= i)
                    {
                        format = defaultFmt;
                    }
                    format[i] = (ExMesh)EditorGUILayout.EnumFlagsField(format[i], GUILayout.MaxWidth(80));
                    if (GUILayout.Button("X", GUILayout.MaxWidth(36)))
                    {
                        del = true;
                    }
                    EditorGUILayout.EndHorizontal();
                    if (levels[i] <= 0 || levels[i] >= 1)
                    {
                        EditorGUILayout.HelpBox("lod range [0-1]", MessageType.Error);
                    }
                    if (del)
                    {
                        levels = LodUtil.Remv <float>(levels, i);
                        format = LodUtil.Remv <ExMesh>(format, i);
                        break;
                    }
                    if (i > 0 && levels[i] >= levels[i - 1])
                    {
                        sort = false;
                    }
                }
                if (!sort)
                {
                    EditorGUILayout.HelpBox("lod sort invalid", MessageType.Error);
                }
            }
            return(lodOP);
        }