Ejemplo n.º 1
0
 private void InitDynamicsManager()
 {
     if (UsingDynamicsManager)
     {
         _dynamicsManager = new DynamicsManager(transform.position, transform.rotation);
     }
 }
        /// <summary>
        /// Imports the DynamicsManager from another project.
        /// </summary>
        /// <param name="dynamicsManager">
        /// The <see cref="DynamicsManager" /> object.
        /// </param>
        /// <param name="projectPath">
        /// The path to the project.
        /// </param>
        public static void ImportDynamicsManagerFromProject(DynamicsManager dynamicsManager, string projectPath)
        {
            if (dynamicsManager == null)
            {
                throw new System.ArgumentNullException("dynamicsManager");
            }

            if (string.IsNullOrEmpty(projectPath))
            {
                throw new System.ArgumentNullException("projectPath");
            }

            string assetPath;

            assetPath = Path.Combine(projectPath, "ProjectSettings/DynamicsManager.asset");

            if (!Directory.Exists(projectPath) || string.IsNullOrEmpty(assetPath) || !File.Exists(assetPath))
            {
                throw new System.ArgumentException(string.Format("Invalid project path: {0}", projectPath), "projectPath");
            }

            string tempPath;

            tempPath = FileUtil.GetUniqueTempPathInProject();

            if (string.IsNullOrEmpty(tempPath))
            {
                throw new System.InvalidOperationException(string.Format("Could not get temporary path: {0}", tempPath));
            }

            FileUtil.ReplaceFile(assetPath, tempPath);

            if (!File.Exists(tempPath))
            {
                throw new System.InvalidOperationException(string.Format("Could not copy asset to temporary path: {0}", tempPath));
            }

            SerializedObject tempObject;

            tempObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath(tempPath)[0]);

            if (tempObject == null)
            {
                throw new System.InvalidOperationException(string.Format("Could not load temporary asset: {0}", tempPath));
            }

            SerializedProperty tempProperty;

            tempProperty = tempObject.GetIterator();
            tempProperty.Next(true);

            SerializedObject contentObject = new SerializedObject(dynamicsManager);

            while (tempProperty.Next(false))
            {
                SerializedProperty contentProperty = contentObject.FindProperty(tempProperty.name);
                if (contentProperty != null)
                {
                    tempProperty.CopyTo(contentProperty);
                }
            }
            contentObject.ApplyModifiedPropertiesWithoutUndo();

            File.Delete(tempPath);
        }
Ejemplo n.º 3
0
 private static void CreateDefaultSettings()
 {
     DynamicsManager.CreateDefaultDynamicsManager();
     Physics2DSettings.CreateDefaultPhysics2DSettings();
     TimeManager.CreateDefaultTimeManager();
 }