Ejemplo n.º 1
0
        private YamlObject TestGeneral(string text, int childCount)
        {
            var result = new UnityYamlTree().Parse(text);

            result.YamlNodeType.Should().Be(YamlNodeType.UnityYamlFile);

            var fileNode = (UnityYamlFile)result;

            fileNode.FileId.Should().Be("1");
            fileNode.UnityId.Should().Be("29");

            fileNode.Block.Count.Should().Be(1);

            var block = fileNode.Block["OcclusionCullingSettings"];

            block.YamlNodeType.Should().Be(YamlNodeType.Object);
            var obj = (YamlObject)block;

            obj.Values.Count.Should().Be(childCount);

            (obj.Values["m_ObjectHideFlags"] as YamlScalar).Value.Should().Be("0");
            (obj.Values["serializedVersion"] as YamlScalar).Value.Should().Be("2");
            (obj.Values["m_SceneGUID"] as YamlScalar).Value.Should().Be("00000000000000000000000000000000");

            return(obj);
        }
Ejemplo n.º 2
0
        public void TestLists()
        {
            var text   = @"
GameObject:
  m_Component:
  - component: {fileID: 1495266950}
    propertyPath: m_AnchorMin.x
    value: 0
  - component: {fileID: 1495266949, 
    test: 1}
    propertyPath: m_AnchorMin.y
    value: 0
".Trim();
            var result = new UnityYamlTree().Parse(text);

            var gameObject = (YamlObject)result;

            gameObject.Values.Count.Should().Be(1);

            var mComponent = gameObject["m_Component"];

            mComponent.YamlNodeType.Should().Be(YamlNodeType.List);
            mComponent.As <YamlList>().Count().Should().Be(2);
            mComponent.As <YamlList>()[0]["component"]["fileID"].AsString().Should().Be("1495266950");
            mComponent.As <YamlList>()[0]["propertyPath"].AsString().Should().Be("m_AnchorMin.x");
            mComponent.As <YamlList>()[0]["value"].AsInt().Should().Be(0);

            mComponent.As <YamlList>()[1]["component"]["fileID"].AsString().Should().Be("1495266949");
            mComponent.As <YamlList>()[1]["component"]["test"].AsInt().Should().Be(1);
            mComponent.As <YamlList>()[1]["propertyPath"].AsString().Should().Be("m_AnchorMin.y");
            mComponent.As <YamlList>()[1]["value"].AsInt().Should().Be(0);
        }
Ejemplo n.º 3
0
        public void RealLifeTest()
        {
            var text   = @"
RenderSettings:
  m_ObjectHideFlags: 0
  serializedVersion: 9
  m_Fog: 0
  m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
  m_FogMode: 3
  m_FogDensity: 0.01
  m_LinearFogStart: 0
  m_LinearFogEnd: 300
  m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
  m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
  m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
  m_AmbientIntensity: 1
  m_AmbientMode: 3
  m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
  m_SkyboxMaterial: {fileID: 0}
  m_HaloStrength: 0.5
  m_FlareStrength: 1
  m_FlareFadeSpeed: 3
  m_HaloTexture: {fileID: 0}
  m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
  m_DefaultReflectionMode: 0
  m_DefaultReflectionResolution: 128
  m_ReflectionBounces: 1
  m_ReflectionIntensity: 1
  m_CustomReflection: {fileID: 0}
  m_Sun: {fileID: 0}
  m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
  m_UseRadianceAmbientProbe: 0".Trim();
            var result = new UnityYamlTree().Parse(text);

            result.YamlNodeType.Should().Be(YamlNodeType.Object);

            var renderSettings = (YamlObject)result;

            renderSettings.Values.Count.Should().Be(28);

            var fogColorA = renderSettings["m_FogColor"]["a"];

            fogColorA.AsString().Should().Be("1");
            fogColorA.AsInt().Should().Be(1);

            var spotCookieGuid = renderSettings["m_SpotCookie"]["guid"];

            spotCookieGuid.AsString().Should().Be("0000000000000000e000000000000000");
            spotCookieGuid.TryAsInt(out _).Should().BeFalse();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var randomScenePath = @"C:\Users\dohi\Documents\repos\OnAirV2\Assets\Scenes\TestSite.unity";

            var text = File.ReadAllText(randomScenePath);

            var yaml = new UnityYamlTree().Parse(text);

            Console.WriteLine(yaml.As <UnityScene>().UnityYamlFiles.Count);


            return;

            var assetsPath      = @"C:\Users\dohi\Documents\repos\OnAirV2\Assets";
            var targetFile      = @"C:\Users\dohi\Documents\repos\OnAirV2\Assets\Textures\Common\common_ui.png";
            var targetImageName = "btn_common_01";

            var meta            = targetFile + ".meta";
            var guid            = GetGuid(meta);
            var fileIdToRecycle = GetFileIdToRecycle(meta, targetImageName);

            var directoryInfo = new DirectoryInfo(assetsPath);
            var scenes        = FindFilesWithExtension(directoryInfo, ".unity", true);

            foreach (var scene in scenes)
            {
                var usingGameObjects = UsingGameObjects(scene.FullName, guid, fileIdToRecycle);
                if (usingGameObjects.Any() == false)
                {
                    continue;
                }

                Console.WriteLine(scene.Name + ":");
                foreach (var gameObject in usingGameObjects)
                {
                    Console.WriteLine($"  {gameObject}");
                }
            }
        }