private void OnEnable() { HANDLE_ICON_NORMAL = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/HandleIcon-Normal.png", typeof(Texture2D)); HANDLE_ICON_ACTIVE = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/HandleIcon-Active.png", typeof(Texture2D)); INSERT_ICON_ACTIVE = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/InsertPoint-Active.png", typeof(Texture2D)); INSERT_ICON_NORMAL = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/InsertPoint-Normal.png", typeof(Texture2D)); DELETE_ICON_ACTIVE = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/DeletePoint-Active.png", typeof(Texture2D)); DELETE_ICON_NORMAL = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Polydraw/Icons/DeletePoint-Normal.png", typeof(Texture2D)); insertIconStyle = new GUIStyle(); insertIconStyle.normal.background = INSERT_ICON_NORMAL; insertIconStyle.active.background = INSERT_ICON_ACTIVE; deletePointStyle = new GUIStyle(); deletePointStyle.normal.background = DELETE_ICON_NORMAL; deletePointStyle.active.background = DELETE_ICON_ACTIVE; #if UNITY_4_3 if (Undo.undoRedoPerformed != this.UndoRedoPerformed) { Undo.undoRedoPerformed += this.UndoRedoPerformed; } #endif poly = (PolydrawObject)target; snapEnabled = EditorPrefs.HasKey("polydraw_snapEnabled") ? EditorPrefs.GetBool("polydraw_snapEnabled") : false; snapValue = EditorPrefs.HasKey("polydraw_snapValue") ? EditorPrefs.GetFloat("polydraw_snapValue") : .25f; }
public static void CreatePolydrawObject() { PolydrawObject polydrawObject = PolydrawObject.CreateInstance(); polydrawObject.drawSettings.frontMaterial = (Material)AssetDatabase.LoadAssetAtPath( "Assets/Polydraw/Default Textures/Cardboard.mat", typeof(Material)); polydrawObject.drawSettings.sideMaterial = (Material)AssetDatabase.LoadAssetAtPath( "Assets/Polydraw/Default Textures/Cardboard Grass.mat", typeof(Material)); Selection.activeTransform = polydrawObject.transform; }