コード例 #1
0
    void OnGUI()
    {
        tempObject = (GameObject)EditorGUILayout.ObjectField(tempObject, typeof(GameObject), true);

        if (GUILayout.Button("Create a new interchangable in current List"))
        {
            prefabInterchangableSerializer.prefabInterchangableList.Add(InstantiatorUtil.ParsePrefabInfoFromGameObject(collectGameObjectPrefabDependency(tempObject)));

            ClearObjectField();
        }

        if (GUILayout.Button("Load"))
        {
            prefabInterchangableSerializer = Load(Path.Combine(Application.dataPath, "PrefabInterChangable.xml"));
        }

        if (GUILayout.Button("Save"))
        {
            Save(Path.Combine(Application.dataPath, "PrefabInterChangable.xml"));
        }

        if (initialized)
        {
            foreach (PrefabInfo pi in prefabInterchangableSerializer.prefabInterchangableList)
            {
                EditorGUILayout.BeginHorizontal();
                pi.prefabName = EditorGUILayout.TextField(pi.prefabName);
                pi.assetPath  = EditorGUILayout.TextField(pi.assetPath);
                EditorGUILayout.EndHorizontal();
            }
        }
    }
コード例 #2
0
    public void applyMaterialArrayRandomShader(Material[] materialArray, MaterialColor[] materialColorArray)
    {
        for (int i = 0; i < materialArray.Length; i++)
        {
            // must be in same order
            // materialArray[i].SetColor(materialColorArray[i].property_2_Name, materialColorArray[i].property_2_Value);
            // materialArray[i].SetColor(materialColorArray[i].property_3_Name, materialColorArray[i].property_3_Value);

            // or...
            for (int j = 0; j < materialColorArray.Length; j++)
            {
                if (Regex.Match(materialColorArray[j].materialName, InstantiatorUtil.trimMaterialInstanceString(materialArray[i].name)).Success)
                {
                    // Debug.Log("match success" + materialColorArray[j].materialName + " " + trimString(materialArray[i].name));
                    materialArray[i].SetColor(materialColorArray[j].property_2_Name, materialColorArray[j].property_2_Value);
                    materialArray[i].SetColor(materialColorArray[j].property_3_Name, materialColorArray[j].property_3_Value);
                    // Debug.Log("apply color to: " + materialArray[i].name);
                }
            }
        }
    }
コード例 #3
0
    private GameObject replacePrefabInterchangablePerObject(GameObject gameObject)
    {
        PrefabInfo prefabInfo = currentPrefabInterchangable.getRandomPrefabInfo(InstantiatorUtil.ParsePrefabInfoFromGameObject(gameObject));

        return(Instantiate((GameObject)AssetDatabase.LoadAssetAtPath(prefabInfo.assetPath, typeof(GameObject)), gameObject.transform.parent));
    }