コード例 #1
0
    public static GameObject createNewModel(string m_name = null)
    {
        GameObject modelGO = new GameObject();
        AXModel    model   = modelGO.AddComponent <AXModel>();

        ArchimatixEngine.currentModel = model;



        if (String.IsNullOrEmpty(m_name))
        {
            // for auto naming, get highest count...
            // (can't use static variable for this, since it is cleared when scene reloads).
            int       highestnum = 0;
            AXModel[] axModels   = GameObject.FindObjectsOfType(typeof(AXModel)) as AXModel[];
            foreach (AXModel m in axModels)
            {
                String[] numbers = Regex.Split(m.name, @"\D+");
                if (numbers != null && numbers.Length > 0)
                {
                    string numString = numbers[numbers.Length - 1];
                    if (!string.IsNullOrEmpty(numString))
                    {
                        int num = int.Parse(numString);

                        if (num > highestnum)
                        {
                            highestnum = num;
                        }
                    }
                }
            }
            highestnum++;

            modelGO.name = "AXModel_" + highestnum;
        }
        else
        {
            modelGO.name = m_name;
        }

        Selection.activeGameObject = modelGO;


        model.axMat = new AXMaterial();

        model.axMat.mat     = (Material)AssetDatabase.LoadAssetAtPath(ArchimatixEngine.ArchimatixAssetPath + "/Materials/AX_GridPurple.mat", typeof(Material));
        model.axMat.physMat = (PhysicMaterial)AssetDatabase.LoadAssetAtPath(ArchimatixEngine.ArchimatixAssetPath + "/Materials/AX_DefaultPhysicMaterial.physicMaterial", typeof(PhysicMaterial));
        model.axMat.density = 1;

        //if (ArchimatixEngine.graphEditorIsOpen())
        if (ArchimatixEngine.useKyle)
        {
            ArchimatixEngine.createScalingFigure();
        }


        return(modelGO);
    }