当前位置: 首页>>代码示例>>C#>>正文


C# Movie.CreateObject方法代码示例

本文整理汇总了C#中Movie.CreateObject方法的典型用法代码示例。如果您正苦于以下问题:C# Movie.CreateObject方法的具体用法?C# Movie.CreateObject怎么用?C# Movie.CreateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Movie的用法示例。


在下文中一共展示了Movie.CreateObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToASObject

            public static Value ConvertToASObject(object obj, Movie mv)
            {
                // Step1: Get object type
                System.Type tp = obj.GetType();
                UnityEngine.Debug.Log(String.Format ("Type of CS object to convert: {0} \n", tp.Name));
                // Step 2: Create AS object of the correct type using CreateObject (defined in SFMovie for now)
                // The ActionScript class must have a default constructor that accepts no arguments, otherwise we will
                // get error# 1063
                Value result = mv.CreateObject(tp.Name);
                if(null == result || !result.IsValid())
                {
                return null;
                }
                // Step 3: Iterate over the properties of obj and fill in the corresponding members of the ASObject, if
                // the members exist
                // Also think about nested objects etc.
                foreach (var propInfo in tp.GetProperties())
                {
                UnityEngine.Debug.Log(propInfo.PropertyType);

                Value propertyValue = result.GetMember(propInfo.Name);
                if (propertyValue == null)
                {
                continue;
                }

                if (propInfo.PropertyType == typeof(System.Int32))
                {
                result.SetMember(propInfo.Name, (Int32)propInfo.GetValue(obj, null));
                }
                else if (propInfo.PropertyType == typeof(String))
                {
                result.SetMember(propInfo.Name, (String)propInfo.GetValue(obj, null));
                }
                else if (propInfo.PropertyType == typeof(System.UInt32))
                {
                result.SetMember(propInfo.Name, propertyValue);
                }
                else if (propInfo.PropertyType == typeof(Double))
                {
                result.SetMember(propInfo.Name, (Double)propInfo.GetValue(obj, null));
                }
                else if (propInfo.PropertyType == typeof(System.Single)) // float
                {
                result.SetMember(propInfo.Name, (Single)propInfo.GetValue(obj, null));
                }
                else if (propInfo.PropertyType == typeof(System.Boolean))
                {
                result.SetMember(propInfo.Name, (Boolean)propInfo.GetValue(obj, null));
                }
                else
                {
                if(!propInfo.PropertyType.IsPrimitive )
                {
                    propertyValue = ConvertToASObject(propInfo.GetValue(obj, null), mv);
                    result.SetMember(propInfo.Name, propertyValue);
                }
                else
                {
                    UnityEngine.Debug.Log(String.Format("Trying to convert a not handled managed type{0}!", propInfo.PropertyType.Name));
                }
                }
                }

                return result;
            }
开发者ID:BiDuc,项目名称:Stereoscopic_Scatterplot,代码行数:66,代码来源:SFValue.cs


注:本文中的Movie.CreateObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。