Exemplo n.º 1
0
        private void CreateNPC(ScriptableNPC npc)
        {
            settingTypes.Clear();
            GameObject newNpc = Instantiate(npc.Model, npc.SpawnPosition.position, Quaternion.identity);

            Component script = newNpc.AddComponent(npc.AISystem.ObjectToClassType());

            foreach (var setting in npc.settings)
            {
                System.Type settingType = setting.ObjectToClassType();
                newNpc.AddComponent(settingType);
                settingTypes.Add(settingType);
            }
            SetCurrentNPC(newNpc);
            //Let's see if the aisystem component is my AISystem
            try
            {
                var system = script as AISystem;
                if (system == null)
                {
                    return;
                }
                newNpc.name = npc.NpcName;
                newNpc.GetComponent <Animator>().runtimeAnimatorController = npc.AnimatorController;
            }
            catch (Exception e)
            {
                Debug.Log("It's not an AiSystem created with the reguired methods");
            }
        }
        public static void CreateMyNpc()
        {
            ScriptableNPC asset = ScriptableObject.CreateInstance <ScriptableNPC>();

            AssetDatabase.CreateAsset(asset, "Assets/Resources/NewScriptableNPC.asset");
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = asset;
        }
Exemplo n.º 3
0
 private void DrawNPCSettings(ScriptableNPC npc)
 {
     try
     {
         foreach (var setting in npc.settings)
         {
             settingTypes.Add(setting.ObjectToClassType());
         }
     }
     catch (Exception e)
     {
         Debug.Log(settingTypes);
     }
 }