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();
            }
        }
    }
Ejemplo n.º 2
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));
    }