Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by a19samvigpul · Nov 17, 2020 at 08:01 PM · gameobjectdllxmlsave datadata storage

Pass a GameObject to a DLL

Hey,I have a DLL that I use to save the player's position, but when passing the parameters I can only pass Floats created by me, but I want to pass the entire GameObject to the DLL. This is my code in the DLL;

 using System;
 using System.Text;
 using System.Xml;
 using System.Xml.Serialization;
 
 namespace SaveXML
 {
     public class MyXML
     {
 
         public void Save(float lx, float ly, float lz)
         {
             XmlDocument xmlDoc = new XmlDocument();
             XmlNode rootNode;
             string filename = "MiPrimerXML.xml";
 
             if (System.IO.File.Exists(filename))
             {
                 xmlDoc.Load(filename);
                 rootNode = xmlDoc.SelectSingleNode("Game");
             }
             else
             {
                 rootNode = xmlDoc.CreateElement("Game");
                 xmlDoc.AppendChild(rootNode);
             }
 
             XmlNode userNode = xmlDoc.CreateElement("GameObject");
             XmlAttribute attribute = xmlDoc.CreateAttribute("name");
             attribute.Value = "Player";
             userNode.Attributes.Append(attribute);
             rootNode.AppendChild(userNode);
 
             XmlNode Vector = xmlDoc.CreateElement("Vector");
             XmlAttribute x = xmlDoc.CreateAttribute("X");
             x.Value = lx.ToString();
             XmlAttribute y = xmlDoc.CreateAttribute("Y");
             y.Value = ly.ToString();
             XmlAttribute z = xmlDoc.CreateAttribute("Z");
             z.Value = lz.ToString();
 
             Vector.Attributes.Append(x);
             Vector.Attributes.Append(y);
             Vector.Attributes.Append(z);
             userNode.AppendChild(Vector);
 
             XmlWriterSettings settings = new XmlWriterSettings();
             settings.Encoding = new UTF8Encoding(false); // Falso = no escribir BOM
             settings.Indent = true;
             XmlWriter writer = XmlTextWriter.Create(filename, settings);
             xmlDoc.Save(writer);
         }
     }
 }
 

And this is my code in Unity

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using SaveXML;
 public class Save : MonoBehaviour
 {
     private SaveXML.MyXML savedll;
     private GameObject Jugador;
     // Start is called before the first frame update
     void Start()
     {
         savedll = new MyXML();
         Jugador = GameObject.FindGameObjectWithTag("Player");
     }
 
     // Update is called once per frame
     public void SaveXML()
     {
         float x = Jugador.transform.position.x;
         float y = Jugador.transform.position.y;
         float z = Jugador.transform.position.z;
         savedll.Save(x, y, z);
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by a19samvigpul · Nov 20, 2020 at 10:39 PM

I found the solution, I had to export the Dll called UnityEngine.CoreModule.dll. And I just had to create a GameObject as if it were in Unity itself.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by xxmariofer · Nov 18, 2020 at 09:19 AM

Hello, you should probably rewrite the question because it has nothing to do with DLL, you are asking if it is posible to serialize a GameObject and the simple answer is no, you cant serialize a full gameobject that would require serializing all the componentes and even meshes, what you can serialize are your own classes llike a class Player with your needed properties

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

221 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Return a Exist GameObject 0 Answers

Help on making a Database. 0 Answers

Differences between mobile save/load data 1 Answer

Saving usermade creations in game 1 Answer

Adding only once a new Value to a saved int List 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges