Esempio n. 1
0
        private static void RemoveOverCloud()
        {
            GameObject overCloudPrefab = GameObject.Find("OverCloud");

            if (overCloudPrefab != null)
            {
                GameObject.DestroyImmediate(overCloudPrefab);
            }

            Camera mainCamera = GaiaUtils.GetCamera();

            if (mainCamera != null)
            {
                OverCloudCamera ocCamera = mainCamera.gameObject.GetComponent <OverCloudCamera>();
                if (ocCamera != null)
                {
                    GameObject.DestroyImmediate(ocCamera);
                }
            }

            if (GaiaUtils.CheckIfSceneProfileExists())
            {
                GaiaGlobal.Instance.SceneProfile.m_waterSystemMode = GaiaConstants.GlobalSystemMode.Gaia;
                GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
                if (gaiaSettings != null)
                {
                    UnityPipelineProfile pipelineProfile = gaiaSettings.m_pipelineProfile;
                    if (pipelineProfile != null)
                    {
                        GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, pipelineProfile, GaiaUtils.GetActivePipeline());
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Global Main Panel
        /// </summary>
        /// <param name="helpEnabled"></param>
        private void GlobalSettings(bool helpEnabled)
        {
            m_editorUtils.Heading("Setup");
            EditorGUI.indentLevel++;
            WaterReflections.SunLight     = (Light)m_editorUtils.ObjectField("SunLight", WaterReflections.SunLight, typeof(Light), true, helpEnabled);
            WaterReflections.m_player     = (Transform)m_editorUtils.ObjectField("Player", WaterReflections.m_player, typeof(Transform), true, helpEnabled);
            WaterReflections.SeaLevel     = m_editorUtils.FloatField("SeaLevel", WaterReflections.SeaLevel, helpEnabled);
            WaterReflections.InfiniteMode = m_editorUtils.Toggle("InfiniteMode", WaterReflections.InfiniteMode, helpEnabled);
            EditorGUI.indentLevel--;

            /*m_editorUtils.Heading("SurfaceSettings");
             * EditorGUI.indentLevel++;
             * WaterReflections.m_minSurfaceLight = m_editorUtils.FloatField("MinSurfaceLight", WaterReflections.m_minSurfaceLight, helpEnabled);
             * if (WaterReflections.m_minSurfaceLight > WaterReflections.m_maxSurfaceLight)
             * {
             *  WaterReflections.m_minSurfaceLight = WaterReflections.m_maxSurfaceLight - 0.1f;
             * }
             *
             * if (WaterReflections.m_minSurfaceLight < 0f)
             * {
             *  WaterReflections.m_minSurfaceLight = 0f;
             * }
             * WaterReflections.m_maxSurfaceLight = m_editorUtils.FloatField("MaxSurfaceLight", WaterReflections.m_maxSurfaceLight, helpEnabled);
             * if (WaterReflections.m_maxSurfaceLight < 0.1f)
             * {
             *  WaterReflections.m_maxSurfaceLight = 0.1f;
             * }
             * EditorGUI.indentLevel--;*/

            if (m_editorUtils.Button("EditReflectionSettings"))
            {
                GaiaUtils.FocusWaterProfile();
            }
        }
Esempio n. 3
0
        private static void AddOverCloud()
        {
            GameObject overCloudPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(GaiaUtils.GetAssetPath("OverCloud.prefab"));

            if (overCloudPrefab != null)
            {
                Light sunLight = GaiaUtils.GetMainDirectionalLight();
                if (sunLight != null)
                {
                    GameObject.DestroyImmediate(sunLight.gameObject);
                }

                PrefabUtility.InstantiatePrefab(overCloudPrefab, GetOrCreateParentObject(GaiaConstants.gaiaLightingObject, true).transform);

                Camera mainCamera = GaiaUtils.GetCamera();
                if (mainCamera != null)
                {
                    OverCloudCamera ocCamera = mainCamera.gameObject.GetComponent <OverCloudCamera>();
                    if (ocCamera == null)
                    {
                        ocCamera = mainCamera.gameObject.AddComponent <OverCloudCamera>();
                    }
                }

                GaiaUtils.SetCustomLightSystem(overCloudPrefab);
            }
            else
            {
                Debug.LogError("OverCloud Prefab was not found");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a CTS profile with a certain name to all terrains (loaded or not) and then bakes the textures for that terrain
        /// </summary>
        /// <param name="profileName"></param>
        public static void AddCTSProfile(string profileName)
        {
            bool bakeTerrainNormals = false;

            if (EditorUtility.DisplayDialog("Bake Terrain Normals?", "Do you want CTS to bake terrain normal maps while applying the profile as well?", "Yes", "No"))
            {
                bakeTerrainNormals = true;
            }


            CTSProfile ctsProfile = (CTSProfile)AssetDatabase.LoadAssetAtPath(GetCTSProfilePath(profileName), typeof(CTSProfile));

            if (ctsProfile != null)
            {
                if (GaiaUtils.HasDynamicLoadedTerrains())
                {
                    Action <Terrain> act = (t) => ApplyCTSProfile(t, ctsProfile, bakeTerrainNormals);
                    GaiaUtils.CallFunctionOnDynamicLoadedTerrains(act, true);
                }
                else
                {
                    foreach (Terrain t in Terrain.activeTerrains)
                    {
                        ApplyCTSProfile(t, ctsProfile, bakeTerrainNormals);
                    }
                }
                if (ctsProfile.m_needsAlbedosArrayUpdate || ctsProfile.m_needsNormalsArrayUpdate)
                {
                    CTSTerrainManager.Instance.BroadcastShaderSetup(ctsProfile);
                }
            }
        }
Esempio n. 5
0
 public static void GX_TimeOfDay_SetupLightingProfiles()
 {
     if (EditorUtility.DisplayDialog("Opening Lighting Profile", "This will open the lighting profile settings. In there you will be able to adjust lighting settings for Gaia, and you can also edit the default lighting parameters for 'Day', 'Nighttime', etc.", "OK", "Cancel"))
     {
         GaiaUtils.FocusLightingProfile();
     }
 }
Esempio n. 6
0
 public static void GX_WaterSetup_SetupWaterProfiles()
 {
     if (EditorUtility.DisplayDialog("Opening Water Profile", "This will open the water profile settings. In there you will be able to adjust water settings for Gaia, and you can also edit the default water shader parameters for the different water types.", "OK", "Cancel"))
     {
         GaiaUtils.FocusWaterProfile();
     }
 }
Esempio n. 7
0
        public static void GX_BakeColorMaps()
        {
            if (EditorUtility.DisplayDialog("Bake Terrain Color Maps", "This will bake the color maps for all Gaia Terrains in the scene (currently loaded or not). This can take a while depending on the number of your terrains.", "Bake Color Maps Now", "Cancel"))
            {
                bool bakeGrass = false;

                if (EditorUtility.DisplayDialog("Bake Grass?", "Do you want to bake the terrain details / grass in the color map?", "Yes", "No"))
                {
                    bakeGrass = true;
                }

                if (GaiaUtils.HasDynamicLoadedTerrains())
                {
                    Action <Terrain> act = (t) => BakeCTSColorMapForTerrain(t, bakeGrass);
                    GaiaUtils.CallFunctionOnDynamicLoadedTerrains(BakeCTSNormalsForTerrain, true);
                }
                else
                {
                    foreach (Terrain t in Terrain.activeTerrains)
                    {
                        BakeCTSColorMapForTerrain(t, bakeGrass);
                    }
                }
            }
        }
Esempio n. 8
0
        protected override fsResult DoDeserialize(Dictionary <string, fsData> data, ref Texture2D model)
        {
            var result = fsResult.Success;

            var present = false;

            result += DeserializeMember(data, "present", out present);

            if (present == true)
            {
                var path = "";
                result += DeserializeMember(data, "path", out path);
                if (!string.IsNullOrEmpty(path))
                {
                    model = GaiaUtils.GetAsset(path, typeof(Texture2D)) as Texture2D;
                    if (model == null)
                    {
                        Debug.LogWarning("Unable to locate asset : " + path);
                    }
                    else
                    {
                        var name = model.name;
                        result    += DeserializeMember(data, "name", out name);
                        model.name = name;
                    }
                }
            }

            return(result);
        }
Esempio n. 9
0
        static MewlistMassiveClouds()
        {
            string folderName = "MassiveClouds";

            if (Directory.Exists(GaiaUtils.GetAssetPath(folderName)))
            {
                //Make sure we inject GAIA_2_PRESENT
                bool updateScripting = false;
                var  symbols         = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                if (!symbols.Contains("MEWLIST_MASSIVE_CLOUDS"))
                {
                    updateScripting = true;
                    if (symbols.Length < 1)
                    {
                        symbols += "MEWLIST_MASSIVE_CLOUDS";
                    }
                    else
                    {
                        symbols += ";MEWLIST_MASSIVE_CLOUDS";
                    }
                }

                if (updateScripting)
                {
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, symbols);
                }
            }
        }
Esempio n. 10
0
        private static void AddClouds()
        {
            Camera mainCamera = GaiaUtils.GetCamera();

            if (mainCamera != null)
            {
                MassiveClouds clouds = mainCamera.GetComponent <MassiveClouds>();
                if (clouds == null)
                {
                    clouds = mainCamera.gameObject.AddComponent <MassiveClouds>();
                }

                List <MassiveCloudsProfile>   profiles   = new List <MassiveCloudsProfile>();
                MassiveCloudsProfile          profile    = AssetDatabase.LoadAssetAtPath <MassiveCloudsProfile>(GaiaUtils.GetAssetPath("Cloudy C.asset"));
                List <MassiveCloudsParameter> parameters = new List <MassiveCloudsParameter>();
                if (profile != null)
                {
                    profiles.Add(profile);
                    parameters.Add(profile.Parameter);
                    clouds.SetProfiles(profiles);
                    clouds.SetParameters(parameters);
                }

                MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent <MassiveCloudsCameraEffect>();
                if (cloudsEffect == null)
                {
                    cloudsEffect = mainCamera.gameObject.AddComponent <MassiveCloudsCameraEffect>();
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Get or create a parent object
        /// </summary>
        /// <param name="parentGameObject"></param>
        /// <param name="parentToGaia"></param>
        /// <returns>Parent Object</returns>
        public static GameObject GetOrCreateParentObject(string parentGameObject, bool parentToGaia)
        {
            //Get the parent object
            GameObject theParentGo = GameObject.Find(parentGameObject);

            if (theParentGo == null)
            {
                theParentGo = GameObject.Find(GaiaConstants.gaiaLightingObject);

                if (theParentGo == null)
                {
                    theParentGo = new GameObject(GaiaConstants.gaiaLightingObject);
                }
            }

            if (theParentGo.GetComponent <GaiaSceneLighting>() == null)
            {
                theParentGo.AddComponent <GaiaSceneLighting>();
            }

            if (parentToGaia)
            {
                GameObject gaiaParent = GaiaUtils.GetRuntimeSceneObject();
                if (gaiaParent != null)
                {
                    theParentGo.transform.SetParent(gaiaParent.transform);
                }
            }

            return(theParentGo);
        }
Esempio n. 12
0
        /// <summary>
        /// Does a quick optimize to your scene/project settings
        /// </summary>
        public static void GX_Optimization_QuickOptimize()
        {
            GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();

            if (gaiaSettings != null)
            {
                GaiaLighting.QuickOptimize(gaiaSettings);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Bakes lightmapping
        /// </summary>
        public static void GX_Lightmaps_BakeLighting()
        {
            GaiaSettings settings = GaiaUtils.GetGaiaSettings();

            if (settings != null)
            {
                if (GaiaUtils.CheckIfSceneProfileExists())
                {
                    GaiaLighting.BakeLighting(GaiaGlobal.Instance.SceneProfile.m_lightingBakeMode, GaiaGlobal.Instance.SceneProfile.m_lightingProfiles[GaiaGlobal.Instance.SceneProfile.m_selectedLightingProfileValuesIndex]);
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Gets the pipeline profile
        /// </summary>
        /// <returns></returns>
        private static UnityPipelineProfile GetPipelineProfile()
        {
            UnityPipelineProfile profile = null;

            GaiaSettings settings = GaiaUtils.GetGaiaSettings();

            if (settings != null)
            {
                profile = settings.m_pipelineProfile;
            }

            return(profile);
        }
Esempio n. 15
0
        private static void SetOverCloudQuality(OverCloudQuality quality)
        {
            Camera mainCamera = GaiaUtils.GetCamera();

            if (mainCamera != null)
            {
                OverCloudCamera ocCamera = mainCamera.GetComponent <OverCloudCamera>();
                if (ocCamera != null)
                {
                    switch (quality)
                    {
                    case OverCloudQuality.High:
                        ocCamera.downsample2DClouds     = false;
                        ocCamera.downsampleFactor       = DownSampleFactor.Full;
                        ocCamera.highQualityClouds      = true;
                        ocCamera.renderAtmosphere       = true;
                        ocCamera.renderScatteringMask   = true;
                        ocCamera.renderVolumetricClouds = true;
                        ocCamera.scatteringMaskSamples  = SampleCount.High;
                        ocCamera.lightSampleCount       = SampleCount.High;
                        break;

                    case OverCloudQuality.Medium:
                        ocCamera.downsample2DClouds     = true;
                        ocCamera.downsampleFactor       = DownSampleFactor.Half;
                        ocCamera.highQualityClouds      = true;
                        ocCamera.renderAtmosphere       = true;
                        ocCamera.renderScatteringMask   = true;
                        ocCamera.renderVolumetricClouds = true;
                        ocCamera.scatteringMaskSamples  = SampleCount.Normal;
                        ocCamera.lightSampleCount       = SampleCount.Normal;
                        break;

                    case OverCloudQuality.Low:
                        ocCamera.downsample2DClouds     = true;
                        ocCamera.downsampleFactor       = DownSampleFactor.Eight;
                        ocCamera.highQualityClouds      = false;
                        ocCamera.renderAtmosphere       = true;
                        ocCamera.renderScatteringMask   = false;
                        ocCamera.renderVolumetricClouds = false;
                        ocCamera.scatteringMaskSamples  = SampleCount.Low;
                        ocCamera.lightSampleCount       = SampleCount.Low;
                        break;
                    }
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Gets the shader
        /// </summary>
        /// <param name="path"></param>
        /// <param name="seachPattern"></param>
        /// <returns></returns>
        public static Shader GetShaderFile(string path, string seachPattern)
        {
            Shader        returningShader = null;
            DirectoryInfo dirInfo         = new DirectoryInfo(path);
            var           files           = dirInfo.GetFiles();

            foreach (FileInfo file in files)
            {
                if (file.Extension.EndsWith("shader") && file.Name.Contains(seachPattern))
                {
                    returningShader = AssetDatabase.LoadAssetAtPath <Shader>(GaiaUtils.GetAssetPath(file.Name));
                    return(returningShader);
                }
            }

            return(null);
        }
Esempio n. 17
0
 public static void GX_BakeTerrainNormals()
 {
     if (EditorUtility.DisplayDialog("Bake Terrain Normals", "This will bake the normal maps for all Gaia Terrains in the scene (currently loaded or not). This can take a while depending on the number of your terrains.", "Bake Normals Now", "Cancel"))
     {
         if (GaiaUtils.HasDynamicLoadedTerrains())
         {
             GaiaUtils.CallFunctionOnDynamicLoadedTerrains(BakeCTSNormalsForTerrain, true);
         }
         else
         {
             foreach (Terrain t in Terrain.activeTerrains)
             {
                 BakeCTSNormalsForTerrain(t);
             }
         }
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Sets the sun intensity
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="volumeProfile"></param>
 public static void SetSunSettings(GaiaLightingProfileValues profile)
 {
     try
     {
         Light light = GaiaUtils.GetMainDirectionalLight();
         if (light != null)
         {
             light.color     = profile.m_lWSunColor;
             light.intensity = profile.m_lWSunIntensity;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Esempio n. 19
0
        public override void OnInspectorGUI()
        {
            //Initialization
            m_editorUtils.Initialize(); // Do not remove this!

            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box)
                {
                    normal    = { textColor = GUI.skin.label.normal.textColor },
                    fontStyle = FontStyle.Bold,
                    alignment = TextAnchor.UpperLeft
                };
            }

            //Monitor for changes
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField("Profile Version: " + m_version);

            bool enableEditMode = System.IO.Directory.Exists(GaiaUtils.GetAssetPath("Dev Utilities"));

            if (enableEditMode)
            {
                m_profile.m_editorUpdates = EditorGUILayout.ToggleLeft("Use Procedural Worlds Editor Settings", m_profile.m_editorUpdates);
            }
            else
            {
                m_profile.m_editorUpdates = false;
            }

            if (m_profile.m_editorUpdates)
            {
                m_editorUtils.Panel("ProfileSettings", ProfileSettingsEnabled, false);
            }

            //Check for changes, make undo record, make changes and let editor know we are dirty
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(m_profile, "Made changes");
                EditorUtility.SetDirty(m_profile);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// To build the byte array which represents this Gaia Packet over BLE.
        /// The bytes array is built according to the definition of a GAIA Packet sent over BLE:
        /// 0 bytes  1         2        3         4                 len+4
        /// +--------+---------+--------+--------+ +--------+--------+
        /// |    VENDOR ID     |   COMMAND ID    | | PAYLOAD   ...   |
        /// +--------+---------+--------+--------+ +--------+--------+
        /// </summary>
        /// <param name="_commandId">The command ID for the packet bytes to build:
        /// The original command ID of this packet.
        /// The acknowledgement version of the original command ID.</param>
        /// <param name="_payload">The payload to include in the packet bytes.</param>
        /// <returns>A new byte array built with the given information.</returns>
        public override byte[] BuildBytes(int _commandId, byte[] _payload)
        {
            int length = _payload.Length + OFFSET_PAYLOAD;

            byte[] data = new byte[length];

            try
            {
                GaiaUtils.CopyIntIntoByteArray(VendorId, data, OFFSET_VENDOR_ID, LENGTH_VENDOR_ID, false);
                GaiaUtils.CopyIntIntoByteArray(_commandId, data, OFFSET_COMMAND_ID, LENGTH_COMMAND_ID, false);
                Array.Copy(_payload, 0, data, OFFSET_PAYLOAD, _payload.Length);
            }
            catch (GaiaException)
            {
                throw new GaiaException(GaiaException.Type.PAYLOAD_LENGTH_TOO_LONG);
            }

            return(data);
        }
Esempio n. 21
0
        private static void RemoveClouds()
        {
            Camera mainCamera = GaiaUtils.GetCamera();

            if (mainCamera != null)
            {
                MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent <MassiveCloudsCameraEffect>();
                if (cloudsEffect != null)
                {
                    GameObject.DestroyImmediate(cloudsEffect);
                }

                MassiveClouds clouds = mainCamera.GetComponent <MassiveClouds>();
                if (clouds != null)
                {
                    GameObject.DestroyImmediate(clouds);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Removes Suffix in file formats required
        /// </summary>
        /// <param name="path"></param>
        private static List <Material> GetMaterials(string path)
        {
            List <Material> materials = new List <Material>();

            DirectoryInfo dirInfo = new DirectoryInfo(path);
            var           files   = dirInfo.GetFiles();

            foreach (FileInfo file in files)
            {
                if (file.Extension.EndsWith("mat"))
                {
                    materials.Add(AssetDatabase.LoadAssetAtPath <Material>(GaiaUtils.GetAssetPath(file.Name)));
                }
            }

            m_allMaterials = materials;

            return(materials);
        }
Esempio n. 23
0
        /// <summary>
        /// Adds water system to the scene
        /// </summary>
        public static void GX_WaterSetup_AddWater()
        {
            GaiaSettings     gaiaSettings = GaiaUtils.GetGaiaSettings();
            GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath <GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
            Material         material     = GaiaWater.GetGaiaOceanMaterial();

            if (material != null)
            {
                GaiaUtils.GetRuntimeSceneObject();
                if (GaiaGlobal.Instance != null)
                {
                    GaiaWater.GetProfile(0, material, GaiaGlobal.Instance.SceneProfile, true, false);
                }
            }
            else
            {
                Debug.Log("Material could not be found");
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Configures project for LWRP
        /// </summary>
        /// <param name="profile"></param>
        private static void ConfigureSceneToLWRP(UnityPipelineProfile profile)
        {
            GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();

            if (gaiaSettings.m_currentRenderer != GaiaConstants.EnvironmentRenderer.Lightweight)
            {
                Debug.LogError("Unable to configure your scene/project to LWRP as the current render inside of gaia does not equal Lightweight as it's active render pipeline. This process [GaiaLWRPPipelineUtils.ConfigureSceneToLWRP()] will now exit.");
                return;
            }

            if (profile.m_setLWPipelineProfile)
            {
                SetPipelineAsset(profile);
            }

            if (profile.m_LWAutoConfigureCamera)
            {
                ConfigureCamera();
            }

            if (profile.m_LWAutoConfigureLighting)
            {
                ConfigureLighting(gaiaSettings.m_gaiaLightingProfile);
            }

            if (profile.m_LWAutoConfigureWater)
            {
                ConfigureWater(profile, gaiaSettings);
            }

            if (profile.m_LWAutoConfigureProbes)
            {
                ConfigureReflectionProbes();
            }

            if (profile.m_LWAutoConfigureTerrain)
            {
                ConfigureTerrain(profile);
            }

            FinalizeLWRP(profile, gaiaSettings);
        }
Esempio n. 25
0
        /// <summary>
        /// Sets the sun intensity
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="volumeProfile"></param>
        public static void SetSunSettings(Light light, GaiaLightingProfileValues profile)
        {
            if (light == null)
            {
                light = GetSunLight();
            }

            if (profile.m_useKelvin)
            {
                profile.m_lWSunColor = GaiaUtils.ExecuteKelvinColor(profile.m_kelvinValue);
            }
            if (light != null)
            {
                light.color            = profile.m_lWSunColor;
                light.intensity        = profile.m_lWSunIntensity;
                light.shadows          = profile.m_shadowCastingMode;
                light.shadowStrength   = profile.m_shadowStrength;
                light.shadowResolution = profile.m_sunShadowResolution;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Constructor that builds a packet from a byte sequence.
        /// </summary>
        /// <param name="source">Array of bytes to build the command from.</param>
        public GaiaPacketBLE(byte[] source)
        {
            int payloadLength = source.Length - PACKET_INFORMATION_LENGTH;

            if (payloadLength < 0)
            {
                throw new GaiaException(GaiaException.Type.PACKET_PAYLOAD_INVALID_PARAMETER);
            }

            VendorId  = GaiaUtils.ExtractIntFromByteArray(source, OFFSET_VENDOR_ID, LENGTH_VENDOR_ID, false);
            CommandId = GaiaUtils.ExtractIntFromByteArray(source, OFFSET_COMMAND_ID, LENGTH_COMMAND_ID, false);

            if (payloadLength > 0)
            {
                Payload = new byte[payloadLength];
                Array.Copy(source, OFFSET_PAYLOAD, Payload, 0, payloadLength);
            }

            Bytes = source;
        }
Esempio n. 27
0
        /// <summary>
        /// Constructor that builds a command from a byte sequence.
        /// </summary>
        /// <param name="_source">Array of bytes to build the command from.</param>
        public GaiaPacketBREDR(byte[] _source)
        {
            int flags         = _source[OFFSET_FLAGS];
            int payloadLength = _source.Length - OFFSET_PAYLOAD;

            if ((flags & FLAG_CHECK_MASK) != 0)
            {
                --payloadLength;
            }

            VendorId  = GaiaUtils.ExtractIntFromByteArray(_source, OFFSET_VENDOR_ID, LENGTH_VENDOR_ID, false);
            CommandId = GaiaUtils.ExtractIntFromByteArray(_source, OFFSET_COMMAND_ID, LENGTH_COMMAND_ID, false);

            if (payloadLength > 0)
            {
                Payload = new byte[payloadLength];
                Array.Copy(_source, OFFSET_PAYLOAD, Payload, 0, payloadLength);
            }

            Bytes = _source;
        }
Esempio n. 28
0
 public static void GX_RemoveCTS()
 {
     if (EditorUtility.DisplayDialog("Remove CTS", "Are you sure you want to completely remove CTS from all the terrains in your scene? This will also remove CTS from terrains which are currently not loaded in this scene.", "Remove CTS", "Cancel"))
     {
         if (GaiaUtils.HasDynamicLoadedTerrains())
         {
             GaiaUtils.CallFunctionOnDynamicLoadedTerrains(RemoveCTSFromTerrain, true);
         }
         else
         {
             foreach (Terrain t in Terrain.activeTerrains)
             {
                 RemoveCTSFromTerrain(t);
             }
         }
         GameObject wm = GameObject.Find("CTS Weather Manager");
         if (wm != null)
         {
             UnityEngine.Object.DestroyImmediate(wm);
         }
     }
 }
Esempio n. 29
0
        /// <summary>
        /// To build the byte array which represents this Gaia Packet over BR/EDR.
        /// The bytes array is built according to the definition of a GAIA Packet sent over BR/EDR:
        /// 0 bytes  1         2        3        4        5        6        7         8         9       len+8
        /// +--------+---------+--------+--------+--------+--------+--------+--------+ +--------+--------+ +--------+
        /// |   SOF  | VERSION | FLAGS  | LENGTH |    VENDOR ID    |   COMMAND ID    | | PAYLOAD   ...   | | CHECK  |
        /// +--------+---------+--------+--------+--------+--------+--------+--------+ +--------+--------+ +--------+
        /// </summary>
        /// <param name="_commandId">The command ID for the packet bytes to build:
        /// The original command ID of this packet.
        /// The acknowledgement version of the original command ID.</param>
        /// <param name="_payload">The payload to include in the packet bytes.</param>
        /// <returns>A new byte array built with the given information.</returns>
        public override byte[] BuildBytes(int _commandId, byte[] _payload)
        {
            // if the payload is bigger than the maximum size: packet won't be sent.
            if (_payload.Length > MAX_PAYLOAD)
            {
                throw new GaiaException(GaiaException.Type.PAYLOAD_LENGTH_TOO_LONG);
            }

            int length = _payload.Length + OFFSET_PAYLOAD + (mHasChecksum ? CHECK_LENGTH : 0);

            byte[] data = new byte[length];
            data[OFFSET_SOF]     = SOF;
            data[OFFSET_VERSION] = (byte)PROTOCOL_VERSION;
            data[OFFSET_FLAGS]   = 0x01;
            if (!mHasChecksum)
            {
                data[OFFSET_FLAGS] = 0x00;
            }
            data[OFFSET_LENGTH] = (byte)Payload.Length;

            GaiaUtils.CopyIntIntoByteArray(VendorId, data, OFFSET_VENDOR_ID, LENGTH_VENDOR_ID, false);
            GaiaUtils.CopyIntIntoByteArray(_commandId, data, OFFSET_COMMAND_ID, LENGTH_COMMAND_ID, false);

            Array.Copy(_payload, 0, data, OFFSET_PAYLOAD, _payload.Length);

            // if there is a checksum, calculating the checksum value
            if (mHasChecksum)
            {
                byte check = 0;
                for (int i = 0; i < length - 1; i++)
                {
                    check ^= data[i];
                }
                data[length - 1] = check;
            }

            return(data);
        }
Esempio n. 30
0
        /// <summary>
        /// Configures camera to LWRP
        /// </summary>
        private static void ConfigureCamera()
        {
            try
            {
                Camera camera = GaiaUtils.GetCamera();
                if (camera == null)
                {
                    Debug.LogWarning("[GaiaUPRPPipelineUtils.ConfigureCamera()] A camera could not be found to upgrade in your scene.");
                }
                else
                {
#if UPPipeline
                    UniversalAdditionalCameraData cameraData = GaiaURPRuntimeUtils.GetUPCameraData(camera);
                    cameraData.renderShadows = true;
#endif
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }