Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        SpatioSet ss = target as SpatioSet;

        GUILayout.Label("SpatioSet Controls");
        ss.slider      = (Slider)EditorGUILayout.ObjectField("Timeline Slider", ss.slider, typeof(Slider), true);
        ss.InfoText    = (Text)EditorGUILayout.ObjectField("Info Text", ss.InfoText, typeof(Text), true);
        ss.DateText    = (Text)EditorGUILayout.ObjectField("Date Text", ss.DateText, typeof(Text), true);
        ss.TestText    = (Text)EditorGUILayout.ObjectField("Test Text", ss.TestText, typeof(Text), true);
        ss.Description = (string)EditorGUILayout.TextField("Description", ss.Description);
    }
    void OnWizardCreate()
    {
        GameObject model;
        GameObject go = Instantiate(Resources.Load("SpatioSet")) as GameObject;
        SpatioSet  rs = go.GetComponent <SpatioSet>();

        string[] files = Directory.GetFiles(folderField);
        if (files != null && files.Length > 0)
        {
            foreach (string filename in files)
            {
                //Check to see if it's an fbx file
                if (!filename.EndsWith(".fbx"))
                {
                    continue;
                }

                //Construct the full file path
                string filepath = folderField;
                filepath = filename;
                //Create a new SpatioModel and begin loading and setting up the components
                model = new GameObject();
                string       model_year   = "tst";
                SpatioModel  sm           = model.AddComponent <SpatioModel>();  //Add a SpatioModel component
                MeshFilter   meshFilter   = model.AddComponent <MeshFilter>();   //Add a MeshFilter Component
                MeshRenderer meshRenderer = model.AddComponent <MeshRenderer>(); //Add a MeshRenderer Component
                //Material mat = new Material(Shader.Find("Legacy/Transparent/Specular")); //Create a Material
                //AssetDatabase.CreateAsset(mat, "Assets/Materials/" + mat.name + ".mat"); //Make the Material into an asset
                //meshRenderer.material = mat; //Assign the Material to the meshRenderer
                meshFilter.mesh = AssetDatabase.LoadAssetAtPath(filepath, typeof(Mesh)) as Mesh; //Load the mesh from the fbx file

                //GameObject pf = PrefabUtility.CreatePrefab("Assets/SpatioModels/" + nameField + "/" + model_year + ".prefab", model);
                model.transform.parent = go.transform;
            }
        }
        go.name = nameField;
    }