예제 #1
0
    public GameObject AddPrefab(string folderName, string prefabName, bool canCreateMultiple, bool selectAfter, bool putInFolder)
    {
        if (canCreateMultiple || !GameObject.Find(AdvGame.GetName(prefabName)))
        {
            string fileName = assetFolder + folderName + Path.DirectorySeparatorChar.ToString() + prefabName + ".prefab";

            GameObject newOb = (GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(fileName, typeof(GameObject)));
            newOb.name = "Temp";

            if (folderName != "" && putInFolder)
            {
                if (!PutInFolder(newOb, "_" + prefabName + "s"))
                {
                    PutInFolder(newOb, "_" + prefabName);
                }
            }

            RenameObject(newOb, prefabName);

            // Select the object
            if (selectAfter)
            {
                Selection.activeObject = newOb;
            }

            return(newOb);
        }

        return(null);
    }
예제 #2
0
    private void Awake()
    {
        // Test for key imports
        References references = (References)Resources.Load(Resource.references);

        if (references)
        {
            SceneManager     sceneManager     = AdvGame.GetReferences().sceneManager;
            SettingsManager  settingsManager  = AdvGame.GetReferences().settingsManager;
            ActionsManager   actionsManager   = AdvGame.GetReferences().actionsManager;
            InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
            VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
            SpeechManager    speechManager    = AdvGame.GetReferences().speechManager;

            if (sceneManager == null)
            {
                Debug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (settingsManager == null)
            {
                Debug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard");
            }
            else
            {
                if (!GameObject.FindGameObjectWithTag(Tags.player))
                {
                    try
                    {
                        Player ref_player = AdvGame.GetReferences().settingsManager.player;
                        Player player     = (Player)Instantiate(ref_player);
                        player.name = ref_player.name;
                    }
                    catch {}
                }
            }

            if (actionsManager == null)
            {
                Debug.LogError("No Actions Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (inventoryManager == null)
            {
                Debug.LogError("No Inventory Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (variablesManager == null)
            {
                Debug.LogError("No Variables Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (speechManager == null)
            {
                Debug.LogError("No Speech Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (GameObject.FindWithTag(Tags.player) == null)
            {
                Debug.LogError("No Player found - please set one using the Settings Manager, tagging it as Player");
            }
        }
        else
        {
            Debug.LogError("No References object found. Please set one using the Adventure Creator Kit wizard.");
        }

        if (!GameObject.FindGameObjectWithTag(Tags.persistentEngine))
        {
            try
            {
                GameObject persistentEngine = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine));
                persistentEngine.name = AdvGame.GetName(Resource.persistentEngine);
            }
            catch {}
        }

        if (GameObject.FindWithTag(Tags.persistentEngine) == null)
        {
            Debug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine");
        }
        else
        {
            GameObject persistentEngine = GameObject.FindWithTag(Tags.persistentEngine);

            if (persistentEngine.GetComponent <Options>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no Options component attached.");
            }
            if (persistentEngine.GetComponent <RuntimeInventory>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no RuntimeInventory component attached.");
            }
            if (persistentEngine.GetComponent <RuntimeVariables>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no RuntimeVariables component attached.");
            }
            if (persistentEngine.GetComponent <StateHandler>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no StateHandler component attached.");
            }
            if (persistentEngine.GetComponent <SceneChanger>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no SceneChanger component attached.");
            }
            if (persistentEngine.GetComponent <SaveSystem>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no SaveSystem component attached.");
            }
            if (persistentEngine.GetComponent <LevelStorage>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no LevelStorage component attached.");
            }
        }

        if (GameObject.FindWithTag(Tags.mainCamera) == null)
        {
            Debug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
        }
        else
        {
            if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null)
            {
                Debug.LogError("MainCamera has no MainCamera component.");
            }
        }

        if (this.tag == Tags.gameEngine)
        {
            if (this.GetComponent <MenuSystem>() == null)
            {
                Debug.LogError(this.name + " has no MenuSystem component attached.");
            }

            if (this.GetComponent <Dialog>() == null)
            {
                Debug.LogError(this.name + " has no Dialog component attached.");
            }

            if (this.GetComponent <PlayerInput>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInput component attached.");
            }

            if (this.GetComponent <PlayerInteraction>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInteraction component attached.");
            }

            if (this.GetComponent <PlayerMenus>() == null)
            {
                Debug.LogError(this.name + " has no PlayerMenus component attached.");
            }

            if (this.GetComponent <PlayerMovement>() == null)
            {
                Debug.LogError(this.name + " has no PlayerMovement component attached.");
            }
            if
            (this.GetComponent <PlayerCursor>() == null)
            {
                Debug.LogError(this.name + " has no PlayerCursor component attached.");
            }

            if (this.GetComponent <SceneSettings>() == null)
            {
                Debug.LogError(this.name + " has no SceneSettings component attached.");
            }
            else
            {
                if (this.GetComponent <SceneSettings>().navMesh == null)
                {
                    Debug.LogWarning("No NavMesh set.  Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                }

                if (this.GetComponent <SceneSettings>().defaultPlayerStart == null)
                {
                    Debug.LogWarning("No default PlayerStart set.  The game may not be able to begin if one is not defined - please choose one using the Scene Manager.");
                }
            }

            if (this.GetComponent <RuntimeActionList>() == null)
            {
                Debug.LogError(this.name + " has no RuntimeActionList component attached.");
            }
        }
    }
예제 #3
0
 private void RenameObject(GameObject ob, string resourceName)
 {
     ob.name = AdvGame.GetName(resourceName);
 }