Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Search the Community

Showing results for tags 'load'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GENERAL
    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
  • RESOURCES
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • SELL | REQUEST
    • Sell
    • Request
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials
  • Busy People's Introductions
  • Photon's Tutorials
  • Photon's Photon General
  • Photon's Showcase

Categories

  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


YouTube URL


Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 12 results

  1. Hello so I've been trying to seek for help in a lot of places for this and for now I still haven't figured this out so I will ask about it here too. I've made Save and Load script by this tutorial and I can't figure out how I can save my floats from other scripts, for example man is using here healh, experience, but it's easy for him because it's just floats from this same script. I wan't to be able to save my floats from other scripts that can't be just typed in (Things like Gold, amount of items, upgrades and more) things that are needed to be achieved not something that you instantly have. https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading?playlist=17117
  2. Hi everyone, I am new here and at scripting so any tip will be welcome. I got a save load Script from the script forum and added some lines so it saved Health, Will and inventory. Health and Will scripts were made by myself and I got the Inventory Script from the asset store (the free one). Health , Will and position get saved and loaded perfectly (thank you so much OcularCash for your explanations). Inventory and their item effects also work nice (I modified the scripts so it worked like a 3d point and click adventure). The PROBLEM comes with the INVENTORY, once you pick and object and click on "save" it gives the following ERROR: InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. UnityEngine.Transform does not implement Add(System.Object). System.Xml.Serialization.TypeData.get_ListItemType () System.Xml.Serialization.TypeData.get_ListItemTypeData () System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, Boolean isPrimitive, System.Xml.Serialization.TypeData mappedType, System.Xml.Schema.XmlSchemaPatternFacet facet) System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, Boolean isPrimitive) System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType) System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type type) System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive (System.String name, System.String ns, System.Object o, Boolean xsiType) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteListContent (System.Object container, System.Xml.Serialization.TypeData listType, System.Xml.Serialization.ListMap map, System.Object ob, System.Text.StringBuilder targetString) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot (System.Object ob) System.Xml.Serialization.XmlSerializer.Serialize (System.Object o, System.Xml.Serialization.XmlSerializationWriter writer) System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces) Rethrow as InvalidOperationException: There was an error generating the XML document. System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces This is the SCRIPT (some variables or script names are in spanish): Vida=Health Cordura=Will Contenido=Contents Inventario=Inventory import System; import System.Collections; import System.Xml; import System.Xml.Serialization; import System.IO; import System.Text; // Anything we want to store in the XML file, we define it here class DemoData { var x : float; var y : float; var z : float; var name : String; var Vida : float; var Cordura : float; var Contenido: Array; } // UserData is our custom class that holds our defined objects we want to store in XML format class UserData { // We have to define a default instance of the structure public var _iUser : DemoData = new DemoData(); // Default constructor doesn't really do anything at the moment function UserData() { } } //public class GameSaveLoad: MonoBehaviour { // An example where the encoding can be found is at // http://www.eggheadcafe.com/articles/system.xml.xmlserialization.asp // We will just use the KISS method and cheat a little and use // the examples from the web page since they are fully described // This is our local private members private var _Save : Rect; private var _Load : Rect; private var _SaveMSG : Rect; private var _LoadMSG : Rect; //var _ShouldSave : boolean; //var _ShouldLoad : boolean; //var _SwitchSave : boolean; //var _SwitchLoad : boolean; private var _FileLocation : String; private var _FileName : String = "SaveData.xml"; //public GameObject _Player; var _Player : GameObject; var _PlayerName : String = "Joe Schmoe"; var _Inventario : GameObject; private var myData : UserData; private var _data : String; private var VPosition : Vector3; private var _Vida : float; private var _Cordura : float; private var _Contenido : Array; // When the EGO is instansiated the Start will trigger // so we setup our initial values for our local members //function Start () { function Awake () { // We setup our rectangles for our messages _Save=new Rect(10,80,100,20); _Load=new Rect(10,100,100,20); _SaveMSG=new Rect(10,120,200,40); _LoadMSG=new Rect(10,140,200,40); // Where we want to save and load to and from _FileLocation=Application.dataPath; // we need soemthing to store the information into myData=new UserData(); } function Update () {} function OnGUI() { // *************************************************** // Loading The Player... // ************************************************** if (GUI.Button(_Load,"Load")) { GUI.Label(_LoadMSG,"Loading from: "+_FileLocation); // Load our UserData into myData LoadXML(); if(_data.ToString() != "") { // notice how I use a reference to type (UserData) here, you need this // so that the returned object is converted into the correct type //myData = (UserData)DeserializeObject(_data); myData = DeserializeObject(_data); // set the players position to the data we loaded _Vida=(myData._iUser.Vida); _Player.GetComponent(Barravida).currentHealth=_Vida; _Cordura=(myData._iUser.Cordura); _Player.GetComponent(Barracordura).currentWill=_Cordura; _Contenido=(myData._iUser.Contenido); _Inventario.GetComponent(InventoryDisplay).UpdatedList=_Contenido; VPosition=new Vector3(myData._iUser.x,myData._iUser.y,myData._iUser.z); _Player.transform.position=VPosition; // just a way to show that we loaded in ok Debug.Log(myData._iUser.name); } } // *************************************************** // Saving The Player... // ************************************************** if (GUI.Button(_Save,"Save")) { GUI.Label(_SaveMSG,"Saving to: "+_FileLocation); //Debug.Log("SaveLoadXML: sanity check:"+ _Player.transform.position.x); myData._iUser.x = _Player.transform.position.x; myData._iUser.y = _Player.transform.position.y; myData._iUser.z = _Player.transform.position.z; myData._iUser.name = _PlayerName; myData._iUser.Vida= _Player.GetComponent(Barravida).currentHealth; myData._iUser.Cordura= _Player.GetComponent(Barracordura).currentWill; myData._iUser.Contenido=_Inventario.GetComponent(InventoryDisplay).UpdatedList; // Time to creat our XML! _data = SerializeObject(myData); // This is the final resulting XML from the serialization process CreateXML(); Debug.Log(_data); } } /* The following metods came from the referenced URL */ //string UTF8ByteArrayToString(byte[] characters) function UTF8ByteArrayToString(characters : byte[] ) { var encoding : UTF8Encoding = new UTF8Encoding(); var constructedString : String = encoding.GetString(characters); return (constructedString); } //byte[] StringToUTF8ByteArray(string pXmlString) function StringToUTF8ByteArray(pXmlString : String) { var encoding : UTF8Encoding = new UTF8Encoding(); var byteArray : byte[] = encoding.GetBytes(pXmlString); return byteArray; } // Here we serialize our UserData object of myData //string SerializeObject(object pObject) function SerializeObject(pObject : Object) { var XmlizedString : String = null; var memoryStream : MemoryStream = new MemoryStream(); var xs : XmlSerializer = new XmlSerializer(typeof(UserData)); var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); xs.Serialize(xmlTextWriter, pObject); memoryStream = xmlTextWriter.BaseStream; // (MemoryStream) XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray()); return XmlizedString; } // Here we deserialize it back into its original form //object DeserializeObject(string pXmlizedString) function DeserializeObject(pXmlizedString : String) { var xs : XmlSerializer = new XmlSerializer(typeof(UserData)); var memoryStream : MemoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString)); var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); return xs.Deserialize(memoryStream); } // Finally our save and load methods for the file itself function CreateXML() { var writer : StreamWriter; //FileInfo t = new FileInfo(_FileLocation+"\\"+ _FileName); var t : FileInfo = new FileInfo(_FileLocation+"/"+ _FileName); if(!t.Exists) { writer = t.CreateText(); } else { t.Delete(); writer = t.CreateText(); } writer.Write(_data); writer.Close(); Debug.Log("File written."); } function LoadXML() { //StreamReader r = File.OpenText(_FileLocation+"\\"+ _FileName); var r : StreamReader = File.OpenText(_FileLocation+"/"+ _FileName); var _info : String = r.ReadToEnd(); r.Close(); _data=_info; Debug.Log("File Read"); }
  3. Hi guys, here is my advanced Save/Load system written in C#. Note : i made this and i use example variable names that can be changed , i made this for 11 variables but i commented the way to add more, so you can add as many as you want. Features : How to call Functions It's a full project, but i made it as UnityPackage, it contains a folder and 3 subfolders : Example (An example Scene) Scripts (All the scripts of the project) Textures (Loading effect textures) (Thanks to OMA) YOU DO NOT NEED ANY OTHER PACKAGE OR PRO Download Link
  4. Dergo

    Unity Question

    Hey, how can I save and load game objects with stats in Unity (C#)?
  5. Keegz

    Detect File

    Hi Everyone I wsa hoping someone could help me with some script. What I would like to do is when a scene loads or when you start up the game I would like it to detect an external file that I placed in my published data folder. once its detected the file to then toggle render my gameobject to show. I have been trying for a long time and my coding just isnt good enough to do this. I saw that I might have to use system.IO File.Exists But that is some next level coding that I just cant rap my head around. Can someone please help me.
  6. Hy guys,I need a Save/Load System,any idea? -Thanks
  7. What I mean is you start up the game, there's your menu, and when you hit play it asks which difficulty you want. If you choose easy, there's barely any monsters in the game. But if you choose HARD then there's more then you can count. So, how do you choose things across scenes? I guess? Or another example, you choose where to spawn on a map before the map itself loads. I wouldn't want to load a different scene for each choice, so how would I do this? Thanks guys.
  8. Hi, I am thinking of this concept, where a user is able to load a 2D texture from pc to a scene created and exported to an exe (game mode). eg: I have a 2 x 4 rectangular plane on my scene and already has a material with texture applied. when the user clicks on this plane they should be able to browse and upload a texture file from there computer.
  9. Hi everyone , I have a script that should make a object with the tag Player the parent of the game object with the script on. Now the object with the tag Player is in a other scene, and that game object that should get the child of the Player have a script with a DontDestroyOnLoad function so it does not get deleted if the game loads the new scene. Now I tried it with it with this script: var bird : GameObject; function Start () { bird = GameObject.FindWithTag("Player"); bird.transform.parent = transform; } But this only works if the game object with the tag Player is in the same scene. Now I think it should work with something like this: var bird : GameObject; if (Application.LoadLevel) { bird = GameObject.FindWithTag("Player"); bird.transform.parent = transform; } But it doesnt work.
  10. Hey there folks! This is my first need help: How would you able to make Unity to remember what scene/level you were in? For example: let's say I have about 5-8 levels and when I quit the game it has to then remember on what scene I were in. I was thinking on running with booleans and put a bool on every level and it ticks on and off on certain levels? Help please :/ pretty confused :S
  11. Hi there! I finally figured out on how to save with PlayerPrefs. But now I'm currently stuck with this WeaponIndex in OMA's FPS KIT... What I'm trying to do is to save what current weapon I was holding and then the script remembers what certain weapon I used and not bring back the old ones I have. I wrote in the WeaponIndex script, like this (and it didn't work...): function Start(){ PlayerPrefs.GetInt("playerWeapons"); } function Update(){ PlayerPrefs.SetInt("playerWeapons", setWeapon); } Is there a way in saving the weps I picked up? Help Please! Thanks!
  12. Hi! I need some help on saving and loading. Like, what gun I'm holding, current health and position. Cos, I don't really know how to do it and i looked around on google to get answers on PlayerPrefs, but to be honest: I don't really get it Note, that I'm using OMA's FPS Kit, and would like to use the save script and load script on it. I've also used whydoidoit.com's save and load assets, but that doesn't work. It just resets the level and nothing else :/ please help! thanks!
×
×
  • Create New...