Inheritance: ScriptableHolder
        internal override bool Transform(string propName, string propData, ResolutionContext ctx, ConvertionManager cm, ExtensionResolution ex)
        {
            var holder = new StringHolder(propData);

            ex.Data.AddDataHolder(propName, holder);
            return(true);
        }
    public override void Loader()
    {
        if (m_AssetBundleCreateRequest.isDone == false)
        {
            Debug.LogError("AnimationLoader : m_AssetBundleCreateRequest");
            return;
        }
        if (m_AnimName == null)
        {
            m_AnimName = (StringHolder)m_AssetBundleCreateRequest.assetBundle.Load(AssemblerConstant.BONE_NAMES, typeof(StringHolder));
        }

        if (m_AnimName == null)
        {
            Debug.LogError("AnimationLoader m_AssetBundleCreateRequest");
            return;
        }

        StringHolder holder = (StringHolder)m_AnimName;

        foreach (string name in holder.content)
        {
            if (!m_Anims.ContainsKey(name))
            {
                AnimationClip ar = (AnimationClip)m_AssetBundleCreateRequest.assetBundle.Load(name, typeof(AnimationClip));
                m_Anims.Add(name, ar);
            }
        }
        IsLoaded = true;
    }
    public override void Loader()
    {
        if (m_WWW.isDone == false || !string.IsNullOrEmpty(m_WWW.error))
        {
            Debug.LogError("AnimationLoader.Loader  : " + m_WWW.error + " @ " + m_WWW.url);
            return;
        }
        if (m_AnimName == null)
        {
            m_AnimName = (StringHolder)m_WWW.assetBundle.LoadAsset(AssemblerConstant.BONE_NAMES, typeof(StringHolder));
        }

        if (m_AnimName == null)
        {
            Debug.LogError("AnimationLoader.Loader m_AnimName " + m_WWW.url + " By " + AssemblerConstant.BONE_NAMES);
            return;
        }

        StringHolder holder = (StringHolder)m_AnimName;

        foreach (string name in holder.content)
        {
            if (!m_Anims.ContainsKey(name))
            {
                AnimationClip ar = (AnimationClip)m_WWW.assetBundle.LoadAsset(name, typeof(AnimationClip));
                m_Anims.Add(name, ar);
            }
        }
        IsLoaded = true;
    }
Esempio n. 4
0
        public static string[] AvailableFontFaceNames()
        {
            IntPtr pStringArray = UnsafeNativeMethods.ON_StringArray_New();
            int    count        = UnsafeNativeMethods.CRhinoFontTable_GetFontNames(pStringArray);

            string[] rc = new string[count];
            using (var sh = new StringHolder())
            {
                IntPtr pStringHolder = sh.NonConstPointer();
                for (int i = 0; i < count; i++)
                {
                    UnsafeNativeMethods.ON_StringArray_Get(pStringArray, i, pStringHolder);
                    rc[i] = sh.ToString();
                }
            }
            UnsafeNativeMethods.ON_StringArray_Delete(pStringArray);
            if (count < 1)
            {
                System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
                rc = new string[fonts.Families.Length];
                for (int i = 0; i < fonts.Families.Length; i++)
                {
                    rc[i] = fonts.Families[i].Name;
                }
            }
            Array.Sort(rc);
            return(rc);
        }
Esempio n. 5
0
    void SaveToJson()
    {
        string savePath   = PrefabsPath + SceneName + "/" + SceneName + ".asset";
        string bundlePath = exportPath + SceneName + "/" + SceneName + ".ab";

        mSceneClient             = new Scene();
        mSceneClient.name        = SceneName;
        mSceneClient.terrainFile = SceneName + "/" + SceneName + ".unity3d";
        mSceneClient.objects     = new List <SceneNode>();


        foreach (SceneNodeE node in PrefabsList)
        {
            writeObjectToScene(mSceneClient, node);
        }
        EditorSerializer.SerializeObjectAndSave(mSceneClient, exportPath + SceneName + "/" + SceneName + ".json");

        //save to asset
        StringHolder jsonAsset = ScriptableObject.CreateInstance <StringHolder>();

        string[] stringholder = { EditorSerializer.ObjectToJson(mSceneClient) };
        jsonAsset.content = stringholder;
        AssetDatabase.CreateAsset(jsonAsset, savePath);
        Object o = AssetDatabase.LoadAssetAtPath(savePath, typeof(StringHolder));

        BuildPipeline.BuildAssetBundle(o, null, bundlePath);
        AssetDatabase.DeleteAsset(savePath);
    }
Esempio n. 6
0
        /// <summary>
        /// Override this function to provide information about which texture is used for
        /// the standard (ie - defined in ON_Texture) texture channels.
        /// </summary>
        /// <param name="slot">An valid slot.</param>
        /// <returns>The texture used for the channel.</returns>
        public virtual string TextureChildSlotName(StandardChildSlots slot)
        {
            if (IsNativeWrapper())
            {
                StringIds iString = StringIds.DiffuseChildSlotName;
                switch (slot)
                {
                case StandardChildSlots.Diffuse:
                    iString = StringIds.DiffuseChildSlotName;
                    break;

                case StandardChildSlots.Transparency:
                    iString = StringIds.TransparencyChildSlotName;
                    break;

                case StandardChildSlots.Bump:
                    iString = StringIds.BumpChildSlotName;
                    break;

                case StandardChildSlots.Environment:
                    iString = StringIds.EnvironmentChildSlotName;
                    break;
                }
                return(GetString(iString));
            }

            using (var sh = new StringHolder())
            {
                IntPtr pString = sh.NonConstPointer();
                UnsafeNativeMethods.Rdk_RenderMaterial_CallTextureChildSlotNameBase(ConstPointer(), pString, (int)slot);
                return(sh.ToString());
            }
        }
Esempio n. 7
0
        private void btnLookup_Click(object sender, EventArgs e)
        {
            string strID = this.txtID.Text;

            if (string.IsNullOrEmpty(strID))
            {
                MessageBox.Show(this, "ID Field is empty.  Please specify a string ID to find.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            uint uiID;

            if (!uint.TryParse(strID, NumberStyles.HexNumber, null, out uiID))
            {
                MessageBox.Show(this, "Unable to parse string id", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                StringHolder holder = this.strings.FirstOrDefault(a => a.ID == uiID);
                if (holder != null)
                {
                    this.SetSelectedItem(holder);
                }
            }
        }
    public override void Loader()
    {
        if (m_WWW.isDone == false || !string.IsNullOrEmpty(m_WWW.error))
        {
            Debug.LogError("AnimationLoader.Loader  : " + m_WWW.error + " @ " + m_WWW.url);
            return;
        }
        if (m_AnimName == null)
            m_AnimName = (StringHolder)m_WWW.assetBundle.Load(AssemblerConstant.BONE_NAMES, typeof(StringHolder));

        if (m_AnimName == null)
        {
            Debug.LogError("AnimationLoader.Loader m_AnimName " + m_WWW.url + " By " + AssemblerConstant.BONE_NAMES);
            return;
        }

        StringHolder holder = (StringHolder)m_AnimName;
        foreach (string name in holder.content)
        {
            if (!m_Anims.ContainsKey(name))
            {
                AnimationClip ar = (AnimationClip)m_WWW.assetBundle.Load(name, typeof(AnimationClip));
                m_Anims.Add(name, ar);
            }
        }
        IsLoaded = true;
    }
Esempio n. 9
0
    /// <summary>
    /// 获取AssetBundle中资源清单
    /// </summary>
    protected void GetResourcsList()
    {
        if (!GlobalConst.IS_DEVELOP)
        {
            string path = AssetRoot + "/ResourceList.assetbundle";

            byte[]      fileBytes   = File.ReadAllBytes(path);
            AssetBundle assetBundle = AssetBundle.LoadFromMemory(fileBytes);

            StringHolder depList = assetBundle.LoadAsset("ResourceList", typeof(StringHolder)) as StringHolder;
            if (depList != null && depList.AssetBundleList != null && depList.ResourceList != null)
            {
                for (int i = 0; i < depList.ResourceList.Count; i++)
                {
                    string resStr = depList.ResourceList[i].ToLower();
                    if (!_dictionaryResourcesPath.ContainsKey(resStr))
                    {
                        _dictionaryResourcesPath.Add(resStr, depList.AssetBundleList[i]);
                    }
                    else
                    {
                        Debug.LogWarning("ResourcsList=>" + resStr);
                    }
                }
            }

            assetBundle.Unload(true);
        }
    }
    /// <summary>
    /// 制作资源清单
    /// </summary>
    private static void CreateResourceList()
    {
        string       resourceList = "Assets/ResourceList.asset";
        StringHolder holder       = ScriptableObject.CreateInstance <StringHolder>();

        holder.ResourceList    = new List <string>();
        holder.AssetBundleList = new List <string>();
        foreach (var d in ResourceDictionary)
        {
            foreach (var l in d.Value)
            {
                string res = l.Replace("Assets/Resources/", "");
                res = res.Substring(0, res.IndexOf("."));

                string ass = d.Key;

                holder.ResourceList.Add(res);
                holder.AssetBundleList.Add(ass);
            }
        }

        if (File.Exists(resourceList))
        {
            File.Delete(resourceList);
        }
        AssetDatabase.CreateAsset(holder, resourceList);
        Object objResourceList = AssetDatabase.LoadAssetAtPath(resourceList, typeof(StringHolder));

        string assetBundle = AssetbundlePath + "ResourceList.assetbundle";
        bool   result      = BuildPipeline.BuildAssetBundle(objResourceList, null, assetBundle, buildOp, buildTarget);

        Log(assetBundle, !result);
    }
Esempio n. 11
0
        public void SetOption(string optionCode, string value)
        {
            string oldValue = GetOption(optionCode);

            if (!string.IsNullOrWhiteSpace(optionCode) &&
                (value != oldValue || (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(oldValue))))
            {
                StringHolder option;

                if (optionCache.TryGetValue(optionCode, out option))
                {
                    if (option == null)
                    {
                        option = new StringHolder(value);
                        optionCache[optionCode] = option;
                    }
                    else
                    {
                        option.Value = value;
                    }
                }
                else
                {
                    option = new StringHolder(value);
                    optionCache.Add(optionCode, option);
                }

                SetDbOption(optionCode, value);
            }
        }
        /// <summary>
        /// Gets a copy of all (user key string, user value string) pairs attached to this geometry.
        /// </summary>
        /// <returns>A new collection.</returns>
        internal System.Collections.Specialized.NameValueCollection _GetUserStrings()
        {
            System.Collections.Specialized.NameValueCollection rc = new System.Collections.Specialized.NameValueCollection();
            IntPtr const_ptr_this  = ConstPointer();
            int    count           = 0;
            IntPtr ptr_userstrings = UnsafeNativeMethods.ON_Object_GetUserStrings(const_ptr_this, ref count);

            using (var keyHolder = new StringHolder())
                using (var valueHolder = new StringHolder())
                {
                    IntPtr pKeyHolder   = keyHolder.NonConstPointer();
                    IntPtr pValueHolder = valueHolder.NonConstPointer();

                    for (int i = 0; i < count; i++)
                    {
                        UnsafeNativeMethods.ON_UserStringList_KeyValue(ptr_userstrings, i, true, pKeyHolder);
                        UnsafeNativeMethods.ON_UserStringList_KeyValue(ptr_userstrings, i, false, pValueHolder);
                        string key   = keyHolder.ToString();
                        string value = valueHolder.ToString();
                        if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                        {
                            rc.Add(key, value);
                        }
                    }
                }

            if (IntPtr.Zero != ptr_userstrings)
            {
                UnsafeNativeMethods.ON_UserStringList_Delete(ptr_userstrings);
            }

            return(rc);
        }
Esempio n. 13
0
        public static void ResizeSettingsProperties()
        {
            var desktopCount = VirtualDesktopService.Count();
            var desktopNames = Settings.General.DesktopNames.Value;

            if (desktopNames == null)
            {
                var temp = new StringHolder[desktopCount];
                for (int i = 0; i < desktopCount; ++i)
                {
                    temp[i] = new StringHolder();
                }
                desktopNames = new ObservableCollection <StringHolder>(temp);
                Settings.General.DesktopNames.Value = desktopNames;
            }
            else if (desktopNames.Count != desktopCount)
            {
                var temp = new StringHolder[desktopNames.Count];
                desktopNames.CopyTo(temp, 0);
                Array.Resize <StringHolder>(ref temp, desktopCount);
                for (int i = desktopNames.Count; i < temp.Length; i++)
                {
                    temp[i] = new StringHolder();
                }
                Settings.General.DesktopNames.Value = new ObservableCollection <StringHolder>(temp);
            }
        }
Esempio n. 14
0
            private static int OnCustomColorDialog(ref int argb, int colorButtons, IntPtr titleAsStringHolder, IntPtr hParent)
            {
                int rc = 0;

                if (m_ShowCustomColorDialog != null)
                {
                    try
                    {
                        var color = System.Drawing.Color.FromArgb(argb);
                        System.Windows.Forms.IWin32Window parent = null;
                        string            title = StringHolder.GetString(titleAsStringHolder);
                        GetColorEventArgs e     = new GetColorEventArgs(color, colorButtons == 1, title);

                        if (hParent != IntPtr.Zero)
                        {
                            parent = new RhinoWindow(hParent);
                        }
                        m_ShowCustomColorDialog(parent, e);
                        if (e.SelectedColor != System.Drawing.Color.Empty)
                        {
                            argb = e.SelectedColor.ToArgb();
                            rc   = 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        Runtime.HostUtils.ExceptionReport(ex);
                    }
                }
                return(rc);
            }
 private List<string> GetLogs(StringHolder s)
 {
     if (s == null) return new List<string>();
     if (string.IsNullOrWhiteSpace(s.Data)) return new List<string>();
     var logs = s.Data;
     return logs.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
 }
    public override void Loader()
    {
        if (m_AssetBundleCreateRequest.isDone == false)
        {
            Debug.LogError("AnimationLoader : m_AssetBundleCreateRequest");
            return;
        }
        if (m_AnimName == null)
            m_AnimName = (StringHolder)m_AssetBundleCreateRequest.assetBundle.Load(AssemblerConstant.BONE_NAMES, typeof(StringHolder));

        if (m_AnimName == null)
        {
            Debug.LogError("AnimationLoader m_AssetBundleCreateRequest");
            return;
        }

        StringHolder holder = (StringHolder)m_AnimName;
        foreach (string name in holder.content)
        {
            if (!m_Anims.ContainsKey(name))
            {
                AnimationClip ar = (AnimationClip)m_AssetBundleCreateRequest.assetBundle.Load(name, typeof(AnimationClip));
                m_Anims.Add(name, ar);
            }
        }
        IsLoaded = true;
    }
Esempio n. 17
0
    public List <SizeboxModel> GetSizeboxModelList(List <string> FilePaths, string Extension)//OYM:获取所有Sziebox模型
    {
        if (FilePaths.Count == 0 || Extension.Length == 0)
        {
            return(null);
        }

        foreach (string m_FilePath in FilePaths)
        {
            if (!m_FilePath.EndsWith(Extension.Substring(1)))
            {
                continue;
            }

            AssetBundle ABundle = AssetBundle.LoadFromFile(m_FilePath);

            if (ABundle == null)
            {
                Debug.Log("Error 000:Can't loading model {0}" + m_FilePath);//OYM:无法加载
            }
            else
            {
                StringHolder modelsInside = (StringHolder)ABundle.LoadAsset("modellist");
                foreach (string m_modelName in modelsInside.content)
                {
                    Texture2D Texture = ABundle.LoadAsset(m_modelName + "Thumb") as Texture2D;
                    //if(Texture == null) Texture ==standardTexture;
                    SizeboxModels.Add(new SizeboxModel(m_FilePath, m_modelName, Texture));
                }
                ABundle.Unload(false);
            }
        }
        return(SizeboxModels);
    }
Esempio n. 18
0
 private void SetSelectedItem(StringHolder str)
 {
     str.ID                       = str.ID;
     this.txtID.Text              = str.ID.ToString("X8");
     this.txtString.Text          = str.Value;
     this.cboPlugins.SelectedItem = str.Plugin.Name;
     this.cboType.SelectedItem    = str.Format.ToString();
 }
Esempio n. 19
0
 public string ToString(IFormatProvider provider)
 {
     using (var sh = new StringHolder())
     {
         UnsafeNativeMethods.Rdk_Variant_GetStringValue(ConstPointer(), sh.NonConstPointer());
         return(sh.ToString());
     }
 }
Esempio n. 20
0
 private void TextBox_Dialog_Console_Press(object sender, KeyEventArgs e)
 {
     if (e.Alt == true && e.KeyCode == Keys.C)
     {
         textBox_Dialog_Console.Clear();
         StringHolder.Clear();
     }
 }
 public static string StringFromProjection(BackgroundProjections projection)
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.Rdk_SimulatedTexture_StringFromProjection(pString, (int)projection);
         return(sh.ToString());
     }
 }
Esempio n. 22
0
 /// <summary>
 /// Gets unused linetype name used as default when creating new linetypes.
 /// </summary>
 /// <param name="ignoreDeleted">
 /// If this is true then a name used by a deleted linetype is allowed.
 /// </param>
 /// <returns>The unused linetype name.</returns>
 public string GetUnusedLinetypeName(bool ignoreDeleted)
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoLinetypeTable_GetUnusedLinetypeName(m_doc.m_docId, ignoreDeleted, pString);
         return(sh.ToString());
     }
 }
    public string[] GetBoneNames()
    {
#if Sync
        StringHolder holder = (StringHolder)boneNameRequest.asset;
#else
        StringHolder holder = (StringHolder)m_BoneName;
#endif
        return(holder.content);
    }
Esempio n. 24
0
 /// <summary>
 /// Get a string version of a number in a given unit system / display mode.
 /// </summary>
 /// <param name="x">The number to format into a string.</param>
 /// <param name="units">The unit system for the number.</param>
 /// <param name="mode">How the number should be formatted.</param>
 /// <param name="precision">The precision of the number.</param>
 /// <param name="appendUnitSystemName">Adds unit system name to the end of the number.</param>
 /// <returns>The formatted number.</returns>
 /// <since>5.0</since>
 public static string FormatNumber(double x, UnitSystem units, DistanceDisplayMode mode, int precision, bool appendUnitSystemName)
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.RHC_RhinoFormatNumber(x, (int)units, (int)mode, precision, appendUnitSystemName, pString);
         return(sh.ToString());
     }
 }
Esempio n. 25
0
 /// <summary>
 /// Gets localized unit system name.  Uses current application locale id.
 /// </summary>
 /// <param name="units">The unit system.</param>
 /// <param name="capitalize">true if the name should be capitalized.</param>
 /// <param name="singular">true if the name is expressed for a singular element.</param>
 /// <param name="abbreviate">true if name should be the abbreviation.</param>
 /// <returns>The unit system name.</returns>
 /// <since>5.0</since>
 public static string UnitSystemName(UnitSystem units, bool capitalize, bool singular, bool abbreviate)
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoApp_UnitSystemName((int)units, capitalize, singular, abbreviate, pString);
         return(sh.ToString());
     }
 }
Esempio n. 26
0
 public string GetUnusedInstanceDefinitionName(string root, uint defaultSuffix)
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoInstanceDefinitionTable_GetUnusedName3(m_doc.m_docId, root, defaultSuffix, pString);
         return(sh.ToString());
     }
 }
 public string GetUnusedDimensionStyleName()
 {
     using (var sh = new StringHolder())
     {
         IntPtr pStringHolder = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoDimStyleTable_GetUnusedDimensionStyleName(m_doc.m_docId, pStringHolder);
         return(sh.ToString());
     }
 }
 /// <summary>
 /// Gets unused linetype name used as default when creating new linetypes.
 /// </summary>
 /// <returns>The unused linetype name.</returns>
 /// <since>6.0</since>
 public string GetUnusedLinetypeName()
 {
     using (var sh = new StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoLinetypeTable_GetUnusedLinetypeName(m_doc.RuntimeSerialNumber, pString);
         return(sh.ToString());
     }
 }
 /// <summary>
 /// Gets unsed instance definition name used as default when creating
 /// new instance definitions.
 /// </summary>
 /// <returns>An unused instance definition name string.</returns>
 public string GetUnusedInstanceDefinitionName()
 {
     using (var sh = new StringHolder())
     {
         IntPtr ptr_string = sh.NonConstPointer();
         UnsafeNativeMethods.CRhinoInstanceDefinitionTable_GetUnusedName(m_doc.m_docId, ptr_string);
         return(sh.ToString());
     }
 }
Esempio n. 30
0
        /*
         * /// <summary>
         * /// Shows the content chooser to allow the user to select a new or existing content.
         * /// </summary>
         * /// <param name="defaultType">The content type that will be initially selected in the 'New' tab.</param>
         * /// <param name="defaultInstanceId">The content instance that will be initially selected in the 'Existing' tab.</param>
         * /// <param name="kinds">Which content kinds will be displayed.</param>
         * /// <param name="instanceIdOut">The UUID of the chosen item. Depending on eRhRdkSccResult, this can be the type id of a content type or the instance id of an existing content.</param>
         * /// <param name="flags">Tabs specifications.</param>
         * /// <param name="doc">A Rhino document.</param>
         * /// <returns>The result.</returns>
         * public static ShowContentChooserResults ShowContentChooser(Guid defaultType, Guid defaultInstanceId, RenderContentKind kinds, ref Guid instanceIdOut, ShowContentChooserFlags flags, RhinoDoc doc)
         * {
         * return (ShowContentChooserResults)UnsafeNativeMethods.Rdk_Globals_ShowContentChooser(defaultType, defaultInstanceId, RenderContent.KindString(kinds), ref instanceIdOut, (int)flags, doc.m_docId);
         * }
         */

        /// <summary>
        /// Finds a file and also handles network shares.
        /// <remarks>This is a replacement for CRhinoFileUtilities::FindFile().</remarks>
        /// </summary>
        /// <param name="fullPathToFile">The file to be found.</param>
        /// <returns>The found file.</returns>
        public static string FindFile(string fullPathToFile)
        {
            using (var sh = new StringHolder())
            {
                IntPtr pString = sh.NonConstPointer();
                bool   found   = (1 == UnsafeNativeMethods.Rdk_Globals_FindFile(fullPathToFile, pString));

                return(found ? sh.ToString() : null);
            }
        }
Esempio n. 31
0
    public override void Dispose()
    {
        m_GameObject = null;

        m_Material = null;

        m_BoneName = null;

        base.Dispose();
    }
Esempio n. 32
0
 /// <summary>
 /// Returns a string that represents the pattern of the linetype, which can be used in user interface.
 /// Values greater than zero represent line segments,
 /// and values less than or equal to zero represent space segments.
 /// </summary>
 /// <param name="millimeters">
 /// If true, the string is formatted in millimeters.
 /// If false, the string is formatted in inches.
 /// </param>
 /// <returns>The pattern string.</returns>
 /// <since>7.4</since>
 public string PatternString(bool millimeters)
 {
     using (var sh = new StringHolder())
     {
         IntPtr ptr_string     = sh.NonConstPointer();
         IntPtr ptr_const_this = ConstPointer();
         UnsafeNativeMethods.RHC_RhPatternStringFromLinetype(ptr_const_this, millimeters, ptr_string);
         return(sh.ToString());
     }
 }
    public override void Dispose()
    {
        m_GameObject = null;

        m_Material = null;

        m_BoneName = null;

        base.Dispose();

    }
    public override void Dispose()
    {
        foreach(AnimationClip e in m_Anims.Values)
        {
            AnimationClip clip = (AnimationClip)e;
            clip = null;
        }

        m_Anims.Clear();

        m_AnimName = null;

        base.Dispose();

    }
    public override void Loader()
    {
        if (m_WWW.isDone == false || !string.IsNullOrEmpty(m_WWW.error))
        {
            Debug.LogError("CharacterElementLoader.Loader : " + m_WWW.error + " @ " + m_WWW.url); 
            return;
        }
        if (m_GameObject == null)
            m_GameObject = (GameObject)m_WWW.assetBundle.Load(AssemblerConstant.RENDERER_OBJECT_NAME, typeof(GameObject));

        if (m_Material == null)
            m_Material = (Material)m_WWW.assetBundle.Load(m_Name, typeof(Material));

        if (m_BoneName == null)
            m_BoneName = (StringHolder)m_WWW.assetBundle.Load(AssemblerConstant.BONE_NAMES, typeof(StringHolder));
        IsLoaded = true;
    }
    public override void Loader()
    {
        if (m_AssetBundleCreateRequest.isDone == false)
        {
            Debug.LogError("AssetLoaderError m_AssetBundleCreateRequest");
            return;
        }
        if (m_GameObject == null)
            m_GameObject = (GameObject)m_AssetBundleCreateRequest.assetBundle.Load(AssemblerConstant.RENDERER_OBJECT_NAME, typeof(GameObject));

        if (m_Material == null)
            m_Material = (Material)m_AssetBundleCreateRequest.assetBundle.Load(m_Name, typeof(Material));

        if (m_BoneName == null)
            m_BoneName = (StringHolder)m_AssetBundleCreateRequest.assetBundle.Load(AssemblerConstant.BONE_NAMES, typeof(StringHolder));

        IsLoaded = true;
    }
Esempio n. 37
0
 /// <summary>
 /// Gets names of all "non-test" commands for a given plug-in.
 /// </summary>
 /// <param name="pluginId">The plug-in ID.</param>
 /// <returns>An array with all plug-in names. This can be empty, but not null.</returns>
 public static string[] GetEnglishCommandNames(Guid pluginId)
 {
   IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New();
   int count = UnsafeNativeMethods.CRhinoPluginManager_GetCommandNames(pluginId, pStrings);
   string[] rc = new string[count];
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     for (int i = 0; i < count; i++)
     {
       UnsafeNativeMethods.ON_StringArray_Get(pStrings, i, pString);
       rc[i] = sh.ToString();
     }
   }
   UnsafeNativeMethods.ON_StringArray_Delete(pStrings);
   return rc;
 }
Esempio n. 38
0
      /// <summary>
      /// Passed as a delegate to LicenseUtils.GetLicense(), will call the C++
      /// ValidateProductKey() method then and copy CRhinoLicenseValidator C++
      /// data to the LicenseData output object.
      /// </summary>
      /// <param name="productKey"></param>
      /// <param name="licenseData">
      /// Key information is coppied to this object
      /// </param>
      /// <returns></returns>
      public ValidateResult ValidateProductKey(string productKey, out LicenseData licenseData)
      {
        // Create an empty LicenseData
        licenseData = new LicenseData();
        var rc = 0;
        // Call back into the C++ unmanaged function pointer
        if (IntPtr.Zero != _validator)
          rc = UnsafeNativeMethods.RHC_ValidateProductKey(productKey, _validator);
        if (rc != 1)
          return (-1 == rc ? ValidateResult.ErrorHideMessage : ValidateResult.ErrorShowMessage);
        // Copy unmanaged C++ validate data to the managed LicenseData
        var year = 0;
        var month = 0;
        var day = 0;
        var hour = 0;
        var minute = 0;
        var second = 0;
        var licenseCount = 0;
        var buildType = 0;
        IntPtr hIcon;
        // String placeholders
        using (var shSerailNumber = new StringHolder())
        using (var shLicenseTitle = new StringHolder())
        using (var shProductLicense = new StringHolder())
        {
          // Get ON_wString pointers
          var pSerialNumber = shSerailNumber.NonConstPointer();
          var pLicenseTitle = shLicenseTitle.NonConstPointer();
          var pProductLicense = shProductLicense.NonConstPointer();
          hIcon = UnsafeNativeMethods.RHC_ExtractLicenseData(_validator,
                                                             ref year,
                                                             ref month,
                                                             ref day,
                                                             ref hour,
                                                             ref minute,
                                                             ref second,
                                                             pSerialNumber,
                                                             ref licenseCount,
                                                             pLicenseTitle,
                                                             pProductLicense,
                                                             ref buildType);
          // Copy ON_wString values to C# strings
          licenseData.SerialNumber = shSerailNumber.ToString();
          licenseData.LicenseTitle = shLicenseTitle.ToString();
          licenseData.ProductLicense = shProductLicense.ToString();
        }
        // Set the expiration date using the C++ date data
        if (year >= 2010)
          licenseData.DateToExpire = new DateTime(year, month, day, hour, minute, second);
        licenseData.LicenseCount = licenseCount;
        licenseData.BuildType = (LicenseBuildType)buildType;
        // Icon associated with the specified license type
        if (hIcon != IntPtr.Zero)
        {
          // 19 May 214 - John Morse
          // Added try catch to the icon copy code, an exception here should not cause
          // license validation to fail.
          try
          {
            // Create a new icon from the handle.
            var newIcon = System.Drawing.Icon.FromHandle(hIcon);

            // Set the LicenseData icon. Note, LicenseData creates it's own copy of the icon.
            licenseData.ProductIcon = newIcon;

            // When using Icon::FromHandle, you must dispose of the original icon by using the
            // DestroyIcon method in the Win32 API to ensure that the resources are released.
            if (newIcon != null)
              DestroyIcon(newIcon.Handle);
          }
          catch { }
        }

        return ValidateResult.Success;
      }
Esempio n. 39
0
	/// <summary>
	/// Changes the equip.
	/// </summary>
	/// <param name="part">Part.</param>
	/// <param name="szEquipName">Size equip name.</param>
	/// <param name="assetBundle">Asset bundle.</param>
	public virtual void 		ChangeEquip(PartType part, GameObject equipMesh, StringHolder holder)
	{
		/*
		if (part == PartType.PT_ARM)
		{
			Transform mount = GetMount(MountType.Dummy_R_HandGun);
			if (!mount)
				throw new System.NullReferenceException(MountType.Dummy_R_HandGun.ToString());

			foreach(string content in holder.content)
			{
				Debug.Log(content);
			}
		}
		*/
	
		m_dMesh [part] = new BoneBuffer (
			equipMesh.GetComponent<SkinnedMeshRenderer>(), holder
			);
		
		// megre equip
		MegreEquip ();

	}
Esempio n. 40
0
	/// <summary>
	/// Changes the equip.
	/// </summary>
	/// <param name="part">Part.</param>
	/// <param name="szEquipName">Size equip name.</param>
	/// <param name="assetBundle">Asset bundle.</param>
	public void 		ChangeEquip(PartType part, GameObject equipMesh, StringHolder holder)
	{	
		SkinnedMeshRenderer skinMeshRender = equipMesh.GetComponent<SkinnedMeshRenderer>();
		if (!skinMeshRender)
			skinMeshRender = equipMesh.AddComponent<SkinnedMeshRenderer>();

		m_dMesh [part] = new BoneBuffer (
			skinMeshRender, holder
			);
		
		// megre equip
		MegreEquip ();

	}
    /// <summary>
    /// Gets a copy of all (user key string, user value string) pairs attached to this geometry.
    /// </summary>
    /// <returns>A new collection.</returns>
    internal System.Collections.Specialized.NameValueCollection _GetUserStrings()
    {
      System.Collections.Specialized.NameValueCollection rc = new System.Collections.Specialized.NameValueCollection();
      IntPtr pThis = ConstPointer();
      int count = 0;
      IntPtr pUserStrings = UnsafeNativeMethods.ON_Object_GetUserStrings(pThis, ref count);

      using( var keyHolder = new StringHolder() )
      using( var valueHolder = new StringHolder() )
      {
        IntPtr pKeyHolder = keyHolder.NonConstPointer();
        IntPtr pValueHolder = valueHolder.NonConstPointer();

        for (int i = 0; i < count; i++)
        {
          UnsafeNativeMethods.ON_UserStringList_KeyValue(pUserStrings, i, true, pKeyHolder);
          UnsafeNativeMethods.ON_UserStringList_KeyValue(pUserStrings, i, false, pValueHolder);
          string key = keyHolder.ToString();
          string value = valueHolder.ToString();
          if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
            rc.Add(key, value);
        }
      }

      if (IntPtr.Zero != pUserStrings)
        UnsafeNativeMethods.ON_UserStringList_Delete(pUserStrings);

      return rc;
    }
Esempio n. 42
0
 /// <summary>
 /// Gets the debug dumps. This is a text description of the geometric contents.
 /// DebugDump() is intended for debugging and is not suitable for creating high
 /// quality text descriptions of an object.
 /// </summary>
 /// <param name="geometry">Some geometry.</param>
 /// <returns>A debug dump text.</returns>
 public static string DebugDumpToString(Rhino.Geometry.GeometryBase geometry)
 {
   IntPtr pConstThis = geometry.ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.ON_Object_Dump(pConstThis, pString);
     return sh.ToString();
   }
 }
Esempio n. 43
0
 /// <summary>
 /// Gets the debug dumps. This is a text description of the geometric contents.
 /// DebugDump() is intended for debugging and is not suitable for creating high
 /// quality text descriptions of an object.
 /// </summary>
 /// <param name="bezierCurve">curve to evaluate</param>
 /// <returns>A debug dump text.</returns>
 public static string DebugDumpToString(Rhino.Geometry.BezierCurve bezierCurve)
 {
   IntPtr pConstThis = bezierCurve.ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.ON_BezierCurve_Dump(pConstThis, pString);
     return sh.ToString();
   }
 }
Esempio n. 44
0
    internal static void WriteIntoSerializationInfo(IntPtr pRhCmnProfileContext, System.Runtime.Serialization.SerializationInfo info, string prefixStrip)
    {
      const int _string = 1;
      const int _multistring = 2;
      const int _uuid = 3;
      const int _color = 4;
      const int _int = 5;
      const int _double = 6;
      const int _rect = 7;
      const int _point = 8;
      const int _3dpoint = 9;
      const int _xform = 10;
      const int _3dvector = 11;
      const int _meshparams = 12;
      const int _buffer = 13;
      const int _bool = 14;
      int count = UnsafeNativeMethods.CRhCmnProfileContext_Count(pRhCmnProfileContext);
      using (StringHolder sectionholder = new StringHolder())
      using (StringHolder entryholder = new StringHolder())
      {
        IntPtr pStringSection = sectionholder.NonConstPointer();
        IntPtr pStringEntry = entryholder.NonConstPointer();
        for (int i = 0; i < count; i++)
        {
          int pctype = 0;
          UnsafeNativeMethods.CRhCmnProfileContext_Item(pRhCmnProfileContext, i, pStringSection, pStringEntry, ref pctype);
          string section = sectionholder.ToString();
          string entry = entryholder.ToString();
          if (string.IsNullOrEmpty(entry))
            continue;
          string name = string.IsNullOrEmpty(section) ? entry : section + "\\" + entry;
          if (name.StartsWith(prefixStrip + "\\"))
            name = name.Substring(prefixStrip.Length + 1);
          name = name.Replace("\\", "::");

          switch (pctype)
          {
            case _string:
              {
                UnsafeNativeMethods.CRhinoProfileContext_LoadString(pRhCmnProfileContext, section, entry, pStringEntry);
                string val = entryholder.ToString();
                info.AddValue(name, val);
              }
              break;
            case _multistring:
              {
                IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New();
                int array_count = UnsafeNativeMethods.CRhinoProfileContext_LoadStrings(pRhCmnProfileContext, section, entry, pStrings);
                string[] s = new string[array_count];
                for( int j=0; j<array_count; j++ )
                {
                  UnsafeNativeMethods.ON_StringArray_Get(pStrings, j, pStringEntry);
                  s[j] = entryholder.ToString();
                }
                info.AddValue(name, s);
              }
              break;
            case _uuid:
              {
                Guid id = Guid.Empty;
                UnsafeNativeMethods.CRhinoProfileContext_LoadGuid(pRhCmnProfileContext, section, entry, ref id);
                info.AddValue(name, id);
              }
              break;
            case _color:
              {
                int abgr = 0;
                UnsafeNativeMethods.CRhinoProfileContext_LoadColor(pRhCmnProfileContext, section, entry, ref abgr);
                System.Drawing.Color c = Interop.ColorFromWin32(abgr);
                //string s = System.Drawing.ColorTranslator.ToHtml(c);
                info.AddValue(name, c);
              }
              break;
            case _int:
              {
                int ival = 0;
                UnsafeNativeMethods.CRhinoProfileContext_LoadInt(pRhCmnProfileContext, section, entry, ref ival);
                info.AddValue(name, ival);
              }
              break;
            case _double:
              {
                double dval = 0;
                UnsafeNativeMethods.CRhinoProfileContext_LoadDouble(pRhCmnProfileContext, section, entry, ref dval);
                info.AddValue(name, dval);
              }
              break;
            case _rect:
              {
                int left = 0, top = 0, right = 0, bottom = 0;
                UnsafeNativeMethods.CRhinoProfileContext_LoadRect(pRhCmnProfileContext, section, entry, ref left, ref top, ref right, ref bottom);
                System.Drawing.Rectangle r = System.Drawing.Rectangle.FromLTRB(left, top, right, bottom);
                info.AddValue(name, r);
              }
              break;
            case _point:
              {
                int x = 0, y = 0;
                UnsafeNativeMethods.CRhinoProfileContext_LoadPoint(pRhCmnProfileContext, section, entry, ref x, ref y);
                System.Drawing.Point pt = new System.Drawing.Point(x, y);
                info.AddValue(name, pt);
              }
              break;
            case _3dpoint:
              {
                Rhino.Geometry.Point3d pt = new Geometry.Point3d();
                UnsafeNativeMethods.CRhinoProfileContext_LoadPoint3d(pRhCmnProfileContext, section, entry, ref pt);
                info.AddValue(name, pt);
              }
              break;
            case _xform:
              {
                Rhino.Geometry.Transform xf = new Geometry.Transform();
                UnsafeNativeMethods.CRhinoProfileContext_LoadXform(pRhCmnProfileContext, section, entry, ref xf);
                info.AddValue(name, xf);
              }
              break;
            case _3dvector:
              {
                Rhino.Geometry.Vector3d vec = new Geometry.Vector3d();
                UnsafeNativeMethods.CRhinoProfileContext_LoadVector3d(pRhCmnProfileContext, section, entry, ref vec);
                info.AddValue(name, vec);
              }
              break;
            case _meshparams:
              {
                Rhino.Geometry.MeshingParameters mp = new Geometry.MeshingParameters();
                UnsafeNativeMethods.CRhinoProfileContext_LoadMeshParameters(pRhCmnProfileContext, section, entry, mp.NonConstPointer());
                info.AddValue(name, mp);
                mp.Dispose();
              }
              break;
            case _buffer:
              {
                //not supported yet
                //int buffer_length = UnsafeNativeMethods.CRhinoProfileContext_BufferLength(pRhCmnProfileContext, section, entry);
                //byte[] buffer = new byte[buffer_length];
                //UnsafeNativeMethods.CRhinoProfileContext_LoadBuffer(pRhCmnProfileContext, section, entry, buffer_length, buffer);
                //info.AddValue(name, buffer);
              }
              break;
            case _bool:
              {
                bool b = false;
                UnsafeNativeMethods.CRhinoProfileContext_LoadBool(pRhCmnProfileContext, section, entry, ref b);
                info.AddValue(name, b);
              }
              break;
          }
        }
      }
    }
Esempio n. 45
0
 /// <summary>
 /// Gets the path to an installed plug-in given the id of that plug-in
 /// </summary>
 /// <param name="pluginId"></param>
 /// <returns></returns>
 public static string PathFromId(Guid pluginId)
 {
   using (var sh = new StringHolder())
   {
     IntPtr ptr_string = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoPlugInManager_PathFromId(pluginId, ptr_string);
     return sh.ToString();
   }
 }
 /// <summary>
 /// Gets user string from this geometry.
 /// </summary>
 /// <param name="key">id used to retrieve the string.</param>
 /// <returns>string associated with the key if successful. null if no key was found.</returns>
 internal string _GetUserString(string key)
 {
   IntPtr pThis = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     UnsafeNativeMethods.ON_Object_GetUserString(pThis, key, pStringHolder);
     return sh.ToString();
   }
 }
Esempio n. 47
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CharacterEntity+BoneInfo"/> class.
		/// </summary>
		/// <param name="m">M.</param>
		/// <param name="h">The height.</param>
		public BoneBuffer(SkinnedMeshRenderer m, StringHolder h)
		{
			smr 	= m;
			holder 	= h;
		}
 /// <summary>
 /// Determines if an object is valid. Also provides a report on errors if this
 /// object happens not to be valid.
 /// </summary>
 /// <param name="log">A textual log. This out parameter is assigned during this call.</param>
 /// <returns>true if this object is valid; false otherwise.</returns>
 public bool IsValidWithLog(out string log)
 {
   IntPtr pConstThis = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     bool rc = UnsafeNativeMethods.ON_Object_IsValid(pConstThis, pString);
     log = sh.ToString();
     return rc;
   }
 }
Esempio n. 49
0
 /// <summary>
 /// Gets a plug-in name for an installed plug-in given the path to that plug-in.
 /// </summary>
 /// <param name="pluginPath">The path of the plug-in.</param>
 /// <returns>The plug-in name.</returns>
 public static string NameFromPath(string pluginPath)
 {
   string rc;
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoPlugInManager_NameFromPath(pluginPath, pString);
     rc = sh.ToString();
   }
   if (string.IsNullOrEmpty(rc))
   {
     // 2-Nov-2011 Dale Fugier
     // Look in our local collection of plug-ins. We may be in "OnLoad"
     // and the plug-in hasn't officially been registered with Rhino.
     for (int i = 0; i < m_plugins.Count; i++)
     {
       if (string.Compare(m_plugins[i].Assembly.Location, pluginPath, StringComparison.OrdinalIgnoreCase) == 0)
       {
         rc = m_plugins[i].Name;
         break;
       }
     }
   }
   return rc;
 }
Esempio n. 50
0
        private void btnAddString_Click(object sender, EventArgs e)
        {
            uint uiID;
            LocalizedStringFormat format;
            Plugin plugin;
            string text = this.txtString.Text;
            if (!this.TryGetCurrentID(out uiID))
            {
                MessageBox.Show(this, "ID Field is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!this.TryGetCurrentFormat(out format))
            {
                MessageBox.Show(this, "Format is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!this.TryGetCurrentPlugin(out plugin))
            {
                MessageBox.Show(this, "Plugin is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool doResize = this.strings.Count == 0;

            StringHolder str = this.strings.FirstOrDefault(a => (a.ID == uiID && a.Plugin.Equals(plugin) && a.Format == format));
            if (str == null)
            {
                str = new StringHolder { ID = uiID, Plugin = plugin, Value = text, Format = format };
                this.strings.Add(str);
            }

            StringHolder addStr = this.addStrings.FirstOrDefault(a => (a.ID == uiID && a.Plugin.Equals(plugin) && a.Format == format));
            if (addStr == null)
            {
                this.addStrings.Add(str);
            }

            if (doResize)
            {
                this.FitColumns();
            }

            this.UpdateStatusBar();
        }
Esempio n. 51
0
 /// <summary>
 /// Returns a list of output types which your renderer can write.
 /// <para>The default implementation returns bmp, jpg, png, tif, tga.</para>
 /// </summary>
 /// <returns>A list of file types.</returns>
 protected virtual List<Rhino.FileIO.FileType> SupportedOutputTypes()
 {
   using (var shExt = new StringHolder())
   using (var shDesc = new StringHolder())
   {
     var rc = new List<Rhino.FileIO.FileType>();
     int iIndex = 0;
     while (1 == UnsafeNativeMethods.Rdk_RenderPlugIn_BaseOutputTypeAtIndex(NonConstPointer(), iIndex++, shExt.NonConstPointer(), shDesc.NonConstPointer()))
     {
       rc.Add(new Rhino.FileIO.FileType(shExt.ToString(), shDesc.ToString()));
     }
     return rc;
   }
 }
Esempio n. 52
0
 private void SetSelectedItem(StringHolder str)
 {
     str.ID = str.ID;
     this.txtID.Text = str.ID.ToString("X8");
     this.txtString.Text = str.Value;
     this.cboPlugins.SelectedItem = str.Plugin.Name;
     this.cboType.SelectedItem = str.Format.ToString();
 }