Compare commits
766 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b830b5961a | |||
| 74bdd26924 | |||
| 0bd5f325de | |||
| 8e9d49c921 | |||
| 200566163a | |||
| 9d3de1e97c | |||
| ad8c4c8674 | |||
| d3f1af9b8b | |||
| 32c644fde8 | |||
| 9b656e9852 | |||
| 2274a13619 | |||
| 63987511e7 | |||
| 629e27f5cd | |||
| 7f56624ec7 | |||
| c209811f9f | |||
| e6fbad7021 | |||
| 71ae54aabe | |||
| 3e80edf0dc | |||
| 99e916905d | |||
| be4e741708 | |||
| 5b39dd985b | |||
| 2697103479 | |||
| 68071a95f6 | |||
| 867b61fc00 | |||
| c5fb7b93a3 | |||
| ae753e51cb | |||
| 46b4c01730 | |||
| 3207d7b191 | |||
| bf3b0d2642 | |||
| eeb9a42c83 | |||
| 4d0a383a88 | |||
| 29625182c3 | |||
| 576a770c7b | |||
| f92818885e | |||
| dc4868bfee | |||
| e80b7ab1f1 | |||
| a588716b30 | |||
| 342740b740 | |||
| fccc830f71 | |||
| bd9696cd81 | |||
| 38a736a259 | |||
| 11693c40af | |||
| 4d4f8feb8b | |||
| 46f7c2d4b1 | |||
| d38330d969 | |||
| 9e2240fd9b | |||
| 1d015706db | |||
| 06b9051b3c | |||
| 701ec3069b | |||
| 84b3e1e7a4 | |||
| 573b96d86c | |||
| 6c9b3f825a | |||
| 6e091bd99c | |||
| 610c98f9b8 | |||
| 0202814f67 | |||
| f25d0b7b8c | |||
| 87a0e7fb6d | |||
| 2f64aa494f | |||
| 72f254af2a | |||
| 6542dd9882 | |||
| 5b54255777 | |||
| 6b3dd70c61 | |||
| 1c9102fbdc | |||
| 46b6c7fa01 | |||
| c333086e30 | |||
| 02d2dcdbf7 | |||
| c7afcbb01f | |||
| ff878d5d50 | |||
| b236e939f4 | |||
| bfc56dded5 | |||
| 383fed4966 | |||
| 6effadc1e9 | |||
| c6d0f7ac13 | |||
| d498dd9148 | |||
| e513eeac5c | |||
| 71c9907c89 | |||
| 154252e3c3 | |||
| cda569afd5 | |||
| 475250e795 | |||
| c579c1b130 | |||
| d9848e4e9d | |||
| 622aaa3b6d | |||
| e7af21b126 | |||
| bfa9f5f998 | |||
| 3f8c189ad4 | |||
| a1010091f8 | |||
| 167a424505 | |||
| ff6d61a606 | |||
| 2524e3a004 | |||
| 95df03e540 | |||
| 9f0f42981e | |||
| 17c2a44e40 | |||
| d876c20def | |||
| 11b131b24a | |||
| be687d6b77 | |||
| 509c309252 | |||
| edc629ed75 | |||
| b0c0890ca3 | |||
| cfa1cc4f7b | |||
| 3c4ecf3e83 | |||
| 06582201fa | |||
| f47f5c9ff6 | |||
| de8dd933e8 | |||
| 597929cd32 | |||
| affc775226 | |||
| 4665feab7c | |||
| 4a3542010f | |||
| 3532978762 | |||
| 8150b99411 | |||
| 995aef63f8 | |||
| a2de06fede | |||
| 2f9dd43e07 | |||
| c8076494fb | |||
| 41240b1398 | |||
| f383c54507 | |||
| 29e7219c21 | |||
| d44638354d | |||
| 874dec5ec6 | |||
| 7780dc5ee5 | |||
| 95ab695632 | |||
| 92d0579060 | |||
| d938a0c8be | |||
| efdc95ed3d | |||
| 0a4925bb39 | |||
| cd1d67d9e8 | |||
| 30e09c9c7a | |||
| ec9337b446 | |||
| 69d73c26cd | |||
| 06aefb93c4 | |||
| 6ec4c0101b | |||
| e0649f7ea1 | |||
| ab653b994f | |||
| bf48989a9c | |||
| 57940568c9 | |||
| b3b882c51e | |||
| 16e416332d | |||
| e6f3e2ecfa | |||
| e3f5280d94 | |||
| 448b6d7798 | |||
| e85d5f8613 | |||
| c3514df331 | |||
| 01df299251 | |||
| b039388a59 | |||
| 0c42fbe2cd | |||
| 7e67184248 | |||
| c1c93c2a60 | |||
| 353c19662c | |||
| 3b0ffd78e7 | |||
| ed9dc53093 | |||
| 6a0bd67a6e | |||
| 1e350fbb4d | |||
| 768f8261da | |||
| 0c1c2ed382 | |||
| 2c7d02ec9a | |||
| f5294b0d39 | |||
| 365fab22d4 | |||
| 1b3743a135 | |||
| 1148e29379 | |||
| 7c1d1e797c | |||
| e231d3540e | |||
| 5f0efe3995 | |||
| 17aee7a740 | |||
| c12df53c18 | |||
| a625db3ebe | |||
| 7476af7701 | |||
| c4bcb36356 | |||
| 5edd784080 | |||
| 0644421279 | |||
| 28487b295b | |||
| 2abb2d81a2 | |||
| 1271e8e5d9 | |||
| f16883465f | |||
| 3da12c3054 | |||
| 0a9adb19e6 | |||
| d4fbeeefc2 | |||
| 37873427e3 | |||
| 5340d3d58b | |||
| cd162f3325 | |||
| 9d48c05ef0 | |||
| 7bb5bafbd2 | |||
| 58a8233697 | |||
| 45b3ee5bbc | |||
| 0458a23c20 | |||
| 2bf534775f | |||
| 8f022e83a6 | |||
| fed54ad85b | |||
| 5bc1bec425 | |||
| 5489fa2a24 | |||
| d89deba02c | |||
| 8a2d4f7b85 | |||
| d33e130eca | |||
| 0a1ba5fbde | |||
| e82592722f | |||
| e70a84db98 | |||
| 697818bae4 | |||
| 4d5523e2ff | |||
| 79ad622026 | |||
| dd1d26e9c8 | |||
| 7a7c1ee55c | |||
| bc5e4d14e4 | |||
| 2fec28e7cd | |||
| 77414ad387 | |||
| 10ffd8160a | |||
| dc4cf87bc4 | |||
| c53fbffe55 | |||
| 02111a57b1 | |||
| 91fa3cc82d | |||
| 61fefda590 | |||
| f7450f0067 | |||
| f0df68bbda | |||
| f949c531a6 | |||
| 939774bd42 | |||
| 9aecb4ce2a | |||
| 623cad18b2 | |||
| 5672898ce4 | |||
| 90be662db1 | |||
| 05e3d2f887 | |||
| e20ddb9bc1 | |||
| bdfe1f6ee7 | |||
| 27ea20b1c8 | |||
| 5bf7635f1e | |||
| dbabaae032 | |||
| d811eb8514 | |||
| f070f5a36c | |||
| 7431228d2f | |||
| e5067228b2 | |||
| e87429d528 | |||
| 79849bd537 | |||
| 9fb819b6fe | |||
| 082b45c43c | |||
| fa0d9e973c | |||
| f5385e31d6 | |||
| 300c61a883 | |||
| 16a89b07b8 | |||
| 14e9e8e23b | |||
| 43dc844998 | |||
| 2d38b63c91 | |||
| 0628bd3716 | |||
| ba36014712 | |||
| 537ae2d6ed | |||
| 7f7318fb36 | |||
| 333c99fb46 | |||
| c5500c269f | |||
| 8a469c3a74 | |||
| 914e2719c1 | |||
| 0fe5b3a953 | |||
| 088ab9a2b8 | |||
| 816742898f | |||
| 6055b2010b | |||
| eab147c263 | |||
| 0e16fec75a | |||
| eece0cffa5 | |||
| 95d845ac0f | |||
| 8dde7520ad | |||
| d4fa2bbb69 | |||
| f3f17c1256 | |||
| be731c471b | |||
| 7661a4e61d | |||
| 0ab425cb52 | |||
| b8a3a30629 | |||
| bac3334a01 | |||
| b3f6bb6861 | |||
| 3ca297ee96 | |||
| 0500736fff | |||
| f23fc4b4c0 | |||
| 8e0ce907d0 | |||
| 2b390717c2 | |||
| ffc98f1a58 | |||
| a2b44262f7 | |||
| 2743c8d185 | |||
| 769b75e2e2 | |||
| 6423007638 | |||
| 4260cf05d3 | |||
| d91dc17ea7 | |||
| 67abc1ef63 | |||
| fc55360be0 | |||
| c8c27bd021 | |||
| 5c2c22b675 | |||
| 4b3dad0b84 | |||
| 939084b074 | |||
| 05d2c74efa | |||
| 348552b0bc | |||
| ebcc83ed6a | |||
| a9e4b1fd34 | |||
| 2c8457c75e | |||
| 7616e09a40 | |||
| 6c0d9f5dec | |||
| 32777c739d | |||
| 77989384fc | |||
| 12e0d8d295 | |||
| 1cb555c13d | |||
| b9d14a590c | |||
| 24044ec772 | |||
| 603efc7508 | |||
| 9231304269 | |||
| 40ac7e1397 | |||
| 98de46f8b1 | |||
| 6ed3895fcd | |||
| ec4a28cd2a | |||
| 3da24b200d | |||
| 16b42a19e4 | |||
| 625e2b7934 | |||
| cbd1ce3313 | |||
| 7d2af849f4 | |||
| b1fedd4831 | |||
| 083b414be0 | |||
| de4292d55a | |||
| 542036fb45 | |||
| fa144dbaa0 | |||
| cc6730cbc4 | |||
| aff636f9a8 | |||
| ef3e3a8321 | |||
| 5d8be079c2 | |||
| aa0c8d4fb6 | |||
| 134dc76ec5 | |||
| 9ff3de1d10 | |||
| a2ff7604cc | |||
| 70a8bc0000 | |||
| 06b102f0eb | |||
| 350103d5a9 | |||
| 2cf77e94ed | |||
| 917cbbfb90 | |||
| eeffccd4e6 | |||
| 0549cdbd52 | |||
| 732e5ac6c6 | |||
| c0ebe80a1f | |||
| 23e5ae6ebd | |||
| 265430053a | |||
| 190a66bb68 | |||
| 8c5ad08475 | |||
| 6cc2486ebf | |||
| 68688c9daf | |||
| d5ea26f15c | |||
| 37e4c54c20 | |||
| 9570334e25 | |||
| 3083224ee6 | |||
| 5ba176725f | |||
| 42e23e2f84 | |||
| 5480de5c6d | |||
| e3e2f5200b | |||
| 6a4390f1b9 | |||
| a73e125a49 | |||
| 3295314b7e | |||
| 8b3dd7a40a | |||
| b79584f745 | |||
| 402f19b8a5 | |||
| 9acde45f4a | |||
| 004410048f | |||
| f7b29819f6 | |||
| 7ebd5f59e3 | |||
| e14a683f62 | |||
| d754ff3b15 | |||
| 1bd1ffdb5a | |||
| c50c229e30 | |||
| 50b46c5b76 | |||
| eb9338390c | |||
| 51834b709c | |||
| 8e88b4adba | |||
| 609e4dc367 | |||
| 9a545f00f4 | |||
| baab5a9fb0 | |||
| e8a12452ca | |||
| f92b623349 | |||
| a9fc25defb | |||
| 558fb16160 | |||
| b9aa0131cc | |||
| eb21914fb7 | |||
| a4e17a56d0 | |||
| e503443f22 | |||
| 3a834fca08 | |||
| 8f8ee0b833 | |||
| 26e4e81402 | |||
| b075279a14 | |||
| f731494396 | |||
| dd4157cbc2 | |||
| 05f6c8a08b | |||
| 3c540dece4 | |||
| d8adb8a5b8 | |||
| 9be2e77ae5 | |||
| 0560d0f278 | |||
| efd1795e63 | |||
| 4d404b9162 | |||
| f0314adb27 | |||
| 2f0291836e | |||
| d4326ffb42 | |||
| 44ff898f8d | |||
| f3da1a5575 | |||
| c19b8630cf | |||
| 55d7304de1 | |||
| f1ddde8a2e | |||
| cad2e92fd2 | |||
| 4aa6178495 | |||
| fd8f419f09 | |||
| 6d1bc8e2c8 | |||
| d035361718 | |||
| 6501284bbc | |||
| 9511e30e50 | |||
| 561ad993b8 | |||
| 8d8fd59a80 | |||
| b74c3b57b4 | |||
| 85e0a13f08 | |||
| 8802676b98 | |||
| 486b385c84 | |||
| 5bd1c3b1ca | |||
| c73545d912 | |||
| 75900ccf3d | |||
| 65e7d9c4f4 | |||
| 1c73701e73 | |||
| 125e9a48c6 | |||
| 9eab7c847b | |||
| f35dea5c6a | |||
| 18b330fa30 | |||
| 211967dda2 | |||
| edf0313155 | |||
| 62e88668e0 | |||
| b89322c59b | |||
| a67602b00b | |||
| 65f2b0af0a | |||
| 40b6205abc | |||
| 9b0c86aefb | |||
| e6e519d166 | |||
| 750d9107b4 | |||
| 26250f3e47 | |||
| a999bf1b72 | |||
| 806116af19 | |||
| 58fe43d59f | |||
| 27881fbb6b | |||
| 8fde11f985 | |||
| bd8089d0a9 | |||
| 1b7e585027 | |||
| d7486c920c | |||
| 8c7a9afaa3 | |||
| 49c264ff36 | |||
| 6640780c93 | |||
| b5c78aba4f | |||
| 7d4617eca6 | |||
| 48397f3d1d | |||
| ad26419654 | |||
| 15015f83a8 | |||
| 6fa4504e46 | |||
| afb8c358f5 | |||
| 0b1247249d | |||
| 7bd058004d | |||
| e84f14250b | |||
| ae6769e24f | |||
| 939d6f1d0c | |||
| dfb80658dd | |||
| 969835e4d7 | |||
| 51cea743be | |||
| ca51e06d37 | |||
| ee1114e2cf | |||
| f1f982b90c | |||
| 50ad74bb09 | |||
| 5a148c28a8 | |||
| 8a4657c11c | |||
| b86cb01ea2 | |||
| 99081519bb | |||
| fe65b83c89 | |||
| 510cd11049 | |||
| b11c5de681 | |||
| 467a6f3810 | |||
| 169b9719f6 | |||
| 1254414415 | |||
| 7af935118e | |||
| 3fb8aee922 | |||
| c280408192 | |||
| c5586b3eb1 | |||
| 2663068574 | |||
| 3ec6fd0569 | |||
| cdccd78602 | |||
| 3a360d3437 | |||
| 29aef943b9 | |||
| 99540eb1fd | |||
| 85130ce6c3 | |||
| 428a7c5507 | |||
| d8927ceca5 | |||
| f21b83697b | |||
| 723c881790 | |||
| e1a85eeb5e | |||
| 0139cbc173 | |||
| eb87fe07aa | |||
| 89e3a04fe9 | |||
| 92c8f246b8 | |||
| bb08b6b762 | |||
| 88beff5b89 | |||
| f155b2b627 | |||
| 341195d78d | |||
| 3de8b1d555 | |||
| 3c9d489c76 | |||
| 31e8e3bebb | |||
| d6c3ea2007 | |||
| 6fab61f97d | |||
| f6740d31bb | |||
| 81a18de9f4 | |||
| ca91f45ef3 | |||
| f14a071179 | |||
| 688c12b28e | |||
| f39500c560 | |||
| 34a2c0bbb2 | |||
| dd669d74f5 | |||
| a6f673f805 | |||
| 49da1493d5 | |||
| 35b5ab59d3 | |||
| 11e9acdb14 | |||
| 906dc7dec8 | |||
| 3902865658 | |||
| 32b6e28736 | |||
| 25dcf0fde3 | |||
| c91bf7ae2f | |||
| a9530096e4 | |||
| bb8a0712b7 | |||
| 570bd1554f | |||
| 3fcc6c0489 | |||
| c717b93169 | |||
| 5642d3f1c9 | |||
| 81a7af517a | |||
| 40bb16a132 | |||
| 7a1042d184 | |||
| 9f19e951cc | |||
| 317f7c6d8c | |||
| 8b5070214e | |||
| fe2c0280dc | |||
| b8a5982bc5 | |||
| da4fed58b0 | |||
| ea70e04ec0 | |||
| be677e766d | |||
| 07a7a95aa8 | |||
| 074200cb4f | |||
| b4e97d5514 | |||
| bea0e40ec1 | |||
| 12838266ba | |||
| 44c1b771f7 | |||
| 3c6edc624b | |||
| 1919370a23 | |||
| 9ab8165630 | |||
| 7884e7ac7e | |||
| 50fd9c3af6 | |||
| 33df128750 | |||
| edce9c676d | |||
| 6ab3ee19f2 | |||
| b9db3325a8 | |||
| b8ffdcbffe | |||
| 09f72d10bd | |||
| 5c96b10385 | |||
| 7d0a4fbd97 | |||
| c96cdbb163 | |||
| abf913b467 | |||
| 978debcd23 | |||
| 4a8239a2db | |||
| 952e5038ed | |||
| 3307d96ff3 | |||
| ea717ccdb8 | |||
| e29f0a8116 | |||
| cfcb302a31 | |||
| 0eb399be9a | |||
| ca938ab6f5 | |||
| ea79b6cfc5 | |||
| c9b5520331 | |||
| 164db7c013 | |||
| d4ae01cd32 | |||
| 17f2b1cedd | |||
| ab9b6a86f3 | |||
| 7d0128d912 | |||
| 1f3485846f | |||
| 929fb0a1a7 | |||
| ac59808915 | |||
| 7f8ac10d47 | |||
| b93fbd2f2e | |||
| ae3f9d2101 | |||
| 21529db9dc | |||
| 1c2afb4125 | |||
| d18ff09002 | |||
| d9d66ab96c | |||
| e76b5c443f | |||
| eed2d13624 | |||
| eb1803c9ef | |||
| b2a527f518 | |||
| d6a7cd798f | |||
| ec45246aa4 | |||
| 380e67cc1e | |||
| 58ec860669 | |||
| 858b76d4d2 | |||
| 2f8318b24e | |||
| 23d049d176 | |||
| 6ad01c50df | |||
| dcc65cdd86 | |||
| 3f718f1490 | |||
| ebe3dc11e6 | |||
| 8dfd4d696c | |||
| 734893ff83 | |||
| dd474f1f61 | |||
| 936d325cf9 | |||
| 5f7cc43593 | |||
| 15e440715d | |||
| abd35810bc | |||
| 5ec6f4caca | |||
| 25c866d090 | |||
| 4064d4294a | |||
| 541aefe4dd | |||
| 1020632757 | |||
| 35b50efded | |||
| aa75bb281f | |||
| b6d70e6856 | |||
| 432e02e3de | |||
| 17eaccb72e | |||
| 5671b35dce | |||
| 7729332f41 | |||
| 2f84f70a5f | |||
| 84e8b50bbf | |||
| 8e1b4bbbca | |||
| e88f32e99b | |||
| 4e4da38252 | |||
| 3757ae6e6c | |||
| a2a6ee1f49 | |||
| 724e43f392 | |||
| 5599d6dcc8 | |||
| 509a7c16bd | |||
| 7eb76291ec | |||
| 0517382612 | |||
| fdf33ba8df | |||
| 2d36d5df39 | |||
| 5db375bcf5 | |||
| 3e38fd65c2 | |||
| 7ba012f5f2 | |||
| 09514e2a8a | |||
| f1eeb11543 | |||
| 470d52b1bc | |||
| eb70ee4397 | |||
| e29381b13b | |||
| 46cc231fe7 | |||
| b694a69f16 | |||
| 87d581291b | |||
| 53ec9c60ac | |||
| a7ea02f70a | |||
| 8f0598580d | |||
| 2c5501a096 | |||
| 2b4b2c4f70 | |||
| 8ca32cd1ae | |||
| 6645310601 | |||
| 696fd256a8 | |||
| 92676d7cf8 | |||
| 9a4e646a8f | |||
| d4339968f6 | |||
| 584cba79ae | |||
| 60bf5bd59d | |||
| e4d4333357 | |||
| 9bc3864790 | |||
| 39d84e2e8a | |||
| 6b380b3442 | |||
| 3ec804f1b0 | |||
| d96721e826 | |||
| 071a0e1170 | |||
| 392eca5dc2 | |||
| af34243c28 | |||
| 9f4e446850 | |||
| 6399c26f7e | |||
| f6a4ebda8c | |||
| 333542a63a | |||
| 2b6be4711c | |||
| 48c5b161b1 | |||
| f7b33bf491 | |||
| cb93e31143 | |||
| 52fd841486 | |||
| aaef57c0b0 | |||
| b030294bd6 | |||
| 82997480fe | |||
| 44abc5ded1 | |||
| 7b4fbc513e | |||
| 8eb201d0ee | |||
| a49acaab1e | |||
| 540bbc9a7c | |||
| de61fbd291 | |||
| ae55258b9b | |||
| 4cb40f2c8e | |||
| b15a4fe2c1 | |||
| 9993752ff5 | |||
| 614d067d25 | |||
| 6d45d052a0 | |||
| 3b63dec2e1 | |||
| c8111d7db3 | |||
| b71a15e2ba | |||
| 00b9c7e796 | |||
| 5080503ebd | |||
| 86a5b68317 | |||
| 8226b8a7c2 | |||
| 4353a38c96 | |||
| 1002b0433a | |||
| 2b275d6dc5 | |||
| 02b8f97d83 | |||
| 8de7e94c8d | |||
| bbc3deeef2 | |||
| 0f8af223fc | |||
| 048538a0c8 | |||
| 9ac7c86ca6 | |||
| 11fdcff7c3 | |||
| 922f66bb75 | |||
| a96d538dc1 | |||
| d35c9daa82 | |||
| 4347a8eeba | |||
| dd08f916eb | |||
| 96f3644b5b | |||
| 40d118cea3 | |||
| e7ad9473a5 | |||
| 1c712ff7d5 | |||
| bb4fabc833 | |||
| 4896fab824 | |||
| f10eeac073 | |||
| 2d20edf57a | |||
| 82923fe4f8 | |||
| 51c6fd7236 | |||
| af63072f29 | |||
| afba150d91 | |||
| f065bf4bbb | |||
| 19766db051 | |||
| 0346b650aa | |||
| 018699c944 | |||
| 10c82703f4 | |||
| 70626ae741 | |||
| 92e43c2cd8 | |||
| f4cbad819b | |||
| c97bd50f3f | |||
| e04ae0b085 | |||
| 62938ec6ae | |||
| 7744eec847 | |||
| 038720e7bd | |||
| d22eecd133 | |||
| 10e738f958 | |||
| 34cde86a28 | |||
| 2fcd9b23fa | |||
| 5156473bb2 | |||
| 07feba912c | |||
| 725b510748 | |||
| 65fc5b5c50 | |||
| e7a3214cb5 | |||
| ae9cefc645 | |||
| ec7589096f | |||
| 2e6338bcf3 | |||
| 996f924719 | |||
| eb93577d68 | |||
| b0f6c39118 | |||
| 8638cd97de | |||
| dad88828d2 | |||
| 9a7830f46a | |||
| d5133ee7b0 | |||
| 8ad36c965d | |||
| 42fa59d103 | |||
| 0ab0e99597 | |||
| 971a6f7e0e | |||
| 326b74bd03 | |||
| 3c2bb10f07 | |||
| f45711f39f | |||
| db3fc6ee83 | |||
| d1d9c92f1c | |||
| cbc79df8a2 | |||
| 38d1c387c3 | |||
| c5bd9daba2 | |||
| e7044b3cde | |||
| ba324aa68d | |||
| ba994e715c | |||
| b7cc1653f4 | |||
| 6f7c4e78bd | |||
| 4ecf26ec80 | |||
| 45801dff22 | |||
| 60d12fcab2 | |||
| 398628017c | |||
| f557e2f5df |
40
.gitignore
vendored
40
.gitignore
vendored
@ -69,3 +69,43 @@ crashlytics-build.properties
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
||||
Assets/Packages
|
||||
Assets/Packages.meta
|
||||
Assets/Shader2D-master
|
||||
Assets/ZFBrowser
|
||||
Assets/Resources/UI/Font/*.ttf
|
||||
Assets/WorldPoliticalMapGlobeEdition
|
||||
Assets/WorldPoliticalMapGlobeEdition.meta
|
||||
Assets/earth
|
||||
Assets/Chart And Graph
|
||||
Assets/NuGet
|
||||
Assets/NuGet.meta
|
||||
Assets/earth.meta
|
||||
Assets/MapWorkoutRecords.meta
|
||||
Assets/Devices.txt
|
||||
Assets/Devices.txt.meta
|
||||
Assets/StreamingAssets.meta
|
||||
Assets/Resources/Sound.meta
|
||||
Assets/MapWorkoutRecords
|
||||
Assets/Mapbox/User
|
||||
Assets/Mapbox/User.meta
|
||||
Packages/packages-lock.json
|
||||
GPUCache
|
||||
Assets/Shatalmic/plugin.unitypackage.meta
|
||||
.idea
|
||||
Assets/AVProVideo
|
||||
Assets/StreamingAssets/AVProVideoSamples
|
||||
Assets/StreamingAssets/AVProVideoSamples.meta
|
||||
Assets/StreamingAssets
|
||||
Assets/FacebookSDK
|
||||
Assets/StreamingAssets
|
||||
Assets/Models/MC_animations
|
||||
Assets/Models/MC_max
|
||||
Assets/FacebookSDK/SDK/Resources/FacebookSettings.asset
|
||||
Assets/FacebookSDK/SDK/Resources/FacebookSettings.asset
|
||||
Assets/AVProVideo.meta
|
||||
Packages
|
||||
Assets/Tree_Textures.meta
|
||||
Packages
|
||||
Assets/FacebookSDK/SDK/Resources.meta
|
||||
Packages
|
||||
|
||||
6
.vsconfig
Normal file
6
.vsconfig
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
||||
130
Assets/AndroidUpdate.cs
Normal file
130
Assets/AndroidUpdate.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AndroidUpdate : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
JObject data { get; set; }
|
||||
public void StartDownload(JObject jo)
|
||||
{
|
||||
transform.Find("Panel/CurrentVersion").GetComponent<Text>().text = $"{App.GetLocalString("Current Version:")} {App.AppVersion}";
|
||||
transform.Find("Panel/LastestVersion").GetComponent<Text>().text = $"{App.GetLocalString("Latest Version:")} {jo.Value<string>("Version")}";
|
||||
data = jo;
|
||||
var path = Application.temporaryCachePath + "/PowerFun.apk";
|
||||
StartCoroutine(DownLoadExe(data.Value<string>("Url"), path, (p, isComplete) =>
|
||||
{
|
||||
transform.Find("Panel/Size").GetComponent<Text>().text = $"{App.GetLocalString("Downloaded")} {Math.Round(p * 100, 0)}%";// string.Format(, a, b);
|
||||
transform.Find("Panel/Progress").GetComponent<Image>().fillAmount = (float)p;
|
||||
if (isComplete)
|
||||
{
|
||||
PlayerPrefs.SetString("exeVersion", data.Value<string>("Version"));
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
OpenApk(path);
|
||||
//Application.Quit();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/*下载文件*/
|
||||
IEnumerator DownLoadExe(string url, string desFileName, Action<double, bool> OnDownloadProgressEvent)
|
||||
{
|
||||
string version = data.Value<string>("Version");
|
||||
if (File.Exists(desFileName))
|
||||
{
|
||||
//if(PlayerPrefs.GetString("exeVersion")==)
|
||||
if (version == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version == PlayerPrefs.GetString("exeVersion"))
|
||||
{
|
||||
OpenApk(desFileName);
|
||||
//Application.Quit();
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(desFileName);
|
||||
}
|
||||
}
|
||||
|
||||
//File.Delete(desFileName);
|
||||
}
|
||||
if (File.Exists(desFileName + ".pfdownload"))
|
||||
{
|
||||
File.Delete(desFileName + ".pfdownload");
|
||||
}
|
||||
|
||||
using (var uwr = UnityWebRequest.Get(url))
|
||||
{
|
||||
var operation = uwr.SendWebRequest();
|
||||
|
||||
while (!operation.isDone)
|
||||
{
|
||||
/*
|
||||
* as BugFinder metnioned in the comments
|
||||
* what you want to track is uwr.downloadProgress
|
||||
*/
|
||||
var downloadDataProgress = uwr.downloadProgress * 100;
|
||||
|
||||
/*
|
||||
* use a float division here
|
||||
* I don't know what type downloadDataProgress is
|
||||
* but if it is an int than you will always get
|
||||
* an int division <somethingSmallerThan100>/100 = 0
|
||||
*/
|
||||
//progressBar.fillAmount = downloadDataProgress / 100.0f;
|
||||
OnDownloadProgressEvent.Invoke(uwr.downloadProgress, false);
|
||||
Debug.Log("Download: " + downloadDataProgress);
|
||||
yield return null;
|
||||
}
|
||||
ByteArrayToFile(desFileName + ".pfdownload", uwr.downloadHandler.data);
|
||||
OnDownloadProgressEvent.Invoke(1, true);
|
||||
}
|
||||
}
|
||||
bool ByteArrayToFile(string fileName, byte[] byteArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
fs.Write(byteArray, 0, byteArray.Length);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenApk(string path)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
var activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
//Debug.Log("打开apk"+ "file://" + path);
|
||||
activity.Call("OpenApk", path);
|
||||
//Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/AndroidUpdate.cs.meta
Normal file
11
Assets/AndroidUpdate.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1001f46abd4064a9837992f252bb97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
159
Assets/AppleInfoController.cs
Normal file
159
Assets/AppleInfoController.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using Assets.Scripts;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AppleInfoController : PFUIPanel
|
||||
{
|
||||
public Action afterClose = null;
|
||||
private SignForm signForm;
|
||||
private Dictionary<string, Selectable> signFormDict;
|
||||
public bool startCaptcha = false;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("FormContainer-Sign/btnClose").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
//if (afterClose != null)
|
||||
//{
|
||||
// afterClose.Invoke();
|
||||
//}
|
||||
});
|
||||
|
||||
signForm = new SignForm()
|
||||
{
|
||||
email = transform.Find("FormContainer-Sign/FirstPage/Email").GetComponent<InputField>(),
|
||||
captcha = transform.Find("FormContainer-Sign/FirstPage/Captcha").GetComponent<InputField>(),
|
||||
password = transform.Find("FormContainer-Sign/FirstPage/Password").GetComponent<InputField>(),
|
||||
cpassword = transform.Find("FormContainer-Sign/FirstPage/CPassword").GetComponent<InputField>(),
|
||||
};
|
||||
signFormDict = new Dictionary<string, Selectable>
|
||||
{
|
||||
{ "Phone",signForm.email},
|
||||
{ "Captcha",signForm.captcha},
|
||||
{ "Pwd",signForm.password},
|
||||
{ "CPwd",signForm.cpassword},
|
||||
};
|
||||
signPage1 = transform.Find("FormContainer-Sign/FirstPage");
|
||||
UIManager.AddEvent(signPage1.Find("Captcha").Find("BtnGet").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
GetCaptcha();
|
||||
});
|
||||
UIManager.AddEvent(signPage1.Find("next").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Submit();
|
||||
});
|
||||
}
|
||||
|
||||
private async void Submit()
|
||||
{
|
||||
if (signForm.password.text != signForm.cpassword.text)
|
||||
{
|
||||
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
|
||||
{
|
||||
new { Field="Pwd"},
|
||||
new { Field="CPwd"},
|
||||
}));
|
||||
Utils.showToast(gameObject, "Two password entries are inconsistent");//两次密码输入不一致
|
||||
return;
|
||||
}
|
||||
var res = await ConfigHelper.userApi.AppleCompleteInfo(signForm.email.text, signForm.captcha.text, signForm.password.text);
|
||||
if (res.result)
|
||||
{
|
||||
Utils.showToast(null, App.GetLocalString("Success"), type: 1);
|
||||
App.CurrentUser.Phone = signForm.email.text;
|
||||
if (afterClose != null)
|
||||
{
|
||||
afterClose.Invoke();
|
||||
}
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.SetValidate(signFormDict, JArray.FromObject(res.data));
|
||||
Utils.showToast(null, res.errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
float timer = 1f;
|
||||
int time = 60;
|
||||
Transform signPage1;
|
||||
async void GetCaptcha()
|
||||
{
|
||||
var btn = signPage1.Find("Captcha").Find("BtnGet");
|
||||
btn.GetComponent<Button>().enabled = false;
|
||||
btn.GetComponent<Button>().interactable = false;
|
||||
var btnText = btn.Find("Text").GetComponent<Text>();
|
||||
var Email = signForm.email;
|
||||
var r = await ConfigHelper.userApi.GetCaptcha(Email.text);
|
||||
//Timer t = new Ti
|
||||
if (r.result)
|
||||
{
|
||||
//if (r.data.Value<bool>("isExist"))
|
||||
//{
|
||||
// signPage1.Find("Password").gameObject.SetActive(false);
|
||||
// signPage1.Find("CPassword").gameObject.SetActive(false);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// signPage1.Find("Password").gameObject.SetActive(true);
|
||||
// signPage1.Find("CPassword").gameObject.SetActive(true);
|
||||
//}
|
||||
time = 60;
|
||||
btnText.text = $"Again({time})";
|
||||
btn.GetComponent<Button>().enabled = false;
|
||||
btn.GetComponent<Button>().interactable = false;
|
||||
startCaptcha = true;
|
||||
//timer.Interval = 1000;
|
||||
//timer.AutoReset = true;
|
||||
//timer.Elapsed += new ElapsedEventHandler(CaptchaTimerTick);
|
||||
//timer.Enabled = true;
|
||||
//btnGet.
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.GetComponent<Button>().enabled = true;
|
||||
btn.GetComponent<Button>().interactable = true;
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
Utils.SetValidate(signFormDict, r.errFieldMsg);
|
||||
}
|
||||
}
|
||||
|
||||
void CaptchaTimerTick()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
var btn = signPage1.Find("Captcha").Find("BtnGet");
|
||||
var btnText = signPage1.Find("Captcha").Find("BtnGet").Find("Text").GetComponent<Text>();
|
||||
btnText.text = $"{App.GetLocalString("Again")}({time--})";
|
||||
if (time < 0)
|
||||
{
|
||||
btnText.text = App.GetLocalString("Get");
|
||||
btn.GetComponent<Button>().enabled = true;
|
||||
btn.GetComponent<Button>().interactable = true;
|
||||
startCaptcha = false;
|
||||
//timer.Stop();
|
||||
}
|
||||
timer += 1.0f;
|
||||
}
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (startCaptcha)
|
||||
{
|
||||
CaptchaTimerTick();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/AppleInfoController.cs.meta
Normal file
11
Assets/AppleInfoController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a404dcc72dc4894c835c2097a5ad469
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
282
Assets/BannerController.cs
Normal file
282
Assets/BannerController.cs
Normal file
@ -0,0 +1,282 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BannerController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private List<CanvasGroup> itemList;
|
||||
private List<Vector3> standardPositions;
|
||||
private List<Recommand> list;
|
||||
private int currentIndex = 1;
|
||||
private Dictionary<string, Texture> caches;
|
||||
void Awake()
|
||||
{
|
||||
itemList = new List<CanvasGroup>
|
||||
{
|
||||
transform.Find("1").GetComponent<CanvasGroup>(),
|
||||
transform.Find("2").GetComponent<CanvasGroup>(),
|
||||
transform.Find("3").GetComponent<CanvasGroup>()
|
||||
};
|
||||
caches = new Dictionary<string, Texture>();
|
||||
standardPositions = new List<Vector3>
|
||||
{
|
||||
transform.Find("1").localPosition,transform.Find("2").localPosition,transform.Find("3").localPosition
|
||||
};
|
||||
AddTouchEvent();
|
||||
|
||||
|
||||
Debug.Log(standardPositions[0]);
|
||||
Debug.Log(standardPositions[1]);
|
||||
Debug.Log(standardPositions[2]);
|
||||
}
|
||||
TKPanRecognizer pan;
|
||||
private void AddTouchEvent()
|
||||
{
|
||||
pan = new TKPanRecognizer();
|
||||
var panList = new List<CanvasGroup>();
|
||||
pan.gestureRecognizedEvent += (r) =>
|
||||
{
|
||||
if (!App.currentPageIsHome) return;
|
||||
int center = GetCenterIndex(),
|
||||
left = GetSideIndex(true),
|
||||
right = GetSideIndex(false);
|
||||
if (!(center == -1 || left == -1 || right == -1) && panList.Count == 0)
|
||||
{
|
||||
panList.Add(itemList[left]);
|
||||
panList.Add(itemList[center]);
|
||||
panList.Add(itemList[right]);
|
||||
}
|
||||
if (panList.Count == 0) return;
|
||||
var startPoint = r.startTouchLocation();
|
||||
if (((RectTransform)transform).isPointInTransfrom(startPoint))
|
||||
{
|
||||
foreach (var item in panList)
|
||||
{
|
||||
item.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
}
|
||||
var offset = pan.deltaTranslation;
|
||||
if (panList[1].transform.localPosition.x == 0)
|
||||
{
|
||||
panList[1].transform.DOScale(0.8f, 0.5f);
|
||||
}
|
||||
if (offset.x > 0)
|
||||
{
|
||||
//-43 0 43
|
||||
//后面的 如果往左,需要回到-43再往右
|
||||
panList[0].transform.localPosition += new Vector3(1, 0, 0);
|
||||
panList[1].transform.localPosition += new Vector3(1, 0, 0);
|
||||
panList[2].transform.localPosition += new Vector3(-1, 0, 0);
|
||||
}
|
||||
else if (offset.x < 0)
|
||||
{
|
||||
panList[0].transform.localPosition += new Vector3(1, 0, 0);
|
||||
panList[1].transform.localPosition += new Vector3(-1, 0, 0);
|
||||
//后面的 如果往右,需要回到43再往左
|
||||
panList[2].transform.localPosition += new Vector3(-1, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
panList.Clear();
|
||||
}
|
||||
};
|
||||
pan.gestureCompleteEvent += (r) =>
|
||||
{
|
||||
if (!App.currentPageIsHome) return;
|
||||
if (panList.Count == 0) return;
|
||||
if (panList[1].transform.localPosition.x < 0)
|
||||
{
|
||||
DOLeft(panList[0], panList[1], panList[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DORight(panList[0], panList[1], panList[2]);
|
||||
}
|
||||
panList.Clear();
|
||||
};
|
||||
TouchKit.addGestureRecognizer(pan);
|
||||
}
|
||||
int sIndex = 0, eIndex = 2;
|
||||
private void Start()
|
||||
{
|
||||
GetList();
|
||||
}
|
||||
async void GetList()
|
||||
{
|
||||
var res = await ConfigHelper.mapApi.GetRecommendList();
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count >= 3)
|
||||
{
|
||||
sIndex = 0;eIndex = 2;
|
||||
Initial(res.data);
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Initial(List<Recommand> list)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (CanvasGroup c in itemList)
|
||||
{
|
||||
var area = list[index++];
|
||||
|
||||
c.GetComponent<RecommendController>().Initial(area, caches);
|
||||
c.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
if (c.alpha != 1)
|
||||
{
|
||||
if (c.transform.localPosition.x < 0)
|
||||
{
|
||||
c.GetComponent<Button>().onClick.AddListener(Right);
|
||||
}
|
||||
else
|
||||
{
|
||||
c.GetComponent<Button>().onClick.AddListener(Left);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c.GetComponent<Button>().onClick.AddListener(()=>GoDetail(c));
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
}
|
||||
bool animateLock = false;
|
||||
private void Right()
|
||||
{
|
||||
int center = GetCenterIndex(),
|
||||
left = GetSideIndex(true),
|
||||
right = GetSideIndex(false);
|
||||
if (center == -1 || left == -1 || right == -1 || animateLock) return;
|
||||
animateLock = true;
|
||||
if (leftse != null) leftse.Complete(true);
|
||||
DORight(itemList[left], itemList[center], itemList[right]);
|
||||
}
|
||||
void DORight(CanvasGroup left, CanvasGroup center, CanvasGroup right)
|
||||
{
|
||||
Sequence se = DOTween.Sequence();
|
||||
se.Join(center.DOFade(0.5f, 0.3f));
|
||||
se.Join(center.GetComponent<RectTransform>().DOScale(Vector3.one * 0.8f, 0.3f));
|
||||
se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(offset, 0.3f));
|
||||
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(-1* offset, 0.3f));
|
||||
var area = list[((sIndex - 1) + list.Count) % list.Count];
|
||||
sIndex--;
|
||||
eIndex--;
|
||||
if (sIndex < 0) sIndex = (sIndex + list.Count) % list.Count;
|
||||
if (eIndex < 0) eIndex = (eIndex + list.Count) % list.Count;
|
||||
Debug.Log($"{sIndex},{eIndex}");
|
||||
right.GetComponent<RecommendController>().Initial(area, caches);
|
||||
se.Join(left.DOFade(1, 0.3f));
|
||||
se.Join(left.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
|
||||
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
|
||||
se.Play().onComplete = ()=> { animateLock = false; };
|
||||
rightse = se;
|
||||
left.transform.SetAsLastSibling();
|
||||
//事件改变
|
||||
left.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
left.GetComponent<Button>().onClick.AddListener(() => GoDetail(left));
|
||||
center.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
center.GetComponent<Button>().onClick.AddListener(Left);
|
||||
right.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
right.GetComponent<Button>().onClick.AddListener(Right);
|
||||
}
|
||||
#if UNITY_STANDALONE_WIN
|
||||
float offset = 110;
|
||||
#else
|
||||
float offset = 43;
|
||||
#endif
|
||||
Sequence leftse, rightse;
|
||||
private void Left()
|
||||
{
|
||||
int center = GetCenterIndex(),
|
||||
left = GetSideIndex(true),
|
||||
right = GetSideIndex(false);
|
||||
if (center == -1 || left == -1 || right == -1|| animateLock) return;
|
||||
animateLock = true;
|
||||
if (rightse != null) rightse.Complete(true);
|
||||
DOLeft(itemList[left], itemList[center], itemList[right]);
|
||||
}
|
||||
void DOLeft(CanvasGroup left, CanvasGroup center, CanvasGroup right)
|
||||
{
|
||||
Sequence se = DOTween.Sequence();
|
||||
se.Join(center.DOFade(0.5f, 0.3f));
|
||||
se.Join(center.GetComponent<RectTransform>().DOScale(Vector3.one * 0.8f, 0.3f));
|
||||
se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(-1* offset, 0.3f));
|
||||
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(offset, 0.3f));
|
||||
var area = list[((eIndex + 1) + list.Count) % list.Count];
|
||||
sIndex++;
|
||||
eIndex++;
|
||||
if (sIndex >= list.Count - 1) sIndex = sIndex % list.Count;
|
||||
if (eIndex >= list.Count - 1) eIndex = eIndex % list.Count;
|
||||
Debug.Log($"{sIndex},{eIndex}");
|
||||
var centerArea = list[currentIndex + 1];
|
||||
left.GetComponent<RecommendController>().Initial(area, caches);
|
||||
if (currentIndex < 0) currentIndex = list.Count - 1;
|
||||
se.Join(right.DOFade(1, 0.3f));
|
||||
se.Join(right.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
|
||||
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
|
||||
se.Play().onComplete = () => { animateLock = false; };
|
||||
leftse = se;
|
||||
right.transform.SetAsLastSibling();
|
||||
//事件改变
|
||||
right.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
right.GetComponent<Button>().onClick.AddListener(() => GoDetail(right));
|
||||
center.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
center.GetComponent<Button>().onClick.AddListener(Right);
|
||||
left.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
left.GetComponent<Button>().onClick.AddListener(Left);
|
||||
}
|
||||
int GetCenterIndex()
|
||||
{
|
||||
return itemList.FindIndex(x => x.transform.localPosition.x == 0);
|
||||
}
|
||||
int GetSideIndex(bool left)
|
||||
{
|
||||
return itemList.FindIndex(x => left ? x.transform.localPosition.x < 0 : x.transform.localPosition.x > 0);
|
||||
}
|
||||
void GoDetail(CanvasGroup c)
|
||||
{
|
||||
if (c.transform.localPosition.x == 0)
|
||||
{
|
||||
var se = DOTween.Sequence();
|
||||
se.Append(c.transform.DOScale(1.05f * Vector3.one, 0.15f));
|
||||
se.Append(c.transform.DOScale(1f * Vector3.one, 0.15f));
|
||||
se.Play().onComplete = ()=>
|
||||
{
|
||||
c.GetComponent<RecommendController>().DoWithType();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
float autoTime = 5;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
autoTime -= Time.deltaTime;
|
||||
if (autoTime < 0)
|
||||
{
|
||||
Left();
|
||||
autoTime += 5;
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.Log(248+"毁灭");
|
||||
TouchKit.removeGestureRecognizer(pan);
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
11
Assets/BannerController.cs.meta
Normal file
11
Assets/BannerController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99085319355aa0f44a5db27b26f6ec95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Chart And Graph.meta
Normal file
8
Assets/Chart And Graph.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21ab74f6196c6da4eb277c2615345f1b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Chart And Graph/3rd party notices.txt
Normal file
19
Assets/Chart And Graph/3rd party notices.txt
Normal file
@ -0,0 +1,19 @@
|
||||
The following 3rd parties are integrated into Graph and Chart:
|
||||
|
||||
In the folder Chart And Graph/Themes/Common/Fonts :
|
||||
|
||||
Each font has it's own folder with full license detials
|
||||
|
||||
Exo2 - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/exo-2
|
||||
ABeeZee - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/abeezee
|
||||
Comprehension - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/comprehension
|
||||
Enriqueta - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/enriqueta
|
||||
Fengardo-neue - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/fengardo-neue
|
||||
Overpass - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/overpass
|
||||
Rambla - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/rambla
|
||||
Scada - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/scada
|
||||
|
||||
SimpleJson in the folder Chart And Graph/SimpleJSON-master:
|
||||
Licensed under MIT license :https://github.com/Bunny83/SimpleJSON/blob/master/LICENSE
|
||||
|
||||
|
||||
8
Assets/Chart And Graph/3rd party notices.txt.meta
Normal file
8
Assets/Chart And Graph/3rd party notices.txt.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b593c70250d4fb94bb76f653a500cd6d
|
||||
timeCreated: 1536774863
|
||||
licenseType: Store
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/ChartParser.meta
Normal file
9
Assets/Chart And Graph/ChartParser.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3cc22ffba1b29a44b56007d189a1750
|
||||
folderAsset: yes
|
||||
timeCreated: 1536396364
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Chart And Graph/ChartParser/ChartParser.cs
Normal file
26
Assets/Chart And Graph/ChartParser/ChartParser.cs
Normal file
@ -0,0 +1,26 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public abstract class ChartParser
|
||||
{
|
||||
public abstract bool SetPathRelativeTo(string pathObject);
|
||||
/// <summary>
|
||||
/// returns null if object not found
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public abstract object GetObject(string name);
|
||||
public abstract object GetChildObject(object obj, string name);
|
||||
public abstract IEnumerable<KeyValuePair<string , object>> GetAllChildObjects(object obj);
|
||||
public abstract string GetChildObjectValue(object obj, string name);
|
||||
public abstract string GetItem(object arr, int item);
|
||||
public abstract object GetItemObject(object arr, int item);
|
||||
public abstract int GetArraySize(object arr);
|
||||
public abstract string ObjectValue(object obj);
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/ChartParser/ChartParser.cs.meta
Normal file
12
Assets/Chart And Graph/ChartParser/ChartParser.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5948d4ad51f370c4f927d0d10573cc84
|
||||
timeCreated: 1536396364
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
134
Assets/Chart And Graph/ChartParser/JsonParser.cs
Normal file
134
Assets/Chart And Graph/ChartParser/JsonParser.cs
Normal file
@ -0,0 +1,134 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using SimpleJSON;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class JsonParser : ChartParser
|
||||
{
|
||||
JSONNode mBaseJson;
|
||||
JSONNode mRelativePath;
|
||||
public JsonParser(string data)
|
||||
{
|
||||
|
||||
mBaseJson = JSON.Parse(data);
|
||||
mRelativePath = mBaseJson;
|
||||
}
|
||||
|
||||
object GetObjectFromRoot(JSONNode root, string name)
|
||||
{
|
||||
string[] parents = name.Split('>');
|
||||
object current = root;
|
||||
for (int i = 0; current != null && i < parents.Length; i++)
|
||||
{
|
||||
string nextNode = parents[i];
|
||||
current = GetChildObject(current, nextNode);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public override int GetArraySize(object arr)
|
||||
{
|
||||
var node = (JSONNode)arr;
|
||||
if (node.IsArray == false)
|
||||
return 0;
|
||||
return node.Count;
|
||||
}
|
||||
|
||||
public override object GetChildObject(object obj, string name)
|
||||
{
|
||||
var node = (JSONNode)obj;
|
||||
if (name.Length <= 0)
|
||||
return obj;
|
||||
if (char.IsDigit(name[0])) // if it is a number then find by order , atag name cannot start with a digit
|
||||
{
|
||||
if (node.IsArray == false)
|
||||
return null;
|
||||
int index = 0;
|
||||
if (int.TryParse(name, out index) == false) // try parsing the number
|
||||
return null;
|
||||
if (index < 0 || index >= node.Count)
|
||||
return null;
|
||||
return node[index];
|
||||
}
|
||||
if(name.Length>=2 && name[0] == '"' && name[name.Length-1] == '"')
|
||||
{
|
||||
name = name.Substring(1, name.Length - 2); //strip quatation marks
|
||||
}
|
||||
return node[name];
|
||||
}
|
||||
|
||||
|
||||
public override bool SetPathRelativeTo(string pathObject)
|
||||
{
|
||||
mRelativePath = (JSONNode)GetObjectFromRoot(mBaseJson, pathObject);
|
||||
if (mRelativePath == null)
|
||||
{
|
||||
mRelativePath = mBaseJson;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override object GetObject(string name)
|
||||
{
|
||||
return GetObjectFromRoot(mRelativePath, name);
|
||||
}
|
||||
|
||||
public override string GetItem(object arr, int item)
|
||||
{
|
||||
var element = arr as JSONNode;
|
||||
if (element == null)
|
||||
return null;
|
||||
var child = element[item] as JSONNode;
|
||||
if (child == null)
|
||||
return null;
|
||||
return ObjectValue(child);
|
||||
}
|
||||
|
||||
public override object GetItemObject(object arr, int item)
|
||||
{
|
||||
var element = arr as JSONNode;
|
||||
if (element == null)
|
||||
return null;
|
||||
var child = element[item];
|
||||
return child;
|
||||
}
|
||||
|
||||
public override string ObjectValue(object obj)
|
||||
{
|
||||
var element = obj as JSONNode;
|
||||
return element.Value;
|
||||
}
|
||||
|
||||
public override string GetChildObjectValue(object obj, string name)
|
||||
{
|
||||
var element = obj as JSONNode;
|
||||
if (element == null)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
var child = element[name] as JSONNode;
|
||||
return ObjectValue(child);
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IEnumerable<KeyValuePair<string, object>> GetAllChildObjects(object obj)
|
||||
{
|
||||
var node = (JSONNode)obj;
|
||||
if (node.IsObject == false)
|
||||
yield break;
|
||||
foreach(var key in node.Keys)
|
||||
yield return new KeyValuePair<string, object>(key, node[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/ChartParser/JsonParser.cs.meta
Normal file
12
Assets/Chart And Graph/ChartParser/JsonParser.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0693b788053aab64a88908e1e3d6b944
|
||||
timeCreated: 1536396364
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
146
Assets/Chart And Graph/ChartParser/XMLParser.cs
Normal file
146
Assets/Chart And Graph/ChartParser/XMLParser.cs
Normal file
@ -0,0 +1,146 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#if WINDOWS_UWP
|
||||
using Windows.Data.Xml.Dom;
|
||||
#else
|
||||
using System.Xml;
|
||||
#endif
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class XMLParser : ChartParser
|
||||
{
|
||||
XmlDocument mXmlDoc;
|
||||
XmlElement mRelativeElement;
|
||||
|
||||
public XMLParser(string xml)
|
||||
{
|
||||
mXmlDoc = new XmlDocument();
|
||||
#if WINDOWS_UWP
|
||||
mXmlDoc.LoadXml(xml);
|
||||
#else
|
||||
using (var reader = new StringReader(xml))
|
||||
{
|
||||
mXmlDoc.Load(reader);
|
||||
}
|
||||
#endif
|
||||
mRelativeElement = mXmlDoc.DocumentElement;
|
||||
}
|
||||
|
||||
public override int GetArraySize(object arr)
|
||||
{
|
||||
var element = arr as XmlElement;
|
||||
if (element == null)
|
||||
return 0;
|
||||
return element.ChildNodes.Count;
|
||||
}
|
||||
|
||||
public override object GetChildObject(object obj, string name)
|
||||
{
|
||||
var node = (XmlElement)obj;
|
||||
if (name.Length <= 0)
|
||||
return obj;
|
||||
if (char.IsDigit(name[0])) // if it is a number then find by order , atag name cannot start with a digit
|
||||
{
|
||||
int index = 0;
|
||||
if (int.TryParse(name, out index) == false) // try parsing the number
|
||||
return null;
|
||||
if (index < 0 || index >= node.ChildNodes.Count)
|
||||
return null;
|
||||
return node.ChildNodes[index];
|
||||
}
|
||||
|
||||
return node.SelectSingleNode(name);
|
||||
}
|
||||
|
||||
public override object GetItemObject(object arr, int item)
|
||||
{
|
||||
var element = arr as XmlElement;
|
||||
if (element == null)
|
||||
return null;
|
||||
var child = element.ChildNodes[item] as XmlElement;
|
||||
return child;
|
||||
}
|
||||
|
||||
object GetObjectFromRoot(XmlElement root, string name)
|
||||
{
|
||||
string[] parents = name.Split('>');
|
||||
object current = root;
|
||||
for (int i = 0; current != null && i < parents.Length; i++)
|
||||
{
|
||||
string nextNode = parents[i];
|
||||
current = GetChildObject(current, nextNode);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public override object GetObject(string name)
|
||||
{
|
||||
return GetObjectFromRoot(mRelativeElement, name);
|
||||
}
|
||||
|
||||
public override bool SetPathRelativeTo(string pathObject)
|
||||
{
|
||||
mRelativeElement = (XmlElement)GetObjectFromRoot(mXmlDoc.DocumentElement, pathObject);
|
||||
if (mRelativeElement == null)
|
||||
{
|
||||
mRelativeElement = mXmlDoc.DocumentElement;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string GetChildObjectValue(object obj, string name)
|
||||
{
|
||||
var element = obj as XmlElement;
|
||||
if (element == null)
|
||||
return null;
|
||||
var child = element.SelectSingleNode(name) as XmlElement;
|
||||
if (child == null)
|
||||
return null;
|
||||
return ObjectValue(child);
|
||||
}
|
||||
|
||||
public override string GetItem(object arr, int item)
|
||||
{
|
||||
var element = arr as XmlElement;
|
||||
if (element == null)
|
||||
return null;
|
||||
var child = element.ChildNodes[item] as XmlElement;
|
||||
if (child == null)
|
||||
return null;
|
||||
return ObjectValue(child);
|
||||
}
|
||||
|
||||
public override string ObjectValue(object obj)
|
||||
{
|
||||
var element = obj as XmlElement;
|
||||
if (element == null)
|
||||
return null;
|
||||
return element.InnerText;
|
||||
}
|
||||
|
||||
public override IEnumerable<KeyValuePair<string, object>> GetAllChildObjects(object obj)
|
||||
{
|
||||
var element = obj as XmlElement;
|
||||
if (element == null)
|
||||
yield break;
|
||||
foreach(var node in element.ChildNodes)
|
||||
{
|
||||
var xml = node as XmlElement;
|
||||
if(xml != null)
|
||||
{
|
||||
#if WINDOWS_UWP
|
||||
yield return new KeyValuePair<string, object>(xml.TagName, xml);
|
||||
#else
|
||||
yield return new KeyValuePair<string, object>(xml.Name, xml);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/ChartParser/XMLParser.cs.meta
Normal file
12
Assets/Chart And Graph/ChartParser/XMLParser.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 878b8742852947849810df5d673d597c
|
||||
timeCreated: 1536396365
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/Editor.meta
Normal file
9
Assets/Chart And Graph/Editor.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf8f979c9af34ff43ab739a7cf401b92
|
||||
folderAsset: yes
|
||||
timeCreated: 1560597265
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Chart And Graph/Editor/AutoFloatInspector.cs
Normal file
32
Assets/Chart And Graph/Editor/AutoFloatInspector.cs
Normal file
@ -0,0 +1,32 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(AutoFloat))]
|
||||
class AutoFloatInspector : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
SerializedProperty auto = property.FindPropertyRelative("Automatic");
|
||||
SerializedProperty val = property.FindPropertyRelative("Value");
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
bool res = EditorGUI.ToggleLeft(position,"Auto",auto.boolValue);
|
||||
EditorGUI.indentLevel = indent;
|
||||
EditorGUI.indentLevel++;
|
||||
if (auto.boolValue == false && EditorGUI.showMixedValue == false)
|
||||
val.floatValue = EditorGUILayout.FloatField("Value",val.floatValue);
|
||||
auto.boolValue = res;
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/AutoFloatInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/AutoFloatInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c989bbf118ca01e4aab213559170875f
|
||||
timeCreated: 1479209594
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
273
Assets/Chart And Graph/Editor/AxisInspector.cs
Normal file
273
Assets/Chart And Graph/Editor/AxisInspector.cs
Normal file
@ -0,0 +1,273 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(AxisBase), true)]
|
||||
class AxisInspector : Editor
|
||||
{
|
||||
bool mMain = false;
|
||||
bool mSub = false;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AxisBase axis = (AxisBase)target;
|
||||
|
||||
if (axis.gameObject == null)
|
||||
return;
|
||||
|
||||
AnyChart chart = axis.gameObject.GetComponent<AnyChart>();
|
||||
if (chart == null)
|
||||
return;
|
||||
if((chart is AxisChart) == false)
|
||||
{
|
||||
EditorGUILayout.LabelField(string.Format("Chart of type {0} does not support axis",chart.GetType().Name));
|
||||
return;
|
||||
}
|
||||
SerializedProperty simpleViewProp = serializedObject.FindProperty("SimpleView");
|
||||
if (simpleViewProp == null)
|
||||
return;
|
||||
|
||||
Type canvasType = (chart is ICanvas) ? typeof(CanvasAttribute) : typeof(NonCanvasAttribute);
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
bool negate = false;
|
||||
if (simpleViewProp.boolValue == true)
|
||||
negate = GUILayout.Button("Advanced View");
|
||||
else
|
||||
negate = GUILayout.Button("Simple View");
|
||||
if (negate)
|
||||
simpleViewProp.boolValue = !simpleViewProp.boolValue;
|
||||
bool simple = simpleViewProp.boolValue;
|
||||
|
||||
|
||||
SerializedProperty depth = serializedObject.FindProperty("depth");
|
||||
if (depth != null)
|
||||
EditorGUILayout.PropertyField(depth);
|
||||
SerializedProperty format= serializedObject.FindProperty("format");
|
||||
EditorGUILayout.PropertyField(format);
|
||||
if (simple)
|
||||
DoSimpleView(canvasType);
|
||||
else
|
||||
DoAdvanvedView(canvasType,true);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
serializedObject.Update();
|
||||
}
|
||||
|
||||
void SetValue(SerializedProperty assignTo,SerializedProperty from)
|
||||
{
|
||||
|
||||
if(assignTo.propertyType != from.propertyType)
|
||||
{
|
||||
Debug.LogWarning("type does not match");
|
||||
return;
|
||||
}
|
||||
|
||||
if (assignTo.type == "AutoFloat")
|
||||
{
|
||||
SerializedProperty auto = assignTo.FindPropertyRelative("Automatic");
|
||||
SerializedProperty val = assignTo.FindPropertyRelative("Value");
|
||||
SerializedProperty autofrom = from.FindPropertyRelative("Automatic");
|
||||
SerializedProperty valfrom = from.FindPropertyRelative("Value");
|
||||
auto.boolValue = autofrom.boolValue;
|
||||
val.floatValue = valfrom.floatValue;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (assignTo.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
assignTo.floatValue = from.floatValue;
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
assignTo.intValue = from.intValue;
|
||||
break;
|
||||
case SerializedPropertyType.Enum:
|
||||
assignTo.enumValueIndex = from.enumValueIndex;
|
||||
break;
|
||||
case SerializedPropertyType.Boolean:
|
||||
assignTo.boolValue = from.boolValue;
|
||||
break;
|
||||
case SerializedPropertyType.String:
|
||||
assignTo.stringValue = from.stringValue;
|
||||
break;
|
||||
case SerializedPropertyType.ObjectReference:
|
||||
assignTo.objectReferenceValue = from.objectReferenceValue;
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning("type cannot be set");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Type getTypeFromField(Type type,string fieldName)
|
||||
{
|
||||
FieldInfo inf = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (inf == null)
|
||||
return null;
|
||||
return inf.FieldType;
|
||||
}
|
||||
|
||||
bool CompareValues(Type type,string fieldName,object a,object b)
|
||||
{
|
||||
FieldInfo inf= type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
object valA = inf.GetValue(a);
|
||||
object valB = inf.GetValue(b);
|
||||
if(valA is UnityEngine.Object && valB is UnityEngine.Object)
|
||||
{
|
||||
if(((UnityEngine.Object)valA) == ((UnityEngine.Object)valB))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (valA == null && valB == null)
|
||||
return true;
|
||||
return valA.Equals(valB);
|
||||
}
|
||||
|
||||
void DoSimpleView(Type canvasType)
|
||||
{
|
||||
SerializedProperty it = serializedObject.FindProperty("mainDivisions");
|
||||
SerializedProperty SubDivisions = serializedObject.FindProperty("subDivisions");
|
||||
object mainDivision = ((AxisBase)target).MainDivisions;
|
||||
object subDivision = ((AxisBase)target).SubDivisions;
|
||||
if (it == null || SubDivisions == null)
|
||||
return;
|
||||
SerializedProperty end = it.GetEndProperty();
|
||||
while(it.NextVisible(true) && SerializedProperty.EqualContents(end,it) == false)
|
||||
{
|
||||
if (it.name == "SimpleView")
|
||||
continue;
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, canvasType) == false)
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, canvasType) == false)
|
||||
continue;
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, typeof(SimpleAttribute)) == false)
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, typeof(SimpleAttribute)) == false)
|
||||
continue;
|
||||
SerializedProperty clone = SubDivisions.FindPropertyRelative(it.name);
|
||||
if (clone == null)
|
||||
Debug.LogWarning("can't find property " + it.name);
|
||||
bool equal = CompareValues(typeof(ChartDivisionInfo), clone.name, mainDivision, subDivision);
|
||||
Type t = getTypeFromField(typeof(ChartDivisionInfo), clone.name);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = !equal;
|
||||
DoMixedFiled(it, t);
|
||||
EditorGUI.showMixedValue = false;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
SetValue(clone, it);
|
||||
}
|
||||
DoAdvanvedView(canvasType,false);
|
||||
}
|
||||
public void DoMixedFiled(SerializedProperty prop,Type type)
|
||||
{
|
||||
if(prop.type == "AutoFloat")
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel(prop.displayName);
|
||||
SerializedProperty auto = prop.FindPropertyRelative("Automatic");
|
||||
SerializedProperty val = prop.FindPropertyRelative("Value");
|
||||
auto.boolValue = EditorGUILayout.ToggleLeft("Auto", auto.boolValue);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel++;
|
||||
if (auto.boolValue == false && EditorGUI.showMixedValue == false)
|
||||
val.floatValue = EditorGUILayout.FloatField("Value",val.floatValue);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
return;
|
||||
}
|
||||
switch(prop.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
if(prop.name == "FontSharpness")
|
||||
prop.floatValue = EditorGUILayout.Slider(prop.displayName, prop.floatValue,1f,3f);
|
||||
else
|
||||
prop.floatValue = EditorGUILayout.FloatField(prop.displayName,prop.floatValue);
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
if (prop.name == "FractionDigits")
|
||||
prop.intValue = EditorGUILayout.IntSlider(prop.displayName, prop.intValue,0,7);
|
||||
else
|
||||
prop.intValue = EditorGUILayout.IntField(prop.displayName, prop.intValue);
|
||||
break;
|
||||
case SerializedPropertyType.Enum:
|
||||
ChartDivisionAligment selected = (ChartDivisionAligment)Enum.Parse( typeof(ChartDivisionAligment), prop.enumNames[prop.enumValueIndex]);
|
||||
Enum res = EditorGUILayout.EnumPopup(prop.displayName, selected);
|
||||
string newName= Enum.GetName(typeof(ChartDivisionAligment), res);
|
||||
for (int i = 0; i < prop.enumNames.Length; ++i)
|
||||
{
|
||||
if (prop.enumNames[i] == newName)
|
||||
{
|
||||
prop.enumValueIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SerializedPropertyType.String:
|
||||
prop.stringValue = EditorGUILayout.TextField(prop.displayName, prop.stringValue);
|
||||
break;
|
||||
case SerializedPropertyType.Boolean:
|
||||
prop.boolValue = EditorGUILayout.Toggle(prop.displayName, prop.boolValue);
|
||||
break;
|
||||
case SerializedPropertyType.ObjectReference:
|
||||
if(type != null)
|
||||
prop.objectReferenceValue = EditorGUILayout.ObjectField(prop.displayName, prop.objectReferenceValue, type, true);
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning("type cannot be set");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DoAdvanvedView(Type canvasType,bool includeSimple)
|
||||
{
|
||||
SerializedProperty mainDivisions = serializedObject.FindProperty("mainDivisions");
|
||||
SerializedProperty subDivisions = serializedObject.FindProperty("subDivisions");
|
||||
mMain =mainDivisions.isExpanded = EditorGUILayout.Foldout(mainDivisions.isExpanded, "Main Divisions");
|
||||
if (mMain)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
SerializedProperty end = mainDivisions.GetEndProperty();
|
||||
while (mainDivisions.NextVisible(true) && SerializedProperty.EqualContents(mainDivisions, end) == false)
|
||||
{
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, canvasType) == false)
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), mainDivisions.name, canvasType) == false)
|
||||
continue;
|
||||
if (includeSimple == false)
|
||||
{
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, typeof(SimpleAttribute)))
|
||||
continue;
|
||||
}
|
||||
EditorGUILayout.PropertyField(mainDivisions);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
mSub = subDivisions.isExpanded = EditorGUILayout.Foldout(subDivisions.isExpanded, "Sub Divisions");
|
||||
if (mSub)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
SerializedProperty end = subDivisions.GetEndProperty();
|
||||
while (subDivisions.NextVisible(true) && SerializedProperty.EqualContents(subDivisions, end) == false)
|
||||
{
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, canvasType) == false)
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), subDivisions.name, canvasType) == false)
|
||||
continue;
|
||||
if (includeSimple == false)
|
||||
{
|
||||
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, typeof(SimpleAttribute)))
|
||||
continue;
|
||||
}
|
||||
EditorGUILayout.PropertyField(subDivisions);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/AxisInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/AxisInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 898567b381452e94794158c16012f617
|
||||
timeCreated: 1479124371
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
364
Assets/Chart And Graph/Editor/BarChartInspetor.cs
Normal file
364
Assets/Chart And Graph/Editor/BarChartInspetor.cs
Normal file
@ -0,0 +1,364 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(BarChart),true)]
|
||||
class BarChartInspetor : Editor
|
||||
{
|
||||
bool mCategories = false;
|
||||
bool mGroups = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
string mNewGroupName = "";
|
||||
string mGroupError = null;
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
ChartDataEditor mWindow;
|
||||
bool mUpdateWindow = false;
|
||||
Texture mSettings;
|
||||
GUIContent MaxBarValue = new GUIContent("Max Bar Value :", "All the bars are scaled according to this value, Bars that are larger then this value are clamped");
|
||||
GUIContent MinBarValue = new GUIContent("Min Bar Value :", "All the bars are scaled according to this value, Bars that are lower then this value are clamped");
|
||||
RenameWindow mRenameWindow;
|
||||
public void OnEnable()
|
||||
{
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items,int size,string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
bool toogle = false;
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if(GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name")
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (ChartEditorCommon.IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
bool RenameGroup(string fromName, string toName)
|
||||
{
|
||||
BarChart barChart = (BarChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
barChart.DataSource.RenameGroup(fromName, toName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (barChart.gameObject.activeInHierarchy)
|
||||
barChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(barChart);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenameCategory(string fromName,string toName)
|
||||
{
|
||||
BarChart barChart = (BarChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
barChart.DataSource.RenameCategory(fromName, toName);
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if(barChart.gameObject.activeInHierarchy)
|
||||
barChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(barChart);
|
||||
return true;
|
||||
}
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
if(data.Key == "category")
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
else if(data.Key == "group")
|
||||
window.ShowDialog(data.Value, data.Key, RenameGroup);
|
||||
}
|
||||
void DoContext(string type,string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false,callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
void UpdateWindow()
|
||||
{
|
||||
mUpdateWindow = true;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if(mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
SerializedProperty barData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if(mBold == null)
|
||||
{
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
//mBold.fontStyle = FontStyle.Bold;
|
||||
}
|
||||
// EditorStyles.foldout.fontStyle = FontStyle.Bold;
|
||||
// fold = EditorGUILayout.Foldout(fold,"Bar Data", EditorStyles.foldout);
|
||||
//EditorStyles.foldout.fontStyle = FontStyle.Normal;
|
||||
// if (fold)
|
||||
// {
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
NamedItemEditor(barData, "group", "mGroups", "Groups", ref mGroupError, ref mGroups, ref mNewGroupName);
|
||||
|
||||
SerializedProperty maxProp = barData.FindPropertyRelative("maxValue");
|
||||
SerializedProperty minProp = barData.FindPropertyRelative("minValue");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(MinBarValue, EditorStyles.boldLabel);
|
||||
SerializedProperty automaticProp = barData.FindPropertyRelative("automaticMinValue");
|
||||
bool automatic = automaticProp.boolValue;
|
||||
automatic = GUILayout.Toggle(automatic, "Auto");
|
||||
GUILayout.FlexibleSpace();
|
||||
automaticProp.boolValue = automatic;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
EditorGUILayout.PropertyField(minProp);
|
||||
if (minProp.doubleValue > maxProp.doubleValue)
|
||||
minProp.doubleValue = maxProp.doubleValue - 0.1;
|
||||
}
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(MaxBarValue, EditorStyles.boldLabel);
|
||||
automaticProp = barData.FindPropertyRelative("automaticMaxValue");
|
||||
automatic = automaticProp.boolValue;
|
||||
automatic = GUILayout.Toggle(automatic, "Auto");
|
||||
GUILayout.FlexibleSpace();
|
||||
automaticProp.boolValue = automatic;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
|
||||
EditorGUILayout.PropertyField(maxProp);
|
||||
if (minProp.doubleValue > maxProp.doubleValue)
|
||||
maxProp.doubleValue = minProp.doubleValue + 0.1;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Edit Values...") && mWindow == null)
|
||||
mWindow = ChartDataEditor.ShowForObject(serializedObject);
|
||||
//}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (mUpdateWindow == true)
|
||||
{
|
||||
mUpdateWindow = false;
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.SetEditedObject(serializedObject);
|
||||
mWindow.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/BarChartInspetor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/BarChartInspetor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 056f0fff5e172de468df8c3392cabaac
|
||||
timeCreated: 1473969758
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
68
Assets/Chart And Graph/Editor/CategoryDataEditor.cs
Normal file
68
Assets/Chart And Graph/Editor/CategoryDataEditor.cs
Normal file
@ -0,0 +1,68 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(GraphDataFiller.CategoryData))]
|
||||
class CategoryDataEditor : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
return -2f;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
var enabled = property.FindPropertyRelative("Enabled");
|
||||
|
||||
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.displayName);
|
||||
if(property.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(enabled);
|
||||
if (enabled.boolValue == true)
|
||||
{
|
||||
var dataType = property.FindPropertyRelative("DataType");
|
||||
EditorGUILayout.PropertyField(dataType);
|
||||
int item = dataType.enumValueIndex;
|
||||
var iterator = property.Copy();
|
||||
var end = iterator.GetEndProperty();
|
||||
bool hasNext = iterator.NextVisible(true);
|
||||
Type t = typeof(GraphDataFiller.CategoryData);
|
||||
while (hasNext)
|
||||
{
|
||||
if ((SerializedProperty.EqualContents(iterator, end)))
|
||||
break;
|
||||
bool show = false;
|
||||
|
||||
foreach (object attrb in t.GetField(iterator.name).GetCustomAttributes(false))
|
||||
{
|
||||
var cast = attrb as ChartFillerEditorAttribute;
|
||||
if (cast != null)
|
||||
{
|
||||
if ((int)cast.ShowForType == item)
|
||||
{
|
||||
show = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (show)
|
||||
EditorGUILayout.PropertyField(iterator);
|
||||
// Debug.Log(iterator.displayName);
|
||||
hasNext = iterator.NextVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/CategoryDataEditor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/CategoryDataEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ad20a161538c146aa76559c3f89754
|
||||
timeCreated: 1536697084
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Chart And Graph/Editor/CategoryLabelsInspector.cs
Normal file
26
Assets/Chart And Graph/Editor/CategoryLabelsInspector.cs
Normal file
@ -0,0 +1,26 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(CategoryLabels))]
|
||||
class CategoryLabelsLabelsInspector : ItemLabelsBaseEditor
|
||||
{
|
||||
protected override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "category labels";
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool isSupported(AnyChart chart)
|
||||
{
|
||||
return ((IInternalUse)chart).InternalSupportsCategoryLables;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31ece195e6c596940a2dd7720c53058e
|
||||
timeCreated: 1480254476
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
96
Assets/Chart And Graph/Editor/ChartDataEditor.cs
Normal file
96
Assets/Chart And Graph/Editor/ChartDataEditor.cs
Normal file
@ -0,0 +1,96 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChartDataEditor : UnityEditor.EditorWindow
|
||||
{
|
||||
SerializedObject mEditedObject;
|
||||
SerializedProperty mBarData;
|
||||
SerializedProperty mCategories;
|
||||
SerializedProperty mGroups;
|
||||
SerializedProperty mData;
|
||||
Dictionary<string, SerializedProperty> mValues;
|
||||
|
||||
public static ChartDataEditor ShowForObject(SerializedObject obj)
|
||||
{
|
||||
ChartDataEditor window = (ChartDataEditor)EditorWindow.GetWindow(typeof(ChartDataEditor));
|
||||
window.SetEditedObject(obj);
|
||||
return window;
|
||||
}
|
||||
|
||||
public void SetEditedObject(SerializedObject obj)
|
||||
{
|
||||
mEditedObject = obj;
|
||||
mBarData = mEditedObject.FindProperty("Data");
|
||||
mCategories = mBarData.FindPropertyRelative("mCategories");
|
||||
mGroups = mBarData.FindPropertyRelative("mGroups");
|
||||
mData = mBarData.FindPropertyRelative("mData");
|
||||
LoadData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LoadData()
|
||||
{
|
||||
if(mValues == null)
|
||||
mValues = new Dictionary<string, SerializedProperty>();
|
||||
mValues.Clear();
|
||||
int size = mData.arraySize;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty prop = mData.GetArrayElementAtIndex(i);
|
||||
string columnName = prop.FindPropertyRelative("ColumnName").stringValue;
|
||||
string rowName = prop.FindPropertyRelative("GroupName").stringValue;
|
||||
SerializedProperty amount = prop.FindPropertyRelative("Amount");
|
||||
string keyName = getKey(columnName, rowName);
|
||||
mValues[keyName] = amount;
|
||||
}
|
||||
}
|
||||
|
||||
string getKey(string column,string row)
|
||||
{
|
||||
return string.Format("{0}|{1}", column, row);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Edit Values", EditorStyles.boldLabel);
|
||||
GUILayout.BeginVertical();
|
||||
int categoryCount = mCategories.arraySize;
|
||||
int groupCount = mGroups.arraySize;
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUILayout.Label(" ",GUILayout.Width(EditorGUIUtility.fieldWidth));
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
{
|
||||
string group = mGroups.GetArrayElementAtIndex(i).stringValue;
|
||||
GUILayout.Label(group, GUILayout.Width(EditorGUIUtility.fieldWidth));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
for (int i=0; i<categoryCount; i++)
|
||||
{
|
||||
SerializedProperty catProp = mCategories.GetArrayElementAtIndex(i);
|
||||
string category = catProp.FindPropertyRelative("Name").stringValue;
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label(category, GUILayout.Width(EditorGUIUtility.fieldWidth));
|
||||
for (int j=0; j<groupCount; j++)
|
||||
{
|
||||
string group = mGroups.GetArrayElementAtIndex(j).stringValue;
|
||||
string keyName = getKey(category, group);
|
||||
double value =0.0;
|
||||
SerializedProperty prop;
|
||||
if (mValues.TryGetValue(keyName, out prop))
|
||||
value = prop.doubleValue;
|
||||
else
|
||||
prop = null;
|
||||
double newVal = EditorGUILayout.DoubleField(value, GUILayout.Width(EditorGUIUtility.fieldWidth));
|
||||
if(newVal != value)
|
||||
prop.doubleValue = newVal;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
mEditedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/ChartDataEditor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/ChartDataEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b917e1b2904ebf348a64f64b59a51908
|
||||
timeCreated: 1474501984
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Chart And Graph/Editor/ChartEditorCommon.cs
Normal file
38
Assets/Chart And Graph/Editor/ChartEditorCommon.cs
Normal file
@ -0,0 +1,38 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class ChartEditorCommon
|
||||
{
|
||||
internal static bool IsAlphaNum(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
internal static bool HasAttributeOfType(Type type, string fieldName, Type attributeType)
|
||||
{
|
||||
FieldInfo inf = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (inf == null)
|
||||
return false;
|
||||
object[] attrb = inf.GetCustomAttributes(attributeType, true);
|
||||
if (attrb == null)
|
||||
return false;
|
||||
return attrb.Length > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/ChartEditorCommon.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/ChartEditorCommon.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fc5bc09e01eda34da606695525bf023
|
||||
timeCreated: 1479124371
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/Chart And Graph/Editor/ChartOrientedSizeInspector.cs
Normal file
58
Assets/Chart And Graph/Editor/ChartOrientedSizeInspector.cs
Normal file
@ -0,0 +1,58 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ChartOrientedSize))]
|
||||
class ChartOrientedSizeInspector : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight * 2;
|
||||
}
|
||||
|
||||
void DoField(SerializedProperty prop, string label, Rect position)
|
||||
{
|
||||
float size = GUI.skin.label.CalcSize(new GUIContent(label)).x;
|
||||
Rect labelRect = new Rect(position.x, position.y, size, position.height);
|
||||
Rect FieldRect = new Rect(labelRect.xMax, position.y, position.width - size, position.height);
|
||||
EditorGUI.LabelField(labelRect, label);
|
||||
float val = prop.floatValue;
|
||||
EditorGUI.LabelField(labelRect, label);
|
||||
float labelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 5;
|
||||
val = EditorGUI.FloatField(FieldRect, " ", val);
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
prop.floatValue = val;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
|
||||
position = EditorGUI.IndentedRect(position);
|
||||
|
||||
float halfWidth = position.width *0.5f;
|
||||
float y = position.y + EditorGUIUtility.singleLineHeight;
|
||||
float height = position.height - EditorGUIUtility.singleLineHeight;
|
||||
Rect breadthRect = new Rect(position.x, y, halfWidth, height);
|
||||
Rect depthRect = new Rect(breadthRect.xMax, y, halfWidth, height);
|
||||
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel=0;
|
||||
SerializedProperty breadth = property.FindPropertyRelative("Breadth");
|
||||
SerializedProperty depth = property.FindPropertyRelative("Depth");
|
||||
DoField(breadth, "Breadth:", breadthRect);
|
||||
DoField(depth, "Depth:", depthRect);
|
||||
EditorGUI.indentLevel = indent;
|
||||
// EditorGUILayout.EndVertical();
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f48c9091dc0c084595117abe8222c22
|
||||
timeCreated: 1473684701
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/Chart And Graph/Editor/EditorMenu.Full.cs
Normal file
60
Assets/Chart And Graph/Editor/EditorMenu.Full.cs
Normal file
@ -0,0 +1,60 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
|
||||
partial class EditorMenu
|
||||
{
|
||||
private static void InstanciateWorldSpace(string path)
|
||||
{
|
||||
GameObject obj = Resources.Load<GameObject>(path);
|
||||
// GameObject obj = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
GameObject newObj = (GameObject)GameObject.Instantiate(obj);
|
||||
newObj.name = newObj.name.Replace("(Clone)", "");
|
||||
Undo.RegisterCreatedObjectUndo(newObj, "Create Object");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Radar/3D")]
|
||||
public static void AddRadarChartWorldSpace()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/3DRadar");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Bar/3D/Simple")]
|
||||
public static void AddBarChartSimple3D()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/Bar3DSimple");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Bar/3D/Multiple Groups")]
|
||||
public static void AddBarChartMultiple3D()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/Bar3DMultiple");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Torus/3D")]
|
||||
public static void AddTorusChart3D()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/Torus3D");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Pie/3D")]
|
||||
public static void AddPieChart3D()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/Pie3D");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Graph/3D")]
|
||||
public static void AddGraph3D()
|
||||
{
|
||||
InstanciateWorldSpace("MenuPrefabs/3DGraph");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/EditorMenu.Full.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/EditorMenu.Full.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 128e6b85597fded4f886f1f5aea62b53
|
||||
timeCreated: 1560597478
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/Chart And Graph/Editor/EditorMenu.cs
Normal file
113
Assets/Chart And Graph/Editor/EditorMenu.cs
Normal file
@ -0,0 +1,113 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
partial class EditorMenu
|
||||
{
|
||||
private static void InstanciateCanvas(string path)
|
||||
{
|
||||
Canvas[] canvases = GameObject.FindObjectsOfType<Canvas>();
|
||||
if (canvases == null || canvases.Length == 0)
|
||||
{
|
||||
EditorUtility.DisplayDialog("No canvas in scene", "Please add a canvas to the scene and try again", "Ok");
|
||||
return;
|
||||
}
|
||||
Canvas canvas = null;
|
||||
foreach(Canvas c in canvases)
|
||||
{
|
||||
if(c.transform.parent == null)
|
||||
{
|
||||
canvas = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (canvas == null)
|
||||
{
|
||||
EditorUtility.DisplayDialog("No canvas in scene", "Please add a canvas to the scene and try again", "Ok");
|
||||
return;
|
||||
}
|
||||
GameObject obj = Resources.Load<GameObject>(path);
|
||||
GameObject newObj = (GameObject)GameObject.Instantiate(obj);
|
||||
newObj.transform.SetParent(canvas.transform,false);
|
||||
newObj.name = newObj.name.Replace("(Clone)","");
|
||||
Undo.RegisterCreatedObjectUndo(newObj, "Create Object");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Clear All")]
|
||||
public static void ClearChartGarbage()
|
||||
{
|
||||
ChartItem[] children = GameObject.FindObjectsOfType<ChartItem>();
|
||||
for (int i = 0; i < children.Length; ++i)
|
||||
{
|
||||
if (children[i] != null)
|
||||
{
|
||||
ChartCommon.SafeDestroy(children[i].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Radar/Canvas")]
|
||||
public static void AddRadarChartCanvas()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/2DRadar");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MenuItem("Tools/Charts/Bar/Canvas/Simple")]
|
||||
public static void AddBarChartSimpleCanvas()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/BarCanvasSimple");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Bar/Canvas/Multiple Groups")]
|
||||
public static void AddBarChartMultipleCanvas()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/BarCanvasMultiple");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem("Tools/Charts/Torus/Canvas")]
|
||||
public static void AddTorusChartCanvas()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/TorusCanvas");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Pie/Canvas")]
|
||||
public static void AddPieChartCanvas()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/PieCanvas");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MenuItem("Tools/Charts/Graph/Canvas/Simple")]
|
||||
public static void AddGraphSimple()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/GraphSimple");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Charts/Graph/Canvas/Multiple")]
|
||||
public static void AddGraphMultiple()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/GraphMultiple");
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Tools/Charts/Legend")]
|
||||
public static void AddChartLegend()
|
||||
{
|
||||
InstanciateCanvas("MenuPrefabs/Legend");
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/EditorMenu.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/EditorMenu.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57e0bbe359ea30c4d814819575d1a81d
|
||||
timeCreated: 1481803595
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
399
Assets/Chart And Graph/Editor/GraphChartInspector.cs
Normal file
399
Assets/Chart And Graph/Editor/GraphChartInspector.cs
Normal file
@ -0,0 +1,399 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(GraphChartBase), true)]
|
||||
class GraphChartInspector : Editor
|
||||
{
|
||||
string mEditedCategory = "";
|
||||
bool mCategories = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
Texture mSettings;
|
||||
GraphDataEditor mWindow;
|
||||
RenameWindow mRenameWindow = null;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAlphaNum(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items, int size, string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
{
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
}
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
private void DataEditor(SerializedProperty data, string type, string property, string caption)
|
||||
{
|
||||
|
||||
}
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
bool toogle = false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name" && entry.name != "data")
|
||||
{
|
||||
if (entry.name == "ViewOrder")
|
||||
continue;
|
||||
if (target is GraphChart) // canvas graph chart
|
||||
{
|
||||
if ((entry.name == "LinePrefab") || (entry.name == "FillPrefab") || (entry.name == "DotPrefab") || (entry.name == "Depth"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((entry.name == "LineHoverPrefab") || (entry.name == "PointHoverPrefab"))
|
||||
continue;
|
||||
}
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
}
|
||||
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect()).xMin);
|
||||
if (GUILayout.Button("Edit Values..."))
|
||||
{
|
||||
mEditedCategory = name;
|
||||
if (mWindow == null)
|
||||
mWindow = GraphDataEditor.ShowForObject(serializedObject, mEditedCategory);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
bool RenameCategory(string oldName, string newName)
|
||||
{
|
||||
GraphChartBase graph = (GraphChartBase)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
graph.DataSource.RenameCategory(oldName, newName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (graph.gameObject.activeInHierarchy)
|
||||
graph.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(graph);
|
||||
return true;
|
||||
}
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
}
|
||||
void DoContext(string type, string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
void UpdateWindow()
|
||||
{
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if (mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//serializedObject.Update();
|
||||
DrawDefaultInspector();
|
||||
|
||||
SerializedProperty autoScrollHorizontally = serializedObject.FindProperty("autoScrollHorizontally");
|
||||
SerializedProperty horizontalScrolling = serializedObject.FindProperty("horizontalScrolling");
|
||||
SerializedProperty autoScrollVertically = serializedObject.FindProperty("autoScrollVertically");
|
||||
SerializedProperty verticalScrolling = serializedObject.FindProperty("verticalScrolling");
|
||||
// SerializedProperty scrollable = serializedObject.FindProperty("scrollable");
|
||||
// EditorGUILayout.PropertyField(scrollable);
|
||||
// if (scrollable.boolValue == true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(autoScrollHorizontally);
|
||||
if (autoScrollHorizontally.boolValue == false)
|
||||
EditorGUILayout.PropertyField(horizontalScrolling);
|
||||
EditorGUILayout.PropertyField(autoScrollVertically);
|
||||
if (autoScrollVertically.boolValue == false)
|
||||
EditorGUILayout.PropertyField(verticalScrolling);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
SerializedProperty graphData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if (mBold == null)
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
|
||||
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
NamedItemEditor(graphData, "category", "mSerializedData", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
SerializedProperty horizontalOrigin = graphData.FindPropertyRelative("horizontalViewOrigin");
|
||||
SerializedProperty horizontalSize = graphData.FindPropertyRelative("horizontalViewSize");
|
||||
SerializedProperty automaticcHorizontaViewGap = graphData.FindPropertyRelative("automaticcHorizontaViewGap");
|
||||
|
||||
SerializedProperty verticalOrigin = graphData.FindPropertyRelative("verticalViewOrigin");
|
||||
SerializedProperty verticalSize = graphData.FindPropertyRelative("verticalViewSize");
|
||||
SerializedProperty automaticVerticalViewGap = graphData.FindPropertyRelative("automaticVerticalViewGap");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Horizontal View", EditorStyles.boldLabel);
|
||||
SerializedProperty automaticProp = graphData.FindPropertyRelative("automaticHorizontalView");
|
||||
EditorGUILayout.PropertyField(automaticProp, new GUIContent("Auto"));
|
||||
bool automatic = automaticProp.boolValue;
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
EditorGUILayout.PropertyField(horizontalOrigin);
|
||||
EditorGUILayout.PropertyField(horizontalSize);
|
||||
// if (horizontalSize.doubleValue < 0.0)
|
||||
// horizontalSize.doubleValue = 0.0001;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(automaticcHorizontaViewGap, new GUIContent("Horizontal Gap"));
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Vertical View", EditorStyles.boldLabel);
|
||||
automaticProp = graphData.FindPropertyRelative("automaticVerticallView");
|
||||
EditorGUILayout.PropertyField(automaticProp, new GUIContent("Auto"));
|
||||
automatic = automaticProp.boolValue;
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
EditorGUILayout.PropertyField(verticalOrigin);
|
||||
EditorGUILayout.PropertyField(verticalSize);
|
||||
// if (verticalSize.doubleValue < 0.0)
|
||||
// verticalSize.doubleValue = 0.0001;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(automaticVerticalViewGap, new GUIContent("Vertical Gap"));
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.SetEditedObject(serializedObject, mEditedCategory);
|
||||
mWindow.Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/GraphChartInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/GraphChartInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8671bd55b44fd0d46ad162bc055df077
|
||||
timeCreated: 1480533379
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
98
Assets/Chart And Graph/Editor/GraphDataEditor.cs
Normal file
98
Assets/Chart And Graph/Editor/GraphDataEditor.cs
Normal file
@ -0,0 +1,98 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
class GraphDataEditor : UnityEditor.EditorWindow
|
||||
{
|
||||
SerializedObject mThisObject;
|
||||
SerializedObject mEditedObject;
|
||||
string category;
|
||||
SerializedProperty mGraphData;
|
||||
SerializedProperty mCategories;
|
||||
SerializedProperty mCategory;
|
||||
Dictionary<string, SerializedProperty> mValues;
|
||||
SerializedObject mObject;
|
||||
|
||||
[SerializeField]
|
||||
Vector2[] Data;
|
||||
public static GraphDataEditor ShowForObject(SerializedObject obj,string category)
|
||||
{
|
||||
GraphDataEditor window = (GraphDataEditor)EditorWindow.GetWindow(typeof(GraphDataEditor));
|
||||
window.SetEditedObject(obj, category);
|
||||
return window;
|
||||
}
|
||||
|
||||
int FindCategoryIndex(string category)
|
||||
{
|
||||
for(int i=0; i<mCategories.arraySize; i++)
|
||||
{
|
||||
string name = mCategories.GetArrayElementAtIndex(i).FindPropertyRelative("Name").stringValue;
|
||||
if (name == category)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public void SetEditedObject(SerializedObject obj,string categoryName)
|
||||
{
|
||||
category = categoryName;
|
||||
mEditedObject = obj;
|
||||
|
||||
mGraphData = mEditedObject.FindProperty("Data");
|
||||
mCategories = mGraphData.FindPropertyRelative("mSerializedData");
|
||||
// LoadData();
|
||||
|
||||
int catIndex = FindCategoryIndex(categoryName);
|
||||
if (catIndex == -1)
|
||||
{
|
||||
mCategory = null;
|
||||
return;
|
||||
}
|
||||
mCategory = mCategories.GetArrayElementAtIndex(catIndex);
|
||||
|
||||
var arr = mCategory.FindPropertyRelative("InitialData");
|
||||
|
||||
mThisObject = new SerializedObject(this);
|
||||
SerializedProperty serialProp = mThisObject.FindProperty("Data");
|
||||
SetArray(arr, serialProp);
|
||||
}
|
||||
|
||||
string getKey(string column, string row)
|
||||
{
|
||||
return string.Format("{0}|{1}", column, row);
|
||||
}
|
||||
|
||||
void ShowCategoryArray()
|
||||
{
|
||||
|
||||
}
|
||||
void SetArray(SerializedProperty from,SerializedProperty to)
|
||||
{
|
||||
to.arraySize = from.arraySize;
|
||||
for (int i = 0; i < from.arraySize; i++)
|
||||
{
|
||||
Vector2 val = from.GetArrayElementAtIndex(i).vector2Value;
|
||||
to.GetArrayElementAtIndex(i).vector2Value = val;
|
||||
}
|
||||
}
|
||||
void OnGUI()
|
||||
{
|
||||
|
||||
SerializedProperty serialProp = mThisObject.FindProperty("Data");
|
||||
|
||||
GUILayout.Label("Edit Values - " + category, EditorStyles.boldLabel);
|
||||
|
||||
if (mCategory == null)
|
||||
return;
|
||||
EditorGUILayout.PropertyField(serialProp, true);
|
||||
|
||||
|
||||
var arr = mCategory.FindPropertyRelative("InitialData");
|
||||
if (mThisObject.ApplyModifiedProperties())
|
||||
SetArray(serialProp,arr);
|
||||
mEditedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/GraphDataEditor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/GraphDataEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03f0eb5ac4118424f8d68f32ef5ffa1b
|
||||
timeCreated: 1584550686
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Chart And Graph/Editor/GraphDataFillerEditor.cs
Normal file
36
Assets/Chart And Graph/Editor/GraphDataFillerEditor.cs
Normal file
@ -0,0 +1,36 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(GraphDataFiller), true)]
|
||||
class GraphDataFillerEditor : Editor
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* This is a work around and must not be deleteed
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
// var cats = serializedObject.FindProperty("Categories");
|
||||
// EditorGUILayout.PropertyField(cats);
|
||||
// CategoryDataEditor
|
||||
// Categories
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/GraphDataFillerEditor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/GraphDataFillerEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05791da4c4a2fc44281046536e32e237
|
||||
timeCreated: 1560715350
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Chart And Graph/Editor/GroupLabelsInspector.cs
Normal file
26
Assets/Chart And Graph/Editor/GroupLabelsInspector.cs
Normal file
@ -0,0 +1,26 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(GroupLabels))]
|
||||
class GroupLabelsInspector : ItemLabelsBaseEditor
|
||||
{
|
||||
protected override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "group labels";
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool isSupported(AnyChart chart)
|
||||
{
|
||||
return ((IInternalUse)chart).InternalSupportsGroupLabels;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/GroupLabelsInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/GroupLabelsInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a56a06b898a879418ba574600eaf84a
|
||||
timeCreated: 1480254476
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Chart And Graph/Editor/ItemLabelsBaseEditor.cs
Normal file
35
Assets/Chart And Graph/Editor/ItemLabelsBaseEditor.cs
Normal file
@ -0,0 +1,35 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
abstract class ItemLabelsBaseEditor : Editor
|
||||
{
|
||||
protected abstract string Name { get; }
|
||||
protected abstract bool isSupported(AnyChart chart);
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
|
||||
ItemLabelsBase labels = (ItemLabelsBase)target;
|
||||
|
||||
if (labels.gameObject == null)
|
||||
return;
|
||||
|
||||
AnyChart chart = labels.gameObject.GetComponent<AnyChart>();
|
||||
if (chart == null)
|
||||
return;
|
||||
if (isSupported(chart) == false)
|
||||
{
|
||||
EditorGUILayout.HelpBox(string.Format("Chart of type {0} does not support {1}", chart.GetType().Name,Name),MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/ItemLabelsBaseEditor.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/ItemLabelsBaseEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67d1379f880dde846adec8a6157669d1
|
||||
timeCreated: 1480254476
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Chart And Graph/Editor/ItemLabelsInspector.cs
Normal file
26
Assets/Chart And Graph/Editor/ItemLabelsInspector.cs
Normal file
@ -0,0 +1,26 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(ItemLabels))]
|
||||
class ItemLabelsLabelsInspector : ItemLabelsBaseEditor
|
||||
{
|
||||
protected override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "item labels";
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool isSupported(AnyChart chart)
|
||||
{
|
||||
return ((IInternalUse)chart).InternalSupportsItemLabels;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/ItemLabelsInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/ItemLabelsInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12cb0562684057a448410b90a0e565f8
|
||||
timeCreated: 1480254476
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Chart And Graph/Editor/MaterialTilingInspector.cs
Normal file
40
Assets/Chart And Graph/Editor/MaterialTilingInspector.cs
Normal file
@ -0,0 +1,40 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(MaterialTiling))]
|
||||
class MaterialTilingInspector : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
SerializedProperty auto = property.FindPropertyRelative("EnableTiling");
|
||||
SerializedProperty val = property.FindPropertyRelative("TileFactor");
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
bool res = !EditorGUI.ToggleLeft(position,"Stretch", !auto.boolValue);
|
||||
EditorGUI.indentLevel = indent;
|
||||
//EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel++;
|
||||
if (auto.boolValue == true && EditorGUI.showMixedValue == false)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Remember to enable texture repeat mode in order to make tiling work !",MessageType.Warning,true);
|
||||
EditorGUILayout.HelpBox("For the best results on canvas , set the tiling factor to the pixel size of the textre", MessageType.Info, true);
|
||||
val.floatValue = EditorGUILayout.FloatField("Tiling Factor",val.floatValue);
|
||||
if (val.floatValue <= 0f)
|
||||
val.floatValue = 0.01f;
|
||||
}
|
||||
auto.boolValue = res;
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c894d939d8cec94fa27b4e6b437e6bc
|
||||
timeCreated: 1479370450
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
326
Assets/Chart And Graph/Editor/PieChartInspector.cs
Normal file
326
Assets/Chart And Graph/Editor/PieChartInspector.cs
Normal file
@ -0,0 +1,326 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PieChart), true)]
|
||||
class PieChartInspetor : Editor
|
||||
{
|
||||
bool mCategories = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
ChartDataEditor mWindow;
|
||||
bool mUpdateWindow = false;
|
||||
Texture mSettings;
|
||||
|
||||
RenameWindow mRenameWindow = null;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAlphaNum(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items, int size, string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private SerializedProperty getArrayCategory(SerializedProperty arr, string name)
|
||||
{
|
||||
for (int i = 0; i < arr.arraySize; i++)
|
||||
{
|
||||
SerializedProperty prop = arr.GetArrayElementAtIndex(i);
|
||||
if (prop.FindPropertyRelative("ColumnName").stringValue == name)
|
||||
return prop.FindPropertyRelative("Amount");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
SerializedProperty dataValues = data.FindPropertyRelative("mData");
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
|
||||
bool toogle = false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded =EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
SerializedProperty valueProp = getArrayCategory(dataValues, name);
|
||||
GUILayout.FlexibleSpace();
|
||||
if(valueProp != null)
|
||||
EditorGUILayout.PropertyField(valueProp);
|
||||
if (GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name")
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
bool RenameCategory(string fromName, string toName)
|
||||
{
|
||||
PieChart pieChart = (PieChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
pieChart.DataSource.RenameCategory(fromName, toName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (pieChart.gameObject.activeInHierarchy)
|
||||
pieChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(pieChart);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
if (data.Key == "category")
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
}
|
||||
void DoContext(string type, string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
void UpdateWindow()
|
||||
{
|
||||
mUpdateWindow = true;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if(mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
SerializedProperty barData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if (mBold == null)
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (mUpdateWindow == true)
|
||||
{
|
||||
mUpdateWindow = false;
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.SetEditedObject(serializedObject);
|
||||
mWindow.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/PieChartInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/PieChartInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcc024b6935dfff44aece802ded95e9a
|
||||
timeCreated: 1480008753
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/Editor/Playmaker.meta
Normal file
9
Assets/Chart And Graph/Editor/Playmaker.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ef85873de9c3f742b12f175025aed9a
|
||||
folderAsset: yes
|
||||
timeCreated: 1539558023
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,71 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
#if PLAYMAKER
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using HutongGames.PlayMaker.Actions;
|
||||
using HutongGames.PlayMakerEditor;
|
||||
|
||||
[CustomActionEditor(typeof(AppendGraphPointAction))]
|
||||
public class CustomActionEditorTest : CustomActionEditor
|
||||
{
|
||||
enum DateOrNumeric
|
||||
{
|
||||
Numeric,
|
||||
Date
|
||||
}
|
||||
public override void OnEnable()
|
||||
{
|
||||
// Do any expensive initialization stuff here.
|
||||
// This is called when the editor is created.
|
||||
}
|
||||
|
||||
public override bool OnGUI()
|
||||
{
|
||||
var action = target as AppendGraphPointAction;
|
||||
|
||||
EditField("ChartObject");
|
||||
EditField("CategoryName");
|
||||
EditField("AnimationTime");
|
||||
EditField("DateTimeKind");
|
||||
EditField("PointSize");
|
||||
|
||||
EditorGUILayout.LabelField("X value:");
|
||||
DateOrNumeric type = DateOrNumeric.Numeric;
|
||||
if (action.XValueIsDate)
|
||||
type = DateOrNumeric.Date;
|
||||
type = (DateOrNumeric)EditorGUILayout.EnumPopup("type", type);
|
||||
action.XValueIsDate = type == DateOrNumeric.Date;
|
||||
if (action.XValueIsDate)
|
||||
{
|
||||
EditField("XDateYear");
|
||||
EditField("XDateMonth");
|
||||
EditField("XDateDay");
|
||||
EditField("XDateHour");
|
||||
EditField("XDateMinute");
|
||||
EditField("XDateSecond");
|
||||
}
|
||||
else
|
||||
EditField("XValueFloat");
|
||||
|
||||
EditorGUILayout.LabelField("Y value:");
|
||||
type = DateOrNumeric.Numeric;
|
||||
if (action.YValueIsDate)
|
||||
type = DateOrNumeric.Date;
|
||||
type = (DateOrNumeric)EditorGUILayout.EnumPopup("type", type);
|
||||
action.YValueIsDate = type == DateOrNumeric.Date;
|
||||
if (action.YValueIsDate)
|
||||
{
|
||||
EditField("YDateYear");
|
||||
EditField("YDateMonth");
|
||||
EditField("YDateDay");
|
||||
EditField("YDateHour");
|
||||
EditField("YDateMinute");
|
||||
EditField("YDateSecond");
|
||||
}
|
||||
else
|
||||
EditField("YValueFloat");
|
||||
|
||||
return GUI.changed;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99d21976d8cc674488ca0e4bffe806f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/Chart And Graph/Editor/PrefabOverrideChart.cs
Normal file
83
Assets/Chart And Graph/Editor/PrefabOverrideChart.cs
Normal file
@ -0,0 +1,83 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using ChartAndGraph;
|
||||
|
||||
public class PrefabOverrideChart : UnityEditor.AssetPostprocessor
|
||||
{
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
foreach (string path in importedAssets)
|
||||
{
|
||||
string lowPath = path.ToLower();
|
||||
if (lowPath.EndsWith(".prefab"))
|
||||
{
|
||||
if (ContainsPath(lowPath) == false)
|
||||
{
|
||||
// Debug.Log(lowPath);
|
||||
EditorApplication.delayCall += () => CleanPrefab(path);
|
||||
AddPath(lowPath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach (string path in deletedAssets)
|
||||
{
|
||||
RemovePath(path.ToLower());
|
||||
}
|
||||
}
|
||||
[MenuItem("EditorPrefs/Clear all Editor Preferences")]
|
||||
static void deleteAllExample()
|
||||
{
|
||||
|
||||
EditorPrefs.DeleteAll();
|
||||
}
|
||||
static bool ContainsPath(string path)
|
||||
{
|
||||
return EditorPrefs.GetBool("GraphAndChartPrefabOverride$" + path, false);
|
||||
}
|
||||
static void RemovePath(string path)
|
||||
{
|
||||
EditorPrefs.DeleteKey("GraphAndChartPrefabOverride$" + path);
|
||||
}
|
||||
static void AddPath(string path)
|
||||
{
|
||||
EditorPrefs.SetBool("GraphAndChartPrefabOverride$" + path, true);
|
||||
}
|
||||
static void CleanPrefab(string path)
|
||||
{
|
||||
GameObject obj = PrefabUtility.LoadPrefabContents(path);
|
||||
//AssetDatabase.DeleteAsset(path);
|
||||
bool savePrefab = false;
|
||||
foreach (var item in obj.GetComponentsInChildren<AnyChart>(true))
|
||||
{
|
||||
savePrefab = true;
|
||||
// if (item == null)
|
||||
// continue;
|
||||
// if (item.gameObject == null)
|
||||
// continue;
|
||||
// Debug.Log("destroy " + item.gameObject.name);
|
||||
while (item.gameObject.transform.childCount > 0)
|
||||
{
|
||||
var innerObj = item.gameObject.transform.GetChild(0).gameObject;
|
||||
if (innerObj != null)
|
||||
{
|
||||
// Debug.Log("destroy inner" + innerObj.name);
|
||||
|
||||
GameObject.DestroyImmediate(innerObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (savePrefab)
|
||||
PrefabUtility.SaveAsPrefabAsset(obj, path);
|
||||
PrefabUtility.UnloadPrefabContents(obj);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
12
Assets/Chart And Graph/Editor/PrefabOverrideChart.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/PrefabOverrideChart.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb3ccf7dc2806314e99c1bbc160aabec
|
||||
timeCreated: 1579105195
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
375
Assets/Chart And Graph/Editor/RadarChartInspector.cs
Normal file
375
Assets/Chart And Graph/Editor/RadarChartInspector.cs
Normal file
@ -0,0 +1,375 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
[CustomEditor(typeof(RadarChart), true)]
|
||||
class RadarChartInspector : UnityEditor.Editor
|
||||
{
|
||||
bool mCategories = false;
|
||||
bool mGroups = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
string mNewGroupName = "";
|
||||
string mGroupError = null;
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
ChartDataEditor mWindow;
|
||||
bool mUpdateWindow = false;
|
||||
Texture mSettings;
|
||||
GUIContent MaxRadarValue = new GUIContent("Max Value :", "All radar values are scale according to this value");
|
||||
RenameWindow mRenameWindow;
|
||||
|
||||
string[] NonCanvas = new string[]
|
||||
{
|
||||
"LinePrefab",
|
||||
"PointPrefab",
|
||||
"Seperation",
|
||||
"Curve",
|
||||
"FillSmoothing"
|
||||
};
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items, int size, string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
bool toogle = false;
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name")
|
||||
{
|
||||
if(target is CanvasRadarChart)
|
||||
{
|
||||
|
||||
if (NonCanvas.Contains(entry.name))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.name == "LineHover" || entry.name == "PointHover")
|
||||
continue;
|
||||
}
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
|
||||
}
|
||||
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (ChartEditorCommon.IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
bool RenameGroup(string fromName, string toName)
|
||||
{
|
||||
RadarChart radarChart = (RadarChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
radarChart.DataSource.RenameGroup(fromName, toName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (radarChart.gameObject.activeInHierarchy)
|
||||
radarChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(radarChart);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenameCategory(string fromName, string toName)
|
||||
{
|
||||
RadarChart radarChart = (RadarChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
radarChart.DataSource.RenameCategory(fromName, toName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (radarChart.gameObject.activeInHierarchy)
|
||||
radarChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(radarChart);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
if (data.Key == "category")
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
else if (data.Key == "group")
|
||||
window.ShowDialog(data.Value, data.Key, RenameGroup);
|
||||
}
|
||||
|
||||
void DoContext(string type, string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
void UpdateWindow()
|
||||
{
|
||||
mUpdateWindow = true;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
SerializedProperty radarData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if (mBold == null)
|
||||
{
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
NamedItemEditor(radarData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
NamedItemEditor(radarData, "group", "mGroups", "Groups", ref mGroupError, ref mGroups, ref mNewGroupName);
|
||||
|
||||
SerializedProperty maxProp = radarData.FindPropertyRelative("maxValue");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(MaxRadarValue, EditorStyles.boldLabel);
|
||||
SerializedProperty automaticProp = radarData.FindPropertyRelative("automaticMaxValue");
|
||||
bool automatic = automaticProp.boolValue;
|
||||
automatic = GUILayout.Toggle(automatic, "Auto");
|
||||
GUILayout.FlexibleSpace();
|
||||
automaticProp.boolValue = automatic;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
|
||||
EditorGUILayout.PropertyField(maxProp);
|
||||
if (0f > maxProp.doubleValue)
|
||||
maxProp.doubleValue = 0.001f;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Edit Values...") && mWindow == null)
|
||||
mWindow = ChartDataEditor.ShowForObject(serializedObject);
|
||||
//}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (mUpdateWindow == true)
|
||||
{
|
||||
mUpdateWindow = false;
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.SetEditedObject(serializedObject);
|
||||
mWindow.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/RadarChartInspector.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/RadarChartInspector.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec3a557017cfb7040b5a426cb7f71a47
|
||||
timeCreated: 1489858254
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Chart And Graph/Editor/RenameWindow.cs
Normal file
71
Assets/Chart And Graph/Editor/RenameWindow.cs
Normal file
@ -0,0 +1,71 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class RenameWindow :EditorWindow
|
||||
{
|
||||
string mStartName;
|
||||
string mValue = "";
|
||||
string mType;
|
||||
Func<string, string, bool> mRenameMethod;
|
||||
string mMessage = null;
|
||||
|
||||
public void ShowDialog(string currentName,string type,Func<string,string, bool> renameMethod)
|
||||
{
|
||||
mStartName = currentName;
|
||||
mValue = currentName;
|
||||
mType = type;
|
||||
mRenameMethod = renameMethod;
|
||||
float height = (float)(EditorGUIUtility.singleLineHeight * 6f);
|
||||
minSize = maxSize = new Vector2(300, height);
|
||||
Show();
|
||||
|
||||
}
|
||||
void OnGUI()
|
||||
{
|
||||
EditorGUILayout.LabelField(string.Format("Select a new {0} name",mType));
|
||||
mValue = EditorGUILayout.TextField(mValue);
|
||||
bool disabled = false;
|
||||
if (mValue.Trim().Length == 0)
|
||||
{
|
||||
mMessage = null;
|
||||
EditorGUILayout.LabelField("Name can't be empty");
|
||||
disabled = true;
|
||||
}
|
||||
else
|
||||
if (ChartEditorCommon.IsAlphaNum(mValue) == false)
|
||||
{
|
||||
mMessage = null;
|
||||
EditorGUILayout.LabelField("Name contains invalid charecters");
|
||||
disabled = true;
|
||||
}
|
||||
if (mMessage != null)
|
||||
EditorGUILayout.LabelField(mMessage);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUI.enabled = !disabled;
|
||||
if (GUILayout.Button("Rename"))
|
||||
{
|
||||
if (mStartName == mValue)
|
||||
Close();
|
||||
else
|
||||
{
|
||||
if (mRenameMethod(mStartName,mValue))
|
||||
Close();
|
||||
else
|
||||
mMessage = string.Format("A {0} by the name {1} already exists", mType, mValue);
|
||||
}
|
||||
}
|
||||
GUI.enabled = true;
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("Cancel"))
|
||||
Close();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Editor/RenameWindow.cs.meta
Normal file
12
Assets/Chart And Graph/Editor/RenameWindow.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66d4769f533803d49a88420cd97553f9
|
||||
timeCreated: 1481046854
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/InBeta.meta
Normal file
9
Assets/Chart And Graph/InBeta.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3203417d7436b60468e85cdd312a55cf
|
||||
folderAsset: yes
|
||||
timeCreated: 1559401944
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/InBeta/Editor.meta
Normal file
9
Assets/Chart And Graph/InBeta/Editor.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32578c1a672aa5c44bdd3d005e4adff1
|
||||
folderAsset: yes
|
||||
timeCreated: 1505898578
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
408
Assets/Chart And Graph/InBeta/Editor/CandleChartInspector.cs
Normal file
408
Assets/Chart And Graph/InBeta/Editor/CandleChartInspector.cs
Normal file
@ -0,0 +1,408 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[CustomEditor(typeof(CandleChart), true)]
|
||||
class CandleChartInspector : Editor
|
||||
{
|
||||
bool mCategories = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
ChartDataEditor mWindow;
|
||||
Texture mSettings;
|
||||
|
||||
RenameWindow mRenameWindow = null;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAlphaNum(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items, int size, string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
{
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
}
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void CandleSettings(SerializedProperty item)
|
||||
{
|
||||
SerializedProperty entry = item.Copy();
|
||||
EditorGUILayout.LabelField(entry.name);
|
||||
EditorGUI.indentLevel++;
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (target is CandleChart) // canvas graph chart
|
||||
{
|
||||
if ((entry.name == "CandlePrefab"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.name == "CandleHoverPrefab")
|
||||
continue;
|
||||
}
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
bool toogle = false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name" && entry.name != "Data")
|
||||
{
|
||||
if (target is CandleChart) // canvas graph chart
|
||||
{
|
||||
if ((entry.name == "LinePrefab") || (entry.name == "FillPrefab") || (entry.name == "DotPrefab") || (entry.name == "Depth"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((entry.name == "LineHoverPrefab") || (entry.name == "PointHoverPrefab"))
|
||||
continue;
|
||||
}
|
||||
if (entry.name == "UpCandle" || entry.name == "DownCandle")
|
||||
CandleSettings(entry);
|
||||
else
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
}
|
||||
}
|
||||
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
bool RenameCategory(string oldName, string newName)
|
||||
{
|
||||
CandleChart graph = (CandleChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
graph.DataSource.RenameCategory(oldName, newName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (graph.gameObject.activeInHierarchy)
|
||||
graph.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(graph);
|
||||
return true;
|
||||
}
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
}
|
||||
void DoContext(string type, string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
void UpdateWindow()
|
||||
{
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if (mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
SerializedProperty autoScrollHorizontally = serializedObject.FindProperty("autoScrollHorizontally");
|
||||
SerializedProperty horizontalScrolling = serializedObject.FindProperty("horizontalScrolling");
|
||||
SerializedProperty autoScrollVertically = serializedObject.FindProperty("autoScrollVertically");
|
||||
SerializedProperty verticalScrolling = serializedObject.FindProperty("verticalScrolling");
|
||||
// SerializedProperty scrollable = serializedObject.FindProperty("scrollable");
|
||||
// EditorGUILayout.PropertyField(scrollable);
|
||||
// if (scrollable.boolValue == true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(autoScrollHorizontally);
|
||||
if (autoScrollHorizontally.boolValue == false)
|
||||
EditorGUILayout.PropertyField(horizontalScrolling);
|
||||
EditorGUILayout.PropertyField(autoScrollVertically);
|
||||
if (autoScrollVertically.boolValue == false)
|
||||
EditorGUILayout.PropertyField(verticalScrolling);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
SerializedProperty graphData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if (mBold == null)
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
NamedItemEditor(graphData, "category", "mSerializedData", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
SerializedProperty horizontalOrigin = graphData.FindPropertyRelative("horizontalViewOrigin");
|
||||
SerializedProperty horizontalSize = graphData.FindPropertyRelative("horizontalViewSize");
|
||||
SerializedProperty automaticcHorizontaViewGap = graphData.FindPropertyRelative("automaticcHorizontaViewGap");
|
||||
|
||||
SerializedProperty verticalOrigin = graphData.FindPropertyRelative("verticalViewOrigin");
|
||||
SerializedProperty verticalSize = graphData.FindPropertyRelative("verticalViewSize");
|
||||
SerializedProperty automaticVerticalViewGap = graphData.FindPropertyRelative("automaticVerticalViewGap");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Horizontal View", EditorStyles.boldLabel);
|
||||
SerializedProperty automaticProp = graphData.FindPropertyRelative("automaticHorizontalView");
|
||||
bool automatic = automaticProp.boolValue;
|
||||
automatic = GUILayout.Toggle(automatic, "Auto");
|
||||
GUILayout.FlexibleSpace();
|
||||
automaticProp.boolValue = automatic;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
EditorGUILayout.PropertyField(horizontalOrigin);
|
||||
EditorGUILayout.PropertyField(horizontalSize);
|
||||
// if (horizontalSize.doubleValue < 0.0)
|
||||
// horizontalSize.doubleValue = 0.0001;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(automaticcHorizontaViewGap, new GUIContent("Horizontal Gap"));
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Vertical View", EditorStyles.boldLabel);
|
||||
automaticProp = graphData.FindPropertyRelative("automaticVerticallView");
|
||||
automatic = automaticProp.boolValue;
|
||||
automatic = GUILayout.Toggle(automatic, "Auto");
|
||||
GUILayout.FlexibleSpace();
|
||||
automaticProp.boolValue = automatic;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (automatic == false)
|
||||
{
|
||||
EditorGUILayout.PropertyField(verticalOrigin);
|
||||
EditorGUILayout.PropertyField(verticalSize);
|
||||
// if (verticalSize.doubleValue < 0.0)
|
||||
// verticalSize.doubleValue = 0.0001;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(automaticVerticalViewGap, new GUIContent("Vertical Gap"));
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
serializedObject.Update();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e95afd72773c44d4ab4ccd60a38ac39e
|
||||
timeCreated: 1504187754
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
328
Assets/Chart And Graph/InBeta/Editor/PyramidChartInspector.cs
Normal file
328
Assets/Chart And Graph/InBeta/Editor/PyramidChartInspector.cs
Normal file
@ -0,0 +1,328 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PyramidChart), true)]
|
||||
class PyramidChartInspetor : Editor
|
||||
{
|
||||
bool mCategories = false;
|
||||
string mCategoryError = null;
|
||||
string mNewCategoryName = "";
|
||||
GUIStyle mRedStyle;
|
||||
GUIStyle mBold;
|
||||
HashSet<string> mAllNames = new HashSet<string>();
|
||||
GUIStyle mSplitter;
|
||||
List<int> mToRemove = new List<int>();
|
||||
List<int> mToUp = new List<int>();
|
||||
Dictionary<string, string> mOperations = new Dictionary<string, string>();
|
||||
ChartDataEditor mWindow;
|
||||
bool mUpdateWindow = false;
|
||||
Texture mSettings;
|
||||
|
||||
RenameWindow mRenameWindow = null;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
mRedStyle = new GUIStyle();
|
||||
mRedStyle.normal.textColor = Color.red;
|
||||
|
||||
mSplitter = new GUIStyle();
|
||||
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
|
||||
mSplitter.stretchWidth = true;
|
||||
mSplitter.margin = new RectOffset(0, 0, 7, 7);
|
||||
}
|
||||
|
||||
public void Splitter()
|
||||
{
|
||||
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
Color restoreColor = GUI.color;
|
||||
GUI.color = new Color(0.5f, 0.5f, 0.5f);
|
||||
mSplitter.Draw(position, false, false, false, false);
|
||||
GUI.color = restoreColor;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAlphaNum(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DoOperations(SerializedProperty items, int size, string type)
|
||||
{
|
||||
mToRemove.Clear();
|
||||
mToUp.Clear();
|
||||
bool up = false;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
|
||||
string arg = type + "|" + name;
|
||||
string res = null;
|
||||
if (up == true)
|
||||
{
|
||||
mToUp.Add(i);
|
||||
up = false;
|
||||
}
|
||||
if (mOperations.TryGetValue(arg, out res))
|
||||
{
|
||||
if (res == "remove")
|
||||
mToRemove.Add(i);
|
||||
if (res == "up" && i > 0)
|
||||
mToUp.Add(i);
|
||||
if (res == "down")
|
||||
up = true;
|
||||
mOperations.Remove(arg);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mToRemove.Count; i++)
|
||||
items.DeleteArrayElementAtIndex(mToRemove[i]);
|
||||
for (int i = 0; i < mToUp.Count; i++)
|
||||
{
|
||||
int cur = mToUp[i];
|
||||
items.MoveArrayElement(cur, cur - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private SerializedProperty getArrayCategory(SerializedProperty arr, string name)
|
||||
{
|
||||
for (int i = 0; i < arr.arraySize; i++)
|
||||
{
|
||||
SerializedProperty prop = arr.GetArrayElementAtIndex(i);
|
||||
if (prop.FindPropertyRelative("ColumnName").stringValue == name)
|
||||
return prop.FindPropertyRelative("Amount");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
|
||||
{
|
||||
SerializedProperty items = data.FindPropertyRelative(property);
|
||||
SerializedProperty dataValues = data.FindPropertyRelative("mData");
|
||||
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
|
||||
//bool up, down;
|
||||
mAllNames.Clear();
|
||||
int size = items.arraySize;
|
||||
if (Event.current.type == EventType.Layout)
|
||||
DoOperations(items, size, type);
|
||||
size = items.arraySize;
|
||||
if (items.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SerializedProperty entry = items.GetArrayElementAtIndex(i);
|
||||
if (entry == null)
|
||||
continue;
|
||||
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
|
||||
string name = null;
|
||||
if (nameProp == null)
|
||||
name = entry.stringValue;
|
||||
else
|
||||
name = nameProp.stringValue;
|
||||
mAllNames.Add(name);
|
||||
|
||||
bool toogle = false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (nameProp != null)
|
||||
toogle = entry.isExpanded =EditorGUILayout.Foldout(entry.isExpanded, name);
|
||||
else
|
||||
{
|
||||
toogle = false;
|
||||
EditorGUILayout.LabelField(name);
|
||||
}
|
||||
SerializedProperty valueProp = getArrayCategory(dataValues, name);
|
||||
GUILayout.FlexibleSpace();
|
||||
// if(valueProp != null)
|
||||
// EditorGUILayout.PropertyField(valueProp);
|
||||
if (GUILayout.Button("..."))
|
||||
DoContext(type, name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (toogle)
|
||||
{
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
if (nameProp != null)
|
||||
{
|
||||
SerializedProperty end = entry.GetEndProperty(true);
|
||||
entry.Next(true);
|
||||
if (SerializedProperty.EqualContents(entry, end) == false)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (entry.name != "Name")
|
||||
EditorGUILayout.PropertyField(entry, true);
|
||||
if (entry.name == "HeightRatio" && valueProp != null)
|
||||
valueProp.floatValue = entry.floatValue;
|
||||
|
||||
}
|
||||
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
EditorGUILayout.LabelField(errorMessage, mRedStyle);
|
||||
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
|
||||
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
newName = EditorGUILayout.TextField(newName);
|
||||
//GUILayout.Space(indentAdd.xMin);
|
||||
if (GUILayout.Button("Add"))
|
||||
{
|
||||
bool error = false;
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
errorMessage = "Name can't be empty";
|
||||
error = true;
|
||||
}
|
||||
else if (IsAlphaNum(newName) == false)
|
||||
{
|
||||
errorMessage = "Name conatins invalid characters";
|
||||
error = true;
|
||||
}
|
||||
else if (mAllNames.Contains(newName))
|
||||
{
|
||||
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
|
||||
error = true;
|
||||
}
|
||||
if (error == false)
|
||||
{
|
||||
errorMessage = null;
|
||||
items.InsertArrayElementAtIndex(size);
|
||||
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
|
||||
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
|
||||
if (newItemName == null)
|
||||
newItem.stringValue = newName;
|
||||
else
|
||||
newItemName.stringValue = newName;
|
||||
newName = "";
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = null;
|
||||
}
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
void callback(object val)
|
||||
{
|
||||
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
|
||||
mOperations[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
bool RenameCategory(string fromName, string toName)
|
||||
{
|
||||
PyramidChart pyramidChart = (PyramidChart)serializedObject.targetObject;
|
||||
try
|
||||
{
|
||||
pyramidChart.DataSource.RenameCategory(fromName, toName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
serializedObject.Update();
|
||||
if (pyramidChart.gameObject.activeInHierarchy)
|
||||
pyramidChart.GenerateChart();
|
||||
else
|
||||
EditorUtility.SetDirty(pyramidChart);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenameCalled(object val)
|
||||
{
|
||||
var data = (KeyValuePair<string, string>)val;
|
||||
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
|
||||
mRenameWindow = window;
|
||||
if (data.Key == "category")
|
||||
window.ShowDialog(data.Value, data.Key, RenameCategory);
|
||||
}
|
||||
void DoContext(string type, string name)
|
||||
{
|
||||
string arg = type + "|" + name;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
|
||||
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
|
||||
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
|
||||
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
void UpdateWindow()
|
||||
{
|
||||
mUpdateWindow = true;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if(mRenameWindow != null)
|
||||
{
|
||||
mRenameWindow.Close();
|
||||
mRenameWindow = null;
|
||||
}
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.Close();
|
||||
mWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
SerializedProperty barData = serializedObject.FindProperty("Data");
|
||||
EditorGUILayout.BeginVertical();
|
||||
Splitter();
|
||||
if (mBold == null)
|
||||
mBold = new GUIStyle(EditorStyles.foldout);
|
||||
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
serializedObject.Update();
|
||||
if (mUpdateWindow == true)
|
||||
{
|
||||
mUpdateWindow = false;
|
||||
if (mWindow != null)
|
||||
{
|
||||
mWindow.SetEditedObject(serializedObject);
|
||||
mWindow.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79e4c0b8020ab4a42a6d990ae8dc88c3
|
||||
timeCreated: 1579446121
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/InBeta/PyramidChart.meta
Normal file
9
Assets/Chart And Graph/InBeta/PyramidChart.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30e0bcb506988d7498bdbaa0867abcf1
|
||||
folderAsset: yes
|
||||
timeCreated: 1578946274
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,14 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
interface IInternalPyramidData
|
||||
{
|
||||
ChartSparseDataSource InternalDataSource { get; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 369d1c0e7b4b9fc498252bc1ed05b04c
|
||||
timeCreated: 1579445919
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,21 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
|
||||
public interface IPyramidGenerator
|
||||
{
|
||||
GameObject ContainerObject { get; }
|
||||
void SetParams(float baseX1, float baseX2, float baseSize, float slopLeft, float slopeRight, float height,float inset,float startV,float endV);
|
||||
Vector3 GetTextPosition(PyramidChart.JustificationType justification,bool isBase);
|
||||
void GetUpperBase(out float baseX1, out float baseX2);
|
||||
void Generate();
|
||||
void ApplyInfo(string title, string text, Sprite image, float scale);
|
||||
void SetAlpha(float alpha);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a1189b51e201054181a7018cd594f6c
|
||||
timeCreated: 1579168376
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,42 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
|
||||
public class PyramidAnimation : MonoBehaviour {
|
||||
|
||||
|
||||
public AnimationCurve Curve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
public bool AnimateOnStart = true;
|
||||
public float AnimationTime = 3f;
|
||||
float animationStart = -1f;
|
||||
PyramidChart chart;
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
chart = GetComponent<PyramidChart>();
|
||||
if (AnimateOnStart)
|
||||
Animate();
|
||||
}
|
||||
public void Animate()
|
||||
{
|
||||
animationStart = Time.time;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (chart == null)
|
||||
return;
|
||||
if (animationStart < 0f)
|
||||
return;
|
||||
float elasped = (Time.time - animationStart) / AnimationTime;
|
||||
elasped = Mathf.Clamp(elasped, 0f, 1f);
|
||||
float blend = Curve.Evaluate(elasped);
|
||||
for(int i=0; i<chart.DataSource.TotalCategories; i++)
|
||||
{
|
||||
string name = chart.DataSource.GetCategoryName(i);
|
||||
chart.DataSource.SetCategoryAlpha(name, blend);
|
||||
chart.DataSource.SetCategoryOrientation(name, blend, 0f, 0f);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f8e5b63d2caba14993994657aeb9d90
|
||||
timeCreated: 1579516412
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,202 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[Serializable]
|
||||
public class PyramidCanvasGenerator : MaskableGraphic, IPyramidGenerator
|
||||
{
|
||||
|
||||
public RectTransform Container;
|
||||
public Text Title;
|
||||
public Text Info;
|
||||
public Image Sprite;
|
||||
|
||||
bool mPopulated = false;
|
||||
float mBaseX1;
|
||||
float mBaseX2;
|
||||
float mBaseSize;
|
||||
float mSlopLeft;
|
||||
float mSlopeRight;
|
||||
float mHeight;
|
||||
float mInset;
|
||||
float mStartV;
|
||||
float mEndV;
|
||||
CanvasGroup mGroup;
|
||||
UIVertex[] vertices = new UIVertex[4];
|
||||
Vector2[] normals = new Vector2[4];
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
mGroup = ChartCommon.EnsureComponent<CanvasGroup>(gameObject);
|
||||
|
||||
}
|
||||
|
||||
public GameObject ContainerObject {
|
||||
get {
|
||||
if (Container == null)
|
||||
return null;
|
||||
return Container.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAlpha(float alpha)
|
||||
{
|
||||
if(mGroup != null)
|
||||
mGroup.alpha = alpha;
|
||||
}
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get { return material.mainTexture; }
|
||||
}
|
||||
public void ApplyInfo(string title, string text, Sprite image,float scale)
|
||||
{
|
||||
if(Container != null)
|
||||
{
|
||||
Vector3 centtroid = vertices[0].position + vertices[1].position + vertices[2].position + vertices[3].position;
|
||||
centtroid *= 0.25f;
|
||||
float upperSize = Math.Abs(vertices[2].position.x - vertices[3].position.x);
|
||||
float downSize = Math.Abs(vertices[0].position.x - vertices[1].position.x);
|
||||
float total = upperSize + downSize;
|
||||
float weight = (downSize - upperSize) / total;
|
||||
weight = -weight * 0.5f + 0.5f;
|
||||
weight = Mathf.Lerp(0.3f, 0.7f, weight);
|
||||
centtroid.y = Mathf.Lerp(vertices[0].position.y, vertices[2].position.y, weight);
|
||||
centtroid = new Vector3(centtroid.x / rectTransform.rect.width, centtroid.y / rectTransform.rect.height);
|
||||
centtroid += new Vector3(0.5f, 0.5f, 0f);
|
||||
Container.anchorMax = centtroid;
|
||||
Container.anchorMin = centtroid;
|
||||
Container.anchoredPosition = new Vector2();
|
||||
Container.sizeDelta = new Vector2(Mathf.Abs(mBaseX1 - mBaseX2) - mInset*4, mHeight - mInset*2);
|
||||
Container.localScale = new Vector3(scale, scale, scale);
|
||||
}
|
||||
if (Title != null)
|
||||
Title.text = title;
|
||||
if (Info != null)
|
||||
Info.text = text;
|
||||
if (Sprite != null)
|
||||
Sprite.sprite = image;
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
SetAllDirty();
|
||||
Rebuild(CanvasUpdate.PreRender);
|
||||
}
|
||||
|
||||
public Vector3 GetTextPosition(PyramidChart.JustificationType justification, bool isBase)
|
||||
{
|
||||
Vector3 res = new Vector3();
|
||||
switch(justification)
|
||||
{
|
||||
case PyramidChart.JustificationType.LeftAligned:
|
||||
if (isBase)
|
||||
res = vertices[0].position;
|
||||
else
|
||||
res = (vertices[0].position + vertices[2].position) * 0.5f;
|
||||
break;
|
||||
case PyramidChart.JustificationType.RightAligned:
|
||||
if (isBase)
|
||||
res = vertices[1].position;
|
||||
else
|
||||
res = (vertices[1].position + vertices[3].position) * 0.5f;
|
||||
break;
|
||||
case PyramidChart.JustificationType.CenterAligned:
|
||||
if (isBase)
|
||||
res = (vertices[0].position + vertices[1].position) * 0.5f;
|
||||
else
|
||||
res = (vertices[0].position + vertices[1].position +vertices[2].position + vertices[3].position) * 0.25f;
|
||||
break;
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void GetUpperBase(out float baseX1, out float baseX2)
|
||||
{
|
||||
baseX1 = vertices[2].position.x + mBaseSize * 0.5f;
|
||||
baseX2 = vertices[3].position.x + mBaseSize * 0.5f;
|
||||
}
|
||||
|
||||
public void SetParams(float baseX1, float baseX2, float baseSize, float slopLeft, float slopeRight, float height, float inset, float startV, float endV)
|
||||
{
|
||||
mPopulated = true;
|
||||
mBaseX1 = baseX1;
|
||||
mBaseX2 = baseX2;
|
||||
mBaseSize = baseSize;
|
||||
mSlopLeft = slopLeft;
|
||||
mSlopeRight = slopeRight;
|
||||
mHeight = height;
|
||||
mInset = inset;
|
||||
mStartV = startV;
|
||||
mEndV = endV;
|
||||
PyramidMesh.Generate2dMesh(vertices, normals, mBaseX1, mBaseX2, mBaseSize, mSlopLeft, mSlopeRight, mHeight,mStartV,mEndV);
|
||||
}
|
||||
|
||||
#pragma warning disable 0672
|
||||
|
||||
protected override void OnFillVBO(List<UIVertex> vbo)
|
||||
{
|
||||
vbo.Clear();
|
||||
if (mPopulated == false)
|
||||
return;
|
||||
CanvasChartMesh mesh = new CanvasChartMesh(vbo);
|
||||
FillChartMesh(mesh);
|
||||
}
|
||||
|
||||
#pragma warning restore 0672
|
||||
|
||||
#if (!UNITY_5_2_0) && (!UNITY_5_2_1)
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
if (mPopulated == false)
|
||||
return;
|
||||
CanvasChartMesh mesh = new CanvasChartMesh(vh);
|
||||
FillChartMesh(mesh);
|
||||
}
|
||||
#endif
|
||||
#pragma warning disable 0672
|
||||
#if !UNITY_2017_1_OR_NEWER
|
||||
protected override void OnPopulateMesh(Mesh m)
|
||||
{
|
||||
m.Clear();
|
||||
if (mPopulated == false)
|
||||
return;
|
||||
WorldSpaceChartMesh chartmesh = new WorldSpaceChartMesh(true);
|
||||
FillChartMesh(chartmesh);
|
||||
chartmesh.ApplyToMesh(m);
|
||||
}
|
||||
#endif
|
||||
#pragma warning restore 0672
|
||||
|
||||
void FillChartMesh(IChartMesh mesh)
|
||||
{
|
||||
UIVertex v1 = vertices[0];
|
||||
UIVertex v2 = vertices[1];
|
||||
UIVertex v3 = vertices[2];
|
||||
UIVertex v4 = vertices[3];
|
||||
|
||||
v1.position += (Vector3)(normals[0] * mInset);
|
||||
v2.position += (Vector3)(normals[1] * mInset);
|
||||
v3.position += (Vector3)(normals[2] * mInset);
|
||||
v4.position += (Vector3)(normals[3] * mInset);
|
||||
|
||||
Vector2 inter;
|
||||
if(ChartCommon.SegmentIntersection(v1.position,v3.position,v2.position,v4.position,out inter))
|
||||
{
|
||||
v3.position = inter;
|
||||
v4.position = inter;
|
||||
}
|
||||
|
||||
mesh.AddQuad(v1, v2, v3, v4);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b2cb334c0c0a6448971702fcddbfecd
|
||||
timeCreated: 1579182822
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
639
Assets/Chart And Graph/InBeta/PyramidChart/PyramidChart.cs
Normal file
639
Assets/Chart And Graph/InBeta/PyramidChart/PyramidChart.cs
Normal file
@ -0,0 +1,639 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Pie chart class
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[Serializable]
|
||||
public class PyramidChart : AnyChart
|
||||
{
|
||||
public class PyramidEventArgs
|
||||
{
|
||||
public PyramidEventArgs(string category, string title,string text)
|
||||
{
|
||||
Title = title;
|
||||
Text = text;
|
||||
Category = category;
|
||||
}
|
||||
public string Category { get; private set; }
|
||||
public string Title { get; private set; }
|
||||
public string Text { get; private set; }
|
||||
}
|
||||
|
||||
public enum JustificationType
|
||||
{
|
||||
LeftAligned,
|
||||
RightAligned,
|
||||
CenterAligned
|
||||
}
|
||||
|
||||
public enum SlopeType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right,
|
||||
Custom
|
||||
}
|
||||
|
||||
bool mQuick = false;
|
||||
[Serializable]
|
||||
public class PyramidEvent : UnityEvent<PyramidEventArgs>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// occures when a pie item is clicked
|
||||
/// </summary>
|
||||
public PyramidEvent ItemClicked = new PyramidEvent();
|
||||
|
||||
/// <summary>
|
||||
/// occures when a pie item is hovered
|
||||
/// </summary>
|
||||
public PyramidEvent ItemHovered = new PyramidEvent();
|
||||
|
||||
/// <summary>
|
||||
/// occurs when no pie is hovered any longer
|
||||
/// </summary>
|
||||
public UnityEvent NonHovered = new UnityEvent();
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The material of the back of the pyramid")]
|
||||
public Material backMaterial;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The inset of each pyramid component
|
||||
/// </summary>
|
||||
public Material BackMaterial
|
||||
{
|
||||
get { return backMaterial; }
|
||||
set
|
||||
{
|
||||
backMaterial = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The inset of each pyramid component")]
|
||||
public float inset;
|
||||
|
||||
/// <summary>
|
||||
/// The inset of each pyramid component
|
||||
/// </summary>
|
||||
public float Inset
|
||||
{
|
||||
get { return inset; }
|
||||
set
|
||||
{
|
||||
inset = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("the text justification of the pyramid chart")]
|
||||
private JustificationType justification;
|
||||
|
||||
/// <summary>
|
||||
/// the text justification of the pyramid chart
|
||||
/// </summary>
|
||||
public JustificationType Justification
|
||||
{
|
||||
get { return justification; }
|
||||
set
|
||||
{
|
||||
justification = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("the slope type of the pyramid")]
|
||||
public SlopeType slope;
|
||||
|
||||
/// <summary>
|
||||
/// prefab for the pie item. must contain a PieCanvasGenerator component
|
||||
/// </summary>
|
||||
public SlopeType Slope
|
||||
{
|
||||
get { return slope; }
|
||||
set
|
||||
{
|
||||
slope = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("prefab for the pyramid item. must contain a PyramidCanvasGenerator component")]
|
||||
private PyramidCanvasGenerator prefab;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// prefab for the pie item. must contain a PieCanvasGenerator component
|
||||
/// </summary>
|
||||
public PyramidCanvasGenerator Prefab
|
||||
{
|
||||
get { return prefab; }
|
||||
set
|
||||
{
|
||||
prefab = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
private PyramidData Data = new PyramidData();
|
||||
|
||||
|
||||
float totalWidth, totalHeight;
|
||||
protected override IChartData DataLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
|
||||
public PyramidData DataSource
|
||||
{
|
||||
get { return Data; }
|
||||
}
|
||||
|
||||
public override bool SupportRealtimeGeneration
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override LegenedData LegendInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
LegenedData legend = new LegenedData();
|
||||
if (Data == null)
|
||||
return legend;
|
||||
foreach (var column in ((IInternalPyramidData)Data).InternalDataSource.Columns)
|
||||
{
|
||||
var item = new LegenedData.LegenedItem();
|
||||
item.Name = column.Name;
|
||||
if (column.Material != null)
|
||||
item.Material = column.Material.Normal;
|
||||
else
|
||||
item.Material = null;
|
||||
legend.AddLegenedItem(item);
|
||||
}
|
||||
return legend;
|
||||
}
|
||||
}
|
||||
|
||||
public PyramidChart()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class PyramidObject
|
||||
{
|
||||
public string category;
|
||||
public GameObject pyramidObject;
|
||||
public GameObject backObject;
|
||||
public IPyramidGenerator Generator;
|
||||
public IPyramidGenerator BackGenerator;
|
||||
public string Title, Text;
|
||||
public BillboardText ItemLabel;
|
||||
}
|
||||
Dictionary<string, PyramidObject> mPyramids = new Dictionary<string, PyramidObject>();
|
||||
void HookEvents()
|
||||
{
|
||||
Data.ProperyUpdated -= Data_ProperyUpdated;
|
||||
Data.ProperyUpdated += Data_ProperyUpdated;
|
||||
Data.RealtimeProperyUpdated -= Data_RealtimeProperyUpdated;
|
||||
Data.RealtimeProperyUpdated += Data_RealtimeProperyUpdated;
|
||||
|
||||
((IInternalPyramidData)Data).InternalDataSource.DataStructureChanged -= MDataSource_DataStructureChanged;
|
||||
((IInternalPyramidData)Data).InternalDataSource.DataStructureChanged += MDataSource_DataStructureChanged;
|
||||
((IInternalPyramidData)Data).InternalDataSource.DataValueChanged -= MDataSource_DataValueChanged;
|
||||
((IInternalPyramidData)Data).InternalDataSource.DataValueChanged += MDataSource_DataValueChanged;
|
||||
}
|
||||
|
||||
private void Data_RealtimeProperyUpdated()
|
||||
{
|
||||
QuickInvalidate();
|
||||
}
|
||||
|
||||
private void Data_ProperyUpdated()
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected void QuickInvalidate()
|
||||
{
|
||||
if (Invalidating)
|
||||
return;
|
||||
Invalidate();
|
||||
mQuick = true;
|
||||
}
|
||||
|
||||
public override void Invalidate()
|
||||
{
|
||||
base.Invalidate();
|
||||
mQuick = false;
|
||||
}
|
||||
|
||||
private void MDataSource_DataValueChanged(object sender, DataSource.ChartDataSourceBase.DataValueChangedEventArgs e)
|
||||
{
|
||||
QuickInvalidate();
|
||||
}
|
||||
|
||||
private void MDataSource_DataStructureChanged(object sender, EventArgs e)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
if (ChartCommon.IsInEditMode == false)
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void ClearChart()
|
||||
{
|
||||
base.ClearChart();
|
||||
mPyramids.Clear();
|
||||
}
|
||||
|
||||
Vector3 AlignTextPosition(AlignedItemLabels labels, PyramidObject obj, IPyramidGenerator generator,float height)
|
||||
{
|
||||
Vector3 position = new Vector3(labels.Location.Breadth, labels.Seperation, labels.Location.Depth);
|
||||
position.y += height;
|
||||
position = generator.GetTextPosition(justification, labels.Alignment == ChartLabelAlignment.Base);
|
||||
return position;
|
||||
}
|
||||
|
||||
protected IPyramidGenerator PreparePyramidObject(out GameObject pyramidObject)
|
||||
{
|
||||
if (Prefab == null)
|
||||
pyramidObject = new GameObject();
|
||||
else
|
||||
pyramidObject = GameObject.Instantiate(Prefab.gameObject);
|
||||
ChartCommon.EnsureComponent<RectTransform>(pyramidObject);
|
||||
ChartCommon.EnsureComponent<CanvasRenderer>(pyramidObject);
|
||||
return ChartCommon.EnsureComponent<PyramidCanvasGenerator>(pyramidObject);
|
||||
}
|
||||
|
||||
private void GeneratePyramid(bool update)
|
||||
{
|
||||
if (update == false)
|
||||
ClearChart();
|
||||
else
|
||||
EnsureTextController();
|
||||
if (((IInternalPyramidData)Data).InternalDataSource == null)
|
||||
return;
|
||||
|
||||
double[,] data = ((IInternalPyramidData)Data).InternalDataSource.getRawData();
|
||||
int rowCount = data.GetLength(0);
|
||||
int columnCount = data.GetLength(1);
|
||||
|
||||
if (rowCount != 1) // row count for pie must be 1
|
||||
return;
|
||||
|
||||
double total = 0.0;
|
||||
|
||||
for (int i = 0; i < columnCount; ++i)
|
||||
{
|
||||
double val = Math.Max(data[0, i], 0);
|
||||
total += val;
|
||||
}
|
||||
|
||||
var rectTrans = GetComponent<RectTransform>();
|
||||
totalHeight = rectTrans.rect.height;
|
||||
totalWidth = rectTrans.rect.width;
|
||||
|
||||
float baseX1 = 0;
|
||||
float baseX2 = totalWidth;
|
||||
float accumilatedHeight = 0;
|
||||
float? firstCenterHeight = null;
|
||||
float acummilatedWeight = 0;
|
||||
for (int i = 0; i < columnCount; ++i)
|
||||
{
|
||||
object userData = ((IInternalPyramidData)Data).InternalDataSource.Columns[i].UserData;
|
||||
var categoryData = ((PyramidData.CategoryData)userData);
|
||||
|
||||
string name = ((IInternalPyramidData)Data).InternalDataSource.Columns[i].Name;
|
||||
double amount = Math.Max(data[0, i], 0);
|
||||
if (amount == 0f)
|
||||
continue;
|
||||
|
||||
float weight = (float)(amount / total);
|
||||
float actualHeight = totalHeight * weight;
|
||||
|
||||
float slopeRight = categoryData.RightSlope;
|
||||
float slopeLeft = categoryData.LeftSlope;
|
||||
float atan;
|
||||
switch(slope)
|
||||
{
|
||||
case SlopeType.Center:
|
||||
atan = -Mathf.Atan2(totalHeight, totalWidth * 0.5f) * Mathf.Rad2Deg +90;
|
||||
slopeRight = atan;
|
||||
slopeLeft = atan;
|
||||
break;
|
||||
case SlopeType.Left:
|
||||
atan = -Mathf.Atan2(totalHeight, totalWidth) * Mathf.Rad2Deg + 90;
|
||||
slopeLeft = 0;
|
||||
slopeRight = atan;
|
||||
break;
|
||||
case SlopeType.Right:
|
||||
atan = -Mathf.Atan2(totalHeight, totalWidth) * Mathf.Rad2Deg + 90;
|
||||
slopeLeft = atan;
|
||||
slopeRight = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
GameObject pyramidObject = null;
|
||||
GameObject pyramidBackObject = null;
|
||||
IPyramidGenerator generator = null;
|
||||
IPyramidGenerator backgenerator = null;
|
||||
PyramidObject dataObject;
|
||||
float centerHeight = actualHeight * 0.5f + accumilatedHeight;
|
||||
float unblendedHeight = centerHeight;
|
||||
if (firstCenterHeight.HasValue == false)
|
||||
firstCenterHeight = centerHeight;
|
||||
centerHeight = Mathf.Lerp(firstCenterHeight.Value, centerHeight, categoryData.PositionBlend);
|
||||
|
||||
if (mPyramids.TryGetValue(name, out dataObject))
|
||||
{
|
||||
pyramidBackObject = dataObject.backObject;
|
||||
pyramidObject = dataObject.pyramidObject;
|
||||
backgenerator = dataObject.BackGenerator;
|
||||
generator = dataObject.Generator;
|
||||
generator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight,inset,0f,1f);
|
||||
if (backgenerator !=null)
|
||||
backgenerator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, 0f, acummilatedWeight, acummilatedWeight + weight);
|
||||
if (dataObject.ItemLabel)
|
||||
{
|
||||
Vector3 labelPos = AlignTextPosition(mItemLabels, dataObject,generator, centerHeight);
|
||||
dataObject.ItemLabel.transform.localPosition = labelPos;
|
||||
ChartCommon.UpdateTextParams(dataObject.ItemLabel.UIText, categoryData.Title);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dataObject = new PyramidObject();
|
||||
|
||||
if (backMaterial != null)
|
||||
{
|
||||
var backGenerator = PreparePyramidObject(out pyramidBackObject);
|
||||
backGenerator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, 0f, acummilatedWeight, acummilatedWeight +weight);
|
||||
dataObject.backObject = pyramidBackObject;
|
||||
dataObject.BackGenerator = backGenerator;
|
||||
ChartCommon.HideObject(pyramidBackObject, hideHierarchy);
|
||||
pyramidBackObject.transform.SetParent(transform,false);
|
||||
ChartCommon.EnsureComponent<ChartItem>(pyramidBackObject);
|
||||
ChartMaterialController backcontrol = ChartCommon.EnsureComponent<ChartMaterialController>(pyramidBackObject);
|
||||
backcontrol.Materials = new ChartDynamicMaterial(backMaterial);
|
||||
foreach(var itemEffect in pyramidBackObject.GetComponents<ChartItemEffect>())
|
||||
ChartCommon.SafeDestroy(itemEffect);
|
||||
ChartCommon.SafeDestroy(backGenerator.ContainerObject);
|
||||
}
|
||||
|
||||
generator = PreparePyramidObject(out pyramidObject);
|
||||
generator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, inset,0f,1f);
|
||||
ChartCommon.HideObject(pyramidObject, hideHierarchy);
|
||||
pyramidObject.transform.SetParent(transform,false);
|
||||
ChartCommon.EnsureComponent<ChartItem>(pyramidObject);
|
||||
|
||||
|
||||
|
||||
ChartMaterialController control = ChartCommon.EnsureComponent<ChartMaterialController>(pyramidObject);
|
||||
control.Materials = Data.GetMaterial(name);
|
||||
control.Refresh();
|
||||
|
||||
|
||||
dataObject.Generator = generator;
|
||||
dataObject.category = name;
|
||||
dataObject.pyramidObject = pyramidObject;
|
||||
mPyramids.Add(name, dataObject);
|
||||
|
||||
CharItemEffectController effect = ChartCommon.EnsureComponent<CharItemEffectController>(pyramidObject);
|
||||
effect.WorkOnParent = false;
|
||||
effect.InitialScale = false;
|
||||
|
||||
ChartItemEvents[] events = pyramidObject.GetComponentsInChildren<ChartItemEvents>();
|
||||
for (int j = 0; j < events.Length; ++j)
|
||||
{
|
||||
if (events[j] == null)
|
||||
continue;
|
||||
InternalItemEvents comp = (InternalItemEvents)events[j];
|
||||
comp.Parent = this;
|
||||
comp.UserData = dataObject;
|
||||
}
|
||||
|
||||
|
||||
if (mItemLabels != null)
|
||||
{
|
||||
|
||||
Vector3 labelPos = AlignTextPosition(mItemLabels, dataObject, generator, 0f);
|
||||
float angle = justification == JustificationType.LeftAligned ? -180f : 180f;
|
||||
BillboardText billboard = ChartCommon.CreateBillboardText(null, mItemLabels.TextPrefab, dataObject.pyramidObject.transform, categoryData.Title, labelPos.x, labelPos.y, labelPos.z, angle, null, hideHierarchy, mItemLabels.FontSize, mItemLabels.FontSharpness);
|
||||
dataObject.ItemLabel = billboard;
|
||||
dataObject.ItemLabel.transform.localPosition = labelPos;
|
||||
TextController.AddText(billboard);
|
||||
}
|
||||
}
|
||||
|
||||
dataObject.Text = categoryData.Text;
|
||||
dataObject.Title = categoryData.Title;
|
||||
|
||||
if (IsCanvas)
|
||||
{
|
||||
if (pyramidObject != null)
|
||||
{
|
||||
Vector2 actualPosition = new Vector2(0.5f, centerHeight) + categoryData.Shift;
|
||||
actualPosition = new Vector2(actualPosition.x , actualPosition.y / TotalHeight);
|
||||
var objectRect = pyramidObject.GetComponent<RectTransform>();
|
||||
objectRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
objectRect.anchorMin = actualPosition;
|
||||
objectRect.anchorMax = actualPosition;
|
||||
objectRect.anchoredPosition = new Vector2();
|
||||
objectRect.sizeDelta = new Vector2(totalWidth, actualHeight);
|
||||
}
|
||||
if(pyramidBackObject != null)
|
||||
{
|
||||
Vector2 actualPosition = new Vector2(0.5f, unblendedHeight);
|
||||
actualPosition = new Vector2(actualPosition.x, actualPosition.y / TotalHeight);
|
||||
var objectRect = pyramidBackObject.GetComponent<RectTransform>();
|
||||
objectRect.pivot = new Vector2(0f, 0f);
|
||||
objectRect.anchorMin = actualPosition;
|
||||
objectRect.anchorMax = actualPosition;
|
||||
objectRect.anchoredPosition = new Vector2();
|
||||
}
|
||||
}
|
||||
accumilatedHeight += actualHeight;
|
||||
acummilatedWeight += weight;
|
||||
if(backgenerator!= null)
|
||||
backgenerator.Generate();
|
||||
generator.Generate();
|
||||
generator.GetUpperBase(out baseX1, out baseX2);
|
||||
generator.ApplyInfo(categoryData.Title, categoryData.Text, categoryData.Image,categoryData.Scale);
|
||||
generator.SetAlpha(categoryData.Alpha);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLabelSettingChanged()
|
||||
{
|
||||
base.OnLabelSettingChanged();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLabelSettingsSet()
|
||||
{
|
||||
base.OnLabelSettingsSet();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public override void InternalGenerateChart()
|
||||
{
|
||||
if (gameObject.activeInHierarchy == false)
|
||||
return;
|
||||
base.InternalGenerateChart();
|
||||
GeneratePyramid(mQuick);
|
||||
mQuick = false;
|
||||
}
|
||||
|
||||
protected override bool HasValues(AxisBase axis)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override double MaxValue(AxisBase axis)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected override double MinValue(AxisBase axis)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged()
|
||||
{
|
||||
QuickInvalidate();
|
||||
}
|
||||
|
||||
protected override void OnPropertyUpdated()
|
||||
{
|
||||
base.OnPropertyUpdated();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void ValidateProperties()
|
||||
{
|
||||
base.ValidateProperties();
|
||||
if (inset < 0)
|
||||
inset = 0;
|
||||
}
|
||||
|
||||
PyramidEventArgs userDataToEventArgs(object userData)
|
||||
{
|
||||
PyramidObject pyramid = (PyramidObject)userData;
|
||||
return new PyramidEventArgs(pyramid.category, pyramid.Title,pyramid.Text);
|
||||
}
|
||||
|
||||
protected override void OnNonHoverted()
|
||||
{
|
||||
base.OnNonHoverted();
|
||||
if (NonHovered != null)
|
||||
NonHovered.Invoke();
|
||||
}
|
||||
|
||||
protected override void OnItemHoverted(object userData)
|
||||
{
|
||||
base.OnItemHoverted(userData);
|
||||
if (ItemHovered != null)
|
||||
ItemHovered.Invoke(userDataToEventArgs(userData));
|
||||
}
|
||||
|
||||
protected override void OnItemSelected(object userData)
|
||||
{
|
||||
base.OnItemSelected(userData);
|
||||
var args = userDataToEventArgs(userData);
|
||||
if (ItemClicked != null)
|
||||
ItemClicked.Invoke(args);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected override bool SupportsCategoryLabels
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsGroupLables
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsItemLabels
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ShouldFitCanvas { get { return false; } }
|
||||
|
||||
protected override float TotalDepthLink { get { return 0f; } }
|
||||
|
||||
protected override float TotalHeightLink { get { return totalHeight; } }
|
||||
|
||||
protected override float TotalWidthLink { get { return totalWidth; } }
|
||||
|
||||
public override bool IsCanvas { get { return true; } }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d0cd7c0544e4cc439d4a030e8a7a470
|
||||
timeCreated: 1578949498
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
450
Assets/Chart And Graph/InBeta/PyramidChart/PyramidData.cs
Normal file
450
Assets/Chart And Graph/InBeta/PyramidChart/PyramidData.cs
Normal file
@ -0,0 +1,450 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph.DataSource;
|
||||
using ChartAndGraph.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[Serializable]
|
||||
public class PyramidData : AbstractChartData, IInternalPyramidData, IChartData
|
||||
{
|
||||
[Serializable]
|
||||
internal class CategoryData
|
||||
{
|
||||
public string Name;
|
||||
public ChartDynamicMaterial Materials;
|
||||
public String Title;
|
||||
public String Text;
|
||||
public Sprite Image;
|
||||
|
||||
public float RightSlope;
|
||||
public float LeftSlope;
|
||||
public float HeightRatio;
|
||||
|
||||
public float Alpha;
|
||||
public float Scale;
|
||||
public float ShiftX, ShiftY;
|
||||
public float PositionBlend;
|
||||
public Vector2 Shift { get { return new Vector2(ShiftX, ShiftY); } }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
class DataEntry
|
||||
{
|
||||
public string GroupName;
|
||||
public string ColumnName;
|
||||
public double Amount;
|
||||
}
|
||||
|
||||
public PyramidData()
|
||||
{
|
||||
mDataSource = new ChartSparseDataSource();
|
||||
if (mDataSource.Rows.Count == 0)
|
||||
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
|
||||
}
|
||||
|
||||
private ChartSparseDataSource mDataSource;
|
||||
ChartSparseDataSource IInternalPyramidData.InternalDataSource { get { return mDataSource; } }
|
||||
[SerializeField]
|
||||
private CategoryData[] mCategories = new CategoryData[0];
|
||||
[SerializeField]
|
||||
private string[] mGroups = new string[1] { "Pyramid" };
|
||||
[SerializeField]
|
||||
private DataEntry[] mData = new DataEntry[0];
|
||||
|
||||
public int TotalCategories { get { return mDataSource.Columns.Count; } }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
UpdateSliders();
|
||||
}
|
||||
|
||||
public string GetCategoryName(int index)
|
||||
{
|
||||
return mDataSource.Columns[index].Name;
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
int totalColumns = mDataSource.Columns.Count;
|
||||
mCategories = new CategoryData[totalColumns];
|
||||
for (int i = 0; i < totalColumns; i++)
|
||||
{
|
||||
CategoryData data = new CategoryData();
|
||||
data.Name = mDataSource.Columns[i].Name;
|
||||
data.Materials = mDataSource.Columns[i].Material;
|
||||
object userData = mDataSource.Columns[i].UserData;
|
||||
if (userData != null && userData is CategoryData)
|
||||
{
|
||||
data.Alpha = ((CategoryData)userData).Alpha;
|
||||
data.HeightRatio = ((CategoryData)userData).HeightRatio;
|
||||
data.Image = ((CategoryData)userData).Image;
|
||||
data.Title = ((CategoryData)userData).Title;
|
||||
data.LeftSlope = ((CategoryData)userData).LeftSlope;
|
||||
data.RightSlope = ((CategoryData)userData).RightSlope;
|
||||
data.Scale = ((CategoryData)userData).Scale;
|
||||
data.ShiftX = ((CategoryData)userData).ShiftX;
|
||||
data.ShiftY = ((CategoryData)userData).ShiftY;
|
||||
data.Text = ((CategoryData)userData).Text;
|
||||
data.PositionBlend = ((CategoryData)userData).PositionBlend;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.Alpha = 1f;
|
||||
data.HeightRatio = 1f;
|
||||
data.Image = null;
|
||||
data.Title = "";
|
||||
data.LeftSlope = -0.5f;
|
||||
data.RightSlope = -0.5f;
|
||||
data.Scale = 1f;
|
||||
data.ShiftX = 0f;
|
||||
data.ShiftY = 0f;
|
||||
data.Text = ((CategoryData)userData).Text;
|
||||
data.PositionBlend = 1f;
|
||||
}
|
||||
mCategories[i] = data;
|
||||
}
|
||||
|
||||
int totalRows = mDataSource.Rows.Count;
|
||||
mGroups = new string[totalRows];
|
||||
for (int i = 0; i < totalRows; i++)
|
||||
mGroups[i] = mDataSource.Rows[i].Name;
|
||||
|
||||
double[,] raw = mDataSource.getRawData();
|
||||
int current = 0;
|
||||
mData = new DataEntry[raw.GetLength(0) * raw.GetLength(1)];
|
||||
for (int i = 0; i < raw.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < raw.GetLength(1); ++j)
|
||||
{
|
||||
DataEntry entry = new DataEntry();
|
||||
entry.ColumnName = mDataSource.Columns[j].Name;
|
||||
entry.GroupName = mDataSource.Rows[i].Name;
|
||||
entry.Amount = raw[i, j];
|
||||
mData[current++] = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Action ProperyUpdated;
|
||||
public event Action RealtimeProperyUpdated;
|
||||
|
||||
protected void RaiseRealtimePropertyUpdated()
|
||||
{
|
||||
if (RealtimeProperyUpdated != null)
|
||||
RealtimeProperyUpdated();
|
||||
}
|
||||
|
||||
protected void RaisePropertyUpdated()
|
||||
{
|
||||
if (ProperyUpdated != null)
|
||||
ProperyUpdated();
|
||||
}
|
||||
public bool HasCategory(string category)
|
||||
{
|
||||
try
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
if (col != null)
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rename a category. throws an exception on error
|
||||
/// </summary>
|
||||
/// <param name="prevName"></param>
|
||||
/// <param name="newName"></param>
|
||||
public void RenameCategory(string prevName, string newName)
|
||||
{
|
||||
mDataSource.Columns[prevName].Name = newName;
|
||||
RaisePropertyUpdated();
|
||||
}
|
||||
|
||||
public object StoreCategory(string category)
|
||||
{
|
||||
CategoryData data = (CategoryData)(mDataSource.Columns[category].UserData);
|
||||
data.Materials = mDataSource.Columns[category].Material;
|
||||
return data;
|
||||
}
|
||||
|
||||
public void RestoreCategory(string category, object data)
|
||||
{
|
||||
var toSet = (CategoryData)data;
|
||||
CategoryData current = (CategoryData)(mDataSource.Columns[category].UserData);
|
||||
current.Alpha = ((CategoryData)toSet).Alpha;
|
||||
current.HeightRatio = ((CategoryData)toSet).HeightRatio;
|
||||
current.Image = ((CategoryData)toSet).Image;
|
||||
current.Title = ((CategoryData)toSet).Title;
|
||||
current.LeftSlope = ((CategoryData)toSet).LeftSlope;
|
||||
current.RightSlope = ((CategoryData)toSet).RightSlope;
|
||||
current.Scale = ((CategoryData)toSet).Scale;
|
||||
current.ShiftX = ((CategoryData)toSet).ShiftX;
|
||||
current.ShiftY = ((CategoryData)toSet).ShiftY;
|
||||
current.Text = ((CategoryData)toSet).Text;
|
||||
current.PositionBlend = ((CategoryData)toSet).PositionBlend;
|
||||
|
||||
current.Materials = toSet.Materials;
|
||||
mDataSource.Columns[category].Material = toSet.Materials;
|
||||
RaisePropertyUpdated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// call this to suspend chart redrawing while updating the data of the chart
|
||||
/// </summary>
|
||||
public void StartBatch()
|
||||
{
|
||||
mDataSource.SuspendEvents = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// call this after StartBatch , this will apply all the changed made between the StartBatch call to this call
|
||||
/// </summary>
|
||||
public void EndBatch()
|
||||
{
|
||||
mDataSource.SuspendEvents = false;
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
mDataSource = new ChartSparseDataSource();
|
||||
mDataSource.SuspendEvents = true;
|
||||
mDataSource.Clear();
|
||||
if (mCategories == null)
|
||||
mCategories = new CategoryData[0];
|
||||
if (mGroups == null)
|
||||
mGroups = new string[0];
|
||||
if (mData == null)
|
||||
mData = new DataEntry[0];
|
||||
|
||||
for (int i = 0; i < mCategories.Length; i++)
|
||||
AddCategory(mCategories[i].Name, mCategories[i].Materials, mCategories[i].Title, mCategories[i].Text, mCategories[i].Image, mCategories[i].Alpha, mCategories[i].HeightRatio, mCategories[i].LeftSlope, mCategories[i].RightSlope, mCategories[i].PositionBlend, mCategories[i].Scale, mCategories[i].ShiftX, mCategories[i].ShiftY);
|
||||
// for (int i = 0; i < mGroups.Length; i++)
|
||||
// AddGroup(mGroups[i]);
|
||||
if (mDataSource.Rows.Count == 0)
|
||||
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
|
||||
for (int i = 0; i < mData.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataEntry entry = mData[i];
|
||||
mDataSource.SetValue(entry.ColumnName, entry.GroupName, entry.Amount);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mDataSource.SuspendEvents = false;
|
||||
}
|
||||
|
||||
private void AddGroup(string name)
|
||||
{
|
||||
mDataSource.Rows.Add(new ChartDataRow(name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new category to the pyramid chart. Each category has it's own material and name. each category corresponds to one pyr slice
|
||||
/// </summary>
|
||||
/// <param name="name">the name of the category</param>
|
||||
/// <param name="material">the material of the category</param>
|
||||
public void AddCategory(string name, Material material, String title, String text, Sprite image)
|
||||
{
|
||||
AddCategory(name, new ChartDynamicMaterial(material),title,text,image);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new category to the pyramid chart. Each category has it's own material and name. each category corresponds to one pie slice
|
||||
/// </summary>
|
||||
/// <param name="name">the name of the category</param>
|
||||
/// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
|
||||
public void AddCategory(string name, ChartDynamicMaterial material, String title, String text, Sprite image,float alpha = 1f,float heightRatio = 1f,float leftSlope = 45f,float rightSlope = 45f,float positionBlend = 1f,float scale = 1f, float shiftX = 0f,float shiftY =0f)
|
||||
{
|
||||
if (title == null)
|
||||
title = "";
|
||||
if (text == null)
|
||||
text = "";
|
||||
|
||||
ChartDataColumn column = new ChartDataColumn(name);
|
||||
column.Material = material;
|
||||
CategoryData d = new CategoryData();
|
||||
d.Title = title;
|
||||
d.Text = text;
|
||||
d.Image = image;
|
||||
d.Alpha = alpha;
|
||||
d.HeightRatio = heightRatio;
|
||||
d.LeftSlope = leftSlope;
|
||||
d.RightSlope = rightSlope;
|
||||
d.PositionBlend = positionBlend;
|
||||
d.Scale = scale;
|
||||
d.ShiftX = shiftX;
|
||||
d.ShiftY = shiftY;
|
||||
column.UserData = d;
|
||||
mDataSource.mColumns.Add(column);
|
||||
SetValueInternal(name, "Pyramid", heightRatio);
|
||||
}
|
||||
|
||||
public void SetCategoryInfo(string category,string title,string text,Sprite image)
|
||||
{
|
||||
if (title == null)
|
||||
title = "";
|
||||
if (text == null)
|
||||
text = "";
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.Text = text;
|
||||
data.Title = title;
|
||||
data.Image = image;
|
||||
RaisePropertyUpdated();
|
||||
}
|
||||
public void SetCategoryAlpha(string category, float alpha)
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.Alpha = alpha;
|
||||
RaiseRealtimePropertyUpdated();
|
||||
}
|
||||
public void SetCategoryContentScale(string category,float scale)
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.Scale = scale;
|
||||
RaiseRealtimePropertyUpdated();
|
||||
}
|
||||
public void SetCategoryOrientation(string category,float positionBlend,float shiftX ,float shiftY)
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.PositionBlend = positionBlend;
|
||||
data.ShiftX = shiftX;
|
||||
data.ShiftY = shiftY;
|
||||
RaiseRealtimePropertyUpdated();
|
||||
}
|
||||
public void SetCategorySlope(string category,float leftSlop,float rightSlope)
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.LeftSlope = leftSlop;
|
||||
data.RightSlope = rightSlope;
|
||||
RaiseRealtimePropertyUpdated();
|
||||
}
|
||||
public void SetCategoryHeightRatio(string category, float heightRatio)
|
||||
{
|
||||
var col = mDataSource.Columns[category];
|
||||
CategoryData data = col.UserData as CategoryData;
|
||||
data.HeightRatio = heightRatio;
|
||||
SetValueInternal(category, "Pyramid", heightRatio);
|
||||
RaiseRealtimePropertyUpdated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clears the pyramid chart data
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
string[] groups = mDataSource.Columns.Select(x => x.Name).ToArray();
|
||||
foreach (string s in groups)
|
||||
{
|
||||
RemoveCategory(s);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets the material for the specified category
|
||||
/// </summary>
|
||||
/// <param name="category">the name of the category</param>
|
||||
/// <param name="material">the material of the category</param>
|
||||
public void SetMaterial(string category, Material material)
|
||||
{
|
||||
SetMaterial(category, new ChartDynamicMaterial(material));
|
||||
|
||||
}
|
||||
|
||||
internal ChartDynamicMaterial GetMaterial(string category)
|
||||
{
|
||||
return mDataSource.Columns[category].Material;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets the material for the specified category
|
||||
/// </summary>
|
||||
/// <param name="category">the name of the category</param>
|
||||
/// <param name="material">the dynamic material of the category. dynamic materials allow setting the material for different events</param>
|
||||
public void SetMaterial(string category, ChartDynamicMaterial material)
|
||||
{
|
||||
mDataSource.Columns[category].Material = material;
|
||||
RaisePropertyUpdated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// removes a category from the pyramid chart
|
||||
/// </summary>
|
||||
/// <param name="name">the name of the category to remove</param>
|
||||
public void RemoveCategory(string name)
|
||||
{
|
||||
ChartDataColumn column = mDataSource.Columns[name];
|
||||
RemoveSlider(name, "Pyramid");
|
||||
mDataSource.Columns.Remove(column);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the value for the specified category
|
||||
/// </summary>
|
||||
/// <param name="category">the category name</param>
|
||||
/// <param name="group">the group name</param>
|
||||
/// <returns></returns>
|
||||
public double GetValue(string category)
|
||||
{
|
||||
return mDataSource.GetValue(category, "Pyramid");
|
||||
}
|
||||
|
||||
public bool CheckAnimationEnded(float time, AnimationCurve curve)
|
||||
{
|
||||
if (curve.length == 0)
|
||||
return true;
|
||||
return time > curve.keys[curve.length - 1].time;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// used intenally , do not call
|
||||
/// </summary>
|
||||
/// <param name="cats"></param>
|
||||
public object[] StoreAllCategoriesinOrder()
|
||||
{
|
||||
return mCategories.ToArray();
|
||||
}
|
||||
|
||||
private void FixEaseFunction(AnimationCurve curve)
|
||||
{
|
||||
curve.postWrapMode = WrapMode.Once;
|
||||
curve.preWrapMode = WrapMode.Once;
|
||||
}
|
||||
|
||||
|
||||
protected override void SetValueInternal(string column, string row, double value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(mDataSource.Rows.Count ==0 )
|
||||
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
|
||||
mDataSource.SetValue(column, "Pyramid", value);
|
||||
}
|
||||
catch (ChartException e)
|
||||
{
|
||||
Debug.LogWarning(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46cd052151826fb41a072a83f913f790
|
||||
timeCreated: 1578948915
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/Chart And Graph/InBeta/PyramidChart/PyramidMesh.cs
Normal file
47
Assets/Chart And Graph/InBeta/PyramidChart/PyramidMesh.cs
Normal file
@ -0,0 +1,47 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class PyramidMesh
|
||||
{
|
||||
public static void Generate2dMesh(UIVertex[] mesh, Vector2[] normals,float baseX1, float baseX2,float baseSize, float slopLeft, float slopeRight, float height,float startV,float endV)
|
||||
{
|
||||
float halfHeight = height * 0.5f;
|
||||
float halfWidth = baseSize * 0.5f;
|
||||
slopLeft = -Mathf.Clamp(slopLeft, -90, 90) +90;
|
||||
slopeRight = Mathf.Clamp(slopeRight ,- 90, 90) +90;
|
||||
|
||||
float tanLeft = (1f/Mathf.Tan(slopLeft * Mathf.Deg2Rad)) * height;
|
||||
float tanRight =(1f/Mathf.Tan(slopeRight * Mathf.Deg2Rad)) * height;
|
||||
|
||||
float leftPos = baseX1 + tanLeft;
|
||||
float rightPos = baseX2 + tanRight;
|
||||
leftPos = Mathf.Clamp(leftPos, 0,baseSize);
|
||||
rightPos = Mathf.Clamp(rightPos, 0, baseSize);
|
||||
|
||||
|
||||
if (leftPos > rightPos)
|
||||
leftPos = rightPos = Mathf.Clamp(Mathf.Lerp(leftPos, rightPos, 0.5f), 0, baseSize);
|
||||
|
||||
UIVertex v1 = ChartCommon.CreateVertex(new Vector3(baseX1 - halfWidth, -halfHeight), new Vector2(0f, startV));
|
||||
UIVertex v2 = ChartCommon.CreateVertex(new Vector3(baseX2 - halfWidth, -halfHeight), new Vector2(1f, startV));
|
||||
UIVertex v3 = ChartCommon.CreateVertex(new Vector3(leftPos - halfWidth, halfHeight), new Vector2(0f, endV));
|
||||
UIVertex v4 = ChartCommon.CreateVertex(new Vector3(rightPos - halfWidth, halfHeight), new Vector2(1f, endV));
|
||||
|
||||
normals[0] = ((Vector2.up + ChartCommon.Perpendicular(v3.position - v1.position).normalized) * 0.5f).normalized;
|
||||
normals[1] = ((Vector2.up + ChartCommon.Perpendicular(v2.position - v4.position).normalized) * 0.5f).normalized;
|
||||
normals[2] = ((Vector2.down + ChartCommon.Perpendicular(v3.position - v1.position).normalized) * 0.5f).normalized;
|
||||
normals[3] = ((Vector2.down + ChartCommon.Perpendicular(v2.position - v4.position).normalized) * 0.5f).normalized;
|
||||
|
||||
mesh[0] = v1;
|
||||
mesh[1] = v2;
|
||||
mesh[2] = v3;
|
||||
mesh[3] = v4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cc5bd615b17ae34292624585cda8e6a
|
||||
timeCreated: 1579182822
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/InBeta/Script.meta
Normal file
9
Assets/Chart And Graph/InBeta/Script.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b321e42897743dd4aa55fd6373025c34
|
||||
folderAsset: yes
|
||||
timeCreated: 1505898441
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/InBeta/Script/Candle Chart.meta
Normal file
9
Assets/Chart And Graph/InBeta/Script/Candle Chart.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c5df8a40695a4340beca4c338df7e39
|
||||
folderAsset: yes
|
||||
timeCreated: 1491152606
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
651
Assets/Chart And Graph/InBeta/Script/Candle Chart/CandleChart.cs
Normal file
651
Assets/Chart And Graph/InBeta/Script/Candle Chart/CandleChart.cs
Normal file
@ -0,0 +1,651 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
#define CandleChart
|
||||
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public abstract class CandleChart : ScrollableAxisChart
|
||||
{
|
||||
/// <summary>
|
||||
/// a candle chart event
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CandleEvent : UnityEvent<CandleEventArgs>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The height ratio of the chart")]
|
||||
protected float heightRatio = 300;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The width ratio of the chart")]
|
||||
protected float widthRatio = 600;
|
||||
|
||||
|
||||
protected override float TotalHeightLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return heightRatio;
|
||||
}
|
||||
}
|
||||
|
||||
protected override float TotalWidthLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return widthRatio;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// occures when a point is clicked
|
||||
/// </summary>
|
||||
public CandleEvent CandleClicked = new CandleEvent();
|
||||
/// <summary>
|
||||
/// occurs when a point is hovered
|
||||
/// </summary>
|
||||
public CandleEvent CandleHovered = new CandleEvent();
|
||||
/// <summary>
|
||||
/// occurs when no candle is hovered any longer
|
||||
/// </summary>
|
||||
public UnityEvent NonHovered = new UnityEvent();
|
||||
|
||||
public enum CandleThicknessMode
|
||||
{
|
||||
/// <summary>
|
||||
/// the candle size is detemined only by the candle duration paramenter
|
||||
/// </summary>
|
||||
Fill,
|
||||
/// <summary>
|
||||
/// the candle is of constant size , regardless of the view size
|
||||
/// </summary>
|
||||
Constant,
|
||||
/// <summary>
|
||||
/// the candle size is fixed , but proportional to the view size
|
||||
/// </summary>
|
||||
Proportional
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// format a candle value to the parameter strings
|
||||
/// </summary>
|
||||
/// <param name="candleVal"></param>
|
||||
/// <param name="fractionDigits"></param>
|
||||
/// <param name="open"></param>
|
||||
/// <param name="high"></param>
|
||||
/// <param name="low"></param>
|
||||
/// <param name="close"></param>
|
||||
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string open, out string high, out string low, out string close)
|
||||
{
|
||||
|
||||
open = StringFromAxisFormat(new DoubleVector3(candleVal.Start,candleVal.Open,0.0), mVerticalAxis,false);
|
||||
close = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Close, 0.0), mVerticalAxis, false);
|
||||
high = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.High, 0.0), mVerticalAxis, false);
|
||||
low = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Low, 0.0), mVerticalAxis, false);
|
||||
}
|
||||
/// <summary>
|
||||
/// format a candle value to the parameter strings
|
||||
/// </summary>
|
||||
/// <param name="candleVal"></param>
|
||||
/// <param name="fractionDigits"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="duration"></param>
|
||||
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string start, out string duration)
|
||||
{
|
||||
start = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mHorizontalAxis, true);
|
||||
duration = StringFromAxisFormat(new DoubleVector3(candleVal.Duration, candleVal.Open, 0.0), mHorizontalAxis, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// format a candle value to the parameter strings
|
||||
/// </summary>
|
||||
/// <param name="candleVal"></param>
|
||||
/// <param name="fractionDigits"></param>
|
||||
/// <param name="open"></param>
|
||||
/// <param name="high"></param>
|
||||
/// <param name="low"></param>
|
||||
/// <param name="close"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="duration"></param>
|
||||
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string open, out string high, out string low, out string close, out string start, out string duration)
|
||||
{
|
||||
FormatCandleValue(candleVal, fractionDigits, out open, out high, out low, out close);
|
||||
FormatCandleValue(candleVal, fractionDigits, out start, out duration);
|
||||
}
|
||||
|
||||
public class CandleEventArgs
|
||||
{
|
||||
int mType;
|
||||
|
||||
public CandleEventArgs(int index, int type, Rect selectionRect, Vector3 position, CandleChartData.CandleValue value, string category)
|
||||
{
|
||||
mType = type;
|
||||
Position = position;
|
||||
SelectionRect = selectionRect;
|
||||
CandleValue = value;
|
||||
Category = category;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if this event is triggered for the high portion of the candle
|
||||
/// </summary>
|
||||
public bool IsHighEvent { get { return mType == 0; } }
|
||||
/// <summary>
|
||||
/// true if this event is triggered for the low portion of the candle
|
||||
/// </summary>
|
||||
public bool IsLowEvent { get { return mType == 2; } }
|
||||
/// <summary>
|
||||
/// true if this event is triggerd for the body portion of the candle (open/close)
|
||||
/// </summary>
|
||||
public bool IsBodyEvent { get { return mType == 1; } }
|
||||
/// <summary>
|
||||
/// the rect on the canvas that represents the selected object
|
||||
/// </summary>
|
||||
public Rect SelectionRect { get; private set; }
|
||||
/// <summary>
|
||||
/// mouse position
|
||||
/// </summary>
|
||||
public Vector3 Position { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// the index of the candle in the data
|
||||
/// </summary>
|
||||
public int Index { get; private set; }
|
||||
/// <summary>
|
||||
/// the value of the candle
|
||||
/// </summary>
|
||||
public CandleChartData.CandleValue CandleValue { get; private set; }
|
||||
/// <summary>
|
||||
/// the category of the candle
|
||||
/// </summary>
|
||||
public string Category { get; private set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Thickness mode for the candle chart")]
|
||||
protected CandleThicknessMode thicknessMode = CandleThicknessMode.Constant;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Thickness mode for the candle chart
|
||||
/// </summary>
|
||||
public CandleThicknessMode ThicknessMode
|
||||
{
|
||||
get { return thicknessMode; }
|
||||
set
|
||||
{
|
||||
thicknessMode = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override IChartData DataLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Thickness contant for the candle chart , it's meaning depends on the thickness mode")]
|
||||
protected float thicknessConstant = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// Thickness contant for the candle chart , it's meaning depends on the thickness mode\
|
||||
/// Fill - multiply the duration size of the candle by a constant , should be between 0f to 1f
|
||||
/// Constant - the pixel size of the candle
|
||||
/// Proportional - constant size of the candle in seconds
|
||||
/// </summary>
|
||||
public float ThicknessConstant
|
||||
{
|
||||
get { return thicknessConstant; }
|
||||
set
|
||||
{
|
||||
thicknessConstant = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override float GetScrollingRange(int axis)
|
||||
{
|
||||
float min = (float)((IInternalCandleData)Data).GetMinValue(axis, false);
|
||||
float max = (float)((IInternalCandleData)Data).GetMaxValue(axis, false);
|
||||
return max - min;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
|
||||
private string itemFormat = "O:<?open>,H:<?high>,L:<?low>,C:<?close>";
|
||||
|
||||
/// <summary>
|
||||
/// format with the following labels:
|
||||
/// <?start>
|
||||
/// <?duration>
|
||||
/// <?open>
|
||||
/// <?close>
|
||||
/// <?high>
|
||||
/// <?low>
|
||||
/// </summary>
|
||||
public string ItemFormat
|
||||
{
|
||||
get { return itemFormat; }
|
||||
set
|
||||
{
|
||||
itemFormat = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the body of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
|
||||
private string bodyFormat = "O:<?open>,C:<?close>";
|
||||
|
||||
/// <summary>
|
||||
/// format with the following labels:
|
||||
/// <?start>
|
||||
/// <?duration>
|
||||
/// <?open>
|
||||
/// <?close>
|
||||
/// <?high>
|
||||
/// <?low>
|
||||
/// </summary>
|
||||
public string BodyFormat
|
||||
{
|
||||
get { return bodyFormat; }
|
||||
set
|
||||
{
|
||||
bodyFormat = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the high line of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
|
||||
private string highFormat = "H:<?high>";
|
||||
|
||||
public string HighFormat
|
||||
{
|
||||
get { return highFormat; }
|
||||
set
|
||||
{
|
||||
highFormat = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the low line of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
|
||||
private string lowFormat = "L:<?low>";
|
||||
|
||||
public string LowFormat
|
||||
{
|
||||
get { return lowFormat; }
|
||||
set
|
||||
{
|
||||
lowFormat = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the candle chart data
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
protected CandleChartData Data = new CandleChartData();
|
||||
|
||||
/// <summary>
|
||||
/// Holds the candle chart data. including values and categories
|
||||
/// </summary>
|
||||
public CandleChartData DataSource { get { return Data; } }
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
if (ChartCommon.IsInEditMode == false)
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (ChartCommon.IsInEditMode == false)
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
Data.RestoreDataValues();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// hooks data source events.
|
||||
/// </summary>
|
||||
protected void HookEvents()
|
||||
{
|
||||
((IInternalCandleData)Data).InternalDataChanged -= CandleChart_InternalDataChanged;
|
||||
((IInternalCandleData)Data).InternalDataChanged += CandleChart_InternalDataChanged;
|
||||
|
||||
((IInternalCandleData)Data).InternalViewPortionChanged -= CandleChart_InternalViewPortionChanged;
|
||||
((IInternalCandleData)Data).InternalViewPortionChanged += CandleChart_InternalViewPortionChanged;
|
||||
|
||||
|
||||
((IInternalCandleData)Data).InternalRealTimeDataChanged -= CandleChart_InternalRealTimeDataChanged;
|
||||
((IInternalCandleData)Data).InternalRealTimeDataChanged += CandleChart_InternalRealTimeDataChanged;
|
||||
}
|
||||
|
||||
private void CandleChart_InternalViewPortionChanged(object sender, EventArgs e)
|
||||
{
|
||||
InvalidateRealtime();
|
||||
}
|
||||
|
||||
private void CandleChart_InternalRealTimeDataChanged(int index,string str)
|
||||
{
|
||||
InvalidateRealtime();
|
||||
}
|
||||
|
||||
private void CandleChart_InternalDataChanged(object sender, EventArgs e)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
protected override void OnLabelSettingChanged()
|
||||
{
|
||||
base.OnLabelSettingChanged();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnAxisValuesChanged()
|
||||
{
|
||||
base.OnAxisValuesChanged();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLabelSettingsSet()
|
||||
{
|
||||
base.OnLabelSettingsSet();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override LegenedData LegendInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
LegenedData data = new LegenedData();
|
||||
if (Data == null)
|
||||
return data;
|
||||
foreach (var cat in ((IInternalCandleData)Data).Categories)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
LegenedData.LegenedItem item = new LegenedData.LegenedItem();
|
||||
CandleChartData.CandleSettings settings = cat.UpCandle;
|
||||
if (i == 0)
|
||||
{
|
||||
item.Name = cat.Name + " Increasing";
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Name = cat.Name + " Decreasing";
|
||||
settings = cat.DownCandle;
|
||||
}
|
||||
|
||||
if (settings.Fill != null)
|
||||
item.Material = settings.Fill;
|
||||
else
|
||||
{
|
||||
if (settings.Outline != null)
|
||||
item.Material = settings.Outline;
|
||||
else
|
||||
item.Material = settings.Line;
|
||||
}
|
||||
data.AddLegenedItem(item);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsCategoryLabels
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsGroupLables
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsItemLabels
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override bool HasValues(AxisBase axis)
|
||||
{
|
||||
if (axis == mVerticalAxis || axis == mHorizontalAxis) // has both horizontal and vertical axis
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override double MaxValue(AxisBase axis)
|
||||
{
|
||||
if (axis == null)
|
||||
return 0.0;
|
||||
if (axis == mHorizontalAxis)
|
||||
return ((IInternalCandleData)Data).GetMaxValue(0, false);
|
||||
if (axis == mVerticalAxis)
|
||||
return ((IInternalCandleData)Data).GetMaxValue(1, false);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected override double MinValue(AxisBase axis)
|
||||
{
|
||||
if (axis == null)
|
||||
return 0.0;
|
||||
if (axis == mHorizontalAxis)
|
||||
return ((IInternalCandleData)Data).GetMinValue(0, false);
|
||||
if (axis == mVerticalAxis)
|
||||
return ((IInternalCandleData)Data).GetMinValue(1, false);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void Deflate(ref double start, ref double duration, double amount)
|
||||
{
|
||||
double center = start + duration * 0.5;
|
||||
duration *= amount;
|
||||
start = center - duration * 0.5;
|
||||
}
|
||||
CandleChartData.CandleValue NormalizeCandle(CandleChartData.CandleValue candle, DoubleVector3 min, DoubleVector3 range)
|
||||
{
|
||||
CandleChartData.CandleValue res = new CandleChartData.CandleValue();
|
||||
res.Open = ChartCommon.normalizeInRangeY(candle.Open, min, range);
|
||||
res.Close = ChartCommon.normalizeInRangeY(candle.Close, min, range);
|
||||
res.High = ChartCommon.normalizeInRangeY(candle.High, min, range);
|
||||
res.Low = ChartCommon.normalizeInRangeY(candle.Low, min, range);
|
||||
|
||||
double duration = candle.Duration;
|
||||
double start = candle.Start;
|
||||
if (ThicknessMode == CandleThicknessMode.Fill)
|
||||
Deflate(ref start, ref duration, ThicknessConstant);
|
||||
else if (thicknessMode == CandleThicknessMode.Proportional)
|
||||
Deflate(ref start, ref duration, ThicknessConstant / duration);
|
||||
double candleEnd = start + duration;
|
||||
candleEnd = ChartCommon.normalizeInRangeX(candleEnd, min, range);
|
||||
|
||||
res.Start = ChartCommon.normalizeInRangeX(start, min, range);
|
||||
res.Duration = candleEnd - res.Start;
|
||||
return res;
|
||||
}
|
||||
public CandleChartData.CandleValue InterpolateCandleInRect(CandleChartData.CandleValue candle, Rect viewRect)
|
||||
{
|
||||
CandleChartData.CandleValue res = new CandleChartData.CandleValue();
|
||||
res.Open = ChartCommon.interpolateInRectY(viewRect, candle.Open);
|
||||
res.Close = ChartCommon.interpolateInRectY(viewRect, candle.Close);
|
||||
res.High = ChartCommon.interpolateInRectY(viewRect, candle.High);
|
||||
res.Low = ChartCommon.interpolateInRectY(viewRect, candle.Low);
|
||||
|
||||
if (res.High < res.Low)
|
||||
{
|
||||
double tmp = res.High;
|
||||
res.High = res.Low;
|
||||
res.Low = tmp;
|
||||
tmp = res.Open;
|
||||
res.Open = res.Close;
|
||||
res.Close = tmp;
|
||||
}
|
||||
double candleEnd = candle.Start + candle.Duration;
|
||||
candleEnd = ChartCommon.interpolateInRectX(viewRect, candleEnd);
|
||||
double start = ChartCommon.interpolateInRectX(viewRect, candle.Start);
|
||||
double duration = candleEnd - start;
|
||||
|
||||
if (start > candleEnd)
|
||||
{
|
||||
double tmp = start;
|
||||
start = candleEnd;
|
||||
candleEnd = tmp;
|
||||
}
|
||||
if (ThicknessMode == CandleThicknessMode.Constant)
|
||||
{
|
||||
Deflate(ref start, ref duration, ThicknessConstant / duration);
|
||||
}
|
||||
|
||||
res.Start = start;
|
||||
res.Duration = duration;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
StringBuilder mTmpBuilder = new StringBuilder();
|
||||
|
||||
protected string FormatItemWithFormat(string format, string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
FormatItemWithFormat(mTmpBuilder, format, open, close, high, low, start, duration);
|
||||
return mTmpBuilder.ToString();
|
||||
|
||||
}
|
||||
public string FormatItem(string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
return FormatItemWithFormat(itemFormat, open, close, high, low, start, duration);
|
||||
}
|
||||
|
||||
public string FormatLow(string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
return FormatItemWithFormat(lowFormat, open, close, high, low, start, duration);
|
||||
}
|
||||
public string FormatHigh(string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
return FormatItemWithFormat(highFormat, open, close, high, low, start, duration);
|
||||
}
|
||||
public string FormatBody(string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
return FormatItemWithFormat(bodyFormat, open, close, high, low, start, duration);
|
||||
}
|
||||
|
||||
protected void FormatItem(StringBuilder builder, string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
FormatItemWithFormat(builder, itemFormat, open, close, high, low, start, duration);
|
||||
}
|
||||
protected void FormatItemWithFormat(StringBuilder builder, string format, string open, string close, string high, string low, string start, string duration)
|
||||
{
|
||||
builder.Length = 0;
|
||||
builder.Append(format);
|
||||
builder.Replace("<?open>", open).Replace("<?close>", close).Replace("<?high>", high).Replace("<?low>", low).Replace("<?start>", start).Replace("<?duration>", duration);
|
||||
}
|
||||
|
||||
protected void TransformCandles(IList<CandleChartData.CandleValue> candles, List<CandleChartData.CandleValue> output, Rect viewRect, DoubleVector3 min, DoubleVector3 max)
|
||||
{
|
||||
DoubleVector3 range = max - min;
|
||||
if (Math.Abs(range.x) <= 0.0001f || Math.Abs(range.y) < 0.0001f)
|
||||
return;
|
||||
output.Clear();
|
||||
for (int i = 0; i < candles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = candles[i];
|
||||
candle = InterpolateCandleInRect(NormalizeCandle(candle, min, range), viewRect);
|
||||
output.Add(candle);
|
||||
}
|
||||
}
|
||||
|
||||
protected int ClipCandles(IList<CandleChartData.CandleValue> candles, List<CandleChartData.CandleValue> result)
|
||||
{
|
||||
result.Clear();
|
||||
|
||||
double minX, minY, maxX, maxY, xScroll, yScroll, xSize, ySize, xOut;
|
||||
GetScrollParams(out minX, out minY, out maxX, out maxY, out xScroll, out yScroll, out xSize, out ySize, out xOut);
|
||||
double direction = 1.0;
|
||||
if (minX > maxX)
|
||||
direction = -1.0;
|
||||
bool prevOut = true;
|
||||
int refrenceIndex = 0;
|
||||
|
||||
for (int i = 0; i < candles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = candles[i];
|
||||
double candleEnd = candle.Duration + candle.Start;
|
||||
|
||||
if (candleEnd* direction >= xScroll* direction && candle.Start* direction <= xOut* direction) // if the candle is within range
|
||||
{
|
||||
if (prevOut)
|
||||
{
|
||||
refrenceIndex = i;
|
||||
prevOut = false;
|
||||
}
|
||||
result.Add(candle);
|
||||
}
|
||||
}
|
||||
return refrenceIndex;
|
||||
}
|
||||
protected override void OnNonHoverted()
|
||||
{
|
||||
base.OnNonHoverted();
|
||||
if (NonHovered != null)
|
||||
NonHovered.Invoke();
|
||||
}
|
||||
protected override void OnItemSelected(object userData)
|
||||
{
|
||||
base.OnItemSelected(userData);
|
||||
CandleEventArgs args = userData as CandleEventArgs;
|
||||
if (CandleClicked != null)
|
||||
CandleClicked.Invoke(args);
|
||||
}
|
||||
protected override void OnItemHoverted(object userData)
|
||||
{
|
||||
base.OnItemHoverted(userData);
|
||||
CandleEventArgs args = userData as CandleEventArgs;
|
||||
if (CandleHovered != null)
|
||||
CandleHovered.Invoke(args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8205d387a1db4a04c85ed37decb56caf
|
||||
timeCreated: 1491152606
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,657 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[Serializable]
|
||||
public class CandleChartData : ScrollableChartData, IInternalCandleData
|
||||
{
|
||||
[Serializable]
|
||||
public struct CandleValue
|
||||
{
|
||||
public CandleValue(double open, double high, double low, double close, DateTime start, TimeSpan duration)
|
||||
{
|
||||
Open = open;
|
||||
High = high;
|
||||
Low = low;
|
||||
Close = close;
|
||||
Start = ChartDateUtility.DateToValue(start);
|
||||
Duration = ChartDateUtility.TimeSpanToValue(duration);
|
||||
}
|
||||
|
||||
public CandleValue(double open, double high, double low, double close, double start, double duration)
|
||||
{
|
||||
Open = open;
|
||||
High = high;
|
||||
Low = low;
|
||||
Close = close;
|
||||
Start = start;
|
||||
Duration = duration;
|
||||
}
|
||||
|
||||
public double Open;
|
||||
public double High;
|
||||
public double Low;
|
||||
public double Close;
|
||||
public double Start;
|
||||
public double Duration;
|
||||
|
||||
public bool isUp
|
||||
{
|
||||
get { return Close > Open; }
|
||||
}
|
||||
|
||||
public double End
|
||||
{
|
||||
get { return Start + Duration; }
|
||||
}
|
||||
|
||||
public DoubleVector2 MidPoint
|
||||
{
|
||||
get { return new DoubleVector2(Start + (Duration * 0.5), (Open + Close) * 0.5); }
|
||||
}
|
||||
|
||||
public double Max
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Max(Open, Close);
|
||||
}
|
||||
}
|
||||
|
||||
public double LowBound
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Min(Math.Min(High, Low), Math.Min(Open, Close));
|
||||
}
|
||||
}
|
||||
|
||||
public double HighBound
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Max(Math.Max(High, Low), Math.Max(Open, Close));
|
||||
}
|
||||
}
|
||||
|
||||
public double Min
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Min(Open, Close);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CandleSettings
|
||||
{
|
||||
public double LineThickness = 2.0;
|
||||
public double CandleThicknessMultiplier = 1.0;
|
||||
public double OutlineThickness = 0.0;
|
||||
public ChartItemEffect CandleHoverPrefab;
|
||||
public Material Outline;
|
||||
public Material Line;
|
||||
public Material Fill;
|
||||
public GameObject CandlePrefab;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CategoryData : BaseScrollableCategoryData
|
||||
{
|
||||
public List<CandleValue> Data = new List<CandleValue>();
|
||||
public CandleSettings UpCandle = new CandleSettings();
|
||||
public CandleSettings DownCandle = new CandleSettings();
|
||||
public double Depth = 0f;
|
||||
}
|
||||
|
||||
class CandleComparer : IComparer<CandleValue>
|
||||
{
|
||||
public int Compare(CandleValue x, CandleValue y)
|
||||
{
|
||||
if (x.Open < y.Open)
|
||||
return -1;
|
||||
if (x.Open > y.Open)
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
class SerializedCategory
|
||||
{
|
||||
public string Name;
|
||||
[HideInInspector]
|
||||
public CandleValue[] Data;
|
||||
[HideInInspector]
|
||||
public double? MaxX, MaxY, MinX, MinY;
|
||||
public CandleSettings UpCandle = new CandleSettings();
|
||||
public CandleSettings DownCandle = new CandleSettings();
|
||||
public double Depth = 0f;
|
||||
}
|
||||
|
||||
CandleComparer mComparer = new CandleComparer();
|
||||
|
||||
[SerializeField]
|
||||
SerializedCategory[] mSerializedData = new SerializedCategory[0];
|
||||
|
||||
event EventHandler IInternalCandleData.InternalViewPortionChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
ViewPortionChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
ViewPortionChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
event EventHandler IInternalCandleData.InternalDataChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
DataChanged += value;
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
DataChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rename a category. throws and exception on error
|
||||
/// </summary>
|
||||
/// <param name="prevName"></param>
|
||||
/// <param name="newName"></param>
|
||||
public void RenameCategory(string prevName, string newName)
|
||||
{
|
||||
if (prevName == newName)
|
||||
return;
|
||||
if (mData.ContainsKey(newName))
|
||||
throw new ArgumentException(String.Format("A category named {0} already exists", newName));
|
||||
CategoryData cat = (CategoryData)mData[prevName];
|
||||
mData.Remove(prevName);
|
||||
cat.Name = newName;
|
||||
mData.Add(newName, cat);
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new category to the candle chart.
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="innerFill"></param>
|
||||
public void AddCategory(string category, CandleSettings up, CandleSettings down, double depth)
|
||||
{
|
||||
AddCategory3DCandle(category, up, down, 0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add category to the candle chart
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="up"></param>
|
||||
/// <param name="down"></param>
|
||||
/// <param name="depth"></param>
|
||||
public void AddCategory3DCandle(string category, CandleSettings up, CandleSettings down, double depth)
|
||||
{
|
||||
if (mData.ContainsKey(category))
|
||||
throw new ArgumentException(String.Format("A category named {0} already exists", category));
|
||||
CategoryData data = new CategoryData();
|
||||
mData.Add(category, data);
|
||||
data.Name = category;
|
||||
data.DownCandle = down;
|
||||
data.UpCandle = up;
|
||||
data.Depth = depth;
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// removed a category from the DataSource. returnes true on success , or false if the category does not exist
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveCategory(string category)
|
||||
{
|
||||
return mData.Remove(category);
|
||||
}
|
||||
|
||||
public void SetDownCandle(string category, CandleSettings down)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
data.DownCandle = down;
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
public void SetUpCandle(string category, CandleSettings up)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
data.UpCandle = up;
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// sets the depth for a 3d graph category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="depth"></param>
|
||||
public void Set3DCategoryDepth(string category, double depth)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
if (depth < 0)
|
||||
depth = 0f;
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
data.Depth = depth;
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clears all the data for the selected category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
public void ClearCategory(string category)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
mData[category].MaxX = null;
|
||||
mData[category].MaxY = null;
|
||||
mData[category].MinX = null;
|
||||
mData[category].MinY = null;
|
||||
((CategoryData)mData[category]).Data.Clear();
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the candle at the specified index for a given category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public int GetCandleCount(string category)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return 0;
|
||||
}
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
return data.Data.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the candle at the specified index for a given category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public CandleValue GetCandle(string category, int index)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return new CandleValue();
|
||||
}
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
return data.Data[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the total amount of candles in the given category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public int GetTotalCandlesInCategory(string category)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return 0;
|
||||
}
|
||||
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
return data.Data.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// use this to modify candles in realtime.
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="candle"></param>
|
||||
public void ModifyCandleInCategory(string category, int candleIndex, double open, double high, double low, double close)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
List<CandleValue> candles = data.Data;
|
||||
|
||||
if (candleIndex == -1)
|
||||
candleIndex = data.Data.Count - 1;
|
||||
if (candleIndex < 0 || candleIndex >= candles.Count)
|
||||
{
|
||||
Debug.LogWarning("Candle index is out of range, call is ignored");
|
||||
return;
|
||||
}
|
||||
|
||||
double candleMax = Math.Max(Math.Max(open, close), Math.Max(high, low));
|
||||
double candleMin = Math.Min(Math.Min(open, close), Math.Min(high, low));
|
||||
|
||||
if (data.MaxY.HasValue == false || data.MaxY.Value < candleMax)
|
||||
data.MaxY = candleMax;
|
||||
if (data.MinY.HasValue == false || data.MinY.Value > candleMin)
|
||||
data.MinY = candleMin;
|
||||
|
||||
CandleValue candle = data.Data[candleIndex];
|
||||
candle.Open = open;
|
||||
candle.Close = close;
|
||||
candle.High = high;
|
||||
candle.Low = low;
|
||||
data.Data[candleIndex] = candle;
|
||||
RaiseRealtimeDataChanged(candleIndex, category);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// removes a candle from a category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="index"></param>
|
||||
public void RemoveCandleInCategory(string category, int candleIndex)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
List<CandleValue> candles = data.Data;
|
||||
|
||||
if (candleIndex < 0 || candleIndex >= candles.Count)
|
||||
{
|
||||
Debug.LogWarning("Candle index is out of range, call is ignored");
|
||||
return;
|
||||
}
|
||||
|
||||
data.Data.RemoveAt(candleIndex);
|
||||
RaiseRealtimeDataChanged(candleIndex, category);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// use this to modify candles in realtime. this overload modifies the last candle and can be used for realtime candle data stream
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="candle"></param>
|
||||
public void ModifyLastCandleInCategory(string category, double open, double high, double low, double close)
|
||||
{
|
||||
ModifyCandleInCategory(category, -1, open, high, low, close);
|
||||
}
|
||||
|
||||
|
||||
class Slider : BaseSlider
|
||||
{
|
||||
public string category;
|
||||
public double from;
|
||||
public int index;
|
||||
public double to;
|
||||
public double current;
|
||||
public double y;
|
||||
private CandleChartData mParent;
|
||||
|
||||
public Slider(CandleChartData parent)
|
||||
{
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
public override DoubleVector2 Max
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DoubleVector2(current, y);
|
||||
}
|
||||
}
|
||||
|
||||
public override DoubleVector2 Min
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DoubleVector2(current, y);
|
||||
}
|
||||
}
|
||||
|
||||
public override string Category { get { return category; } }
|
||||
|
||||
public override int MinIndex
|
||||
{
|
||||
get { return index; }
|
||||
}
|
||||
public override bool Update()
|
||||
{
|
||||
BaseScrollableCategoryData baseData;
|
||||
|
||||
if (mParent.mData.TryGetValue(category, out baseData) == false)
|
||||
return true;
|
||||
|
||||
double time = Time.time;
|
||||
time -= StartTime;
|
||||
|
||||
if (Duration <= 0.0001f)
|
||||
time = 1f;
|
||||
else
|
||||
{
|
||||
time /= Duration;
|
||||
Math.Max(0.0, Math.Min(time, 1.0));
|
||||
}
|
||||
|
||||
current = from * (1.0 - time) + to * time;
|
||||
if (time >= 1f)
|
||||
{
|
||||
mParent.ModifyMinMax(baseData, new DoubleVector3(current, y, 0.0));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adds a point to the category. The points are sorted by their x value automatically
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="point"></param>
|
||||
public void AddCandleToCategory(string category, CandleValue candle, float autoScrollSlideTime = 0f)
|
||||
{
|
||||
if (mData.ContainsKey(category) == false)
|
||||
{
|
||||
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
|
||||
return;
|
||||
}
|
||||
|
||||
CategoryData data = (CategoryData)mData[category];
|
||||
List<CandleValue> candles = data.Data;
|
||||
|
||||
double start = candle.Start;
|
||||
double end = candle.Start + candle.Duration;
|
||||
|
||||
double candleMax = Math.Max(Math.Max(candle.Open, candle.Close), Math.Max(candle.High, candle.Low));
|
||||
double candleMin = Math.Min(Math.Min(candle.Open, candle.Close), Math.Min(candle.High, candle.Low));
|
||||
|
||||
|
||||
if (autoScrollSlideTime <= 0f)
|
||||
{
|
||||
if (data.MaxX.HasValue == false || data.MaxX.Value < end)
|
||||
data.MaxX = end;
|
||||
}
|
||||
if (data.MinX.HasValue == false || data.MinX.Value > start)
|
||||
data.MinX = start;
|
||||
if (data.MaxY.HasValue == false || data.MaxY.Value < candleMax)
|
||||
data.MaxY = candleMax;
|
||||
if (data.MinY.HasValue == false || data.MinY.Value > candleMin)
|
||||
data.MinY = candleMin;
|
||||
|
||||
if (candles.Count > 0)
|
||||
{
|
||||
if (candles[candles.Count - 1].Start < candle.Start)
|
||||
{
|
||||
if (autoScrollSlideTime > 0f)
|
||||
{
|
||||
Slider s = new Slider(this);
|
||||
s.category = category;
|
||||
s.from = candles[candles.Count - 1].End;
|
||||
s.to = end;
|
||||
s.StartTime = Time.time;
|
||||
s.Duration = autoScrollSlideTime;
|
||||
s.y = (candleMax + candleMin) * 0.5;
|
||||
s.index = candles.Count - 1;
|
||||
mSliders.Add(s);
|
||||
}
|
||||
candles.Add(candle);
|
||||
RaiseRealtimeDataChanged(candles.Count-1, category);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int search = candles.BinarySearch(candle, mComparer);
|
||||
if (search < 0)
|
||||
search = ~search;
|
||||
candles.Insert(search, candle);
|
||||
RaiseRealtimeDataChanged(search, category);
|
||||
}
|
||||
|
||||
double IInternalCandleData.GetMaxValue(int axis, bool dataValue)
|
||||
{
|
||||
return GetMaxValue(axis, dataValue);
|
||||
}
|
||||
|
||||
double IInternalCandleData.GetMinValue(int axis, bool dataValue)
|
||||
{
|
||||
return GetMinValue(axis, dataValue);
|
||||
}
|
||||
|
||||
public override void OnAfterDeserialize()
|
||||
{
|
||||
if (mSerializedData == null)
|
||||
return;
|
||||
mData.Clear();
|
||||
mSuspendEvents = true;
|
||||
for (int i = 0; i < mSerializedData.Length; i++)
|
||||
{
|
||||
SerializedCategory cat = mSerializedData[i];
|
||||
if (cat.Depth < 0)
|
||||
cat.Depth = 0f;
|
||||
string name = cat.Name;
|
||||
AddCategory3DCandle(name, cat.UpCandle, cat.DownCandle, cat.Depth);
|
||||
CategoryData data = (CategoryData)mData[name];
|
||||
data.Data.AddRange(cat.Data);
|
||||
data.MaxX = cat.MaxX;
|
||||
data.MaxY = cat.MaxY;
|
||||
data.MinX = cat.MinX;
|
||||
data.MinY = cat.MinY;
|
||||
}
|
||||
mSuspendEvents = false;
|
||||
}
|
||||
|
||||
public override void OnBeforeSerialize()
|
||||
{
|
||||
List<SerializedCategory> serialized = new List<SerializedCategory>();
|
||||
foreach (KeyValuePair<string, CategoryData> pair in mData.Select(x => new KeyValuePair<string, CategoryData>(x.Key, (CategoryData)x.Value)))
|
||||
{
|
||||
SerializedCategory cat = new SerializedCategory();
|
||||
cat.Name = pair.Key;
|
||||
cat.MaxX = pair.Value.MaxX;
|
||||
cat.MinX = pair.Value.MinX;
|
||||
cat.MaxY = pair.Value.MaxY;
|
||||
cat.MinY = pair.Value.MinY;
|
||||
cat.UpCandle = pair.Value.UpCandle;
|
||||
cat.DownCandle = pair.Value.DownCandle;
|
||||
cat.Depth = pair.Value.Depth;
|
||||
cat.Data = pair.Value.Data.ToArray();
|
||||
if (cat.Depth < 0)
|
||||
cat.Depth = 0f;
|
||||
serialized.Add(cat);
|
||||
}
|
||||
mSerializedData = serialized.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public override BaseScrollableCategoryData GetDefaultCategory()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void InnerClearCategory(string category)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void AppendDatum(string category, MixedSeriesGenericValue value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void AppendDatum(string category, IList<MixedSeriesGenericValue> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override bool AddCategory(string category, BaseScrollableCategoryData data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int IInternalCandleData.TotalCategories
|
||||
{
|
||||
get { return mData.Count; }
|
||||
}
|
||||
|
||||
event Action<int,string> IInternalCandleData.InternalRealTimeDataChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
RealtimeDataChanged += value;
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
RealtimeDataChanged -= value;
|
||||
}
|
||||
}
|
||||
IEnumerable<CategoryData> IInternalCandleData.Categories
|
||||
{
|
||||
get
|
||||
{
|
||||
return mData.Values.Select(x => (CategoryData)x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8db3da49553a7d449f2082158192d56
|
||||
timeCreated: 1491152608
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,136 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class CanvasCandle : MonoBehaviour, ICandleCreator
|
||||
{
|
||||
List<CandleChartData.CandleValue> mEmptyCandle = new List<CandleChartData.CandleValue>();
|
||||
HashSet<CanvasCandleGraphic> mOccupied = new HashSet<CanvasCandleGraphic>();
|
||||
CanvasCandleGraphic mCandle, mLine;
|
||||
CanvasCandleGraphic mOutline;
|
||||
/// <summary>
|
||||
/// The selected index is hovered about the specified point
|
||||
/// </summary>
|
||||
public event EventHandlingGraphic.GraphicEvent Hover;
|
||||
/// <summary>
|
||||
/// The selected index is clicked about the specified point
|
||||
/// </summary>
|
||||
public event EventHandlingGraphic.GraphicEvent Click;
|
||||
/// <summary>
|
||||
/// The currently hovered and selected objects are no longer selected or hovered.
|
||||
/// </summary>
|
||||
public event Action Leave;
|
||||
|
||||
private CanvasCandleGraphic CreateCandleGraphic()
|
||||
{
|
||||
GameObject obj = ChartCommon.CreateCanvasChartItem();
|
||||
CanvasCandleGraphic graphic = obj.AddComponent<CanvasCandleGraphic>();
|
||||
graphic.maskable = true;
|
||||
RectTransform rect = obj.GetComponent<RectTransform>();
|
||||
rect.SetParent(transform, false);
|
||||
rect.anchoredPosition = Vector3.zero;
|
||||
rect.rotation = Quaternion.identity;
|
||||
rect.localScale = new Vector3(1f, 1f, 1f);
|
||||
HookEventsForGraphic(graphic);
|
||||
return graphic;
|
||||
}
|
||||
|
||||
void HookEventsForGraphic(CanvasCandleGraphic graphic)
|
||||
{
|
||||
graphic.Hover += (index, type, data, position) => { Candle_Hover(graphic, index, type, data, position); };
|
||||
graphic.Click += (index, type, data, position) => { Candle_Click(graphic, index, type, data, position); }; ;
|
||||
graphic.Leave += () => { Candle_Leave(graphic); };
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ChartCommon.SafeDestroy(mCandle);
|
||||
ChartCommon.SafeDestroy(mLine);
|
||||
ChartCommon.SafeDestroy(mOutline);
|
||||
}
|
||||
public void SetRefrenceIndex(int index)
|
||||
{
|
||||
if (mCandle != null)
|
||||
mCandle.SetRefrenceIndex(index);
|
||||
if (mLine != null)
|
||||
mCandle.SetRefrenceIndex(index);
|
||||
if (mOutline != null)
|
||||
mOutline.SetRefrenceIndex(index);
|
||||
|
||||
}
|
||||
public void Generate(CandleChart parent, Rect viewRect, IList<CandleChartData.CandleValue> value, CandleChartData.CandleSettings settings)
|
||||
{
|
||||
|
||||
if (parent.IsCanvas == false)
|
||||
{
|
||||
Debug.LogWarning("prefab is meant to be used with canvas candle chart only");
|
||||
return;
|
||||
}
|
||||
if (mCandle == null)
|
||||
mCandle = CreateCandleGraphic();
|
||||
if (settings.Fill == null || settings.CandleThicknessMultiplier < 0.0001f)
|
||||
mCandle.SetCandle(0, mEmptyCandle, settings);
|
||||
else
|
||||
mCandle.SetCandle(0, value, settings);
|
||||
mCandle.HoverTransform(transform);
|
||||
mCandle.SetViewRect(viewRect, new Rect());
|
||||
mCandle.SetHoverPrefab(settings.CandleHoverPrefab);
|
||||
mCandle.material = settings.Fill;
|
||||
|
||||
|
||||
if (mLine == null)
|
||||
mLine = CreateCandleGraphic();
|
||||
if (settings.Line == null || settings.LineThickness < 0.0001f)
|
||||
mLine.SetCandle(1, mEmptyCandle, settings);
|
||||
else
|
||||
mLine.SetCandle(1, value, settings);
|
||||
mLine.HoverTransform(transform);
|
||||
mLine.SetHoverPrefab(settings.CandleHoverPrefab);
|
||||
mLine.material = settings.Line;
|
||||
mLine.SetViewRect(viewRect, new Rect());
|
||||
|
||||
if (mOutline == null)
|
||||
mOutline = CreateCandleGraphic();
|
||||
mOutline.material = settings.Outline;
|
||||
mOutline.SetViewRect(viewRect, new Rect());
|
||||
if (settings.Outline == null || settings.OutlineThickness < 0.0001f)
|
||||
mOutline.SetCandle(2, mEmptyCandle, settings);
|
||||
else
|
||||
mOutline.SetCandle(2, value, settings);
|
||||
}
|
||||
|
||||
private void Candle_Leave(CanvasCandleGraphic graphic)
|
||||
{
|
||||
if (mOccupied.Remove(graphic))
|
||||
{
|
||||
if (mOccupied.Count == 0)
|
||||
{
|
||||
if (Leave != null)
|
||||
Leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Candle_Click(CanvasCandleGraphic graphic, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
mOccupied.Add(graphic);
|
||||
position = graphic.transform.TransformPoint(position);
|
||||
if (Click != null)
|
||||
Click(index, type, data, position);
|
||||
}
|
||||
|
||||
private void Candle_Hover(CanvasCandleGraphic graphic, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
mOccupied.Add(graphic);
|
||||
position = graphic.transform.TransformPoint(position);
|
||||
if (Hover != null)
|
||||
Hover(index, type, data, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 663704866ea20c443b89affc7c7efb2f
|
||||
timeCreated: 1491395378
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,548 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class CanvasCandleChart : CandleChart
|
||||
{
|
||||
List<CandleChartData.CandleValue> mClipped = new List<CandleChartData.CandleValue>();
|
||||
List<CandleChartData.CandleValue> mTransformed = new List<CandleChartData.CandleValue>();
|
||||
List<CandleChartData.CandleValue> mCurrentSeries = new List<CandleChartData.CandleValue>();
|
||||
int mTmpCurrentIndex = 0;
|
||||
List<int> mUpToIndex = new List<int>();
|
||||
List<int> mDownToIndex = new List<int>();
|
||||
Dictionary<string, CategoryObject> mCategoryObjects = new Dictionary<string, CategoryObject>();
|
||||
|
||||
StringBuilder mRealtimeStringBuilder = new StringBuilder();
|
||||
HashSet<string> mOccupiedCateogies = new HashSet<string>();
|
||||
List<int> mTmpToRemove = new List<int>();
|
||||
private bool SupressRealtimeGeneration = false;
|
||||
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private bool fitToContainer = false;
|
||||
public bool FitToContainer
|
||||
{
|
||||
get { return fitToContainer; }
|
||||
set
|
||||
{
|
||||
fitToContainer = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private ChartMagin fitMargin;
|
||||
public ChartMagin FitMargin
|
||||
{
|
||||
get { return fitMargin; }
|
||||
set
|
||||
{
|
||||
fitMargin = value;
|
||||
OnPropertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
protected override float TotalDepthLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SupportRealtimeGeneration
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsCanvas
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class CategoryObject
|
||||
{
|
||||
public CanvasChartMesh mItemLabels;
|
||||
public CanvasCandle mUp;
|
||||
public CanvasCandle mDown;
|
||||
public Dictionary<int, string> mCahced = new Dictionary<int, string>();
|
||||
public HashSet<CanvasCandle> mOccupiedCandles = new HashSet<CanvasCandle>();
|
||||
private CanvasCandleChart mParent;
|
||||
/// <summary>
|
||||
/// The selected index is hovered about the specified point
|
||||
/// </summary>
|
||||
public event EventHandlingGraphic.GraphicEvent Hover;
|
||||
/// <summary>
|
||||
/// The selected index is clicked about the specified point
|
||||
/// </summary>
|
||||
public event EventHandlingGraphic.GraphicEvent Click;
|
||||
/// <summary>
|
||||
/// The currently hovered and selected objects are no longer selected or hovered.
|
||||
/// </summary>
|
||||
public event Action Leave;
|
||||
|
||||
public CategoryObject(CanvasCandleChart parent)
|
||||
{
|
||||
mParent = parent;
|
||||
}
|
||||
public void HookEvents()
|
||||
{
|
||||
HookEvents(mUp, true);
|
||||
HookEvents(mDown, false);
|
||||
}
|
||||
|
||||
void HookEvents(CanvasCandle candle, bool isUp)
|
||||
{
|
||||
if (candle == null)
|
||||
return;
|
||||
candle.Leave += () => mLeave(candle);
|
||||
candle.Hover += (index, type, data, position) => { mHover(candle, mParent.MapIndex(index, isUp), type, data, position); };
|
||||
candle.Click += (index, type, data, position) => { mClick(candle, mParent.MapIndex(index, isUp), type, data, position); };
|
||||
}
|
||||
|
||||
private void mClick(CanvasCandle candle, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
mOccupiedCandles.Add(candle);
|
||||
if (Click != null)
|
||||
Click(index, type, data, position);
|
||||
|
||||
}
|
||||
|
||||
private void mHover(CanvasCandle candle, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
mOccupiedCandles.Add(candle);
|
||||
if (Hover != null)
|
||||
Hover(index, type, data, position);
|
||||
}
|
||||
|
||||
private void mLeave(CanvasCandle candle)
|
||||
{
|
||||
if (mOccupiedCandles.Remove(candle))
|
||||
{
|
||||
if (mOccupiedCandles.Count == 0)
|
||||
{
|
||||
if (Leave != null)
|
||||
Leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override bool ShouldFitCanvas { get { return true; } }
|
||||
protected override FitType FitAspectCanvas
|
||||
{
|
||||
get
|
||||
{
|
||||
return FitType.Aspect;
|
||||
}
|
||||
}
|
||||
private CanvasCandle CreateDataObject(CandleChartData.CategoryData data, GameObject rectMask)
|
||||
{
|
||||
GameObject obj = new GameObject("Candles", typeof(RectTransform));
|
||||
ChartCommon.HideObject(obj, hideHierarchy);
|
||||
obj.AddComponent<ChartItem>();
|
||||
RectTransform t = obj.GetComponent<RectTransform>();
|
||||
obj.AddComponent<CanvasRenderer>();
|
||||
CanvasCandle candles = obj.AddComponent<CanvasCandle>();
|
||||
t.SetParent(rectMask.transform, false);
|
||||
t.localScale = new Vector3(1f, 1f, 1f);
|
||||
t.anchorMin = new Vector2(0f, 0f);
|
||||
t.anchorMax = new Vector2(1f, 1f);
|
||||
t.sizeDelta = new Vector2(0f, 0f);
|
||||
t.anchorMin = new Vector2(0f, 0f);
|
||||
t.anchorMax = new Vector2(0f, 0f);
|
||||
|
||||
t.anchoredPosition = Vector3.zero;
|
||||
return candles;
|
||||
}
|
||||
|
||||
protected override double GetCategoryDepth(string category)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public override void GenerateRealtime()
|
||||
{
|
||||
if (SupressRealtimeGeneration)
|
||||
return;
|
||||
|
||||
base.GenerateRealtime();
|
||||
|
||||
double minX = ((IInternalCandleData)Data).GetMinValue(0, false);
|
||||
double minY = ((IInternalCandleData)Data).GetMinValue(1, false);
|
||||
double maxX = ((IInternalCandleData)Data).GetMaxValue(0, false);
|
||||
double maxY = ((IInternalCandleData)Data).GetMaxValue(1, false);
|
||||
|
||||
double xScroll = GetScrollOffset(0);
|
||||
double yScroll = GetScrollOffset(1);
|
||||
double xSize = maxX - minX;
|
||||
double ySize = maxY - minY;
|
||||
double xOut = minX + xScroll + xSize;
|
||||
double yOut = minY + yScroll + ySize;
|
||||
|
||||
DoubleVector3 min = new DoubleVector3(xScroll + minX, yScroll + minY);
|
||||
DoubleVector3 max = new DoubleVector3(xOut, yOut);
|
||||
|
||||
Rect viewRect = new Rect(0f, 0f, widthRatio, heightRatio);
|
||||
|
||||
ClearBillboardCategories();
|
||||
bool edit = false;
|
||||
|
||||
foreach (CandleChartData.CategoryData data in ((IInternalCandleData)Data).Categories)
|
||||
{
|
||||
CategoryObject obj = null;
|
||||
|
||||
if (mCategoryObjects.TryGetValue(data.Name, out obj) == false)
|
||||
continue;
|
||||
|
||||
mClipped.Clear();
|
||||
mTransformed.Clear();
|
||||
int refrenceIndex = ClipCandles(data.Data, mClipped);
|
||||
|
||||
TransformCandles(mClipped, mTransformed, viewRect, min, max);
|
||||
|
||||
if (data.Data.Count == 0 && ChartCommon.IsInEditMode)
|
||||
{
|
||||
edit = true;
|
||||
}
|
||||
|
||||
mTmpToRemove.Clear();
|
||||
int range = refrenceIndex + mClipped.Count;
|
||||
foreach (int key in obj.mCahced.Keys)
|
||||
{
|
||||
if (key < refrenceIndex || key > range)
|
||||
mTmpToRemove.Add(key);
|
||||
}
|
||||
|
||||
for (int i = 0; i < mTmpToRemove.Count; i++)
|
||||
obj.mCahced.Remove(mTmpToRemove[i]);
|
||||
|
||||
obj.mCahced.Remove(data.Data.Count - 1); // never store the last point cache , it might be intepolating by the realtime feature
|
||||
|
||||
if (data.Data.Count == 0)
|
||||
continue;
|
||||
|
||||
GenerateItemLabels(true, obj, data, viewRect, refrenceIndex, edit);
|
||||
|
||||
if (obj.mUp != null)
|
||||
{
|
||||
FillCurrentSeries(true, refrenceIndex);
|
||||
obj.mUp.Generate(this, viewRect, mCurrentSeries, data.UpCandle);
|
||||
}
|
||||
if (obj.mDown != null)
|
||||
{
|
||||
FillCurrentSeries(false, refrenceIndex);
|
||||
obj.mDown.Generate(this, viewRect, mCurrentSeries, data.DownCandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ClearChart()
|
||||
{
|
||||
base.ClearChart();
|
||||
ClearBillboard();
|
||||
mActiveTexts.Clear();
|
||||
mCategoryObjects.Clear();
|
||||
}
|
||||
|
||||
void GenerateItemLabels(bool realTime, CategoryObject categoryObj, CandleChartData.CategoryData data, Rect viewRect, int refrenceIndex, bool edit)
|
||||
{
|
||||
if (mItemLabels != null && mItemLabels.isActiveAndEnabled)
|
||||
{
|
||||
CanvasChartMesh m = null;
|
||||
if (realTime)
|
||||
{
|
||||
m = categoryObj.mItemLabels;
|
||||
if (m == null)
|
||||
return;
|
||||
m.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m = new CanvasChartMesh(true);
|
||||
m.RecycleText = true;
|
||||
categoryObj.mItemLabels = m;
|
||||
}
|
||||
|
||||
Rect textRect = viewRect;
|
||||
textRect.xMin -= 1f;
|
||||
textRect.yMin -= 1f;
|
||||
textRect.xMax += 1f;
|
||||
textRect.yMax += 1f;
|
||||
|
||||
for (int i = 0; i < mTransformed.Count; i++)
|
||||
{
|
||||
Vector2 pointValue = mTransformed[i].MidPoint.ToVector2();
|
||||
|
||||
if (textRect.Contains(pointValue) == false)
|
||||
continue;
|
||||
|
||||
CandleChartData.CandleValue candleVal = mTransformed[i];
|
||||
int candleIndex = i + refrenceIndex;
|
||||
if (edit == false)
|
||||
candleVal = data.Data[i + refrenceIndex];
|
||||
Vector3 labelPos = ((Vector3)pointValue) + new Vector3(mItemLabels.Location.Breadth, mItemLabels.Seperation, mItemLabels.Location.Depth);
|
||||
if (mItemLabels.Alignment == ChartLabelAlignment.Base)
|
||||
labelPos.y -= (float)mTransformed[i].MidPoint.y;
|
||||
|
||||
string toSet;
|
||||
if (realTime == false || categoryObj.mCahced.TryGetValue(candleIndex, out toSet) == false)
|
||||
{
|
||||
string Open = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mVerticalAxis, false);
|
||||
string Close = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Close, 0.0), mVerticalAxis, false);
|
||||
string High = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.High, 0.0), mVerticalAxis, false);
|
||||
string Low = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Low, 0.0), mVerticalAxis, false);
|
||||
string Start = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mHorizontalAxis, true);
|
||||
string Duration = StringFromAxisFormat(new DoubleVector3(candleVal.Duration, candleVal.Open, 0.0), mHorizontalAxis, true);
|
||||
FormatItem(mRealtimeStringBuilder, Open, Close, High, Low, Start, Duration);
|
||||
toSet = mItemLabels.TextFormat.Format(mRealtimeStringBuilder.ToString(), data.Name, "");
|
||||
categoryObj.mCahced[candleIndex] = toSet;
|
||||
}
|
||||
labelPos -= new Vector3(CanvasFitOffset.x * TotalWidth, CanvasFitOffset.y * TotalHeight, 0f);
|
||||
BillboardText billboard = m.AddText(this, mItemLabels.TextPrefab, transform, mItemLabels.FontSize, mItemLabels.FontSharpness, toSet, labelPos.x, labelPos.y, labelPos.z, 0f, null);
|
||||
TextController.AddText(billboard);
|
||||
AddBillboardText(data.Name, i + refrenceIndex, billboard);
|
||||
}
|
||||
|
||||
if (realTime)
|
||||
{
|
||||
m.DestoryRecycled();
|
||||
if (m.TextObjects != null)
|
||||
{
|
||||
foreach (BillboardText text in m.TextObjects)
|
||||
{
|
||||
((IInternalUse)this).InternalTextController.AddText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool UpPredicate(CandleChartData.CandleValue x)
|
||||
{
|
||||
if (x.isUp)
|
||||
mUpToIndex.Add(mTmpCurrentIndex);
|
||||
mTmpCurrentIndex++;
|
||||
return x.isUp;
|
||||
}
|
||||
bool DownPredicate(CandleChartData.CandleValue x)
|
||||
{
|
||||
if (x.isUp == false)
|
||||
mDownToIndex.Add(mTmpCurrentIndex);
|
||||
mTmpCurrentIndex++;
|
||||
return !x.isUp;
|
||||
}
|
||||
void FillCurrentSeries(bool isUp, int refrenceIndex)
|
||||
{
|
||||
mTmpCurrentIndex = refrenceIndex;
|
||||
mCurrentSeries.Clear();
|
||||
if (isUp)
|
||||
{
|
||||
mUpToIndex.Clear();
|
||||
mCurrentSeries.AddRange(mTransformed.Where(UpPredicate));
|
||||
}
|
||||
else
|
||||
{
|
||||
mDownToIndex.Clear();
|
||||
mCurrentSeries.AddRange(mTransformed.Where(DownPredicate));
|
||||
}
|
||||
}
|
||||
|
||||
int MapIndex(int index, bool isUp)
|
||||
{
|
||||
if (isUp)
|
||||
{
|
||||
if (mUpToIndex.Count <= index)
|
||||
return index;
|
||||
return mUpToIndex[index];
|
||||
}
|
||||
if (mDownToIndex.Count <= index)
|
||||
return index;
|
||||
return mDownToIndex[index];
|
||||
}
|
||||
|
||||
public override void InternalGenerateChart()
|
||||
{
|
||||
if (gameObject.activeInHierarchy == false)
|
||||
return;
|
||||
base.InternalGenerateChart();
|
||||
|
||||
if (FitToContainer)
|
||||
{
|
||||
RectTransform trans = GetComponent<RectTransform>();
|
||||
widthRatio = trans.rect.width;
|
||||
heightRatio = trans.rect.height;
|
||||
}
|
||||
ClearChart();
|
||||
|
||||
if (Data == null)
|
||||
return;
|
||||
GenerateAxis(true);
|
||||
|
||||
double minX = ((IInternalCandleData)Data).GetMinValue(0, false);
|
||||
double minY = ((IInternalCandleData)Data).GetMinValue(1, false);
|
||||
double maxX = ((IInternalCandleData)Data).GetMaxValue(0, false);
|
||||
double maxY = ((IInternalCandleData)Data).GetMaxValue(1, false);
|
||||
|
||||
double xScroll = GetScrollOffset(0);
|
||||
double yScroll = GetScrollOffset(1);
|
||||
double xSize = maxX - minX;
|
||||
double ySize = maxY - minY;
|
||||
double xOut = minX + xScroll + xSize;
|
||||
double yOut = minY + yScroll + ySize;
|
||||
|
||||
DoubleVector3 min = new DoubleVector3(xScroll + minX, yScroll + minY);
|
||||
DoubleVector3 max = new DoubleVector3(xOut, yOut);
|
||||
|
||||
Rect viewRect = new Rect(0f, 0f, widthRatio, heightRatio);
|
||||
|
||||
int total = ((IInternalCandleData)Data).TotalCategories + 1;
|
||||
bool edit = false;
|
||||
ClearBillboard();
|
||||
mActiveTexts.Clear();
|
||||
int index = 0;
|
||||
GameObject mask = CreateRectMask(viewRect);
|
||||
|
||||
foreach (CandleChartData.CategoryData data in ((IInternalCandleData)Data).Categories)
|
||||
{
|
||||
mClipped.Clear();
|
||||
mTransformed.Clear();
|
||||
int refrenceIndex = ClipCandles(data.Data, mClipped);
|
||||
|
||||
TransformCandles(mClipped, mTransformed, viewRect, min, max);
|
||||
|
||||
if (data.Data.Count == 0 && ChartCommon.IsInEditMode)
|
||||
{
|
||||
int tmpIndex = total - 1 - index;
|
||||
float low = (((float)tmpIndex) / (float)total);
|
||||
float high = (((float)tmpIndex + 1) / (float)total);
|
||||
float y1 = Mathf.Lerp(high, low, 0.6f);
|
||||
float y2 = Mathf.Lerp(high, low, 0.3f);
|
||||
mTransformed.Clear();
|
||||
mTransformed.Add(InterpolateCandleInRect(new CandleChartData.CandleValue(y1, high, low, y2, 0.1, 0.1), viewRect));
|
||||
mTransformed.Add(InterpolateCandleInRect(new CandleChartData.CandleValue(y1, low, high, y2, 0.5, 0.2), viewRect));
|
||||
edit = true;
|
||||
index++;
|
||||
}
|
||||
CategoryObject categoryObj = new CategoryObject(this);
|
||||
CanvasCandle up = CreateDataObject(data, mask);
|
||||
CanvasCandle down = CreateDataObject(data, mask);
|
||||
|
||||
FillCurrentSeries(true, refrenceIndex);
|
||||
up.Generate(this, viewRect, mCurrentSeries, data.UpCandle);
|
||||
|
||||
FillCurrentSeries(false, refrenceIndex);
|
||||
down.Generate(this, viewRect, mCurrentSeries, data.DownCandle);
|
||||
|
||||
string catName = data.Name;
|
||||
|
||||
categoryObj.mUp = up;
|
||||
categoryObj.mDown = down;
|
||||
categoryObj.HookEvents();
|
||||
|
||||
GenerateItemLabels(false, categoryObj, data, viewRect, refrenceIndex, edit);
|
||||
|
||||
categoryObj.Hover += (idx, t, d, pos) => { Category_Hover(catName, idx, t, d, pos); };
|
||||
categoryObj.Click += (idx, t, d, pos) => { Category_Click(catName, idx, t, d, pos); };
|
||||
categoryObj.Leave += () => { Category_Leave(catName); };
|
||||
mCategoryObjects[catName] = categoryObj;
|
||||
}
|
||||
}
|
||||
|
||||
void Category_Hover(string category, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
CandleChartData.CandleValue candle = Data.GetCandle(category, index);
|
||||
Dictionary<int, BillboardText> catgoryTexts;
|
||||
BillboardText b;
|
||||
|
||||
if (mTexts.TryGetValue(category, out catgoryTexts))
|
||||
{
|
||||
if (catgoryTexts.TryGetValue(index, out b))
|
||||
SelectActiveText(b);
|
||||
}
|
||||
Rect selection = new Rect();
|
||||
if (data != null && data is Rect)
|
||||
selection = (Rect)data;
|
||||
OnItemHoverted(new CandleEventArgs(index, type, selection, position, candle, category));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// handles click of the category
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="position"></param>
|
||||
void Category_Click(string category, int index, int type, object data, Vector2 position)
|
||||
{
|
||||
CandleChartData.CandleValue candle = Data.GetCandle(category, index);
|
||||
Dictionary<int, BillboardText> catgoryTexts;
|
||||
BillboardText b;
|
||||
|
||||
if (mTexts.TryGetValue(category, out catgoryTexts))
|
||||
{
|
||||
if (catgoryTexts.TryGetValue(index, out b))
|
||||
SelectActiveText(b);
|
||||
}
|
||||
|
||||
Rect selection = new Rect();
|
||||
if (data != null && data is Rect)
|
||||
selection = (Rect)data;
|
||||
OnItemSelected(new CandleEventArgs(index, type, selection, position, candle, category));
|
||||
}
|
||||
|
||||
void Category_Leave(string cat)
|
||||
{
|
||||
TriggerActiveTextsOut();
|
||||
OnItemLeave(new CandleEventArgs(0, 0, new Rect(), new Vector3(), new CandleChartData.CandleValue(), cat),"none");
|
||||
}
|
||||
|
||||
protected override void OnItemHoverted(object userData)
|
||||
{
|
||||
base.OnItemHoverted(userData);
|
||||
var args = userData as CandleEventArgs;
|
||||
mOccupiedCateogies.Add(args.Category);
|
||||
}
|
||||
|
||||
protected override void OnItemSelected(object userData)
|
||||
{
|
||||
base.OnItemSelected(userData);
|
||||
var args = userData as CandleEventArgs;
|
||||
mOccupiedCateogies.Add(args.Category);
|
||||
}
|
||||
|
||||
protected override void OnItemLeave(object userData,string type)
|
||||
{
|
||||
//base.OnItemLeave(userData);
|
||||
CandleEventArgs args = userData as CandleEventArgs;
|
||||
if (args == null)
|
||||
return;
|
||||
|
||||
string category = args.Category;
|
||||
mOccupiedCateogies.Remove(category);
|
||||
mOccupiedCateogies.RemoveWhere(x => !Data.HasCategory(x));
|
||||
if (mOccupiedCateogies.Count == 0)
|
||||
{
|
||||
if (NonHovered != null)
|
||||
NonHovered.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void SetAsMixedSeries()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25a10981261111f4bbc2ed5f2cd476f7
|
||||
timeCreated: 1501868716
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,506 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class CanvasCandleGraphic : EventHandlingGraphic
|
||||
{
|
||||
CandleChartData.CandleSettings mCandleSettings;
|
||||
List<CandleChartData.CandleValue> mCandles = new List<CandleChartData.CandleValue>();
|
||||
|
||||
int mPart;
|
||||
UIVertex[] mTmpVerts = new UIVertex[4];
|
||||
Vector2 mMin, mMax;
|
||||
|
||||
protected override Vector2 Min
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMin;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector2 Max
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMax;
|
||||
}
|
||||
}
|
||||
|
||||
protected Rect RectFromIndex(int index, int type, Rect Default)
|
||||
{
|
||||
if (index >= mCandles.Count)
|
||||
return Default;
|
||||
CandleChartData.CandleValue candle = mCandles[index];
|
||||
float max = (float)candle.Max;
|
||||
float min = (float)candle.Min;
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
|
||||
if (type == 0)
|
||||
return ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, max, (float)candle.High);
|
||||
if (type == 2)
|
||||
return ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, (float)candle.Low, min);
|
||||
return ChartCommon.RectFromCenter(mid, (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration), min, max);
|
||||
}
|
||||
|
||||
protected override void SetUpHoverObject(ChartItemEffect hover, int index, int type, object selectionData)
|
||||
{
|
||||
Rect selectionRect = (Rect)selectionData;
|
||||
selectionRect = RectFromIndex(index, type, selectionRect);
|
||||
hover.ItemData = selectionRect;
|
||||
SetupHoverObjectToRect(hover, index, type, selectionRect);
|
||||
}
|
||||
|
||||
protected void PickLine(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
|
||||
{
|
||||
pickedIndex = -1;
|
||||
pickedType = -1;
|
||||
selectionData = null;
|
||||
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = mCandles[i];
|
||||
|
||||
float max = (float)candle.Max;
|
||||
float min = (float)candle.Min;
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
|
||||
Rect high = ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, max, (float)candle.High);
|
||||
Rect low = ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, (float)candle.Low, min);
|
||||
if (high.Contains(mouse))
|
||||
{
|
||||
selectionData = high;
|
||||
pickedType = 0;
|
||||
pickedIndex = i;
|
||||
return;
|
||||
}
|
||||
|
||||
if (low.Contains(mouse))
|
||||
{
|
||||
selectionData = low;
|
||||
pickedType = 2;
|
||||
pickedIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void PickBody(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
|
||||
{
|
||||
pickedIndex = -1;
|
||||
pickedType = -1;
|
||||
selectionData = null;
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = mCandles[i];
|
||||
float max = (float)candle.Max;
|
||||
float min = (float)candle.Min;
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
Rect Body = ChartCommon.RectFromCenter(mid, (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration), min, max);
|
||||
|
||||
if (Body.Contains(mouse))
|
||||
{
|
||||
selectionData = Body;
|
||||
pickedType = 1;
|
||||
pickedIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Pick(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
|
||||
{
|
||||
if (mPart == 0)
|
||||
PickBody(mouse, out pickedIndex, out pickedType, out selectionData);
|
||||
else
|
||||
PickLine(mouse, out pickedIndex, out pickedType, out selectionData);
|
||||
if (pickedIndex >= 0)
|
||||
pickedIndex += refrenceIndex;
|
||||
}
|
||||
|
||||
protected override float MouseInThreshold
|
||||
{
|
||||
get
|
||||
{
|
||||
return Sensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearCandles()
|
||||
{
|
||||
mCandles = null;
|
||||
SetAllDirty();
|
||||
Rebuild(CanvasUpdate.PreRender);
|
||||
}
|
||||
|
||||
public void SetCandle(int part, IList<CandleChartData.CandleValue> candles, CandleChartData.CandleSettings settings)
|
||||
{
|
||||
mPart = part;
|
||||
mCandles.Clear();
|
||||
mCandles.AddRange(candles);
|
||||
mCandleSettings = settings;
|
||||
double minX = double.PositiveInfinity;
|
||||
double minY = double.PositiveInfinity;
|
||||
double maxX = double.NegativeInfinity;
|
||||
double maxY = double.NegativeInfinity;
|
||||
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
var candle = mCandles[i];
|
||||
minY = Math.Min(candle.LowBound, minY);
|
||||
maxY = Math.Max(candle.HighBound, maxY);
|
||||
minX = Math.Min(minX, candle.Start);
|
||||
maxX = Math.Max(maxX, candle.Start + candle.Duration);
|
||||
}
|
||||
mMin = new Vector2((float)minX, (float)minY);
|
||||
mMax = new Vector2((float)maxX, (float)maxY);
|
||||
|
||||
SetAllDirty();
|
||||
Rebuild(CanvasUpdate.PreRender);
|
||||
SetUpAllHoverObjects();
|
||||
|
||||
|
||||
}
|
||||
|
||||
IEnumerable<UIVertex> getOutline()
|
||||
{
|
||||
UIVertex v = new UIVertex();
|
||||
|
||||
if (mCandles == null)
|
||||
yield break;
|
||||
|
||||
float outlineThickness = (float)mCandleSettings.OutlineThickness * 0.5f;
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = mCandles[i];
|
||||
float max = (float)Math.Max(candle.Open, candle.Close);
|
||||
float min = (float)Math.Min(candle.Open, candle.Close);
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
float thickness = (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration * 0.5);
|
||||
|
||||
//long and dirty part the defines all the verices of the candle outline
|
||||
|
||||
//outline of the body
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid - thickness + outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid - thickness + outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
//outline of the body
|
||||
v.position = new Vector3(mid + thickness - outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid + thickness - outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
//outline of the high line
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
//outline of the high line
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
//outline of the low line
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
//outline of the low line
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
//outline of the low line connection with body
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, min + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, min - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
//outline of the low line connection with body
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, min + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, min - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
//outline of the high line connection with body
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, max - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - thickness - outlineThickness, max + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
//outline of the high line connection with body
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, max - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max - outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + thickness + outlineThickness, max + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max + outlineThickness, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
}
|
||||
}
|
||||
IEnumerable<UIVertex> getCandle()
|
||||
{
|
||||
UIVertex v = new UIVertex();
|
||||
|
||||
if (mCandles == null)
|
||||
yield break;
|
||||
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = mCandles[i];
|
||||
float max = (float)Math.Max(candle.Open, candle.Close);
|
||||
float min = (float)Math.Min(candle.Open, candle.Close);
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
float thickness = (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration * 0.5);
|
||||
|
||||
v.position = new Vector3(mid - thickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid + thickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid - thickness, min, 0f);
|
||||
v.uv0 = new Vector2(-0f, 1f);
|
||||
yield return v;
|
||||
v.position = new Vector3(mid + thickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<UIVertex> getLine()
|
||||
{
|
||||
UIVertex v = new UIVertex();
|
||||
if (mCandles == null)
|
||||
yield break;
|
||||
for (int i = 0; i < mCandles.Count; i++)
|
||||
{
|
||||
CandleChartData.CandleValue candle = mCandles[i];
|
||||
float max = (float)Math.Max(candle.Open, candle.Close);
|
||||
float min = (float)Math.Min(candle.Open, candle.Close);
|
||||
|
||||
float start = (float)candle.Start;
|
||||
float end = (float)(candle.Start + candle.Duration);
|
||||
float mid = (start + end) * 0.5f;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, (float)candle.High, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(0f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min, 0f);
|
||||
v.uv0 = new Vector2(1f, 0f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(0f, 1f);
|
||||
yield return v;
|
||||
|
||||
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, (float)candle.Low, 0f);
|
||||
v.uv0 = new Vector2(1f, 1f);
|
||||
yield return v;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<UIVertex> getVerices()
|
||||
{
|
||||
if (mCandles == null)
|
||||
return new UIVertex[0];
|
||||
if (mPart == 0)
|
||||
return getCandle();
|
||||
else if (mPart == 1)
|
||||
return getLine();
|
||||
return getOutline();
|
||||
}
|
||||
|
||||
#if (!UNITY_5_2_0) && (!UNITY_5_2_1)
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
base.OnPopulateMesh(vh);
|
||||
vh.Clear();
|
||||
int vPos = 0;
|
||||
foreach (UIVertex v in getVerices())
|
||||
{
|
||||
mTmpVerts[vPos++] = v;
|
||||
if (vPos == 4)
|
||||
{
|
||||
UIVertex tmp = mTmpVerts[2];
|
||||
mTmpVerts[2] = mTmpVerts[3];
|
||||
mTmpVerts[3] = tmp;
|
||||
vPos = 0;
|
||||
vh.AddUIVertexQuad(mTmpVerts);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#pragma warning disable 0672
|
||||
#if !UNITY_2017_1_OR_NEWER
|
||||
protected override void OnPopulateMesh(Mesh m)
|
||||
{
|
||||
WorldSpaceChartMesh mesh = new WorldSpaceChartMesh(1);
|
||||
int vPos = 0;
|
||||
foreach (UIVertex v in getVerices())
|
||||
{
|
||||
mTmpVerts[vPos++] = v;
|
||||
if (vPos == 4)
|
||||
{
|
||||
vPos = 0;
|
||||
|
||||
mesh.AddQuad(mTmpVerts[0], mTmpVerts[1], mTmpVerts[2], mTmpVerts[3]);
|
||||
}
|
||||
}
|
||||
mesh.ApplyToMesh(m);
|
||||
}
|
||||
#endif
|
||||
#pragma warning restore 0672
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05af876f1131be94d999a98f574aa820
|
||||
timeCreated: 1491155958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,15 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
interface ICandleCreator
|
||||
{
|
||||
void Generate(CandleChart parent, Rect viewRect, IList<CandleChartData.CandleValue> value, CandleChartData.CandleSettings settings);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc37318de0ced4249a4f86d43c9799cc
|
||||
timeCreated: 1491395378
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,27 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
interface IInternalCandleData
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="axis">0 for horizontal 1 for vertical</param>
|
||||
/// <returns></returns>
|
||||
double GetMinValue(int axis, bool dataValue);
|
||||
double GetMaxValue(int axis, bool dataValue);
|
||||
void OnBeforeSerialize();
|
||||
void OnAfterDeserialize();
|
||||
event EventHandler InternalDataChanged;
|
||||
event EventHandler InternalViewPortionChanged;
|
||||
event Action<int,string> InternalRealTimeDataChanged;
|
||||
int TotalCategories { get; }
|
||||
IEnumerable<CandleChartData.CategoryData> Categories { get; }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user